...

Source file src/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/features/providers.go

Documentation: github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/features

     1  package features
     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  // ProvidersClient is the provides operations for working with resources and resource groups.
    18  type ProvidersClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewProvidersClient creates an instance of the ProvidersClient client.
    23  func NewProvidersClient(subscriptionID string) ProvidersClient {
    24  	return NewProvidersClientWithBaseURI(DefaultBaseURI, subscriptionID)
    25  }
    26  
    27  // NewProvidersClientWithBaseURI creates an instance of the ProvidersClient client using a custom endpoint.  Use this
    28  // when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    29  func NewProvidersClientWithBaseURI(baseURI string, subscriptionID string) ProvidersClient {
    30  	return ProvidersClient{NewWithBaseURI(baseURI, subscriptionID)}
    31  }
    32  
    33  // Get gets the specified resource provider.
    34  // Parameters:
    35  // resourceProviderNamespace - the namespace of the resource provider.
    36  // expand - the $expand query parameter. For example, to include property aliases in response, use
    37  // $expand=resourceTypes/aliases.
    38  func (client ProvidersClient) Get(ctx context.Context, resourceProviderNamespace string, expand string) (result Provider, err error) {
    39  	if tracing.IsEnabled() {
    40  		ctx = tracing.StartSpan(ctx, fqdn+"/ProvidersClient.Get")
    41  		defer func() {
    42  			sc := -1
    43  			if result.Response.Response != nil {
    44  				sc = result.Response.Response.StatusCode
    45  			}
    46  			tracing.EndSpan(ctx, sc, err)
    47  		}()
    48  	}
    49  	req, err := client.GetPreparer(ctx, resourceProviderNamespace, expand)
    50  	if err != nil {
    51  		err = autorest.NewErrorWithError(err, "features.ProvidersClient", "Get", nil, "Failure preparing request")
    52  		return
    53  	}
    54  
    55  	resp, err := client.GetSender(req)
    56  	if err != nil {
    57  		result.Response = autorest.Response{Response: resp}
    58  		err = autorest.NewErrorWithError(err, "features.ProvidersClient", "Get", resp, "Failure sending request")
    59  		return
    60  	}
    61  
    62  	result, err = client.GetResponder(resp)
    63  	if err != nil {
    64  		err = autorest.NewErrorWithError(err, "features.ProvidersClient", "Get", resp, "Failure responding to request")
    65  		return
    66  	}
    67  
    68  	return
    69  }
    70  
    71  // GetPreparer prepares the Get request.
    72  func (client ProvidersClient) GetPreparer(ctx context.Context, resourceProviderNamespace string, expand string) (*http.Request, error) {
    73  	pathParameters := map[string]interface{}{
    74  		"resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace),
    75  		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
    76  	}
    77  
    78  	const APIVersion = "2019-07-01"
    79  	queryParameters := map[string]interface{}{
    80  		"api-version": APIVersion,
    81  	}
    82  	if len(expand) > 0 {
    83  		queryParameters["$expand"] = autorest.Encode("query", expand)
    84  	}
    85  
    86  	preparer := autorest.CreatePreparer(
    87  		autorest.AsGet(),
    88  		autorest.WithBaseURL(client.BaseURI),
    89  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}", pathParameters),
    90  		autorest.WithQueryParameters(queryParameters))
    91  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    92  }
    93  
    94  // GetSender sends the Get request. The method will close the
    95  // http.Response Body if it receives an error.
    96  func (client ProvidersClient) GetSender(req *http.Request) (*http.Response, error) {
    97  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
    98  }
    99  
   100  // GetResponder handles the response to the Get request. The method always
   101  // closes the http.Response Body.
   102  func (client ProvidersClient) GetResponder(resp *http.Response) (result Provider, err error) {
   103  	err = autorest.Respond(
   104  		resp,
   105  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   106  		autorest.ByUnmarshallingJSON(&result),
   107  		autorest.ByClosing())
   108  	result.Response = autorest.Response{Response: resp}
   109  	return
   110  }
   111  
   112  // GetAtTenantScope gets the specified resource provider at the tenant level.
   113  // Parameters:
   114  // resourceProviderNamespace - the namespace of the resource provider.
   115  // expand - the $expand query parameter. For example, to include property aliases in response, use
   116  // $expand=resourceTypes/aliases.
   117  func (client ProvidersClient) GetAtTenantScope(ctx context.Context, resourceProviderNamespace string, expand string) (result Provider, err error) {
   118  	if tracing.IsEnabled() {
   119  		ctx = tracing.StartSpan(ctx, fqdn+"/ProvidersClient.GetAtTenantScope")
   120  		defer func() {
   121  			sc := -1
   122  			if result.Response.Response != nil {
   123  				sc = result.Response.Response.StatusCode
   124  			}
   125  			tracing.EndSpan(ctx, sc, err)
   126  		}()
   127  	}
   128  	req, err := client.GetAtTenantScopePreparer(ctx, resourceProviderNamespace, expand)
   129  	if err != nil {
   130  		err = autorest.NewErrorWithError(err, "features.ProvidersClient", "GetAtTenantScope", nil, "Failure preparing request")
   131  		return
   132  	}
   133  
   134  	resp, err := client.GetAtTenantScopeSender(req)
   135  	if err != nil {
   136  		result.Response = autorest.Response{Response: resp}
   137  		err = autorest.NewErrorWithError(err, "features.ProvidersClient", "GetAtTenantScope", resp, "Failure sending request")
   138  		return
   139  	}
   140  
   141  	result, err = client.GetAtTenantScopeResponder(resp)
   142  	if err != nil {
   143  		err = autorest.NewErrorWithError(err, "features.ProvidersClient", "GetAtTenantScope", resp, "Failure responding to request")
   144  		return
   145  	}
   146  
   147  	return
   148  }
   149  
   150  // GetAtTenantScopePreparer prepares the GetAtTenantScope request.
   151  func (client ProvidersClient) GetAtTenantScopePreparer(ctx context.Context, resourceProviderNamespace string, expand string) (*http.Request, error) {
   152  	pathParameters := map[string]interface{}{
   153  		"resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace),
   154  	}
   155  
   156  	const APIVersion = "2019-07-01"
   157  	queryParameters := map[string]interface{}{
   158  		"api-version": APIVersion,
   159  	}
   160  	if len(expand) > 0 {
   161  		queryParameters["$expand"] = autorest.Encode("query", expand)
   162  	}
   163  
   164  	preparer := autorest.CreatePreparer(
   165  		autorest.AsGet(),
   166  		autorest.WithBaseURL(client.BaseURI),
   167  		autorest.WithPathParameters("/providers/{resourceProviderNamespace}", pathParameters),
   168  		autorest.WithQueryParameters(queryParameters))
   169  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   170  }
   171  
   172  // GetAtTenantScopeSender sends the GetAtTenantScope request. The method will close the
   173  // http.Response Body if it receives an error.
   174  func (client ProvidersClient) GetAtTenantScopeSender(req *http.Request) (*http.Response, error) {
   175  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   176  }
   177  
   178  // GetAtTenantScopeResponder handles the response to the GetAtTenantScope request. The method always
   179  // closes the http.Response Body.
   180  func (client ProvidersClient) GetAtTenantScopeResponder(resp *http.Response) (result Provider, err error) {
   181  	err = autorest.Respond(
   182  		resp,
   183  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   184  		autorest.ByUnmarshallingJSON(&result),
   185  		autorest.ByClosing())
   186  	result.Response = autorest.Response{Response: resp}
   187  	return
   188  }
   189  
   190  // List gets all resource providers for a subscription.
   191  // Parameters:
   192  // top - the number of results to return. If null is passed returns all deployments.
   193  // expand - the properties to include in the results. For example, use &$expand=metadata in the query string to
   194  // retrieve resource provider metadata. To include property aliases in response, use
   195  // $expand=resourceTypes/aliases.
   196  func (client ProvidersClient) List(ctx context.Context, top *int32, expand string) (result ProviderListResultPage, err error) {
   197  	if tracing.IsEnabled() {
   198  		ctx = tracing.StartSpan(ctx, fqdn+"/ProvidersClient.List")
   199  		defer func() {
   200  			sc := -1
   201  			if result.plr.Response.Response != nil {
   202  				sc = result.plr.Response.Response.StatusCode
   203  			}
   204  			tracing.EndSpan(ctx, sc, err)
   205  		}()
   206  	}
   207  	result.fn = client.listNextResults
   208  	req, err := client.ListPreparer(ctx, top, expand)
   209  	if err != nil {
   210  		err = autorest.NewErrorWithError(err, "features.ProvidersClient", "List", nil, "Failure preparing request")
   211  		return
   212  	}
   213  
   214  	resp, err := client.ListSender(req)
   215  	if err != nil {
   216  		result.plr.Response = autorest.Response{Response: resp}
   217  		err = autorest.NewErrorWithError(err, "features.ProvidersClient", "List", resp, "Failure sending request")
   218  		return
   219  	}
   220  
   221  	result.plr, err = client.ListResponder(resp)
   222  	if err != nil {
   223  		err = autorest.NewErrorWithError(err, "features.ProvidersClient", "List", resp, "Failure responding to request")
   224  		return
   225  	}
   226  	if result.plr.hasNextLink() && result.plr.IsEmpty() {
   227  		err = result.NextWithContext(ctx)
   228  		return
   229  	}
   230  
   231  	return
   232  }
   233  
   234  // ListPreparer prepares the List request.
   235  func (client ProvidersClient) ListPreparer(ctx context.Context, top *int32, expand string) (*http.Request, error) {
   236  	pathParameters := map[string]interface{}{
   237  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
   238  	}
   239  
   240  	const APIVersion = "2019-07-01"
   241  	queryParameters := map[string]interface{}{
   242  		"api-version": APIVersion,
   243  	}
   244  	if top != nil {
   245  		queryParameters["$top"] = autorest.Encode("query", *top)
   246  	}
   247  	if len(expand) > 0 {
   248  		queryParameters["$expand"] = autorest.Encode("query", expand)
   249  	}
   250  
   251  	preparer := autorest.CreatePreparer(
   252  		autorest.AsGet(),
   253  		autorest.WithBaseURL(client.BaseURI),
   254  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers", pathParameters),
   255  		autorest.WithQueryParameters(queryParameters))
   256  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   257  }
   258  
   259  // ListSender sends the List request. The method will close the
   260  // http.Response Body if it receives an error.
   261  func (client ProvidersClient) ListSender(req *http.Request) (*http.Response, error) {
   262  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   263  }
   264  
   265  // ListResponder handles the response to the List request. The method always
   266  // closes the http.Response Body.
   267  func (client ProvidersClient) ListResponder(resp *http.Response) (result ProviderListResult, err error) {
   268  	err = autorest.Respond(
   269  		resp,
   270  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   271  		autorest.ByUnmarshallingJSON(&result),
   272  		autorest.ByClosing())
   273  	result.Response = autorest.Response{Response: resp}
   274  	return
   275  }
   276  
   277  // listNextResults retrieves the next set of results, if any.
   278  func (client ProvidersClient) listNextResults(ctx context.Context, lastResults ProviderListResult) (result ProviderListResult, err error) {
   279  	req, err := lastResults.providerListResultPreparer(ctx)
   280  	if err != nil {
   281  		return result, autorest.NewErrorWithError(err, "features.ProvidersClient", "listNextResults", nil, "Failure preparing next results request")
   282  	}
   283  	if req == nil {
   284  		return
   285  	}
   286  	resp, err := client.ListSender(req)
   287  	if err != nil {
   288  		result.Response = autorest.Response{Response: resp}
   289  		return result, autorest.NewErrorWithError(err, "features.ProvidersClient", "listNextResults", resp, "Failure sending next results request")
   290  	}
   291  	result, err = client.ListResponder(resp)
   292  	if err != nil {
   293  		err = autorest.NewErrorWithError(err, "features.ProvidersClient", "listNextResults", resp, "Failure responding to next results request")
   294  	}
   295  	return
   296  }
   297  
   298  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   299  func (client ProvidersClient) ListComplete(ctx context.Context, top *int32, expand string) (result ProviderListResultIterator, err error) {
   300  	if tracing.IsEnabled() {
   301  		ctx = tracing.StartSpan(ctx, fqdn+"/ProvidersClient.List")
   302  		defer func() {
   303  			sc := -1
   304  			if result.Response().Response.Response != nil {
   305  				sc = result.page.Response().Response.Response.StatusCode
   306  			}
   307  			tracing.EndSpan(ctx, sc, err)
   308  		}()
   309  	}
   310  	result.page, err = client.List(ctx, top, expand)
   311  	return
   312  }
   313  
   314  // ListAtTenantScope gets all resource providers for the tenant.
   315  // Parameters:
   316  // top - the number of results to return. If null is passed returns all providers.
   317  // expand - the properties to include in the results. For example, use &$expand=metadata in the query string to
   318  // retrieve resource provider metadata. To include property aliases in response, use
   319  // $expand=resourceTypes/aliases.
   320  func (client ProvidersClient) ListAtTenantScope(ctx context.Context, top *int32, expand string) (result ProviderListResultPage, err error) {
   321  	if tracing.IsEnabled() {
   322  		ctx = tracing.StartSpan(ctx, fqdn+"/ProvidersClient.ListAtTenantScope")
   323  		defer func() {
   324  			sc := -1
   325  			if result.plr.Response.Response != nil {
   326  				sc = result.plr.Response.Response.StatusCode
   327  			}
   328  			tracing.EndSpan(ctx, sc, err)
   329  		}()
   330  	}
   331  	result.fn = client.listAtTenantScopeNextResults
   332  	req, err := client.ListAtTenantScopePreparer(ctx, top, expand)
   333  	if err != nil {
   334  		err = autorest.NewErrorWithError(err, "features.ProvidersClient", "ListAtTenantScope", nil, "Failure preparing request")
   335  		return
   336  	}
   337  
   338  	resp, err := client.ListAtTenantScopeSender(req)
   339  	if err != nil {
   340  		result.plr.Response = autorest.Response{Response: resp}
   341  		err = autorest.NewErrorWithError(err, "features.ProvidersClient", "ListAtTenantScope", resp, "Failure sending request")
   342  		return
   343  	}
   344  
   345  	result.plr, err = client.ListAtTenantScopeResponder(resp)
   346  	if err != nil {
   347  		err = autorest.NewErrorWithError(err, "features.ProvidersClient", "ListAtTenantScope", resp, "Failure responding to request")
   348  		return
   349  	}
   350  	if result.plr.hasNextLink() && result.plr.IsEmpty() {
   351  		err = result.NextWithContext(ctx)
   352  		return
   353  	}
   354  
   355  	return
   356  }
   357  
   358  // ListAtTenantScopePreparer prepares the ListAtTenantScope request.
   359  func (client ProvidersClient) ListAtTenantScopePreparer(ctx context.Context, top *int32, expand string) (*http.Request, error) {
   360  	const APIVersion = "2019-07-01"
   361  	queryParameters := map[string]interface{}{
   362  		"api-version": APIVersion,
   363  	}
   364  	if top != nil {
   365  		queryParameters["$top"] = autorest.Encode("query", *top)
   366  	}
   367  	if len(expand) > 0 {
   368  		queryParameters["$expand"] = autorest.Encode("query", expand)
   369  	}
   370  
   371  	preparer := autorest.CreatePreparer(
   372  		autorest.AsGet(),
   373  		autorest.WithBaseURL(client.BaseURI),
   374  		autorest.WithPath("/providers"),
   375  		autorest.WithQueryParameters(queryParameters))
   376  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   377  }
   378  
   379  // ListAtTenantScopeSender sends the ListAtTenantScope request. The method will close the
   380  // http.Response Body if it receives an error.
   381  func (client ProvidersClient) ListAtTenantScopeSender(req *http.Request) (*http.Response, error) {
   382  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   383  }
   384  
   385  // ListAtTenantScopeResponder handles the response to the ListAtTenantScope request. The method always
   386  // closes the http.Response Body.
   387  func (client ProvidersClient) ListAtTenantScopeResponder(resp *http.Response) (result ProviderListResult, err error) {
   388  	err = autorest.Respond(
   389  		resp,
   390  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   391  		autorest.ByUnmarshallingJSON(&result),
   392  		autorest.ByClosing())
   393  	result.Response = autorest.Response{Response: resp}
   394  	return
   395  }
   396  
   397  // listAtTenantScopeNextResults retrieves the next set of results, if any.
   398  func (client ProvidersClient) listAtTenantScopeNextResults(ctx context.Context, lastResults ProviderListResult) (result ProviderListResult, err error) {
   399  	req, err := lastResults.providerListResultPreparer(ctx)
   400  	if err != nil {
   401  		return result, autorest.NewErrorWithError(err, "features.ProvidersClient", "listAtTenantScopeNextResults", nil, "Failure preparing next results request")
   402  	}
   403  	if req == nil {
   404  		return
   405  	}
   406  	resp, err := client.ListAtTenantScopeSender(req)
   407  	if err != nil {
   408  		result.Response = autorest.Response{Response: resp}
   409  		return result, autorest.NewErrorWithError(err, "features.ProvidersClient", "listAtTenantScopeNextResults", resp, "Failure sending next results request")
   410  	}
   411  	result, err = client.ListAtTenantScopeResponder(resp)
   412  	if err != nil {
   413  		err = autorest.NewErrorWithError(err, "features.ProvidersClient", "listAtTenantScopeNextResults", resp, "Failure responding to next results request")
   414  	}
   415  	return
   416  }
   417  
   418  // ListAtTenantScopeComplete enumerates all values, automatically crossing page boundaries as required.
   419  func (client ProvidersClient) ListAtTenantScopeComplete(ctx context.Context, top *int32, expand string) (result ProviderListResultIterator, err error) {
   420  	if tracing.IsEnabled() {
   421  		ctx = tracing.StartSpan(ctx, fqdn+"/ProvidersClient.ListAtTenantScope")
   422  		defer func() {
   423  			sc := -1
   424  			if result.Response().Response.Response != nil {
   425  				sc = result.page.Response().Response.Response.StatusCode
   426  			}
   427  			tracing.EndSpan(ctx, sc, err)
   428  		}()
   429  	}
   430  	result.page, err = client.ListAtTenantScope(ctx, top, expand)
   431  	return
   432  }
   433  
   434  // Register registers a subscription with a resource provider.
   435  // Parameters:
   436  // resourceProviderNamespace - the namespace of the resource provider to register.
   437  func (client ProvidersClient) Register(ctx context.Context, resourceProviderNamespace string) (result Provider, err error) {
   438  	if tracing.IsEnabled() {
   439  		ctx = tracing.StartSpan(ctx, fqdn+"/ProvidersClient.Register")
   440  		defer func() {
   441  			sc := -1
   442  			if result.Response.Response != nil {
   443  				sc = result.Response.Response.StatusCode
   444  			}
   445  			tracing.EndSpan(ctx, sc, err)
   446  		}()
   447  	}
   448  	req, err := client.RegisterPreparer(ctx, resourceProviderNamespace)
   449  	if err != nil {
   450  		err = autorest.NewErrorWithError(err, "features.ProvidersClient", "Register", nil, "Failure preparing request")
   451  		return
   452  	}
   453  
   454  	resp, err := client.RegisterSender(req)
   455  	if err != nil {
   456  		result.Response = autorest.Response{Response: resp}
   457  		err = autorest.NewErrorWithError(err, "features.ProvidersClient", "Register", resp, "Failure sending request")
   458  		return
   459  	}
   460  
   461  	result, err = client.RegisterResponder(resp)
   462  	if err != nil {
   463  		err = autorest.NewErrorWithError(err, "features.ProvidersClient", "Register", resp, "Failure responding to request")
   464  		return
   465  	}
   466  
   467  	return
   468  }
   469  
   470  // RegisterPreparer prepares the Register request.
   471  func (client ProvidersClient) RegisterPreparer(ctx context.Context, resourceProviderNamespace string) (*http.Request, error) {
   472  	pathParameters := map[string]interface{}{
   473  		"resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace),
   474  		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
   475  	}
   476  
   477  	const APIVersion = "2019-07-01"
   478  	queryParameters := map[string]interface{}{
   479  		"api-version": APIVersion,
   480  	}
   481  
   482  	preparer := autorest.CreatePreparer(
   483  		autorest.AsPost(),
   484  		autorest.WithBaseURL(client.BaseURI),
   485  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register", pathParameters),
   486  		autorest.WithQueryParameters(queryParameters))
   487  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   488  }
   489  
   490  // RegisterSender sends the Register request. The method will close the
   491  // http.Response Body if it receives an error.
   492  func (client ProvidersClient) RegisterSender(req *http.Request) (*http.Response, error) {
   493  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   494  }
   495  
   496  // RegisterResponder handles the response to the Register request. The method always
   497  // closes the http.Response Body.
   498  func (client ProvidersClient) RegisterResponder(resp *http.Response) (result Provider, err error) {
   499  	err = autorest.Respond(
   500  		resp,
   501  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   502  		autorest.ByUnmarshallingJSON(&result),
   503  		autorest.ByClosing())
   504  	result.Response = autorest.Response{Response: resp}
   505  	return
   506  }
   507  
   508  // Unregister unregisters a subscription from a resource provider.
   509  // Parameters:
   510  // resourceProviderNamespace - the namespace of the resource provider to unregister.
   511  func (client ProvidersClient) Unregister(ctx context.Context, resourceProviderNamespace string) (result Provider, err error) {
   512  	if tracing.IsEnabled() {
   513  		ctx = tracing.StartSpan(ctx, fqdn+"/ProvidersClient.Unregister")
   514  		defer func() {
   515  			sc := -1
   516  			if result.Response.Response != nil {
   517  				sc = result.Response.Response.StatusCode
   518  			}
   519  			tracing.EndSpan(ctx, sc, err)
   520  		}()
   521  	}
   522  	req, err := client.UnregisterPreparer(ctx, resourceProviderNamespace)
   523  	if err != nil {
   524  		err = autorest.NewErrorWithError(err, "features.ProvidersClient", "Unregister", nil, "Failure preparing request")
   525  		return
   526  	}
   527  
   528  	resp, err := client.UnregisterSender(req)
   529  	if err != nil {
   530  		result.Response = autorest.Response{Response: resp}
   531  		err = autorest.NewErrorWithError(err, "features.ProvidersClient", "Unregister", resp, "Failure sending request")
   532  		return
   533  	}
   534  
   535  	result, err = client.UnregisterResponder(resp)
   536  	if err != nil {
   537  		err = autorest.NewErrorWithError(err, "features.ProvidersClient", "Unregister", resp, "Failure responding to request")
   538  		return
   539  	}
   540  
   541  	return
   542  }
   543  
   544  // UnregisterPreparer prepares the Unregister request.
   545  func (client ProvidersClient) UnregisterPreparer(ctx context.Context, resourceProviderNamespace string) (*http.Request, error) {
   546  	pathParameters := map[string]interface{}{
   547  		"resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace),
   548  		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
   549  	}
   550  
   551  	const APIVersion = "2019-07-01"
   552  	queryParameters := map[string]interface{}{
   553  		"api-version": APIVersion,
   554  	}
   555  
   556  	preparer := autorest.CreatePreparer(
   557  		autorest.AsPost(),
   558  		autorest.WithBaseURL(client.BaseURI),
   559  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister", pathParameters),
   560  		autorest.WithQueryParameters(queryParameters))
   561  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   562  }
   563  
   564  // UnregisterSender sends the Unregister request. The method will close the
   565  // http.Response Body if it receives an error.
   566  func (client ProvidersClient) UnregisterSender(req *http.Request) (*http.Response, error) {
   567  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   568  }
   569  
   570  // UnregisterResponder handles the response to the Unregister request. The method always
   571  // closes the http.Response Body.
   572  func (client ProvidersClient) UnregisterResponder(resp *http.Response) (result Provider, err error) {
   573  	err = autorest.Respond(
   574  		resp,
   575  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   576  		autorest.ByUnmarshallingJSON(&result),
   577  		autorest.ByClosing())
   578  	result.Response = autorest.Response{Response: resp}
   579  	return
   580  }
   581  

View as plain text