...

Source file src/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/features/resources.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/autorest/validation"
    14  	"github.com/Azure/go-autorest/tracing"
    15  	"net/http"
    16  )
    17  
    18  // ResourcesClient is the provides operations for working with resources and resource groups.
    19  type ResourcesClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewResourcesClient creates an instance of the ResourcesClient client.
    24  func NewResourcesClient(subscriptionID string) ResourcesClient {
    25  	return NewResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewResourcesClientWithBaseURI creates an instance of the ResourcesClient client using a custom endpoint.  Use this
    29  // when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    30  func NewResourcesClientWithBaseURI(baseURI string, subscriptionID string) ResourcesClient {
    31  	return ResourcesClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // CheckExistence checks whether a resource exists.
    35  // Parameters:
    36  // resourceGroupName - the name of the resource group containing the resource to check. The name is case
    37  // insensitive.
    38  // resourceProviderNamespace - the resource provider of the resource to check.
    39  // parentResourcePath - the parent resource identity.
    40  // resourceType - the resource type.
    41  // resourceName - the name of the resource to check whether it exists.
    42  // APIVersion - the API version to use for the operation.
    43  func (client ResourcesClient) CheckExistence(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string) (result autorest.Response, err error) {
    44  	if tracing.IsEnabled() {
    45  		ctx = tracing.StartSpan(ctx, fqdn+"/ResourcesClient.CheckExistence")
    46  		defer func() {
    47  			sc := -1
    48  			if result.Response != nil {
    49  				sc = result.Response.StatusCode
    50  			}
    51  			tracing.EndSpan(ctx, sc, err)
    52  		}()
    53  	}
    54  	if err := validation.Validate([]validation.Validation{
    55  		{TargetValue: resourceGroupName,
    56  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
    57  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
    58  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
    59  		return result, validation.NewError("features.ResourcesClient", "CheckExistence", err.Error())
    60  	}
    61  
    62  	req, err := client.CheckExistencePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, APIVersion)
    63  	if err != nil {
    64  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "CheckExistence", nil, "Failure preparing request")
    65  		return
    66  	}
    67  
    68  	resp, err := client.CheckExistenceSender(req)
    69  	if err != nil {
    70  		result.Response = resp
    71  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "CheckExistence", resp, "Failure sending request")
    72  		return
    73  	}
    74  
    75  	result, err = client.CheckExistenceResponder(resp)
    76  	if err != nil {
    77  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "CheckExistence", resp, "Failure responding to request")
    78  		return
    79  	}
    80  
    81  	return
    82  }
    83  
    84  // CheckExistencePreparer prepares the CheckExistence request.
    85  func (client ResourcesClient) CheckExistencePreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string) (*http.Request, error) {
    86  	pathParameters := map[string]interface{}{
    87  		"parentResourcePath":        parentResourcePath,
    88  		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
    89  		"resourceName":              autorest.Encode("path", resourceName),
    90  		"resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace),
    91  		"resourceType":              resourceType,
    92  		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
    93  	}
    94  
    95  	queryParameters := map[string]interface{}{
    96  		"api-version": APIVersion,
    97  	}
    98  
    99  	preparer := autorest.CreatePreparer(
   100  		autorest.AsHead(),
   101  		autorest.WithBaseURL(client.BaseURI),
   102  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", pathParameters),
   103  		autorest.WithQueryParameters(queryParameters))
   104  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   105  }
   106  
   107  // CheckExistenceSender sends the CheckExistence request. The method will close the
   108  // http.Response Body if it receives an error.
   109  func (client ResourcesClient) CheckExistenceSender(req *http.Request) (*http.Response, error) {
   110  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   111  }
   112  
   113  // CheckExistenceResponder handles the response to the CheckExistence request. The method always
   114  // closes the http.Response Body.
   115  func (client ResourcesClient) CheckExistenceResponder(resp *http.Response) (result autorest.Response, err error) {
   116  	err = autorest.Respond(
   117  		resp,
   118  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusNotFound),
   119  		autorest.ByClosing())
   120  	result.Response = resp
   121  	return
   122  }
   123  
   124  // CheckExistenceByID checks by ID whether a resource exists.
   125  // Parameters:
   126  // resourceID - the fully qualified ID of the resource, including the resource name and resource type. Use the
   127  // format,
   128  // /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
   129  // APIVersion - the API version to use for the operation.
   130  func (client ResourcesClient) CheckExistenceByID(ctx context.Context, resourceID string, APIVersion string) (result autorest.Response, err error) {
   131  	if tracing.IsEnabled() {
   132  		ctx = tracing.StartSpan(ctx, fqdn+"/ResourcesClient.CheckExistenceByID")
   133  		defer func() {
   134  			sc := -1
   135  			if result.Response != nil {
   136  				sc = result.Response.StatusCode
   137  			}
   138  			tracing.EndSpan(ctx, sc, err)
   139  		}()
   140  	}
   141  	req, err := client.CheckExistenceByIDPreparer(ctx, resourceID, APIVersion)
   142  	if err != nil {
   143  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "CheckExistenceByID", nil, "Failure preparing request")
   144  		return
   145  	}
   146  
   147  	resp, err := client.CheckExistenceByIDSender(req)
   148  	if err != nil {
   149  		result.Response = resp
   150  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "CheckExistenceByID", resp, "Failure sending request")
   151  		return
   152  	}
   153  
   154  	result, err = client.CheckExistenceByIDResponder(resp)
   155  	if err != nil {
   156  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "CheckExistenceByID", resp, "Failure responding to request")
   157  		return
   158  	}
   159  
   160  	return
   161  }
   162  
   163  // CheckExistenceByIDPreparer prepares the CheckExistenceByID request.
   164  func (client ResourcesClient) CheckExistenceByIDPreparer(ctx context.Context, resourceID string, APIVersion string) (*http.Request, error) {
   165  	pathParameters := map[string]interface{}{
   166  		"resourceId": resourceID,
   167  	}
   168  
   169  	queryParameters := map[string]interface{}{
   170  		"api-version": APIVersion,
   171  	}
   172  
   173  	preparer := autorest.CreatePreparer(
   174  		autorest.AsHead(),
   175  		autorest.WithBaseURL(client.BaseURI),
   176  		autorest.WithPathParameters("/{resourceId}", pathParameters),
   177  		autorest.WithQueryParameters(queryParameters))
   178  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   179  }
   180  
   181  // CheckExistenceByIDSender sends the CheckExistenceByID request. The method will close the
   182  // http.Response Body if it receives an error.
   183  func (client ResourcesClient) CheckExistenceByIDSender(req *http.Request) (*http.Response, error) {
   184  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   185  }
   186  
   187  // CheckExistenceByIDResponder handles the response to the CheckExistenceByID request. The method always
   188  // closes the http.Response Body.
   189  func (client ResourcesClient) CheckExistenceByIDResponder(resp *http.Response) (result autorest.Response, err error) {
   190  	err = autorest.Respond(
   191  		resp,
   192  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusNotFound),
   193  		autorest.ByClosing())
   194  	result.Response = resp
   195  	return
   196  }
   197  
   198  // CreateOrUpdate creates a resource.
   199  // Parameters:
   200  // resourceGroupName - the name of the resource group for the resource. The name is case insensitive.
   201  // resourceProviderNamespace - the namespace of the resource provider.
   202  // parentResourcePath - the parent resource identity.
   203  // resourceType - the resource type of the resource to create.
   204  // resourceName - the name of the resource to create.
   205  // APIVersion - the API version to use for the operation.
   206  // parameters - parameters for creating or updating the resource.
   207  func (client ResourcesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string, parameters GenericResource) (result ResourcesCreateOrUpdateFuture, err error) {
   208  	if tracing.IsEnabled() {
   209  		ctx = tracing.StartSpan(ctx, fqdn+"/ResourcesClient.CreateOrUpdate")
   210  		defer func() {
   211  			sc := -1
   212  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   213  				sc = result.FutureAPI.Response().StatusCode
   214  			}
   215  			tracing.EndSpan(ctx, sc, err)
   216  		}()
   217  	}
   218  	if err := validation.Validate([]validation.Validation{
   219  		{TargetValue: resourceGroupName,
   220  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   221  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   222  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}},
   223  		{TargetValue: parameters,
   224  			Constraints: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Null, Rule: false,
   225  				Chain: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Pattern, Rule: `^[-\w\._,\(\)]+$`, Chain: nil}}}}}}); err != nil {
   226  		return result, validation.NewError("features.ResourcesClient", "CreateOrUpdate", err.Error())
   227  	}
   228  
   229  	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, APIVersion, parameters)
   230  	if err != nil {
   231  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "CreateOrUpdate", nil, "Failure preparing request")
   232  		return
   233  	}
   234  
   235  	result, err = client.CreateOrUpdateSender(req)
   236  	if err != nil {
   237  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "CreateOrUpdate", result.Response(), "Failure sending request")
   238  		return
   239  	}
   240  
   241  	return
   242  }
   243  
   244  // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
   245  func (client ResourcesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string, parameters GenericResource) (*http.Request, error) {
   246  	pathParameters := map[string]interface{}{
   247  		"parentResourcePath":        parentResourcePath,
   248  		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
   249  		"resourceName":              autorest.Encode("path", resourceName),
   250  		"resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace),
   251  		"resourceType":              resourceType,
   252  		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
   253  	}
   254  
   255  	queryParameters := map[string]interface{}{
   256  		"api-version": APIVersion,
   257  	}
   258  
   259  	preparer := autorest.CreatePreparer(
   260  		autorest.AsContentType("application/json; charset=utf-8"),
   261  		autorest.AsPut(),
   262  		autorest.WithBaseURL(client.BaseURI),
   263  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", pathParameters),
   264  		autorest.WithJSON(parameters),
   265  		autorest.WithQueryParameters(queryParameters))
   266  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   267  }
   268  
   269  // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
   270  // http.Response Body if it receives an error.
   271  func (client ResourcesClient) CreateOrUpdateSender(req *http.Request) (future ResourcesCreateOrUpdateFuture, err error) {
   272  	var resp *http.Response
   273  	future.FutureAPI = &azure.Future{}
   274  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   275  	if err != nil {
   276  		return
   277  	}
   278  	var azf azure.Future
   279  	azf, err = azure.NewFutureFromResponse(resp)
   280  	future.FutureAPI = &azf
   281  	future.Result = future.result
   282  	return
   283  }
   284  
   285  // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
   286  // closes the http.Response Body.
   287  func (client ResourcesClient) CreateOrUpdateResponder(resp *http.Response) (result GenericResource, err error) {
   288  	err = autorest.Respond(
   289  		resp,
   290  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
   291  		autorest.ByUnmarshallingJSON(&result),
   292  		autorest.ByClosing())
   293  	result.Response = autorest.Response{Response: resp}
   294  	return
   295  }
   296  
   297  // CreateOrUpdateByID create a resource by ID.
   298  // Parameters:
   299  // resourceID - the fully qualified ID of the resource, including the resource name and resource type. Use the
   300  // format,
   301  // /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
   302  // APIVersion - the API version to use for the operation.
   303  // parameters - create or update resource parameters.
   304  func (client ResourcesClient) CreateOrUpdateByID(ctx context.Context, resourceID string, APIVersion string, parameters GenericResource) (result ResourcesCreateOrUpdateByIDFuture, err error) {
   305  	if tracing.IsEnabled() {
   306  		ctx = tracing.StartSpan(ctx, fqdn+"/ResourcesClient.CreateOrUpdateByID")
   307  		defer func() {
   308  			sc := -1
   309  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   310  				sc = result.FutureAPI.Response().StatusCode
   311  			}
   312  			tracing.EndSpan(ctx, sc, err)
   313  		}()
   314  	}
   315  	if err := validation.Validate([]validation.Validation{
   316  		{TargetValue: parameters,
   317  			Constraints: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Null, Rule: false,
   318  				Chain: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Pattern, Rule: `^[-\w\._,\(\)]+$`, Chain: nil}}}}}}); err != nil {
   319  		return result, validation.NewError("features.ResourcesClient", "CreateOrUpdateByID", err.Error())
   320  	}
   321  
   322  	req, err := client.CreateOrUpdateByIDPreparer(ctx, resourceID, APIVersion, parameters)
   323  	if err != nil {
   324  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "CreateOrUpdateByID", nil, "Failure preparing request")
   325  		return
   326  	}
   327  
   328  	result, err = client.CreateOrUpdateByIDSender(req)
   329  	if err != nil {
   330  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "CreateOrUpdateByID", result.Response(), "Failure sending request")
   331  		return
   332  	}
   333  
   334  	return
   335  }
   336  
   337  // CreateOrUpdateByIDPreparer prepares the CreateOrUpdateByID request.
   338  func (client ResourcesClient) CreateOrUpdateByIDPreparer(ctx context.Context, resourceID string, APIVersion string, parameters GenericResource) (*http.Request, error) {
   339  	pathParameters := map[string]interface{}{
   340  		"resourceId": resourceID,
   341  	}
   342  
   343  	queryParameters := map[string]interface{}{
   344  		"api-version": APIVersion,
   345  	}
   346  
   347  	preparer := autorest.CreatePreparer(
   348  		autorest.AsContentType("application/json; charset=utf-8"),
   349  		autorest.AsPut(),
   350  		autorest.WithBaseURL(client.BaseURI),
   351  		autorest.WithPathParameters("/{resourceId}", pathParameters),
   352  		autorest.WithJSON(parameters),
   353  		autorest.WithQueryParameters(queryParameters))
   354  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   355  }
   356  
   357  // CreateOrUpdateByIDSender sends the CreateOrUpdateByID request. The method will close the
   358  // http.Response Body if it receives an error.
   359  func (client ResourcesClient) CreateOrUpdateByIDSender(req *http.Request) (future ResourcesCreateOrUpdateByIDFuture, err error) {
   360  	var resp *http.Response
   361  	future.FutureAPI = &azure.Future{}
   362  	resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   363  	if err != nil {
   364  		return
   365  	}
   366  	var azf azure.Future
   367  	azf, err = azure.NewFutureFromResponse(resp)
   368  	future.FutureAPI = &azf
   369  	future.Result = future.result
   370  	return
   371  }
   372  
   373  // CreateOrUpdateByIDResponder handles the response to the CreateOrUpdateByID request. The method always
   374  // closes the http.Response Body.
   375  func (client ResourcesClient) CreateOrUpdateByIDResponder(resp *http.Response) (result GenericResource, err error) {
   376  	err = autorest.Respond(
   377  		resp,
   378  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
   379  		autorest.ByUnmarshallingJSON(&result),
   380  		autorest.ByClosing())
   381  	result.Response = autorest.Response{Response: resp}
   382  	return
   383  }
   384  
   385  // Delete deletes a resource.
   386  // Parameters:
   387  // resourceGroupName - the name of the resource group that contains the resource to delete. The name is case
   388  // insensitive.
   389  // resourceProviderNamespace - the namespace of the resource provider.
   390  // parentResourcePath - the parent resource identity.
   391  // resourceType - the resource type.
   392  // resourceName - the name of the resource to delete.
   393  // APIVersion - the API version to use for the operation.
   394  func (client ResourcesClient) Delete(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string) (result ResourcesDeleteFuture, err error) {
   395  	if tracing.IsEnabled() {
   396  		ctx = tracing.StartSpan(ctx, fqdn+"/ResourcesClient.Delete")
   397  		defer func() {
   398  			sc := -1
   399  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   400  				sc = result.FutureAPI.Response().StatusCode
   401  			}
   402  			tracing.EndSpan(ctx, sc, err)
   403  		}()
   404  	}
   405  	if err := validation.Validate([]validation.Validation{
   406  		{TargetValue: resourceGroupName,
   407  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   408  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   409  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
   410  		return result, validation.NewError("features.ResourcesClient", "Delete", err.Error())
   411  	}
   412  
   413  	req, err := client.DeletePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, APIVersion)
   414  	if err != nil {
   415  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "Delete", nil, "Failure preparing request")
   416  		return
   417  	}
   418  
   419  	result, err = client.DeleteSender(req)
   420  	if err != nil {
   421  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "Delete", result.Response(), "Failure sending request")
   422  		return
   423  	}
   424  
   425  	return
   426  }
   427  
   428  // DeletePreparer prepares the Delete request.
   429  func (client ResourcesClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string) (*http.Request, error) {
   430  	pathParameters := map[string]interface{}{
   431  		"parentResourcePath":        parentResourcePath,
   432  		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
   433  		"resourceName":              autorest.Encode("path", resourceName),
   434  		"resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace),
   435  		"resourceType":              resourceType,
   436  		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
   437  	}
   438  
   439  	queryParameters := map[string]interface{}{
   440  		"api-version": APIVersion,
   441  	}
   442  
   443  	preparer := autorest.CreatePreparer(
   444  		autorest.AsDelete(),
   445  		autorest.WithBaseURL(client.BaseURI),
   446  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", pathParameters),
   447  		autorest.WithQueryParameters(queryParameters))
   448  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   449  }
   450  
   451  // DeleteSender sends the Delete request. The method will close the
   452  // http.Response Body if it receives an error.
   453  func (client ResourcesClient) DeleteSender(req *http.Request) (future ResourcesDeleteFuture, err error) {
   454  	var resp *http.Response
   455  	future.FutureAPI = &azure.Future{}
   456  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   457  	if err != nil {
   458  		return
   459  	}
   460  	var azf azure.Future
   461  	azf, err = azure.NewFutureFromResponse(resp)
   462  	future.FutureAPI = &azf
   463  	future.Result = future.result
   464  	return
   465  }
   466  
   467  // DeleteResponder handles the response to the Delete request. The method always
   468  // closes the http.Response Body.
   469  func (client ResourcesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   470  	err = autorest.Respond(
   471  		resp,
   472  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   473  		autorest.ByClosing())
   474  	result.Response = resp
   475  	return
   476  }
   477  
   478  // DeleteByID deletes a resource by ID.
   479  // Parameters:
   480  // resourceID - the fully qualified ID of the resource, including the resource name and resource type. Use the
   481  // format,
   482  // /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
   483  // APIVersion - the API version to use for the operation.
   484  func (client ResourcesClient) DeleteByID(ctx context.Context, resourceID string, APIVersion string) (result ResourcesDeleteByIDFuture, err error) {
   485  	if tracing.IsEnabled() {
   486  		ctx = tracing.StartSpan(ctx, fqdn+"/ResourcesClient.DeleteByID")
   487  		defer func() {
   488  			sc := -1
   489  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   490  				sc = result.FutureAPI.Response().StatusCode
   491  			}
   492  			tracing.EndSpan(ctx, sc, err)
   493  		}()
   494  	}
   495  	req, err := client.DeleteByIDPreparer(ctx, resourceID, APIVersion)
   496  	if err != nil {
   497  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "DeleteByID", nil, "Failure preparing request")
   498  		return
   499  	}
   500  
   501  	result, err = client.DeleteByIDSender(req)
   502  	if err != nil {
   503  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "DeleteByID", result.Response(), "Failure sending request")
   504  		return
   505  	}
   506  
   507  	return
   508  }
   509  
   510  // DeleteByIDPreparer prepares the DeleteByID request.
   511  func (client ResourcesClient) DeleteByIDPreparer(ctx context.Context, resourceID string, APIVersion string) (*http.Request, error) {
   512  	pathParameters := map[string]interface{}{
   513  		"resourceId": resourceID,
   514  	}
   515  
   516  	queryParameters := map[string]interface{}{
   517  		"api-version": APIVersion,
   518  	}
   519  
   520  	preparer := autorest.CreatePreparer(
   521  		autorest.AsDelete(),
   522  		autorest.WithBaseURL(client.BaseURI),
   523  		autorest.WithPathParameters("/{resourceId}", pathParameters),
   524  		autorest.WithQueryParameters(queryParameters))
   525  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   526  }
   527  
   528  // DeleteByIDSender sends the DeleteByID request. The method will close the
   529  // http.Response Body if it receives an error.
   530  func (client ResourcesClient) DeleteByIDSender(req *http.Request) (future ResourcesDeleteByIDFuture, err error) {
   531  	var resp *http.Response
   532  	future.FutureAPI = &azure.Future{}
   533  	resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   534  	if err != nil {
   535  		return
   536  	}
   537  	var azf azure.Future
   538  	azf, err = azure.NewFutureFromResponse(resp)
   539  	future.FutureAPI = &azf
   540  	future.Result = future.result
   541  	return
   542  }
   543  
   544  // DeleteByIDResponder handles the response to the DeleteByID request. The method always
   545  // closes the http.Response Body.
   546  func (client ResourcesClient) DeleteByIDResponder(resp *http.Response) (result autorest.Response, err error) {
   547  	err = autorest.Respond(
   548  		resp,
   549  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   550  		autorest.ByClosing())
   551  	result.Response = resp
   552  	return
   553  }
   554  
   555  // Get gets a resource.
   556  // Parameters:
   557  // resourceGroupName - the name of the resource group containing the resource to get. The name is case
   558  // insensitive.
   559  // resourceProviderNamespace - the namespace of the resource provider.
   560  // parentResourcePath - the parent resource identity.
   561  // resourceType - the resource type of the resource.
   562  // resourceName - the name of the resource to get.
   563  // APIVersion - the API version to use for the operation.
   564  func (client ResourcesClient) Get(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string) (result GenericResource, err error) {
   565  	if tracing.IsEnabled() {
   566  		ctx = tracing.StartSpan(ctx, fqdn+"/ResourcesClient.Get")
   567  		defer func() {
   568  			sc := -1
   569  			if result.Response.Response != nil {
   570  				sc = result.Response.Response.StatusCode
   571  			}
   572  			tracing.EndSpan(ctx, sc, err)
   573  		}()
   574  	}
   575  	if err := validation.Validate([]validation.Validation{
   576  		{TargetValue: resourceGroupName,
   577  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   578  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   579  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
   580  		return result, validation.NewError("features.ResourcesClient", "Get", err.Error())
   581  	}
   582  
   583  	req, err := client.GetPreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, APIVersion)
   584  	if err != nil {
   585  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "Get", nil, "Failure preparing request")
   586  		return
   587  	}
   588  
   589  	resp, err := client.GetSender(req)
   590  	if err != nil {
   591  		result.Response = autorest.Response{Response: resp}
   592  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "Get", resp, "Failure sending request")
   593  		return
   594  	}
   595  
   596  	result, err = client.GetResponder(resp)
   597  	if err != nil {
   598  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "Get", resp, "Failure responding to request")
   599  		return
   600  	}
   601  
   602  	return
   603  }
   604  
   605  // GetPreparer prepares the Get request.
   606  func (client ResourcesClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string) (*http.Request, error) {
   607  	pathParameters := map[string]interface{}{
   608  		"parentResourcePath":        parentResourcePath,
   609  		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
   610  		"resourceName":              autorest.Encode("path", resourceName),
   611  		"resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace),
   612  		"resourceType":              resourceType,
   613  		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
   614  	}
   615  
   616  	queryParameters := map[string]interface{}{
   617  		"api-version": APIVersion,
   618  	}
   619  
   620  	preparer := autorest.CreatePreparer(
   621  		autorest.AsGet(),
   622  		autorest.WithBaseURL(client.BaseURI),
   623  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", pathParameters),
   624  		autorest.WithQueryParameters(queryParameters))
   625  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   626  }
   627  
   628  // GetSender sends the Get request. The method will close the
   629  // http.Response Body if it receives an error.
   630  func (client ResourcesClient) GetSender(req *http.Request) (*http.Response, error) {
   631  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   632  }
   633  
   634  // GetResponder handles the response to the Get request. The method always
   635  // closes the http.Response Body.
   636  func (client ResourcesClient) GetResponder(resp *http.Response) (result GenericResource, err error) {
   637  	err = autorest.Respond(
   638  		resp,
   639  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   640  		autorest.ByUnmarshallingJSON(&result),
   641  		autorest.ByClosing())
   642  	result.Response = autorest.Response{Response: resp}
   643  	return
   644  }
   645  
   646  // GetByID gets a resource by ID.
   647  // Parameters:
   648  // resourceID - the fully qualified ID of the resource, including the resource name and resource type. Use the
   649  // format,
   650  // /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
   651  // APIVersion - the API version to use for the operation.
   652  func (client ResourcesClient) GetByID(ctx context.Context, resourceID string, APIVersion string) (result GenericResource, err error) {
   653  	if tracing.IsEnabled() {
   654  		ctx = tracing.StartSpan(ctx, fqdn+"/ResourcesClient.GetByID")
   655  		defer func() {
   656  			sc := -1
   657  			if result.Response.Response != nil {
   658  				sc = result.Response.Response.StatusCode
   659  			}
   660  			tracing.EndSpan(ctx, sc, err)
   661  		}()
   662  	}
   663  	req, err := client.GetByIDPreparer(ctx, resourceID, APIVersion)
   664  	if err != nil {
   665  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "GetByID", nil, "Failure preparing request")
   666  		return
   667  	}
   668  
   669  	resp, err := client.GetByIDSender(req)
   670  	if err != nil {
   671  		result.Response = autorest.Response{Response: resp}
   672  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "GetByID", resp, "Failure sending request")
   673  		return
   674  	}
   675  
   676  	result, err = client.GetByIDResponder(resp)
   677  	if err != nil {
   678  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "GetByID", resp, "Failure responding to request")
   679  		return
   680  	}
   681  
   682  	return
   683  }
   684  
   685  // GetByIDPreparer prepares the GetByID request.
   686  func (client ResourcesClient) GetByIDPreparer(ctx context.Context, resourceID string, APIVersion string) (*http.Request, error) {
   687  	pathParameters := map[string]interface{}{
   688  		"resourceId": resourceID,
   689  	}
   690  
   691  	queryParameters := map[string]interface{}{
   692  		"api-version": APIVersion,
   693  	}
   694  
   695  	preparer := autorest.CreatePreparer(
   696  		autorest.AsGet(),
   697  		autorest.WithBaseURL(client.BaseURI),
   698  		autorest.WithPathParameters("/{resourceId}", pathParameters),
   699  		autorest.WithQueryParameters(queryParameters))
   700  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   701  }
   702  
   703  // GetByIDSender sends the GetByID request. The method will close the
   704  // http.Response Body if it receives an error.
   705  func (client ResourcesClient) GetByIDSender(req *http.Request) (*http.Response, error) {
   706  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   707  }
   708  
   709  // GetByIDResponder handles the response to the GetByID request. The method always
   710  // closes the http.Response Body.
   711  func (client ResourcesClient) GetByIDResponder(resp *http.Response) (result GenericResource, err error) {
   712  	err = autorest.Respond(
   713  		resp,
   714  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   715  		autorest.ByUnmarshallingJSON(&result),
   716  		autorest.ByClosing())
   717  	result.Response = autorest.Response{Response: resp}
   718  	return
   719  }
   720  
   721  // List get all the resources in a subscription.
   722  // Parameters:
   723  // filter - the filter to apply on the operation.<br><br>The properties you can use for eq (equals) or ne (not
   724  // equals) are: location, resourceType, name, resourceGroup, identity, identity/principalId, plan,
   725  // plan/publisher, plan/product, plan/name, plan/version, and plan/promotionCode.<br><br>For example, to filter
   726  // by a resource type, use: $filter=resourceType eq 'Microsoft.Network/virtualNetworks'<br><br>You can use
   727  // substringof(value, property) in the filter. The properties you can use for substring are: name and
   728  // resourceGroup.<br><br>For example, to get all resources with 'demo' anywhere in the name, use:
   729  // $filter=substringof('demo', name)<br><br>You can link more than one substringof together by adding and/or
   730  // operators.<br><br>You can filter by tag names and values. For example, to filter for a tag name and value,
   731  // use $filter=tagName eq 'tag1' and tagValue eq 'Value1'<br><br>You can use some properties together when
   732  // filtering. The combinations you can use are: substringof and/or resourceType, plan and plan/publisher and
   733  // plan/name, identity and identity/principalId.
   734  // expand - comma-separated list of additional properties to be included in the response. Valid values include
   735  // `createdTime`, `changedTime` and `provisioningState`. For example, `$expand=createdTime,changedTime`.
   736  // top - the number of results to return. If null is passed, returns all resource groups.
   737  func (client ResourcesClient) List(ctx context.Context, filter string, expand string, top *int32) (result ResourceListResultPage, err error) {
   738  	if tracing.IsEnabled() {
   739  		ctx = tracing.StartSpan(ctx, fqdn+"/ResourcesClient.List")
   740  		defer func() {
   741  			sc := -1
   742  			if result.rlr.Response.Response != nil {
   743  				sc = result.rlr.Response.Response.StatusCode
   744  			}
   745  			tracing.EndSpan(ctx, sc, err)
   746  		}()
   747  	}
   748  	result.fn = client.listNextResults
   749  	req, err := client.ListPreparer(ctx, filter, expand, top)
   750  	if err != nil {
   751  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "List", nil, "Failure preparing request")
   752  		return
   753  	}
   754  
   755  	resp, err := client.ListSender(req)
   756  	if err != nil {
   757  		result.rlr.Response = autorest.Response{Response: resp}
   758  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "List", resp, "Failure sending request")
   759  		return
   760  	}
   761  
   762  	result.rlr, err = client.ListResponder(resp)
   763  	if err != nil {
   764  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "List", resp, "Failure responding to request")
   765  		return
   766  	}
   767  	if result.rlr.hasNextLink() && result.rlr.IsEmpty() {
   768  		err = result.NextWithContext(ctx)
   769  		return
   770  	}
   771  
   772  	return
   773  }
   774  
   775  // ListPreparer prepares the List request.
   776  func (client ResourcesClient) ListPreparer(ctx context.Context, filter string, expand string, top *int32) (*http.Request, error) {
   777  	pathParameters := map[string]interface{}{
   778  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
   779  	}
   780  
   781  	const APIVersion = "2019-07-01"
   782  	queryParameters := map[string]interface{}{
   783  		"api-version": APIVersion,
   784  	}
   785  	if len(filter) > 0 {
   786  		queryParameters["$filter"] = autorest.Encode("query", filter)
   787  	}
   788  	if len(expand) > 0 {
   789  		queryParameters["$expand"] = autorest.Encode("query", expand)
   790  	}
   791  	if top != nil {
   792  		queryParameters["$top"] = autorest.Encode("query", *top)
   793  	}
   794  
   795  	preparer := autorest.CreatePreparer(
   796  		autorest.AsGet(),
   797  		autorest.WithBaseURL(client.BaseURI),
   798  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resources", pathParameters),
   799  		autorest.WithQueryParameters(queryParameters))
   800  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   801  }
   802  
   803  // ListSender sends the List request. The method will close the
   804  // http.Response Body if it receives an error.
   805  func (client ResourcesClient) ListSender(req *http.Request) (*http.Response, error) {
   806  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   807  }
   808  
   809  // ListResponder handles the response to the List request. The method always
   810  // closes the http.Response Body.
   811  func (client ResourcesClient) ListResponder(resp *http.Response) (result ResourceListResult, err error) {
   812  	err = autorest.Respond(
   813  		resp,
   814  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   815  		autorest.ByUnmarshallingJSON(&result),
   816  		autorest.ByClosing())
   817  	result.Response = autorest.Response{Response: resp}
   818  	return
   819  }
   820  
   821  // listNextResults retrieves the next set of results, if any.
   822  func (client ResourcesClient) listNextResults(ctx context.Context, lastResults ResourceListResult) (result ResourceListResult, err error) {
   823  	req, err := lastResults.resourceListResultPreparer(ctx)
   824  	if err != nil {
   825  		return result, autorest.NewErrorWithError(err, "features.ResourcesClient", "listNextResults", nil, "Failure preparing next results request")
   826  	}
   827  	if req == nil {
   828  		return
   829  	}
   830  	resp, err := client.ListSender(req)
   831  	if err != nil {
   832  		result.Response = autorest.Response{Response: resp}
   833  		return result, autorest.NewErrorWithError(err, "features.ResourcesClient", "listNextResults", resp, "Failure sending next results request")
   834  	}
   835  	result, err = client.ListResponder(resp)
   836  	if err != nil {
   837  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "listNextResults", resp, "Failure responding to next results request")
   838  	}
   839  	return
   840  }
   841  
   842  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   843  func (client ResourcesClient) ListComplete(ctx context.Context, filter string, expand string, top *int32) (result ResourceListResultIterator, err error) {
   844  	if tracing.IsEnabled() {
   845  		ctx = tracing.StartSpan(ctx, fqdn+"/ResourcesClient.List")
   846  		defer func() {
   847  			sc := -1
   848  			if result.Response().Response.Response != nil {
   849  				sc = result.page.Response().Response.Response.StatusCode
   850  			}
   851  			tracing.EndSpan(ctx, sc, err)
   852  		}()
   853  	}
   854  	result.page, err = client.List(ctx, filter, expand, top)
   855  	return
   856  }
   857  
   858  // ListByResourceGroup get all the resources for a resource group.
   859  // Parameters:
   860  // resourceGroupName - the resource group with the resources to get.
   861  // filter - the filter to apply on the operation.<br><br>The properties you can use for eq (equals) or ne (not
   862  // equals) are: location, resourceType, name, resourceGroup, identity, identity/principalId, plan,
   863  // plan/publisher, plan/product, plan/name, plan/version, and plan/promotionCode.<br><br>For example, to filter
   864  // by a resource type, use: $filter=resourceType eq 'Microsoft.Network/virtualNetworks'<br><br>You can use
   865  // substringof(value, property) in the filter. The properties you can use for substring are: name and
   866  // resourceGroup.<br><br>For example, to get all resources with 'demo' anywhere in the name, use:
   867  // $filter=substringof('demo', name)<br><br>You can link more than one substringof together by adding and/or
   868  // operators.<br><br>You can filter by tag names and values. For example, to filter for a tag name and value,
   869  // use $filter=tagName eq 'tag1' and tagValue eq 'Value1'<br><br>You can use some properties together when
   870  // filtering. The combinations you can use are: substringof and/or resourceType, plan and plan/publisher and
   871  // plan/name, identity and identity/principalId.
   872  // expand - comma-separated list of additional properties to be included in the response. Valid values include
   873  // `createdTime`, `changedTime` and `provisioningState`. For example, `$expand=createdTime,changedTime`.
   874  // top - the number of results to return. If null is passed, returns all resources.
   875  func (client ResourcesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string, expand string, top *int32) (result ResourceListResultPage, err error) {
   876  	if tracing.IsEnabled() {
   877  		ctx = tracing.StartSpan(ctx, fqdn+"/ResourcesClient.ListByResourceGroup")
   878  		defer func() {
   879  			sc := -1
   880  			if result.rlr.Response.Response != nil {
   881  				sc = result.rlr.Response.Response.StatusCode
   882  			}
   883  			tracing.EndSpan(ctx, sc, err)
   884  		}()
   885  	}
   886  	if err := validation.Validate([]validation.Validation{
   887  		{TargetValue: resourceGroupName,
   888  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   889  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   890  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
   891  		return result, validation.NewError("features.ResourcesClient", "ListByResourceGroup", err.Error())
   892  	}
   893  
   894  	result.fn = client.listByResourceGroupNextResults
   895  	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, filter, expand, top)
   896  	if err != nil {
   897  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "ListByResourceGroup", nil, "Failure preparing request")
   898  		return
   899  	}
   900  
   901  	resp, err := client.ListByResourceGroupSender(req)
   902  	if err != nil {
   903  		result.rlr.Response = autorest.Response{Response: resp}
   904  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "ListByResourceGroup", resp, "Failure sending request")
   905  		return
   906  	}
   907  
   908  	result.rlr, err = client.ListByResourceGroupResponder(resp)
   909  	if err != nil {
   910  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "ListByResourceGroup", resp, "Failure responding to request")
   911  		return
   912  	}
   913  	if result.rlr.hasNextLink() && result.rlr.IsEmpty() {
   914  		err = result.NextWithContext(ctx)
   915  		return
   916  	}
   917  
   918  	return
   919  }
   920  
   921  // ListByResourceGroupPreparer prepares the ListByResourceGroup request.
   922  func (client ResourcesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, filter string, expand string, top *int32) (*http.Request, error) {
   923  	pathParameters := map[string]interface{}{
   924  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   925  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   926  	}
   927  
   928  	const APIVersion = "2019-07-01"
   929  	queryParameters := map[string]interface{}{
   930  		"api-version": APIVersion,
   931  	}
   932  	if len(filter) > 0 {
   933  		queryParameters["$filter"] = autorest.Encode("query", filter)
   934  	}
   935  	if len(expand) > 0 {
   936  		queryParameters["$expand"] = autorest.Encode("query", expand)
   937  	}
   938  	if top != nil {
   939  		queryParameters["$top"] = autorest.Encode("query", *top)
   940  	}
   941  
   942  	preparer := autorest.CreatePreparer(
   943  		autorest.AsGet(),
   944  		autorest.WithBaseURL(client.BaseURI),
   945  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources", pathParameters),
   946  		autorest.WithQueryParameters(queryParameters))
   947  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   948  }
   949  
   950  // ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
   951  // http.Response Body if it receives an error.
   952  func (client ResourcesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
   953  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   954  }
   955  
   956  // ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
   957  // closes the http.Response Body.
   958  func (client ResourcesClient) ListByResourceGroupResponder(resp *http.Response) (result ResourceListResult, err error) {
   959  	err = autorest.Respond(
   960  		resp,
   961  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   962  		autorest.ByUnmarshallingJSON(&result),
   963  		autorest.ByClosing())
   964  	result.Response = autorest.Response{Response: resp}
   965  	return
   966  }
   967  
   968  // listByResourceGroupNextResults retrieves the next set of results, if any.
   969  func (client ResourcesClient) listByResourceGroupNextResults(ctx context.Context, lastResults ResourceListResult) (result ResourceListResult, err error) {
   970  	req, err := lastResults.resourceListResultPreparer(ctx)
   971  	if err != nil {
   972  		return result, autorest.NewErrorWithError(err, "features.ResourcesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
   973  	}
   974  	if req == nil {
   975  		return
   976  	}
   977  	resp, err := client.ListByResourceGroupSender(req)
   978  	if err != nil {
   979  		result.Response = autorest.Response{Response: resp}
   980  		return result, autorest.NewErrorWithError(err, "features.ResourcesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
   981  	}
   982  	result, err = client.ListByResourceGroupResponder(resp)
   983  	if err != nil {
   984  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
   985  	}
   986  	return
   987  }
   988  
   989  // ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
   990  func (client ResourcesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string, expand string, top *int32) (result ResourceListResultIterator, err error) {
   991  	if tracing.IsEnabled() {
   992  		ctx = tracing.StartSpan(ctx, fqdn+"/ResourcesClient.ListByResourceGroup")
   993  		defer func() {
   994  			sc := -1
   995  			if result.Response().Response.Response != nil {
   996  				sc = result.page.Response().Response.Response.StatusCode
   997  			}
   998  			tracing.EndSpan(ctx, sc, err)
   999  		}()
  1000  	}
  1001  	result.page, err = client.ListByResourceGroup(ctx, resourceGroupName, filter, expand, top)
  1002  	return
  1003  }
  1004  
  1005  // MoveResources the resources to move must be in the same source resource group. The target resource group may be in a
  1006  // different subscription. When moving resources, both the source group and the target group are locked for the
  1007  // duration of the operation. Write and delete operations are blocked on the groups until the move completes.
  1008  // Parameters:
  1009  // sourceResourceGroupName - the name of the resource group containing the resources to move.
  1010  // parameters - parameters for moving resources.
  1011  func (client ResourcesClient) MoveResources(ctx context.Context, sourceResourceGroupName string, parameters ResourcesMoveInfo) (result ResourcesMoveResourcesFuture, err error) {
  1012  	if tracing.IsEnabled() {
  1013  		ctx = tracing.StartSpan(ctx, fqdn+"/ResourcesClient.MoveResources")
  1014  		defer func() {
  1015  			sc := -1
  1016  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
  1017  				sc = result.FutureAPI.Response().StatusCode
  1018  			}
  1019  			tracing.EndSpan(ctx, sc, err)
  1020  		}()
  1021  	}
  1022  	if err := validation.Validate([]validation.Validation{
  1023  		{TargetValue: sourceResourceGroupName,
  1024  			Constraints: []validation.Constraint{{Target: "sourceResourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
  1025  				{Target: "sourceResourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
  1026  				{Target: "sourceResourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
  1027  		return result, validation.NewError("features.ResourcesClient", "MoveResources", err.Error())
  1028  	}
  1029  
  1030  	req, err := client.MoveResourcesPreparer(ctx, sourceResourceGroupName, parameters)
  1031  	if err != nil {
  1032  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "MoveResources", nil, "Failure preparing request")
  1033  		return
  1034  	}
  1035  
  1036  	result, err = client.MoveResourcesSender(req)
  1037  	if err != nil {
  1038  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "MoveResources", result.Response(), "Failure sending request")
  1039  		return
  1040  	}
  1041  
  1042  	return
  1043  }
  1044  
  1045  // MoveResourcesPreparer prepares the MoveResources request.
  1046  func (client ResourcesClient) MoveResourcesPreparer(ctx context.Context, sourceResourceGroupName string, parameters ResourcesMoveInfo) (*http.Request, error) {
  1047  	pathParameters := map[string]interface{}{
  1048  		"sourceResourceGroupName": autorest.Encode("path", sourceResourceGroupName),
  1049  		"subscriptionId":          autorest.Encode("path", client.SubscriptionID),
  1050  	}
  1051  
  1052  	const APIVersion = "2019-07-01"
  1053  	queryParameters := map[string]interface{}{
  1054  		"api-version": APIVersion,
  1055  	}
  1056  
  1057  	preparer := autorest.CreatePreparer(
  1058  		autorest.AsContentType("application/json; charset=utf-8"),
  1059  		autorest.AsPost(),
  1060  		autorest.WithBaseURL(client.BaseURI),
  1061  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources", pathParameters),
  1062  		autorest.WithJSON(parameters),
  1063  		autorest.WithQueryParameters(queryParameters))
  1064  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1065  }
  1066  
  1067  // MoveResourcesSender sends the MoveResources request. The method will close the
  1068  // http.Response Body if it receives an error.
  1069  func (client ResourcesClient) MoveResourcesSender(req *http.Request) (future ResourcesMoveResourcesFuture, err error) {
  1070  	var resp *http.Response
  1071  	future.FutureAPI = &azure.Future{}
  1072  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
  1073  	if err != nil {
  1074  		return
  1075  	}
  1076  	var azf azure.Future
  1077  	azf, err = azure.NewFutureFromResponse(resp)
  1078  	future.FutureAPI = &azf
  1079  	future.Result = future.result
  1080  	return
  1081  }
  1082  
  1083  // MoveResourcesResponder handles the response to the MoveResources request. The method always
  1084  // closes the http.Response Body.
  1085  func (client ResourcesClient) MoveResourcesResponder(resp *http.Response) (result autorest.Response, err error) {
  1086  	err = autorest.Respond(
  1087  		resp,
  1088  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
  1089  		autorest.ByClosing())
  1090  	result.Response = resp
  1091  	return
  1092  }
  1093  
  1094  // Update updates a resource.
  1095  // Parameters:
  1096  // resourceGroupName - the name of the resource group for the resource. The name is case insensitive.
  1097  // resourceProviderNamespace - the namespace of the resource provider.
  1098  // parentResourcePath - the parent resource identity.
  1099  // resourceType - the resource type of the resource to update.
  1100  // resourceName - the name of the resource to update.
  1101  // APIVersion - the API version to use for the operation.
  1102  // parameters - parameters for updating the resource.
  1103  func (client ResourcesClient) Update(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string, parameters GenericResource) (result ResourcesUpdateFuture, err error) {
  1104  	if tracing.IsEnabled() {
  1105  		ctx = tracing.StartSpan(ctx, fqdn+"/ResourcesClient.Update")
  1106  		defer func() {
  1107  			sc := -1
  1108  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
  1109  				sc = result.FutureAPI.Response().StatusCode
  1110  			}
  1111  			tracing.EndSpan(ctx, sc, err)
  1112  		}()
  1113  	}
  1114  	if err := validation.Validate([]validation.Validation{
  1115  		{TargetValue: resourceGroupName,
  1116  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
  1117  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
  1118  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
  1119  		return result, validation.NewError("features.ResourcesClient", "Update", err.Error())
  1120  	}
  1121  
  1122  	req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, APIVersion, parameters)
  1123  	if err != nil {
  1124  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "Update", nil, "Failure preparing request")
  1125  		return
  1126  	}
  1127  
  1128  	result, err = client.UpdateSender(req)
  1129  	if err != nil {
  1130  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "Update", result.Response(), "Failure sending request")
  1131  		return
  1132  	}
  1133  
  1134  	return
  1135  }
  1136  
  1137  // UpdatePreparer prepares the Update request.
  1138  func (client ResourcesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string, parameters GenericResource) (*http.Request, error) {
  1139  	pathParameters := map[string]interface{}{
  1140  		"parentResourcePath":        parentResourcePath,
  1141  		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
  1142  		"resourceName":              autorest.Encode("path", resourceName),
  1143  		"resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace),
  1144  		"resourceType":              resourceType,
  1145  		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
  1146  	}
  1147  
  1148  	queryParameters := map[string]interface{}{
  1149  		"api-version": APIVersion,
  1150  	}
  1151  
  1152  	preparer := autorest.CreatePreparer(
  1153  		autorest.AsContentType("application/json; charset=utf-8"),
  1154  		autorest.AsPatch(),
  1155  		autorest.WithBaseURL(client.BaseURI),
  1156  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", pathParameters),
  1157  		autorest.WithJSON(parameters),
  1158  		autorest.WithQueryParameters(queryParameters))
  1159  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1160  }
  1161  
  1162  // UpdateSender sends the Update request. The method will close the
  1163  // http.Response Body if it receives an error.
  1164  func (client ResourcesClient) UpdateSender(req *http.Request) (future ResourcesUpdateFuture, err error) {
  1165  	var resp *http.Response
  1166  	future.FutureAPI = &azure.Future{}
  1167  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
  1168  	if err != nil {
  1169  		return
  1170  	}
  1171  	var azf azure.Future
  1172  	azf, err = azure.NewFutureFromResponse(resp)
  1173  	future.FutureAPI = &azf
  1174  	future.Result = future.result
  1175  	return
  1176  }
  1177  
  1178  // UpdateResponder handles the response to the Update request. The method always
  1179  // closes the http.Response Body.
  1180  func (client ResourcesClient) UpdateResponder(resp *http.Response) (result GenericResource, err error) {
  1181  	err = autorest.Respond(
  1182  		resp,
  1183  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
  1184  		autorest.ByUnmarshallingJSON(&result),
  1185  		autorest.ByClosing())
  1186  	result.Response = autorest.Response{Response: resp}
  1187  	return
  1188  }
  1189  
  1190  // UpdateByID updates a resource by ID.
  1191  // Parameters:
  1192  // resourceID - the fully qualified ID of the resource, including the resource name and resource type. Use the
  1193  // format,
  1194  // /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
  1195  // APIVersion - the API version to use for the operation.
  1196  // parameters - update resource parameters.
  1197  func (client ResourcesClient) UpdateByID(ctx context.Context, resourceID string, APIVersion string, parameters GenericResource) (result ResourcesUpdateByIDFuture, err error) {
  1198  	if tracing.IsEnabled() {
  1199  		ctx = tracing.StartSpan(ctx, fqdn+"/ResourcesClient.UpdateByID")
  1200  		defer func() {
  1201  			sc := -1
  1202  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
  1203  				sc = result.FutureAPI.Response().StatusCode
  1204  			}
  1205  			tracing.EndSpan(ctx, sc, err)
  1206  		}()
  1207  	}
  1208  	req, err := client.UpdateByIDPreparer(ctx, resourceID, APIVersion, parameters)
  1209  	if err != nil {
  1210  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "UpdateByID", nil, "Failure preparing request")
  1211  		return
  1212  	}
  1213  
  1214  	result, err = client.UpdateByIDSender(req)
  1215  	if err != nil {
  1216  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "UpdateByID", result.Response(), "Failure sending request")
  1217  		return
  1218  	}
  1219  
  1220  	return
  1221  }
  1222  
  1223  // UpdateByIDPreparer prepares the UpdateByID request.
  1224  func (client ResourcesClient) UpdateByIDPreparer(ctx context.Context, resourceID string, APIVersion string, parameters GenericResource) (*http.Request, error) {
  1225  	pathParameters := map[string]interface{}{
  1226  		"resourceId": resourceID,
  1227  	}
  1228  
  1229  	queryParameters := map[string]interface{}{
  1230  		"api-version": APIVersion,
  1231  	}
  1232  
  1233  	preparer := autorest.CreatePreparer(
  1234  		autorest.AsContentType("application/json; charset=utf-8"),
  1235  		autorest.AsPatch(),
  1236  		autorest.WithBaseURL(client.BaseURI),
  1237  		autorest.WithPathParameters("/{resourceId}", pathParameters),
  1238  		autorest.WithJSON(parameters),
  1239  		autorest.WithQueryParameters(queryParameters))
  1240  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1241  }
  1242  
  1243  // UpdateByIDSender sends the UpdateByID request. The method will close the
  1244  // http.Response Body if it receives an error.
  1245  func (client ResourcesClient) UpdateByIDSender(req *http.Request) (future ResourcesUpdateByIDFuture, err error) {
  1246  	var resp *http.Response
  1247  	future.FutureAPI = &azure.Future{}
  1248  	resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
  1249  	if err != nil {
  1250  		return
  1251  	}
  1252  	var azf azure.Future
  1253  	azf, err = azure.NewFutureFromResponse(resp)
  1254  	future.FutureAPI = &azf
  1255  	future.Result = future.result
  1256  	return
  1257  }
  1258  
  1259  // UpdateByIDResponder handles the response to the UpdateByID request. The method always
  1260  // closes the http.Response Body.
  1261  func (client ResourcesClient) UpdateByIDResponder(resp *http.Response) (result GenericResource, err error) {
  1262  	err = autorest.Respond(
  1263  		resp,
  1264  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
  1265  		autorest.ByUnmarshallingJSON(&result),
  1266  		autorest.ByClosing())
  1267  	result.Response = autorest.Response{Response: resp}
  1268  	return
  1269  }
  1270  
  1271  // ValidateMoveResources this operation checks whether the specified resources can be moved to the target. The
  1272  // resources to move must be in the same source resource group. The target resource group may be in a different
  1273  // subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it
  1274  // returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to
  1275  // check the result of the long-running operation.
  1276  // Parameters:
  1277  // sourceResourceGroupName - the name of the resource group containing the resources to validate for move.
  1278  // parameters - parameters for moving resources.
  1279  func (client ResourcesClient) ValidateMoveResources(ctx context.Context, sourceResourceGroupName string, parameters ResourcesMoveInfo) (result ResourcesValidateMoveResourcesFuture, err error) {
  1280  	if tracing.IsEnabled() {
  1281  		ctx = tracing.StartSpan(ctx, fqdn+"/ResourcesClient.ValidateMoveResources")
  1282  		defer func() {
  1283  			sc := -1
  1284  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
  1285  				sc = result.FutureAPI.Response().StatusCode
  1286  			}
  1287  			tracing.EndSpan(ctx, sc, err)
  1288  		}()
  1289  	}
  1290  	if err := validation.Validate([]validation.Validation{
  1291  		{TargetValue: sourceResourceGroupName,
  1292  			Constraints: []validation.Constraint{{Target: "sourceResourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
  1293  				{Target: "sourceResourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
  1294  				{Target: "sourceResourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
  1295  		return result, validation.NewError("features.ResourcesClient", "ValidateMoveResources", err.Error())
  1296  	}
  1297  
  1298  	req, err := client.ValidateMoveResourcesPreparer(ctx, sourceResourceGroupName, parameters)
  1299  	if err != nil {
  1300  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "ValidateMoveResources", nil, "Failure preparing request")
  1301  		return
  1302  	}
  1303  
  1304  	result, err = client.ValidateMoveResourcesSender(req)
  1305  	if err != nil {
  1306  		err = autorest.NewErrorWithError(err, "features.ResourcesClient", "ValidateMoveResources", result.Response(), "Failure sending request")
  1307  		return
  1308  	}
  1309  
  1310  	return
  1311  }
  1312  
  1313  // ValidateMoveResourcesPreparer prepares the ValidateMoveResources request.
  1314  func (client ResourcesClient) ValidateMoveResourcesPreparer(ctx context.Context, sourceResourceGroupName string, parameters ResourcesMoveInfo) (*http.Request, error) {
  1315  	pathParameters := map[string]interface{}{
  1316  		"sourceResourceGroupName": autorest.Encode("path", sourceResourceGroupName),
  1317  		"subscriptionId":          autorest.Encode("path", client.SubscriptionID),
  1318  	}
  1319  
  1320  	const APIVersion = "2019-07-01"
  1321  	queryParameters := map[string]interface{}{
  1322  		"api-version": APIVersion,
  1323  	}
  1324  
  1325  	preparer := autorest.CreatePreparer(
  1326  		autorest.AsContentType("application/json; charset=utf-8"),
  1327  		autorest.AsPost(),
  1328  		autorest.WithBaseURL(client.BaseURI),
  1329  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources", pathParameters),
  1330  		autorest.WithJSON(parameters),
  1331  		autorest.WithQueryParameters(queryParameters))
  1332  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1333  }
  1334  
  1335  // ValidateMoveResourcesSender sends the ValidateMoveResources request. The method will close the
  1336  // http.Response Body if it receives an error.
  1337  func (client ResourcesClient) ValidateMoveResourcesSender(req *http.Request) (future ResourcesValidateMoveResourcesFuture, err error) {
  1338  	var resp *http.Response
  1339  	future.FutureAPI = &azure.Future{}
  1340  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
  1341  	if err != nil {
  1342  		return
  1343  	}
  1344  	var azf azure.Future
  1345  	azf, err = azure.NewFutureFromResponse(resp)
  1346  	future.FutureAPI = &azf
  1347  	future.Result = future.result
  1348  	return
  1349  }
  1350  
  1351  // ValidateMoveResourcesResponder handles the response to the ValidateMoveResources request. The method always
  1352  // closes the http.Response Body.
  1353  func (client ResourcesClient) ValidateMoveResourcesResponder(resp *http.Response) (result autorest.Response, err error) {
  1354  	err = autorest.Respond(
  1355  		resp,
  1356  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
  1357  		autorest.ByClosing())
  1358  	result.Response = resp
  1359  	return
  1360  }
  1361  

View as plain text