...

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

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/machinelearning/mgmt/2016-05-01-preview/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 = "2016-05-01-preview"
    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  // Get gets the Web Service Definition as specified by a subscription, resource group, and name. Note that the storage
   121  // credentials and web service keys are not returned by this call. To get the web service access keys, call List Keys.
   122  // Parameters:
   123  // resourceGroupName - name of the resource group in which the web service is located.
   124  // webServiceName - the name of the web service.
   125  func (client Client) Get(ctx context.Context, resourceGroupName string, webServiceName string) (result WebService, err error) {
   126  	if tracing.IsEnabled() {
   127  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.Get")
   128  		defer func() {
   129  			sc := -1
   130  			if result.Response.Response != nil {
   131  				sc = result.Response.Response.StatusCode
   132  			}
   133  			tracing.EndSpan(ctx, sc, err)
   134  		}()
   135  	}
   136  	req, err := client.GetPreparer(ctx, resourceGroupName, webServiceName)
   137  	if err != nil {
   138  		err = autorest.NewErrorWithError(err, "webservices.Client", "Get", nil, "Failure preparing request")
   139  		return
   140  	}
   141  
   142  	resp, err := client.GetSender(req)
   143  	if err != nil {
   144  		result.Response = autorest.Response{Response: resp}
   145  		err = autorest.NewErrorWithError(err, "webservices.Client", "Get", resp, "Failure sending request")
   146  		return
   147  	}
   148  
   149  	result, err = client.GetResponder(resp)
   150  	if err != nil {
   151  		err = autorest.NewErrorWithError(err, "webservices.Client", "Get", resp, "Failure responding to request")
   152  		return
   153  	}
   154  
   155  	return
   156  }
   157  
   158  // GetPreparer prepares the Get request.
   159  func (client Client) GetPreparer(ctx context.Context, resourceGroupName string, webServiceName string) (*http.Request, error) {
   160  	pathParameters := map[string]interface{}{
   161  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   162  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   163  		"webServiceName":    autorest.Encode("path", webServiceName),
   164  	}
   165  
   166  	const APIVersion = "2016-05-01-preview"
   167  	queryParameters := map[string]interface{}{
   168  		"api-version": APIVersion,
   169  	}
   170  
   171  	preparer := autorest.CreatePreparer(
   172  		autorest.AsGet(),
   173  		autorest.WithBaseURL(client.BaseURI),
   174  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearning/webServices/{webServiceName}", pathParameters),
   175  		autorest.WithQueryParameters(queryParameters))
   176  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   177  }
   178  
   179  // GetSender sends the Get request. The method will close the
   180  // http.Response Body if it receives an error.
   181  func (client Client) GetSender(req *http.Request) (*http.Response, error) {
   182  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   183  }
   184  
   185  // GetResponder handles the response to the Get request. The method always
   186  // closes the http.Response Body.
   187  func (client Client) GetResponder(resp *http.Response) (result WebService, err error) {
   188  	err = autorest.Respond(
   189  		resp,
   190  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   191  		autorest.ByUnmarshallingJSON(&result),
   192  		autorest.ByClosing())
   193  	result.Response = autorest.Response{Response: resp}
   194  	return
   195  }
   196  
   197  // List gets the web services in the specified subscription.
   198  // Parameters:
   199  // skiptoken - continuation token for pagination.
   200  func (client Client) List(ctx context.Context, skiptoken string) (result PaginatedWebServicesListPage, err error) {
   201  	if tracing.IsEnabled() {
   202  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.List")
   203  		defer func() {
   204  			sc := -1
   205  			if result.pwsl.Response.Response != nil {
   206  				sc = result.pwsl.Response.Response.StatusCode
   207  			}
   208  			tracing.EndSpan(ctx, sc, err)
   209  		}()
   210  	}
   211  	result.fn = client.listNextResults
   212  	req, err := client.ListPreparer(ctx, skiptoken)
   213  	if err != nil {
   214  		err = autorest.NewErrorWithError(err, "webservices.Client", "List", nil, "Failure preparing request")
   215  		return
   216  	}
   217  
   218  	resp, err := client.ListSender(req)
   219  	if err != nil {
   220  		result.pwsl.Response = autorest.Response{Response: resp}
   221  		err = autorest.NewErrorWithError(err, "webservices.Client", "List", resp, "Failure sending request")
   222  		return
   223  	}
   224  
   225  	result.pwsl, err = client.ListResponder(resp)
   226  	if err != nil {
   227  		err = autorest.NewErrorWithError(err, "webservices.Client", "List", resp, "Failure responding to request")
   228  		return
   229  	}
   230  	if result.pwsl.hasNextLink() && result.pwsl.IsEmpty() {
   231  		err = result.NextWithContext(ctx)
   232  		return
   233  	}
   234  
   235  	return
   236  }
   237  
   238  // ListPreparer prepares the List request.
   239  func (client Client) ListPreparer(ctx context.Context, skiptoken string) (*http.Request, error) {
   240  	pathParameters := map[string]interface{}{
   241  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
   242  	}
   243  
   244  	const APIVersion = "2016-05-01-preview"
   245  	queryParameters := map[string]interface{}{
   246  		"api-version": APIVersion,
   247  	}
   248  	if len(skiptoken) > 0 {
   249  		queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken)
   250  	}
   251  
   252  	preparer := autorest.CreatePreparer(
   253  		autorest.AsGet(),
   254  		autorest.WithBaseURL(client.BaseURI),
   255  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.MachineLearning/webServices", pathParameters),
   256  		autorest.WithQueryParameters(queryParameters))
   257  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   258  }
   259  
   260  // ListSender sends the List request. The method will close the
   261  // http.Response Body if it receives an error.
   262  func (client Client) ListSender(req *http.Request) (*http.Response, error) {
   263  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   264  }
   265  
   266  // ListResponder handles the response to the List request. The method always
   267  // closes the http.Response Body.
   268  func (client Client) ListResponder(resp *http.Response) (result PaginatedWebServicesList, err error) {
   269  	err = autorest.Respond(
   270  		resp,
   271  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   272  		autorest.ByUnmarshallingJSON(&result),
   273  		autorest.ByClosing())
   274  	result.Response = autorest.Response{Response: resp}
   275  	return
   276  }
   277  
   278  // listNextResults retrieves the next set of results, if any.
   279  func (client Client) listNextResults(ctx context.Context, lastResults PaginatedWebServicesList) (result PaginatedWebServicesList, err error) {
   280  	req, err := lastResults.paginatedWebServicesListPreparer(ctx)
   281  	if err != nil {
   282  		return result, autorest.NewErrorWithError(err, "webservices.Client", "listNextResults", nil, "Failure preparing next results request")
   283  	}
   284  	if req == nil {
   285  		return
   286  	}
   287  	resp, err := client.ListSender(req)
   288  	if err != nil {
   289  		result.Response = autorest.Response{Response: resp}
   290  		return result, autorest.NewErrorWithError(err, "webservices.Client", "listNextResults", resp, "Failure sending next results request")
   291  	}
   292  	result, err = client.ListResponder(resp)
   293  	if err != nil {
   294  		err = autorest.NewErrorWithError(err, "webservices.Client", "listNextResults", resp, "Failure responding to next results request")
   295  	}
   296  	return
   297  }
   298  
   299  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   300  func (client Client) ListComplete(ctx context.Context, skiptoken string) (result PaginatedWebServicesListIterator, err error) {
   301  	if tracing.IsEnabled() {
   302  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.List")
   303  		defer func() {
   304  			sc := -1
   305  			if result.Response().Response.Response != nil {
   306  				sc = result.page.Response().Response.Response.StatusCode
   307  			}
   308  			tracing.EndSpan(ctx, sc, err)
   309  		}()
   310  	}
   311  	result.page, err = client.List(ctx, skiptoken)
   312  	return
   313  }
   314  
   315  // ListByResourceGroup gets the web services in the specified resource group.
   316  // Parameters:
   317  // resourceGroupName - name of the resource group in which the web service is located.
   318  // skiptoken - continuation token for pagination.
   319  func (client Client) ListByResourceGroup(ctx context.Context, resourceGroupName string, skiptoken string) (result PaginatedWebServicesListPage, err error) {
   320  	if tracing.IsEnabled() {
   321  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListByResourceGroup")
   322  		defer func() {
   323  			sc := -1
   324  			if result.pwsl.Response.Response != nil {
   325  				sc = result.pwsl.Response.Response.StatusCode
   326  			}
   327  			tracing.EndSpan(ctx, sc, err)
   328  		}()
   329  	}
   330  	result.fn = client.listByResourceGroupNextResults
   331  	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, skiptoken)
   332  	if err != nil {
   333  		err = autorest.NewErrorWithError(err, "webservices.Client", "ListByResourceGroup", nil, "Failure preparing request")
   334  		return
   335  	}
   336  
   337  	resp, err := client.ListByResourceGroupSender(req)
   338  	if err != nil {
   339  		result.pwsl.Response = autorest.Response{Response: resp}
   340  		err = autorest.NewErrorWithError(err, "webservices.Client", "ListByResourceGroup", resp, "Failure sending request")
   341  		return
   342  	}
   343  
   344  	result.pwsl, err = client.ListByResourceGroupResponder(resp)
   345  	if err != nil {
   346  		err = autorest.NewErrorWithError(err, "webservices.Client", "ListByResourceGroup", resp, "Failure responding to request")
   347  		return
   348  	}
   349  	if result.pwsl.hasNextLink() && result.pwsl.IsEmpty() {
   350  		err = result.NextWithContext(ctx)
   351  		return
   352  	}
   353  
   354  	return
   355  }
   356  
   357  // ListByResourceGroupPreparer prepares the ListByResourceGroup request.
   358  func (client Client) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, skiptoken string) (*http.Request, error) {
   359  	pathParameters := map[string]interface{}{
   360  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   361  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   362  	}
   363  
   364  	const APIVersion = "2016-05-01-preview"
   365  	queryParameters := map[string]interface{}{
   366  		"api-version": APIVersion,
   367  	}
   368  	if len(skiptoken) > 0 {
   369  		queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken)
   370  	}
   371  
   372  	preparer := autorest.CreatePreparer(
   373  		autorest.AsGet(),
   374  		autorest.WithBaseURL(client.BaseURI),
   375  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearning/webServices", pathParameters),
   376  		autorest.WithQueryParameters(queryParameters))
   377  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   378  }
   379  
   380  // ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
   381  // http.Response Body if it receives an error.
   382  func (client Client) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
   383  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   384  }
   385  
   386  // ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
   387  // closes the http.Response Body.
   388  func (client Client) ListByResourceGroupResponder(resp *http.Response) (result PaginatedWebServicesList, err error) {
   389  	err = autorest.Respond(
   390  		resp,
   391  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   392  		autorest.ByUnmarshallingJSON(&result),
   393  		autorest.ByClosing())
   394  	result.Response = autorest.Response{Response: resp}
   395  	return
   396  }
   397  
   398  // listByResourceGroupNextResults retrieves the next set of results, if any.
   399  func (client Client) listByResourceGroupNextResults(ctx context.Context, lastResults PaginatedWebServicesList) (result PaginatedWebServicesList, err error) {
   400  	req, err := lastResults.paginatedWebServicesListPreparer(ctx)
   401  	if err != nil {
   402  		return result, autorest.NewErrorWithError(err, "webservices.Client", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
   403  	}
   404  	if req == nil {
   405  		return
   406  	}
   407  	resp, err := client.ListByResourceGroupSender(req)
   408  	if err != nil {
   409  		result.Response = autorest.Response{Response: resp}
   410  		return result, autorest.NewErrorWithError(err, "webservices.Client", "listByResourceGroupNextResults", resp, "Failure sending next results request")
   411  	}
   412  	result, err = client.ListByResourceGroupResponder(resp)
   413  	if err != nil {
   414  		err = autorest.NewErrorWithError(err, "webservices.Client", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
   415  	}
   416  	return
   417  }
   418  
   419  // ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
   420  func (client Client) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, skiptoken string) (result PaginatedWebServicesListIterator, err error) {
   421  	if tracing.IsEnabled() {
   422  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListByResourceGroup")
   423  		defer func() {
   424  			sc := -1
   425  			if result.Response().Response.Response != nil {
   426  				sc = result.page.Response().Response.Response.StatusCode
   427  			}
   428  			tracing.EndSpan(ctx, sc, err)
   429  		}()
   430  	}
   431  	result.page, err = client.ListByResourceGroup(ctx, resourceGroupName, skiptoken)
   432  	return
   433  }
   434  
   435  // ListKeys gets the access keys for the specified web service.
   436  // Parameters:
   437  // resourceGroupName - name of the resource group in which the web service is located.
   438  // webServiceName - the name of the web service.
   439  func (client Client) ListKeys(ctx context.Context, resourceGroupName string, webServiceName string) (result Keys, err error) {
   440  	if tracing.IsEnabled() {
   441  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListKeys")
   442  		defer func() {
   443  			sc := -1
   444  			if result.Response.Response != nil {
   445  				sc = result.Response.Response.StatusCode
   446  			}
   447  			tracing.EndSpan(ctx, sc, err)
   448  		}()
   449  	}
   450  	req, err := client.ListKeysPreparer(ctx, resourceGroupName, webServiceName)
   451  	if err != nil {
   452  		err = autorest.NewErrorWithError(err, "webservices.Client", "ListKeys", nil, "Failure preparing request")
   453  		return
   454  	}
   455  
   456  	resp, err := client.ListKeysSender(req)
   457  	if err != nil {
   458  		result.Response = autorest.Response{Response: resp}
   459  		err = autorest.NewErrorWithError(err, "webservices.Client", "ListKeys", resp, "Failure sending request")
   460  		return
   461  	}
   462  
   463  	result, err = client.ListKeysResponder(resp)
   464  	if err != nil {
   465  		err = autorest.NewErrorWithError(err, "webservices.Client", "ListKeys", resp, "Failure responding to request")
   466  		return
   467  	}
   468  
   469  	return
   470  }
   471  
   472  // ListKeysPreparer prepares the ListKeys request.
   473  func (client Client) ListKeysPreparer(ctx context.Context, resourceGroupName string, webServiceName string) (*http.Request, error) {
   474  	pathParameters := map[string]interface{}{
   475  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   476  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   477  		"webServiceName":    autorest.Encode("path", webServiceName),
   478  	}
   479  
   480  	const APIVersion = "2016-05-01-preview"
   481  	queryParameters := map[string]interface{}{
   482  		"api-version": APIVersion,
   483  	}
   484  
   485  	preparer := autorest.CreatePreparer(
   486  		autorest.AsGet(),
   487  		autorest.WithBaseURL(client.BaseURI),
   488  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearning/webServices/{webServiceName}/listKeys", pathParameters),
   489  		autorest.WithQueryParameters(queryParameters))
   490  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   491  }
   492  
   493  // ListKeysSender sends the ListKeys request. The method will close the
   494  // http.Response Body if it receives an error.
   495  func (client Client) ListKeysSender(req *http.Request) (*http.Response, error) {
   496  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   497  }
   498  
   499  // ListKeysResponder handles the response to the ListKeys request. The method always
   500  // closes the http.Response Body.
   501  func (client Client) ListKeysResponder(resp *http.Response) (result Keys, err error) {
   502  	err = autorest.Respond(
   503  		resp,
   504  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   505  		autorest.ByUnmarshallingJSON(&result),
   506  		autorest.ByClosing())
   507  	result.Response = autorest.Response{Response: resp}
   508  	return
   509  }
   510  
   511  // Patch modifies an existing web service resource. The PATCH API call is an asynchronous operation. To determine
   512  // whether it has completed successfully, you must perform a Get operation.
   513  // Parameters:
   514  // resourceGroupName - name of the resource group in which the web service is located.
   515  // webServiceName - the name of the web service.
   516  // patchPayload - the payload to use to patch the web service.
   517  func (client Client) Patch(ctx context.Context, resourceGroupName string, webServiceName string, patchPayload WebService) (result PatchFuture, err error) {
   518  	if tracing.IsEnabled() {
   519  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.Patch")
   520  		defer func() {
   521  			sc := -1
   522  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   523  				sc = result.FutureAPI.Response().StatusCode
   524  			}
   525  			tracing.EndSpan(ctx, sc, err)
   526  		}()
   527  	}
   528  	req, err := client.PatchPreparer(ctx, resourceGroupName, webServiceName, patchPayload)
   529  	if err != nil {
   530  		err = autorest.NewErrorWithError(err, "webservices.Client", "Patch", nil, "Failure preparing request")
   531  		return
   532  	}
   533  
   534  	result, err = client.PatchSender(req)
   535  	if err != nil {
   536  		err = autorest.NewErrorWithError(err, "webservices.Client", "Patch", result.Response(), "Failure sending request")
   537  		return
   538  	}
   539  
   540  	return
   541  }
   542  
   543  // PatchPreparer prepares the Patch request.
   544  func (client Client) PatchPreparer(ctx context.Context, resourceGroupName string, webServiceName string, patchPayload WebService) (*http.Request, error) {
   545  	pathParameters := map[string]interface{}{
   546  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   547  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   548  		"webServiceName":    autorest.Encode("path", webServiceName),
   549  	}
   550  
   551  	const APIVersion = "2016-05-01-preview"
   552  	queryParameters := map[string]interface{}{
   553  		"api-version": APIVersion,
   554  	}
   555  
   556  	preparer := autorest.CreatePreparer(
   557  		autorest.AsContentType("application/json; charset=utf-8"),
   558  		autorest.AsPatch(),
   559  		autorest.WithBaseURL(client.BaseURI),
   560  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearning/webServices/{webServiceName}", pathParameters),
   561  		autorest.WithJSON(patchPayload),
   562  		autorest.WithQueryParameters(queryParameters))
   563  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   564  }
   565  
   566  // PatchSender sends the Patch request. The method will close the
   567  // http.Response Body if it receives an error.
   568  func (client Client) PatchSender(req *http.Request) (future PatchFuture, err error) {
   569  	var resp *http.Response
   570  	future.FutureAPI = &azure.Future{}
   571  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   572  	if err != nil {
   573  		return
   574  	}
   575  	var azf azure.Future
   576  	azf, err = azure.NewFutureFromResponse(resp)
   577  	future.FutureAPI = &azf
   578  	future.Result = future.result
   579  	return
   580  }
   581  
   582  // PatchResponder handles the response to the Patch request. The method always
   583  // closes the http.Response Body.
   584  func (client Client) PatchResponder(resp *http.Response) (result WebService, err error) {
   585  	err = autorest.Respond(
   586  		resp,
   587  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   588  		autorest.ByUnmarshallingJSON(&result),
   589  		autorest.ByClosing())
   590  	result.Response = autorest.Response{Response: resp}
   591  	return
   592  }
   593  
   594  // Remove deletes the specified web service.
   595  // Parameters:
   596  // resourceGroupName - name of the resource group in which the web service is located.
   597  // webServiceName - the name of the web service.
   598  func (client Client) Remove(ctx context.Context, resourceGroupName string, webServiceName string) (result RemoveFuture, err error) {
   599  	if tracing.IsEnabled() {
   600  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.Remove")
   601  		defer func() {
   602  			sc := -1
   603  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   604  				sc = result.FutureAPI.Response().StatusCode
   605  			}
   606  			tracing.EndSpan(ctx, sc, err)
   607  		}()
   608  	}
   609  	req, err := client.RemovePreparer(ctx, resourceGroupName, webServiceName)
   610  	if err != nil {
   611  		err = autorest.NewErrorWithError(err, "webservices.Client", "Remove", nil, "Failure preparing request")
   612  		return
   613  	}
   614  
   615  	result, err = client.RemoveSender(req)
   616  	if err != nil {
   617  		err = autorest.NewErrorWithError(err, "webservices.Client", "Remove", result.Response(), "Failure sending request")
   618  		return
   619  	}
   620  
   621  	return
   622  }
   623  
   624  // RemovePreparer prepares the Remove request.
   625  func (client Client) RemovePreparer(ctx context.Context, resourceGroupName string, webServiceName string) (*http.Request, error) {
   626  	pathParameters := map[string]interface{}{
   627  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   628  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   629  		"webServiceName":    autorest.Encode("path", webServiceName),
   630  	}
   631  
   632  	const APIVersion = "2016-05-01-preview"
   633  	queryParameters := map[string]interface{}{
   634  		"api-version": APIVersion,
   635  	}
   636  
   637  	preparer := autorest.CreatePreparer(
   638  		autorest.AsDelete(),
   639  		autorest.WithBaseURL(client.BaseURI),
   640  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearning/webServices/{webServiceName}", pathParameters),
   641  		autorest.WithQueryParameters(queryParameters))
   642  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   643  }
   644  
   645  // RemoveSender sends the Remove request. The method will close the
   646  // http.Response Body if it receives an error.
   647  func (client Client) RemoveSender(req *http.Request) (future RemoveFuture, err error) {
   648  	var resp *http.Response
   649  	future.FutureAPI = &azure.Future{}
   650  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   651  	if err != nil {
   652  		return
   653  	}
   654  	var azf azure.Future
   655  	azf, err = azure.NewFutureFromResponse(resp)
   656  	future.FutureAPI = &azf
   657  	future.Result = future.result
   658  	return
   659  }
   660  
   661  // RemoveResponder handles the response to the Remove request. The method always
   662  // closes the http.Response Body.
   663  func (client Client) RemoveResponder(resp *http.Response) (result autorest.Response, err error) {
   664  	err = autorest.Respond(
   665  		resp,
   666  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   667  		autorest.ByClosing())
   668  	result.Response = resp
   669  	return
   670  }
   671  

View as plain text