...

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

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/machinelearning/mgmt/2016-05-01-preview/commitmentplans

     1  package commitmentplans
     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 Commitment Plans resources and their
    18  // child Commitment Association resources. They support CRUD operations for commitment plans, get and list operations
    19  // for commitment associations, moving commitment associations between commitment plans, and retrieving commitment plan
    20  // usage history.
    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 a new Azure ML commitment plan resource or updates an existing one.
    37  // Parameters:
    38  // createOrUpdatePayload - the payload to create or update the Azure ML commitment plan.
    39  // resourceGroupName - the resource group name.
    40  // commitmentPlanName - the Azure ML commitment plan name.
    41  func (client Client) CreateOrUpdate(ctx context.Context, createOrUpdatePayload CommitmentPlan, resourceGroupName string, commitmentPlanName string) (result CommitmentPlan, err error) {
    42  	if tracing.IsEnabled() {
    43  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.CreateOrUpdate")
    44  		defer func() {
    45  			sc := -1
    46  			if result.Response.Response != nil {
    47  				sc = result.Response.Response.StatusCode
    48  			}
    49  			tracing.EndSpan(ctx, sc, err)
    50  		}()
    51  	}
    52  	req, err := client.CreateOrUpdatePreparer(ctx, createOrUpdatePayload, resourceGroupName, commitmentPlanName)
    53  	if err != nil {
    54  		err = autorest.NewErrorWithError(err, "commitmentplans.Client", "CreateOrUpdate", nil, "Failure preparing request")
    55  		return
    56  	}
    57  
    58  	resp, err := client.CreateOrUpdateSender(req)
    59  	if err != nil {
    60  		result.Response = autorest.Response{Response: resp}
    61  		err = autorest.NewErrorWithError(err, "commitmentplans.Client", "CreateOrUpdate", resp, "Failure sending request")
    62  		return
    63  	}
    64  
    65  	result, err = client.CreateOrUpdateResponder(resp)
    66  	if err != nil {
    67  		err = autorest.NewErrorWithError(err, "commitmentplans.Client", "CreateOrUpdate", resp, "Failure responding to request")
    68  		return
    69  	}
    70  
    71  	return
    72  }
    73  
    74  // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
    75  func (client Client) CreateOrUpdatePreparer(ctx context.Context, createOrUpdatePayload CommitmentPlan, resourceGroupName string, commitmentPlanName string) (*http.Request, error) {
    76  	pathParameters := map[string]interface{}{
    77  		"commitmentPlanName": autorest.Encode("path", commitmentPlanName),
    78  		"resourceGroupName":  autorest.Encode("path", resourceGroupName),
    79  		"subscriptionId":     autorest.Encode("path", client.SubscriptionID),
    80  	}
    81  
    82  	const APIVersion = "2016-05-01-preview"
    83  	queryParameters := map[string]interface{}{
    84  		"api-version": APIVersion,
    85  	}
    86  
    87  	createOrUpdatePayload.Properties = nil
    88  	preparer := autorest.CreatePreparer(
    89  		autorest.AsContentType("application/json; charset=utf-8"),
    90  		autorest.AsPut(),
    91  		autorest.WithBaseURL(client.BaseURI),
    92  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearning/commitmentPlans/{commitmentPlanName}", pathParameters),
    93  		autorest.WithJSON(createOrUpdatePayload),
    94  		autorest.WithQueryParameters(queryParameters))
    95  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    96  }
    97  
    98  // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
    99  // http.Response Body if it receives an error.
   100  func (client Client) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
   101  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   102  }
   103  
   104  // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
   105  // closes the http.Response Body.
   106  func (client Client) CreateOrUpdateResponder(resp *http.Response) (result CommitmentPlan, err error) {
   107  	err = autorest.Respond(
   108  		resp,
   109  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   110  		autorest.ByUnmarshallingJSON(&result),
   111  		autorest.ByClosing())
   112  	result.Response = autorest.Response{Response: resp}
   113  	return
   114  }
   115  
   116  // Get retrieve an Azure ML commitment plan by its subscription, resource group and name.
   117  // Parameters:
   118  // resourceGroupName - the resource group name.
   119  // commitmentPlanName - the Azure ML commitment plan name.
   120  func (client Client) Get(ctx context.Context, resourceGroupName string, commitmentPlanName string) (result CommitmentPlan, err error) {
   121  	if tracing.IsEnabled() {
   122  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.Get")
   123  		defer func() {
   124  			sc := -1
   125  			if result.Response.Response != nil {
   126  				sc = result.Response.Response.StatusCode
   127  			}
   128  			tracing.EndSpan(ctx, sc, err)
   129  		}()
   130  	}
   131  	req, err := client.GetPreparer(ctx, resourceGroupName, commitmentPlanName)
   132  	if err != nil {
   133  		err = autorest.NewErrorWithError(err, "commitmentplans.Client", "Get", nil, "Failure preparing request")
   134  		return
   135  	}
   136  
   137  	resp, err := client.GetSender(req)
   138  	if err != nil {
   139  		result.Response = autorest.Response{Response: resp}
   140  		err = autorest.NewErrorWithError(err, "commitmentplans.Client", "Get", resp, "Failure sending request")
   141  		return
   142  	}
   143  
   144  	result, err = client.GetResponder(resp)
   145  	if err != nil {
   146  		err = autorest.NewErrorWithError(err, "commitmentplans.Client", "Get", resp, "Failure responding to request")
   147  		return
   148  	}
   149  
   150  	return
   151  }
   152  
   153  // GetPreparer prepares the Get request.
   154  func (client Client) GetPreparer(ctx context.Context, resourceGroupName string, commitmentPlanName string) (*http.Request, error) {
   155  	pathParameters := map[string]interface{}{
   156  		"commitmentPlanName": autorest.Encode("path", commitmentPlanName),
   157  		"resourceGroupName":  autorest.Encode("path", resourceGroupName),
   158  		"subscriptionId":     autorest.Encode("path", client.SubscriptionID),
   159  	}
   160  
   161  	const APIVersion = "2016-05-01-preview"
   162  	queryParameters := map[string]interface{}{
   163  		"api-version": APIVersion,
   164  	}
   165  
   166  	preparer := autorest.CreatePreparer(
   167  		autorest.AsGet(),
   168  		autorest.WithBaseURL(client.BaseURI),
   169  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearning/commitmentPlans/{commitmentPlanName}", pathParameters),
   170  		autorest.WithQueryParameters(queryParameters))
   171  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   172  }
   173  
   174  // GetSender sends the Get request. The method will close the
   175  // http.Response Body if it receives an error.
   176  func (client Client) GetSender(req *http.Request) (*http.Response, error) {
   177  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   178  }
   179  
   180  // GetResponder handles the response to the Get request. The method always
   181  // closes the http.Response Body.
   182  func (client Client) GetResponder(resp *http.Response) (result CommitmentPlan, err error) {
   183  	err = autorest.Respond(
   184  		resp,
   185  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   186  		autorest.ByUnmarshallingJSON(&result),
   187  		autorest.ByClosing())
   188  	result.Response = autorest.Response{Response: resp}
   189  	return
   190  }
   191  
   192  // List retrieve all Azure ML commitment plans in a subscription.
   193  // Parameters:
   194  // skipToken - continuation token for pagination.
   195  func (client Client) List(ctx context.Context, skipToken string) (result ListResultPage, err error) {
   196  	if tracing.IsEnabled() {
   197  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.List")
   198  		defer func() {
   199  			sc := -1
   200  			if result.lr.Response.Response != nil {
   201  				sc = result.lr.Response.Response.StatusCode
   202  			}
   203  			tracing.EndSpan(ctx, sc, err)
   204  		}()
   205  	}
   206  	result.fn = client.listNextResults
   207  	req, err := client.ListPreparer(ctx, skipToken)
   208  	if err != nil {
   209  		err = autorest.NewErrorWithError(err, "commitmentplans.Client", "List", nil, "Failure preparing request")
   210  		return
   211  	}
   212  
   213  	resp, err := client.ListSender(req)
   214  	if err != nil {
   215  		result.lr.Response = autorest.Response{Response: resp}
   216  		err = autorest.NewErrorWithError(err, "commitmentplans.Client", "List", resp, "Failure sending request")
   217  		return
   218  	}
   219  
   220  	result.lr, err = client.ListResponder(resp)
   221  	if err != nil {
   222  		err = autorest.NewErrorWithError(err, "commitmentplans.Client", "List", resp, "Failure responding to request")
   223  		return
   224  	}
   225  	if result.lr.hasNextLink() && result.lr.IsEmpty() {
   226  		err = result.NextWithContext(ctx)
   227  		return
   228  	}
   229  
   230  	return
   231  }
   232  
   233  // ListPreparer prepares the List request.
   234  func (client Client) ListPreparer(ctx context.Context, skipToken string) (*http.Request, error) {
   235  	pathParameters := map[string]interface{}{
   236  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
   237  	}
   238  
   239  	const APIVersion = "2016-05-01-preview"
   240  	queryParameters := map[string]interface{}{
   241  		"api-version": APIVersion,
   242  	}
   243  	if len(skipToken) > 0 {
   244  		queryParameters["$skipToken"] = autorest.Encode("query", skipToken)
   245  	}
   246  
   247  	preparer := autorest.CreatePreparer(
   248  		autorest.AsGet(),
   249  		autorest.WithBaseURL(client.BaseURI),
   250  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.MachineLearning/commitmentPlans", pathParameters),
   251  		autorest.WithQueryParameters(queryParameters))
   252  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   253  }
   254  
   255  // ListSender sends the List request. The method will close the
   256  // http.Response Body if it receives an error.
   257  func (client Client) ListSender(req *http.Request) (*http.Response, error) {
   258  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   259  }
   260  
   261  // ListResponder handles the response to the List request. The method always
   262  // closes the http.Response Body.
   263  func (client Client) ListResponder(resp *http.Response) (result ListResult, err error) {
   264  	err = autorest.Respond(
   265  		resp,
   266  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   267  		autorest.ByUnmarshallingJSON(&result),
   268  		autorest.ByClosing())
   269  	result.Response = autorest.Response{Response: resp}
   270  	return
   271  }
   272  
   273  // listNextResults retrieves the next set of results, if any.
   274  func (client Client) listNextResults(ctx context.Context, lastResults ListResult) (result ListResult, err error) {
   275  	req, err := lastResults.listResultPreparer(ctx)
   276  	if err != nil {
   277  		return result, autorest.NewErrorWithError(err, "commitmentplans.Client", "listNextResults", nil, "Failure preparing next results request")
   278  	}
   279  	if req == nil {
   280  		return
   281  	}
   282  	resp, err := client.ListSender(req)
   283  	if err != nil {
   284  		result.Response = autorest.Response{Response: resp}
   285  		return result, autorest.NewErrorWithError(err, "commitmentplans.Client", "listNextResults", resp, "Failure sending next results request")
   286  	}
   287  	result, err = client.ListResponder(resp)
   288  	if err != nil {
   289  		err = autorest.NewErrorWithError(err, "commitmentplans.Client", "listNextResults", resp, "Failure responding to next results request")
   290  	}
   291  	return
   292  }
   293  
   294  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   295  func (client Client) ListComplete(ctx context.Context, skipToken string) (result ListResultIterator, err error) {
   296  	if tracing.IsEnabled() {
   297  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.List")
   298  		defer func() {
   299  			sc := -1
   300  			if result.Response().Response.Response != nil {
   301  				sc = result.page.Response().Response.Response.StatusCode
   302  			}
   303  			tracing.EndSpan(ctx, sc, err)
   304  		}()
   305  	}
   306  	result.page, err = client.List(ctx, skipToken)
   307  	return
   308  }
   309  
   310  // ListInResourceGroup retrieve all Azure ML commitment plans in a resource group.
   311  // Parameters:
   312  // resourceGroupName - the resource group name.
   313  // skipToken - continuation token for pagination.
   314  func (client Client) ListInResourceGroup(ctx context.Context, resourceGroupName string, skipToken string) (result ListResultPage, err error) {
   315  	if tracing.IsEnabled() {
   316  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListInResourceGroup")
   317  		defer func() {
   318  			sc := -1
   319  			if result.lr.Response.Response != nil {
   320  				sc = result.lr.Response.Response.StatusCode
   321  			}
   322  			tracing.EndSpan(ctx, sc, err)
   323  		}()
   324  	}
   325  	result.fn = client.listInResourceGroupNextResults
   326  	req, err := client.ListInResourceGroupPreparer(ctx, resourceGroupName, skipToken)
   327  	if err != nil {
   328  		err = autorest.NewErrorWithError(err, "commitmentplans.Client", "ListInResourceGroup", nil, "Failure preparing request")
   329  		return
   330  	}
   331  
   332  	resp, err := client.ListInResourceGroupSender(req)
   333  	if err != nil {
   334  		result.lr.Response = autorest.Response{Response: resp}
   335  		err = autorest.NewErrorWithError(err, "commitmentplans.Client", "ListInResourceGroup", resp, "Failure sending request")
   336  		return
   337  	}
   338  
   339  	result.lr, err = client.ListInResourceGroupResponder(resp)
   340  	if err != nil {
   341  		err = autorest.NewErrorWithError(err, "commitmentplans.Client", "ListInResourceGroup", resp, "Failure responding to request")
   342  		return
   343  	}
   344  	if result.lr.hasNextLink() && result.lr.IsEmpty() {
   345  		err = result.NextWithContext(ctx)
   346  		return
   347  	}
   348  
   349  	return
   350  }
   351  
   352  // ListInResourceGroupPreparer prepares the ListInResourceGroup request.
   353  func (client Client) ListInResourceGroupPreparer(ctx context.Context, resourceGroupName string, skipToken string) (*http.Request, error) {
   354  	pathParameters := map[string]interface{}{
   355  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   356  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   357  	}
   358  
   359  	const APIVersion = "2016-05-01-preview"
   360  	queryParameters := map[string]interface{}{
   361  		"api-version": APIVersion,
   362  	}
   363  	if len(skipToken) > 0 {
   364  		queryParameters["$skipToken"] = autorest.Encode("query", skipToken)
   365  	}
   366  
   367  	preparer := autorest.CreatePreparer(
   368  		autorest.AsGet(),
   369  		autorest.WithBaseURL(client.BaseURI),
   370  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearning/commitmentPlans", pathParameters),
   371  		autorest.WithQueryParameters(queryParameters))
   372  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   373  }
   374  
   375  // ListInResourceGroupSender sends the ListInResourceGroup request. The method will close the
   376  // http.Response Body if it receives an error.
   377  func (client Client) ListInResourceGroupSender(req *http.Request) (*http.Response, error) {
   378  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   379  }
   380  
   381  // ListInResourceGroupResponder handles the response to the ListInResourceGroup request. The method always
   382  // closes the http.Response Body.
   383  func (client Client) ListInResourceGroupResponder(resp *http.Response) (result ListResult, err error) {
   384  	err = autorest.Respond(
   385  		resp,
   386  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   387  		autorest.ByUnmarshallingJSON(&result),
   388  		autorest.ByClosing())
   389  	result.Response = autorest.Response{Response: resp}
   390  	return
   391  }
   392  
   393  // listInResourceGroupNextResults retrieves the next set of results, if any.
   394  func (client Client) listInResourceGroupNextResults(ctx context.Context, lastResults ListResult) (result ListResult, err error) {
   395  	req, err := lastResults.listResultPreparer(ctx)
   396  	if err != nil {
   397  		return result, autorest.NewErrorWithError(err, "commitmentplans.Client", "listInResourceGroupNextResults", nil, "Failure preparing next results request")
   398  	}
   399  	if req == nil {
   400  		return
   401  	}
   402  	resp, err := client.ListInResourceGroupSender(req)
   403  	if err != nil {
   404  		result.Response = autorest.Response{Response: resp}
   405  		return result, autorest.NewErrorWithError(err, "commitmentplans.Client", "listInResourceGroupNextResults", resp, "Failure sending next results request")
   406  	}
   407  	result, err = client.ListInResourceGroupResponder(resp)
   408  	if err != nil {
   409  		err = autorest.NewErrorWithError(err, "commitmentplans.Client", "listInResourceGroupNextResults", resp, "Failure responding to next results request")
   410  	}
   411  	return
   412  }
   413  
   414  // ListInResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
   415  func (client Client) ListInResourceGroupComplete(ctx context.Context, resourceGroupName string, skipToken string) (result ListResultIterator, err error) {
   416  	if tracing.IsEnabled() {
   417  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListInResourceGroup")
   418  		defer func() {
   419  			sc := -1
   420  			if result.Response().Response.Response != nil {
   421  				sc = result.page.Response().Response.Response.StatusCode
   422  			}
   423  			tracing.EndSpan(ctx, sc, err)
   424  		}()
   425  	}
   426  	result.page, err = client.ListInResourceGroup(ctx, resourceGroupName, skipToken)
   427  	return
   428  }
   429  
   430  // Patch patch an existing Azure ML commitment plan resource.
   431  // Parameters:
   432  // patchPayload - the payload to use to patch the Azure ML commitment plan. Only tags and SKU may be modified
   433  // on an existing commitment plan.
   434  // resourceGroupName - the resource group name.
   435  // commitmentPlanName - the Azure ML commitment plan name.
   436  func (client Client) Patch(ctx context.Context, patchPayload PatchPayload, resourceGroupName string, commitmentPlanName string) (result CommitmentPlan, err error) {
   437  	if tracing.IsEnabled() {
   438  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.Patch")
   439  		defer func() {
   440  			sc := -1
   441  			if result.Response.Response != nil {
   442  				sc = result.Response.Response.StatusCode
   443  			}
   444  			tracing.EndSpan(ctx, sc, err)
   445  		}()
   446  	}
   447  	req, err := client.PatchPreparer(ctx, patchPayload, resourceGroupName, commitmentPlanName)
   448  	if err != nil {
   449  		err = autorest.NewErrorWithError(err, "commitmentplans.Client", "Patch", nil, "Failure preparing request")
   450  		return
   451  	}
   452  
   453  	resp, err := client.PatchSender(req)
   454  	if err != nil {
   455  		result.Response = autorest.Response{Response: resp}
   456  		err = autorest.NewErrorWithError(err, "commitmentplans.Client", "Patch", resp, "Failure sending request")
   457  		return
   458  	}
   459  
   460  	result, err = client.PatchResponder(resp)
   461  	if err != nil {
   462  		err = autorest.NewErrorWithError(err, "commitmentplans.Client", "Patch", resp, "Failure responding to request")
   463  		return
   464  	}
   465  
   466  	return
   467  }
   468  
   469  // PatchPreparer prepares the Patch request.
   470  func (client Client) PatchPreparer(ctx context.Context, patchPayload PatchPayload, resourceGroupName string, commitmentPlanName string) (*http.Request, error) {
   471  	pathParameters := map[string]interface{}{
   472  		"commitmentPlanName": autorest.Encode("path", commitmentPlanName),
   473  		"resourceGroupName":  autorest.Encode("path", resourceGroupName),
   474  		"subscriptionId":     autorest.Encode("path", client.SubscriptionID),
   475  	}
   476  
   477  	const APIVersion = "2016-05-01-preview"
   478  	queryParameters := map[string]interface{}{
   479  		"api-version": APIVersion,
   480  	}
   481  
   482  	preparer := autorest.CreatePreparer(
   483  		autorest.AsContentType("application/json; charset=utf-8"),
   484  		autorest.AsPatch(),
   485  		autorest.WithBaseURL(client.BaseURI),
   486  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearning/commitmentPlans/{commitmentPlanName}", pathParameters),
   487  		autorest.WithJSON(patchPayload),
   488  		autorest.WithQueryParameters(queryParameters))
   489  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   490  }
   491  
   492  // PatchSender sends the Patch request. The method will close the
   493  // http.Response Body if it receives an error.
   494  func (client Client) PatchSender(req *http.Request) (*http.Response, error) {
   495  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   496  }
   497  
   498  // PatchResponder handles the response to the Patch request. The method always
   499  // closes the http.Response Body.
   500  func (client Client) PatchResponder(resp *http.Response) (result CommitmentPlan, err error) {
   501  	err = autorest.Respond(
   502  		resp,
   503  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   504  		autorest.ByUnmarshallingJSON(&result),
   505  		autorest.ByClosing())
   506  	result.Response = autorest.Response{Response: resp}
   507  	return
   508  }
   509  
   510  // Remove remove an existing Azure ML commitment plan.
   511  // Parameters:
   512  // resourceGroupName - the resource group name.
   513  // commitmentPlanName - the Azure ML commitment plan name.
   514  func (client Client) Remove(ctx context.Context, resourceGroupName string, commitmentPlanName string) (result autorest.Response, err error) {
   515  	if tracing.IsEnabled() {
   516  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.Remove")
   517  		defer func() {
   518  			sc := -1
   519  			if result.Response != nil {
   520  				sc = result.Response.StatusCode
   521  			}
   522  			tracing.EndSpan(ctx, sc, err)
   523  		}()
   524  	}
   525  	req, err := client.RemovePreparer(ctx, resourceGroupName, commitmentPlanName)
   526  	if err != nil {
   527  		err = autorest.NewErrorWithError(err, "commitmentplans.Client", "Remove", nil, "Failure preparing request")
   528  		return
   529  	}
   530  
   531  	resp, err := client.RemoveSender(req)
   532  	if err != nil {
   533  		result.Response = resp
   534  		err = autorest.NewErrorWithError(err, "commitmentplans.Client", "Remove", resp, "Failure sending request")
   535  		return
   536  	}
   537  
   538  	result, err = client.RemoveResponder(resp)
   539  	if err != nil {
   540  		err = autorest.NewErrorWithError(err, "commitmentplans.Client", "Remove", resp, "Failure responding to request")
   541  		return
   542  	}
   543  
   544  	return
   545  }
   546  
   547  // RemovePreparer prepares the Remove request.
   548  func (client Client) RemovePreparer(ctx context.Context, resourceGroupName string, commitmentPlanName string) (*http.Request, error) {
   549  	pathParameters := map[string]interface{}{
   550  		"commitmentPlanName": autorest.Encode("path", commitmentPlanName),
   551  		"resourceGroupName":  autorest.Encode("path", resourceGroupName),
   552  		"subscriptionId":     autorest.Encode("path", client.SubscriptionID),
   553  	}
   554  
   555  	const APIVersion = "2016-05-01-preview"
   556  	queryParameters := map[string]interface{}{
   557  		"api-version": APIVersion,
   558  	}
   559  
   560  	preparer := autorest.CreatePreparer(
   561  		autorest.AsDelete(),
   562  		autorest.WithBaseURL(client.BaseURI),
   563  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearning/commitmentPlans/{commitmentPlanName}", pathParameters),
   564  		autorest.WithQueryParameters(queryParameters))
   565  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   566  }
   567  
   568  // RemoveSender sends the Remove request. The method will close the
   569  // http.Response Body if it receives an error.
   570  func (client Client) RemoveSender(req *http.Request) (*http.Response, error) {
   571  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   572  }
   573  
   574  // RemoveResponder handles the response to the Remove request. The method always
   575  // closes the http.Response Body.
   576  func (client Client) RemoveResponder(resp *http.Response) (result autorest.Response, err error) {
   577  	err = autorest.Respond(
   578  		resp,
   579  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   580  		autorest.ByClosing())
   581  	result.Response = resp
   582  	return
   583  }
   584  

View as plain text