...

Source file src/github.com/Azure/azure-sdk-for-go/services/machinelearning/mgmt/2017-01-01/webservices/webservices.go

Documentation: github.com/Azure/azure-sdk-for-go/services/machinelearning/mgmt/2017-01-01/webservices

     1  package webservices
     2  
     3  // Copyright (c) Microsoft Corporation. All rights reserved.
     4  // Licensed under the MIT License. See License.txt in the project root for license information.
     5  //
     6  // Code generated by Microsoft (R) AutoRest Code Generator.
     7  // Changes may cause incorrect behavior and will be lost if the code is regenerated.
     8  
     9  import (
    10  	"context"
    11  	"github.com/Azure/go-autorest/autorest"
    12  	"github.com/Azure/go-autorest/autorest/azure"
    13  	"github.com/Azure/go-autorest/tracing"
    14  	"net/http"
    15  )
    16  
    17  // Client is the these APIs allow end users to operate on Azure Machine Learning Web Services resources. They support
    18  // the following operations:<ul><li>Create or update a web service</li><li>Get a web service</li><li>Patch a web
    19  // service</li><li>Delete a web service</li><li>Get All Web Services in a Resource Group </li><li>Get All Web Services
    20  // in a Subscription</li><li>Get Web Services Keys</li></ul>
    21  type Client struct {
    22  	BaseClient
    23  }
    24  
    25  // NewClient creates an instance of the Client client.
    26  func NewClient(subscriptionID string) Client {
    27  	return NewClientWithBaseURI(DefaultBaseURI, subscriptionID)
    28  }
    29  
    30  // NewClientWithBaseURI creates an instance of the Client client using a custom endpoint.  Use this when interacting
    31  // with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    32  func NewClientWithBaseURI(baseURI string, subscriptionID string) Client {
    33  	return Client{NewWithBaseURI(baseURI, subscriptionID)}
    34  }
    35  
    36  // CreateOrUpdate create or update a web service. This call will overwrite an existing web service. Note that there is
    37  // no warning or confirmation. This is a nonrecoverable operation. If your intent is to create a new web service, call
    38  // the Get operation first to verify that it does not exist.
    39  // Parameters:
    40  // resourceGroupName - name of the resource group in which the web service is located.
    41  // webServiceName - the name of the web service.
    42  // createOrUpdatePayload - the payload that is used to create or update the web service.
    43  func (client Client) CreateOrUpdate(ctx context.Context, resourceGroupName string, webServiceName string, createOrUpdatePayload WebService) (result CreateOrUpdateFuture, err error) {
    44  	if tracing.IsEnabled() {
    45  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.CreateOrUpdate")
    46  		defer func() {
    47  			sc := -1
    48  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    49  				sc = result.FutureAPI.Response().StatusCode
    50  			}
    51  			tracing.EndSpan(ctx, sc, err)
    52  		}()
    53  	}
    54  	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, webServiceName, createOrUpdatePayload)
    55  	if err != nil {
    56  		err = autorest.NewErrorWithError(err, "webservices.Client", "CreateOrUpdate", nil, "Failure preparing request")
    57  		return
    58  	}
    59  
    60  	result, err = client.CreateOrUpdateSender(req)
    61  	if err != nil {
    62  		err = autorest.NewErrorWithError(err, "webservices.Client", "CreateOrUpdate", result.Response(), "Failure sending request")
    63  		return
    64  	}
    65  
    66  	return
    67  }
    68  
    69  // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
    70  func (client Client) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, webServiceName string, createOrUpdatePayload WebService) (*http.Request, error) {
    71  	pathParameters := map[string]interface{}{
    72  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    73  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    74  		"webServiceName":    autorest.Encode("path", webServiceName),
    75  	}
    76  
    77  	const APIVersion = "2017-01-01"
    78  	queryParameters := map[string]interface{}{
    79  		"api-version": APIVersion,
    80  	}
    81  
    82  	preparer := autorest.CreatePreparer(
    83  		autorest.AsContentType("application/json; charset=utf-8"),
    84  		autorest.AsPut(),
    85  		autorest.WithBaseURL(client.BaseURI),
    86  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearning/webServices/{webServiceName}", pathParameters),
    87  		autorest.WithJSON(createOrUpdatePayload),
    88  		autorest.WithQueryParameters(queryParameters))
    89  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    90  }
    91  
    92  // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
    93  // http.Response Body if it receives an error.
    94  func (client Client) CreateOrUpdateSender(req *http.Request) (future CreateOrUpdateFuture, err error) {
    95  	var resp *http.Response
    96  	future.FutureAPI = &azure.Future{}
    97  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
    98  	if err != nil {
    99  		return
   100  	}
   101  	var azf azure.Future
   102  	azf, err = azure.NewFutureFromResponse(resp)
   103  	future.FutureAPI = &azf
   104  	future.Result = future.result
   105  	return
   106  }
   107  
   108  // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
   109  // closes the http.Response Body.
   110  func (client Client) CreateOrUpdateResponder(resp *http.Response) (result WebService, err error) {
   111  	err = autorest.Respond(
   112  		resp,
   113  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   114  		autorest.ByUnmarshallingJSON(&result),
   115  		autorest.ByClosing())
   116  	result.Response = autorest.Response{Response: resp}
   117  	return
   118  }
   119  
   120  // CreateRegionalProperties creates an encrypted credentials parameter blob for the specified region. To get the web
   121  // service from a region other than the region in which it has been created, you must first call Create Regional Web
   122  // Services Properties to create a copy of the encrypted credential parameter blob in that region. You only need to do
   123  // this before the first time that you get the web service in the new region.
   124  // Parameters:
   125  // resourceGroupName - name of the resource group in which the web service is located.
   126  // webServiceName - the name of the web service.
   127  // region - the region for which encrypted credential parameters are created.
   128  func (client Client) CreateRegionalProperties(ctx context.Context, resourceGroupName string, webServiceName string, region string) (result CreateRegionalPropertiesFuture, err error) {
   129  	if tracing.IsEnabled() {
   130  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.CreateRegionalProperties")
   131  		defer func() {
   132  			sc := -1
   133  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   134  				sc = result.FutureAPI.Response().StatusCode
   135  			}
   136  			tracing.EndSpan(ctx, sc, err)
   137  		}()
   138  	}
   139  	req, err := client.CreateRegionalPropertiesPreparer(ctx, resourceGroupName, webServiceName, region)
   140  	if err != nil {
   141  		err = autorest.NewErrorWithError(err, "webservices.Client", "CreateRegionalProperties", nil, "Failure preparing request")
   142  		return
   143  	}
   144  
   145  	result, err = client.CreateRegionalPropertiesSender(req)
   146  	if err != nil {
   147  		err = autorest.NewErrorWithError(err, "webservices.Client", "CreateRegionalProperties", result.Response(), "Failure sending request")
   148  		return
   149  	}
   150  
   151  	return
   152  }
   153  
   154  // CreateRegionalPropertiesPreparer prepares the CreateRegionalProperties request.
   155  func (client Client) CreateRegionalPropertiesPreparer(ctx context.Context, resourceGroupName string, webServiceName string, region string) (*http.Request, error) {
   156  	pathParameters := map[string]interface{}{
   157  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   158  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   159  		"webServiceName":    autorest.Encode("path", webServiceName),
   160  	}
   161  
   162  	const APIVersion = "2017-01-01"
   163  	queryParameters := map[string]interface{}{
   164  		"api-version": APIVersion,
   165  		"region":      autorest.Encode("query", region),
   166  	}
   167  
   168  	preparer := autorest.CreatePreparer(
   169  		autorest.AsPost(),
   170  		autorest.WithBaseURL(client.BaseURI),
   171  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearning/webServices/{webServiceName}/CreateRegionalBlob", pathParameters),
   172  		autorest.WithQueryParameters(queryParameters))
   173  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   174  }
   175  
   176  // CreateRegionalPropertiesSender sends the CreateRegionalProperties request. The method will close the
   177  // http.Response Body if it receives an error.
   178  func (client Client) CreateRegionalPropertiesSender(req *http.Request) (future CreateRegionalPropertiesFuture, err error) {
   179  	var resp *http.Response
   180  	future.FutureAPI = &azure.Future{}
   181  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   182  	if err != nil {
   183  		return
   184  	}
   185  	var azf azure.Future
   186  	azf, err = azure.NewFutureFromResponse(resp)
   187  	future.FutureAPI = &azf
   188  	future.Result = future.result
   189  	return
   190  }
   191  
   192  // CreateRegionalPropertiesResponder handles the response to the CreateRegionalProperties request. The method always
   193  // closes the http.Response Body.
   194  func (client Client) CreateRegionalPropertiesResponder(resp *http.Response) (result AsyncOperationStatus, err error) {
   195  	err = autorest.Respond(
   196  		resp,
   197  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   198  		autorest.ByUnmarshallingJSON(&result),
   199  		autorest.ByClosing())
   200  	result.Response = autorest.Response{Response: resp}
   201  	return
   202  }
   203  
   204  // Get gets the Web Service Definition as specified by a subscription, resource group, and name. Note that the storage
   205  // credentials and web service keys are not returned by this call. To get the web service access keys, call List Keys.
   206  // Parameters:
   207  // resourceGroupName - name of the resource group in which the web service is located.
   208  // webServiceName - the name of the web service.
   209  // region - the region for which encrypted credential parameters are valid.
   210  func (client Client) Get(ctx context.Context, resourceGroupName string, webServiceName string, region string) (result WebService, err error) {
   211  	if tracing.IsEnabled() {
   212  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.Get")
   213  		defer func() {
   214  			sc := -1
   215  			if result.Response.Response != nil {
   216  				sc = result.Response.Response.StatusCode
   217  			}
   218  			tracing.EndSpan(ctx, sc, err)
   219  		}()
   220  	}
   221  	req, err := client.GetPreparer(ctx, resourceGroupName, webServiceName, region)
   222  	if err != nil {
   223  		err = autorest.NewErrorWithError(err, "webservices.Client", "Get", nil, "Failure preparing request")
   224  		return
   225  	}
   226  
   227  	resp, err := client.GetSender(req)
   228  	if err != nil {
   229  		result.Response = autorest.Response{Response: resp}
   230  		err = autorest.NewErrorWithError(err, "webservices.Client", "Get", resp, "Failure sending request")
   231  		return
   232  	}
   233  
   234  	result, err = client.GetResponder(resp)
   235  	if err != nil {
   236  		err = autorest.NewErrorWithError(err, "webservices.Client", "Get", resp, "Failure responding to request")
   237  		return
   238  	}
   239  
   240  	return
   241  }
   242  
   243  // GetPreparer prepares the Get request.
   244  func (client Client) GetPreparer(ctx context.Context, resourceGroupName string, webServiceName string, region string) (*http.Request, error) {
   245  	pathParameters := map[string]interface{}{
   246  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   247  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   248  		"webServiceName":    autorest.Encode("path", webServiceName),
   249  	}
   250  
   251  	const APIVersion = "2017-01-01"
   252  	queryParameters := map[string]interface{}{
   253  		"api-version": APIVersion,
   254  	}
   255  	if len(region) > 0 {
   256  		queryParameters["region"] = autorest.Encode("query", region)
   257  	}
   258  
   259  	preparer := autorest.CreatePreparer(
   260  		autorest.AsGet(),
   261  		autorest.WithBaseURL(client.BaseURI),
   262  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearning/webServices/{webServiceName}", pathParameters),
   263  		autorest.WithQueryParameters(queryParameters))
   264  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   265  }
   266  
   267  // GetSender sends the Get request. The method will close the
   268  // http.Response Body if it receives an error.
   269  func (client Client) GetSender(req *http.Request) (*http.Response, error) {
   270  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   271  }
   272  
   273  // GetResponder handles the response to the Get request. The method always
   274  // closes the http.Response Body.
   275  func (client Client) GetResponder(resp *http.Response) (result WebService, err error) {
   276  	err = autorest.Respond(
   277  		resp,
   278  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   279  		autorest.ByUnmarshallingJSON(&result),
   280  		autorest.ByClosing())
   281  	result.Response = autorest.Response{Response: resp}
   282  	return
   283  }
   284  
   285  // ListByResourceGroup gets the web services in the specified resource group.
   286  // Parameters:
   287  // resourceGroupName - name of the resource group in which the web service is located.
   288  // skiptoken - continuation token for pagination.
   289  func (client Client) ListByResourceGroup(ctx context.Context, resourceGroupName string, skiptoken string) (result PaginatedWebServicesListPage, err error) {
   290  	if tracing.IsEnabled() {
   291  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListByResourceGroup")
   292  		defer func() {
   293  			sc := -1
   294  			if result.pwsl.Response.Response != nil {
   295  				sc = result.pwsl.Response.Response.StatusCode
   296  			}
   297  			tracing.EndSpan(ctx, sc, err)
   298  		}()
   299  	}
   300  	result.fn = client.listByResourceGroupNextResults
   301  	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, skiptoken)
   302  	if err != nil {
   303  		err = autorest.NewErrorWithError(err, "webservices.Client", "ListByResourceGroup", nil, "Failure preparing request")
   304  		return
   305  	}
   306  
   307  	resp, err := client.ListByResourceGroupSender(req)
   308  	if err != nil {
   309  		result.pwsl.Response = autorest.Response{Response: resp}
   310  		err = autorest.NewErrorWithError(err, "webservices.Client", "ListByResourceGroup", resp, "Failure sending request")
   311  		return
   312  	}
   313  
   314  	result.pwsl, err = client.ListByResourceGroupResponder(resp)
   315  	if err != nil {
   316  		err = autorest.NewErrorWithError(err, "webservices.Client", "ListByResourceGroup", resp, "Failure responding to request")
   317  		return
   318  	}
   319  	if result.pwsl.hasNextLink() && result.pwsl.IsEmpty() {
   320  		err = result.NextWithContext(ctx)
   321  		return
   322  	}
   323  
   324  	return
   325  }
   326  
   327  // ListByResourceGroupPreparer prepares the ListByResourceGroup request.
   328  func (client Client) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, skiptoken string) (*http.Request, error) {
   329  	pathParameters := map[string]interface{}{
   330  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   331  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   332  	}
   333  
   334  	const APIVersion = "2017-01-01"
   335  	queryParameters := map[string]interface{}{
   336  		"api-version": APIVersion,
   337  	}
   338  	if len(skiptoken) > 0 {
   339  		queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken)
   340  	}
   341  
   342  	preparer := autorest.CreatePreparer(
   343  		autorest.AsGet(),
   344  		autorest.WithBaseURL(client.BaseURI),
   345  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearning/webServices", pathParameters),
   346  		autorest.WithQueryParameters(queryParameters))
   347  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   348  }
   349  
   350  // ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
   351  // http.Response Body if it receives an error.
   352  func (client Client) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
   353  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   354  }
   355  
   356  // ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
   357  // closes the http.Response Body.
   358  func (client Client) ListByResourceGroupResponder(resp *http.Response) (result PaginatedWebServicesList, err error) {
   359  	err = autorest.Respond(
   360  		resp,
   361  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   362  		autorest.ByUnmarshallingJSON(&result),
   363  		autorest.ByClosing())
   364  	result.Response = autorest.Response{Response: resp}
   365  	return
   366  }
   367  
   368  // listByResourceGroupNextResults retrieves the next set of results, if any.
   369  func (client Client) listByResourceGroupNextResults(ctx context.Context, lastResults PaginatedWebServicesList) (result PaginatedWebServicesList, err error) {
   370  	req, err := lastResults.paginatedWebServicesListPreparer(ctx)
   371  	if err != nil {
   372  		return result, autorest.NewErrorWithError(err, "webservices.Client", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
   373  	}
   374  	if req == nil {
   375  		return
   376  	}
   377  	resp, err := client.ListByResourceGroupSender(req)
   378  	if err != nil {
   379  		result.Response = autorest.Response{Response: resp}
   380  		return result, autorest.NewErrorWithError(err, "webservices.Client", "listByResourceGroupNextResults", resp, "Failure sending next results request")
   381  	}
   382  	result, err = client.ListByResourceGroupResponder(resp)
   383  	if err != nil {
   384  		err = autorest.NewErrorWithError(err, "webservices.Client", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
   385  	}
   386  	return
   387  }
   388  
   389  // ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
   390  func (client Client) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, skiptoken string) (result PaginatedWebServicesListIterator, err error) {
   391  	if tracing.IsEnabled() {
   392  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListByResourceGroup")
   393  		defer func() {
   394  			sc := -1
   395  			if result.Response().Response.Response != nil {
   396  				sc = result.page.Response().Response.Response.StatusCode
   397  			}
   398  			tracing.EndSpan(ctx, sc, err)
   399  		}()
   400  	}
   401  	result.page, err = client.ListByResourceGroup(ctx, resourceGroupName, skiptoken)
   402  	return
   403  }
   404  
   405  // ListBySubscriptionID gets the web services in the specified subscription.
   406  // Parameters:
   407  // skiptoken - continuation token for pagination.
   408  func (client Client) ListBySubscriptionID(ctx context.Context, skiptoken string) (result PaginatedWebServicesListPage, err error) {
   409  	if tracing.IsEnabled() {
   410  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListBySubscriptionID")
   411  		defer func() {
   412  			sc := -1
   413  			if result.pwsl.Response.Response != nil {
   414  				sc = result.pwsl.Response.Response.StatusCode
   415  			}
   416  			tracing.EndSpan(ctx, sc, err)
   417  		}()
   418  	}
   419  	result.fn = client.listBySubscriptionIDNextResults
   420  	req, err := client.ListBySubscriptionIDPreparer(ctx, skiptoken)
   421  	if err != nil {
   422  		err = autorest.NewErrorWithError(err, "webservices.Client", "ListBySubscriptionID", nil, "Failure preparing request")
   423  		return
   424  	}
   425  
   426  	resp, err := client.ListBySubscriptionIDSender(req)
   427  	if err != nil {
   428  		result.pwsl.Response = autorest.Response{Response: resp}
   429  		err = autorest.NewErrorWithError(err, "webservices.Client", "ListBySubscriptionID", resp, "Failure sending request")
   430  		return
   431  	}
   432  
   433  	result.pwsl, err = client.ListBySubscriptionIDResponder(resp)
   434  	if err != nil {
   435  		err = autorest.NewErrorWithError(err, "webservices.Client", "ListBySubscriptionID", resp, "Failure responding to request")
   436  		return
   437  	}
   438  	if result.pwsl.hasNextLink() && result.pwsl.IsEmpty() {
   439  		err = result.NextWithContext(ctx)
   440  		return
   441  	}
   442  
   443  	return
   444  }
   445  
   446  // ListBySubscriptionIDPreparer prepares the ListBySubscriptionID request.
   447  func (client Client) ListBySubscriptionIDPreparer(ctx context.Context, skiptoken string) (*http.Request, error) {
   448  	pathParameters := map[string]interface{}{
   449  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
   450  	}
   451  
   452  	const APIVersion = "2017-01-01"
   453  	queryParameters := map[string]interface{}{
   454  		"api-version": APIVersion,
   455  	}
   456  	if len(skiptoken) > 0 {
   457  		queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken)
   458  	}
   459  
   460  	preparer := autorest.CreatePreparer(
   461  		autorest.AsGet(),
   462  		autorest.WithBaseURL(client.BaseURI),
   463  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.MachineLearning/webServices", pathParameters),
   464  		autorest.WithQueryParameters(queryParameters))
   465  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   466  }
   467  
   468  // ListBySubscriptionIDSender sends the ListBySubscriptionID request. The method will close the
   469  // http.Response Body if it receives an error.
   470  func (client Client) ListBySubscriptionIDSender(req *http.Request) (*http.Response, error) {
   471  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   472  }
   473  
   474  // ListBySubscriptionIDResponder handles the response to the ListBySubscriptionID request. The method always
   475  // closes the http.Response Body.
   476  func (client Client) ListBySubscriptionIDResponder(resp *http.Response) (result PaginatedWebServicesList, err error) {
   477  	err = autorest.Respond(
   478  		resp,
   479  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   480  		autorest.ByUnmarshallingJSON(&result),
   481  		autorest.ByClosing())
   482  	result.Response = autorest.Response{Response: resp}
   483  	return
   484  }
   485  
   486  // listBySubscriptionIDNextResults retrieves the next set of results, if any.
   487  func (client Client) listBySubscriptionIDNextResults(ctx context.Context, lastResults PaginatedWebServicesList) (result PaginatedWebServicesList, err error) {
   488  	req, err := lastResults.paginatedWebServicesListPreparer(ctx)
   489  	if err != nil {
   490  		return result, autorest.NewErrorWithError(err, "webservices.Client", "listBySubscriptionIDNextResults", nil, "Failure preparing next results request")
   491  	}
   492  	if req == nil {
   493  		return
   494  	}
   495  	resp, err := client.ListBySubscriptionIDSender(req)
   496  	if err != nil {
   497  		result.Response = autorest.Response{Response: resp}
   498  		return result, autorest.NewErrorWithError(err, "webservices.Client", "listBySubscriptionIDNextResults", resp, "Failure sending next results request")
   499  	}
   500  	result, err = client.ListBySubscriptionIDResponder(resp)
   501  	if err != nil {
   502  		err = autorest.NewErrorWithError(err, "webservices.Client", "listBySubscriptionIDNextResults", resp, "Failure responding to next results request")
   503  	}
   504  	return
   505  }
   506  
   507  // ListBySubscriptionIDComplete enumerates all values, automatically crossing page boundaries as required.
   508  func (client Client) ListBySubscriptionIDComplete(ctx context.Context, skiptoken string) (result PaginatedWebServicesListIterator, err error) {
   509  	if tracing.IsEnabled() {
   510  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListBySubscriptionID")
   511  		defer func() {
   512  			sc := -1
   513  			if result.Response().Response.Response != nil {
   514  				sc = result.page.Response().Response.Response.StatusCode
   515  			}
   516  			tracing.EndSpan(ctx, sc, err)
   517  		}()
   518  	}
   519  	result.page, err = client.ListBySubscriptionID(ctx, skiptoken)
   520  	return
   521  }
   522  
   523  // ListKeys gets the access keys for the specified web service.
   524  // Parameters:
   525  // resourceGroupName - name of the resource group in which the web service is located.
   526  // webServiceName - the name of the web service.
   527  func (client Client) ListKeys(ctx context.Context, resourceGroupName string, webServiceName string) (result Keys, err error) {
   528  	if tracing.IsEnabled() {
   529  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListKeys")
   530  		defer func() {
   531  			sc := -1
   532  			if result.Response.Response != nil {
   533  				sc = result.Response.Response.StatusCode
   534  			}
   535  			tracing.EndSpan(ctx, sc, err)
   536  		}()
   537  	}
   538  	req, err := client.ListKeysPreparer(ctx, resourceGroupName, webServiceName)
   539  	if err != nil {
   540  		err = autorest.NewErrorWithError(err, "webservices.Client", "ListKeys", nil, "Failure preparing request")
   541  		return
   542  	}
   543  
   544  	resp, err := client.ListKeysSender(req)
   545  	if err != nil {
   546  		result.Response = autorest.Response{Response: resp}
   547  		err = autorest.NewErrorWithError(err, "webservices.Client", "ListKeys", resp, "Failure sending request")
   548  		return
   549  	}
   550  
   551  	result, err = client.ListKeysResponder(resp)
   552  	if err != nil {
   553  		err = autorest.NewErrorWithError(err, "webservices.Client", "ListKeys", resp, "Failure responding to request")
   554  		return
   555  	}
   556  
   557  	return
   558  }
   559  
   560  // ListKeysPreparer prepares the ListKeys request.
   561  func (client Client) ListKeysPreparer(ctx context.Context, resourceGroupName string, webServiceName string) (*http.Request, error) {
   562  	pathParameters := map[string]interface{}{
   563  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   564  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   565  		"webServiceName":    autorest.Encode("path", webServiceName),
   566  	}
   567  
   568  	const APIVersion = "2017-01-01"
   569  	queryParameters := map[string]interface{}{
   570  		"api-version": APIVersion,
   571  	}
   572  
   573  	preparer := autorest.CreatePreparer(
   574  		autorest.AsGet(),
   575  		autorest.WithBaseURL(client.BaseURI),
   576  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearning/webServices/{webServiceName}/listKeys", pathParameters),
   577  		autorest.WithQueryParameters(queryParameters))
   578  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   579  }
   580  
   581  // ListKeysSender sends the ListKeys request. The method will close the
   582  // http.Response Body if it receives an error.
   583  func (client Client) ListKeysSender(req *http.Request) (*http.Response, error) {
   584  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   585  }
   586  
   587  // ListKeysResponder handles the response to the ListKeys request. The method always
   588  // closes the http.Response Body.
   589  func (client Client) ListKeysResponder(resp *http.Response) (result Keys, err error) {
   590  	err = autorest.Respond(
   591  		resp,
   592  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   593  		autorest.ByUnmarshallingJSON(&result),
   594  		autorest.ByClosing())
   595  	result.Response = autorest.Response{Response: resp}
   596  	return
   597  }
   598  
   599  // Patch modifies an existing web service resource. The PATCH API call is an asynchronous operation. To determine
   600  // whether it has completed successfully, you must perform a Get operation.
   601  // Parameters:
   602  // resourceGroupName - name of the resource group in which the web service is located.
   603  // webServiceName - the name of the web service.
   604  // patchPayload - the payload to use to patch the web service.
   605  func (client Client) Patch(ctx context.Context, resourceGroupName string, webServiceName string, patchPayload PatchedWebService) (result PatchFuture, err error) {
   606  	if tracing.IsEnabled() {
   607  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.Patch")
   608  		defer func() {
   609  			sc := -1
   610  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   611  				sc = result.FutureAPI.Response().StatusCode
   612  			}
   613  			tracing.EndSpan(ctx, sc, err)
   614  		}()
   615  	}
   616  	req, err := client.PatchPreparer(ctx, resourceGroupName, webServiceName, patchPayload)
   617  	if err != nil {
   618  		err = autorest.NewErrorWithError(err, "webservices.Client", "Patch", nil, "Failure preparing request")
   619  		return
   620  	}
   621  
   622  	result, err = client.PatchSender(req)
   623  	if err != nil {
   624  		err = autorest.NewErrorWithError(err, "webservices.Client", "Patch", result.Response(), "Failure sending request")
   625  		return
   626  	}
   627  
   628  	return
   629  }
   630  
   631  // PatchPreparer prepares the Patch request.
   632  func (client Client) PatchPreparer(ctx context.Context, resourceGroupName string, webServiceName string, patchPayload PatchedWebService) (*http.Request, error) {
   633  	pathParameters := map[string]interface{}{
   634  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   635  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   636  		"webServiceName":    autorest.Encode("path", webServiceName),
   637  	}
   638  
   639  	const APIVersion = "2017-01-01"
   640  	queryParameters := map[string]interface{}{
   641  		"api-version": APIVersion,
   642  	}
   643  
   644  	preparer := autorest.CreatePreparer(
   645  		autorest.AsContentType("application/json; charset=utf-8"),
   646  		autorest.AsPatch(),
   647  		autorest.WithBaseURL(client.BaseURI),
   648  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearning/webServices/{webServiceName}", pathParameters),
   649  		autorest.WithJSON(patchPayload),
   650  		autorest.WithQueryParameters(queryParameters))
   651  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   652  }
   653  
   654  // PatchSender sends the Patch request. The method will close the
   655  // http.Response Body if it receives an error.
   656  func (client Client) PatchSender(req *http.Request) (future PatchFuture, err error) {
   657  	var resp *http.Response
   658  	future.FutureAPI = &azure.Future{}
   659  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   660  	if err != nil {
   661  		return
   662  	}
   663  	var azf azure.Future
   664  	azf, err = azure.NewFutureFromResponse(resp)
   665  	future.FutureAPI = &azf
   666  	future.Result = future.result
   667  	return
   668  }
   669  
   670  // PatchResponder handles the response to the Patch request. The method always
   671  // closes the http.Response Body.
   672  func (client Client) PatchResponder(resp *http.Response) (result WebService, err error) {
   673  	err = autorest.Respond(
   674  		resp,
   675  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   676  		autorest.ByUnmarshallingJSON(&result),
   677  		autorest.ByClosing())
   678  	result.Response = autorest.Response{Response: resp}
   679  	return
   680  }
   681  
   682  // Remove deletes the specified web service.
   683  // Parameters:
   684  // resourceGroupName - name of the resource group in which the web service is located.
   685  // webServiceName - the name of the web service.
   686  func (client Client) Remove(ctx context.Context, resourceGroupName string, webServiceName string) (result RemoveFuture, err error) {
   687  	if tracing.IsEnabled() {
   688  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.Remove")
   689  		defer func() {
   690  			sc := -1
   691  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   692  				sc = result.FutureAPI.Response().StatusCode
   693  			}
   694  			tracing.EndSpan(ctx, sc, err)
   695  		}()
   696  	}
   697  	req, err := client.RemovePreparer(ctx, resourceGroupName, webServiceName)
   698  	if err != nil {
   699  		err = autorest.NewErrorWithError(err, "webservices.Client", "Remove", nil, "Failure preparing request")
   700  		return
   701  	}
   702  
   703  	result, err = client.RemoveSender(req)
   704  	if err != nil {
   705  		err = autorest.NewErrorWithError(err, "webservices.Client", "Remove", result.Response(), "Failure sending request")
   706  		return
   707  	}
   708  
   709  	return
   710  }
   711  
   712  // RemovePreparer prepares the Remove request.
   713  func (client Client) RemovePreparer(ctx context.Context, resourceGroupName string, webServiceName string) (*http.Request, error) {
   714  	pathParameters := map[string]interface{}{
   715  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   716  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   717  		"webServiceName":    autorest.Encode("path", webServiceName),
   718  	}
   719  
   720  	const APIVersion = "2017-01-01"
   721  	queryParameters := map[string]interface{}{
   722  		"api-version": APIVersion,
   723  	}
   724  
   725  	preparer := autorest.CreatePreparer(
   726  		autorest.AsDelete(),
   727  		autorest.WithBaseURL(client.BaseURI),
   728  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearning/webServices/{webServiceName}", pathParameters),
   729  		autorest.WithQueryParameters(queryParameters))
   730  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   731  }
   732  
   733  // RemoveSender sends the Remove request. The method will close the
   734  // http.Response Body if it receives an error.
   735  func (client Client) RemoveSender(req *http.Request) (future RemoveFuture, err error) {
   736  	var resp *http.Response
   737  	future.FutureAPI = &azure.Future{}
   738  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   739  	if err != nil {
   740  		return
   741  	}
   742  	var azf azure.Future
   743  	azf, err = azure.NewFutureFromResponse(resp)
   744  	future.FutureAPI = &azf
   745  	future.Result = future.result
   746  	return
   747  }
   748  
   749  // RemoveResponder handles the response to the Remove request. The method always
   750  // closes the http.Response Body.
   751  func (client Client) RemoveResponder(resp *http.Response) (result autorest.Response, err error) {
   752  	err = autorest.Respond(
   753  		resp,
   754  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   755  		autorest.ByClosing())
   756  	result.Response = resp
   757  	return
   758  }
   759  

View as plain text