...

Source file src/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-04-01/locks/managementlocks.go

Documentation: github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-04-01/locks

     1  package locks
     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  // ManagementLocksClient is the azure resources can be locked to prevent other users in your organization from deleting
    19  // or modifying resources.
    20  type ManagementLocksClient struct {
    21  	BaseClient
    22  }
    23  
    24  // NewManagementLocksClient creates an instance of the ManagementLocksClient client.
    25  func NewManagementLocksClient(subscriptionID string) ManagementLocksClient {
    26  	return NewManagementLocksClientWithBaseURI(DefaultBaseURI, subscriptionID)
    27  }
    28  
    29  // NewManagementLocksClientWithBaseURI creates an instance of the ManagementLocksClient client using a custom endpoint.
    30  // Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    31  func NewManagementLocksClientWithBaseURI(baseURI string, subscriptionID string) ManagementLocksClient {
    32  	return ManagementLocksClient{NewWithBaseURI(baseURI, subscriptionID)}
    33  }
    34  
    35  // CreateOrUpdateAtResourceGroupLevel when you apply a lock at a parent scope, all child resources inherit the same
    36  // lock. To create management locks, you must have access to Microsoft.Authorization/* or
    37  // Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted
    38  // those actions.
    39  // Parameters:
    40  // resourceGroupName - the name of the resource group to lock.
    41  // lockName - the lock name. The lock name can be a maximum of 260 characters. It cannot contain <, > %, &, :,
    42  // \, ?, /, or any control characters.
    43  // parameters - the management lock parameters.
    44  func (client ManagementLocksClient) CreateOrUpdateAtResourceGroupLevel(ctx context.Context, resourceGroupName string, lockName string, parameters ManagementLockObject) (result ManagementLockObject, err error) {
    45  	if tracing.IsEnabled() {
    46  		ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.CreateOrUpdateAtResourceGroupLevel")
    47  		defer func() {
    48  			sc := -1
    49  			if result.Response.Response != nil {
    50  				sc = result.Response.Response.StatusCode
    51  			}
    52  			tracing.EndSpan(ctx, sc, err)
    53  		}()
    54  	}
    55  	if err := validation.Validate([]validation.Validation{
    56  		{TargetValue: resourceGroupName,
    57  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
    58  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
    59  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}},
    60  		{TargetValue: parameters,
    61  			Constraints: []validation.Constraint{{Target: "parameters.ManagementLockProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
    62  		return result, validation.NewError("locks.ManagementLocksClient", "CreateOrUpdateAtResourceGroupLevel", err.Error())
    63  	}
    64  
    65  	req, err := client.CreateOrUpdateAtResourceGroupLevelPreparer(ctx, resourceGroupName, lockName, parameters)
    66  	if err != nil {
    67  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "CreateOrUpdateAtResourceGroupLevel", nil, "Failure preparing request")
    68  		return
    69  	}
    70  
    71  	resp, err := client.CreateOrUpdateAtResourceGroupLevelSender(req)
    72  	if err != nil {
    73  		result.Response = autorest.Response{Response: resp}
    74  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "CreateOrUpdateAtResourceGroupLevel", resp, "Failure sending request")
    75  		return
    76  	}
    77  
    78  	result, err = client.CreateOrUpdateAtResourceGroupLevelResponder(resp)
    79  	if err != nil {
    80  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "CreateOrUpdateAtResourceGroupLevel", resp, "Failure responding to request")
    81  		return
    82  	}
    83  
    84  	return
    85  }
    86  
    87  // CreateOrUpdateAtResourceGroupLevelPreparer prepares the CreateOrUpdateAtResourceGroupLevel request.
    88  func (client ManagementLocksClient) CreateOrUpdateAtResourceGroupLevelPreparer(ctx context.Context, resourceGroupName string, lockName string, parameters ManagementLockObject) (*http.Request, error) {
    89  	pathParameters := map[string]interface{}{
    90  		"lockName":          autorest.Encode("path", lockName),
    91  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    92  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    93  	}
    94  
    95  	const APIVersion = "2017-04-01"
    96  	queryParameters := map[string]interface{}{
    97  		"api-version": APIVersion,
    98  	}
    99  
   100  	parameters.ID = nil
   101  	parameters.Type = nil
   102  	parameters.Name = nil
   103  	preparer := autorest.CreatePreparer(
   104  		autorest.AsContentType("application/json; charset=utf-8"),
   105  		autorest.AsPut(),
   106  		autorest.WithBaseURL(client.BaseURI),
   107  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}", pathParameters),
   108  		autorest.WithJSON(parameters),
   109  		autorest.WithQueryParameters(queryParameters))
   110  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   111  }
   112  
   113  // CreateOrUpdateAtResourceGroupLevelSender sends the CreateOrUpdateAtResourceGroupLevel request. The method will close the
   114  // http.Response Body if it receives an error.
   115  func (client ManagementLocksClient) CreateOrUpdateAtResourceGroupLevelSender(req *http.Request) (*http.Response, error) {
   116  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   117  }
   118  
   119  // CreateOrUpdateAtResourceGroupLevelResponder handles the response to the CreateOrUpdateAtResourceGroupLevel request. The method always
   120  // closes the http.Response Body.
   121  func (client ManagementLocksClient) CreateOrUpdateAtResourceGroupLevelResponder(resp *http.Response) (result ManagementLockObject, err error) {
   122  	err = autorest.Respond(
   123  		resp,
   124  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   125  		autorest.ByUnmarshallingJSON(&result),
   126  		autorest.ByClosing())
   127  	result.Response = autorest.Response{Response: resp}
   128  	return
   129  }
   130  
   131  // CreateOrUpdateAtResourceLevel when you apply a lock at a parent scope, all child resources inherit the same lock. To
   132  // create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/*
   133  // actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions.
   134  // Parameters:
   135  // resourceGroupName - the name of the resource group containing the resource to lock.
   136  // resourceProviderNamespace - the resource provider namespace of the resource to lock.
   137  // parentResourcePath - the parent resource identity.
   138  // resourceType - the resource type of the resource to lock.
   139  // resourceName - the name of the resource to lock.
   140  // lockName - the name of lock. The lock name can be a maximum of 260 characters. It cannot contain <, > %, &,
   141  // :, \, ?, /, or any control characters.
   142  // parameters - parameters for creating or updating a  management lock.
   143  func (client ManagementLocksClient) CreateOrUpdateAtResourceLevel(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, lockName string, parameters ManagementLockObject) (result ManagementLockObject, err error) {
   144  	if tracing.IsEnabled() {
   145  		ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.CreateOrUpdateAtResourceLevel")
   146  		defer func() {
   147  			sc := -1
   148  			if result.Response.Response != nil {
   149  				sc = result.Response.Response.StatusCode
   150  			}
   151  			tracing.EndSpan(ctx, sc, err)
   152  		}()
   153  	}
   154  	if err := validation.Validate([]validation.Validation{
   155  		{TargetValue: resourceGroupName,
   156  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   157  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   158  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}},
   159  		{TargetValue: parameters,
   160  			Constraints: []validation.Constraint{{Target: "parameters.ManagementLockProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
   161  		return result, validation.NewError("locks.ManagementLocksClient", "CreateOrUpdateAtResourceLevel", err.Error())
   162  	}
   163  
   164  	req, err := client.CreateOrUpdateAtResourceLevelPreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, lockName, parameters)
   165  	if err != nil {
   166  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "CreateOrUpdateAtResourceLevel", nil, "Failure preparing request")
   167  		return
   168  	}
   169  
   170  	resp, err := client.CreateOrUpdateAtResourceLevelSender(req)
   171  	if err != nil {
   172  		result.Response = autorest.Response{Response: resp}
   173  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "CreateOrUpdateAtResourceLevel", resp, "Failure sending request")
   174  		return
   175  	}
   176  
   177  	result, err = client.CreateOrUpdateAtResourceLevelResponder(resp)
   178  	if err != nil {
   179  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "CreateOrUpdateAtResourceLevel", resp, "Failure responding to request")
   180  		return
   181  	}
   182  
   183  	return
   184  }
   185  
   186  // CreateOrUpdateAtResourceLevelPreparer prepares the CreateOrUpdateAtResourceLevel request.
   187  func (client ManagementLocksClient) CreateOrUpdateAtResourceLevelPreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, lockName string, parameters ManagementLockObject) (*http.Request, error) {
   188  	pathParameters := map[string]interface{}{
   189  		"lockName":                  autorest.Encode("path", lockName),
   190  		"parentResourcePath":        parentResourcePath,
   191  		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
   192  		"resourceName":              autorest.Encode("path", resourceName),
   193  		"resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace),
   194  		"resourceType":              resourceType,
   195  		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
   196  	}
   197  
   198  	const APIVersion = "2017-04-01"
   199  	queryParameters := map[string]interface{}{
   200  		"api-version": APIVersion,
   201  	}
   202  
   203  	parameters.ID = nil
   204  	parameters.Type = nil
   205  	parameters.Name = nil
   206  	preparer := autorest.CreatePreparer(
   207  		autorest.AsContentType("application/json; charset=utf-8"),
   208  		autorest.AsPut(),
   209  		autorest.WithBaseURL(client.BaseURI),
   210  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}", pathParameters),
   211  		autorest.WithJSON(parameters),
   212  		autorest.WithQueryParameters(queryParameters))
   213  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   214  }
   215  
   216  // CreateOrUpdateAtResourceLevelSender sends the CreateOrUpdateAtResourceLevel request. The method will close the
   217  // http.Response Body if it receives an error.
   218  func (client ManagementLocksClient) CreateOrUpdateAtResourceLevelSender(req *http.Request) (*http.Response, error) {
   219  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   220  }
   221  
   222  // CreateOrUpdateAtResourceLevelResponder handles the response to the CreateOrUpdateAtResourceLevel request. The method always
   223  // closes the http.Response Body.
   224  func (client ManagementLocksClient) CreateOrUpdateAtResourceLevelResponder(resp *http.Response) (result ManagementLockObject, err error) {
   225  	err = autorest.Respond(
   226  		resp,
   227  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   228  		autorest.ByUnmarshallingJSON(&result),
   229  		autorest.ByClosing())
   230  	result.Response = autorest.Response{Response: resp}
   231  	return
   232  }
   233  
   234  // CreateOrUpdateAtSubscriptionLevel when you apply a lock at a parent scope, all child resources inherit the same
   235  // lock. To create management locks, you must have access to Microsoft.Authorization/* or
   236  // Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted
   237  // those actions.
   238  // Parameters:
   239  // lockName - the name of lock. The lock name can be a maximum of 260 characters. It cannot contain <, > %, &,
   240  // :, \, ?, /, or any control characters.
   241  // parameters - the management lock parameters.
   242  func (client ManagementLocksClient) CreateOrUpdateAtSubscriptionLevel(ctx context.Context, lockName string, parameters ManagementLockObject) (result ManagementLockObject, err error) {
   243  	if tracing.IsEnabled() {
   244  		ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.CreateOrUpdateAtSubscriptionLevel")
   245  		defer func() {
   246  			sc := -1
   247  			if result.Response.Response != nil {
   248  				sc = result.Response.Response.StatusCode
   249  			}
   250  			tracing.EndSpan(ctx, sc, err)
   251  		}()
   252  	}
   253  	if err := validation.Validate([]validation.Validation{
   254  		{TargetValue: parameters,
   255  			Constraints: []validation.Constraint{{Target: "parameters.ManagementLockProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
   256  		return result, validation.NewError("locks.ManagementLocksClient", "CreateOrUpdateAtSubscriptionLevel", err.Error())
   257  	}
   258  
   259  	req, err := client.CreateOrUpdateAtSubscriptionLevelPreparer(ctx, lockName, parameters)
   260  	if err != nil {
   261  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "CreateOrUpdateAtSubscriptionLevel", nil, "Failure preparing request")
   262  		return
   263  	}
   264  
   265  	resp, err := client.CreateOrUpdateAtSubscriptionLevelSender(req)
   266  	if err != nil {
   267  		result.Response = autorest.Response{Response: resp}
   268  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "CreateOrUpdateAtSubscriptionLevel", resp, "Failure sending request")
   269  		return
   270  	}
   271  
   272  	result, err = client.CreateOrUpdateAtSubscriptionLevelResponder(resp)
   273  	if err != nil {
   274  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "CreateOrUpdateAtSubscriptionLevel", resp, "Failure responding to request")
   275  		return
   276  	}
   277  
   278  	return
   279  }
   280  
   281  // CreateOrUpdateAtSubscriptionLevelPreparer prepares the CreateOrUpdateAtSubscriptionLevel request.
   282  func (client ManagementLocksClient) CreateOrUpdateAtSubscriptionLevelPreparer(ctx context.Context, lockName string, parameters ManagementLockObject) (*http.Request, error) {
   283  	pathParameters := map[string]interface{}{
   284  		"lockName":       autorest.Encode("path", lockName),
   285  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
   286  	}
   287  
   288  	const APIVersion = "2017-04-01"
   289  	queryParameters := map[string]interface{}{
   290  		"api-version": APIVersion,
   291  	}
   292  
   293  	parameters.ID = nil
   294  	parameters.Type = nil
   295  	parameters.Name = nil
   296  	preparer := autorest.CreatePreparer(
   297  		autorest.AsContentType("application/json; charset=utf-8"),
   298  		autorest.AsPut(),
   299  		autorest.WithBaseURL(client.BaseURI),
   300  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}", pathParameters),
   301  		autorest.WithJSON(parameters),
   302  		autorest.WithQueryParameters(queryParameters))
   303  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   304  }
   305  
   306  // CreateOrUpdateAtSubscriptionLevelSender sends the CreateOrUpdateAtSubscriptionLevel request. The method will close the
   307  // http.Response Body if it receives an error.
   308  func (client ManagementLocksClient) CreateOrUpdateAtSubscriptionLevelSender(req *http.Request) (*http.Response, error) {
   309  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   310  }
   311  
   312  // CreateOrUpdateAtSubscriptionLevelResponder handles the response to the CreateOrUpdateAtSubscriptionLevel request. The method always
   313  // closes the http.Response Body.
   314  func (client ManagementLocksClient) CreateOrUpdateAtSubscriptionLevelResponder(resp *http.Response) (result ManagementLockObject, err error) {
   315  	err = autorest.Respond(
   316  		resp,
   317  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   318  		autorest.ByUnmarshallingJSON(&result),
   319  		autorest.ByClosing())
   320  	result.Response = autorest.Response{Response: resp}
   321  	return
   322  }
   323  
   324  // CreateOrUpdateByScope create or update a management lock by scope.
   325  // Parameters:
   326  // scope - the scope for the lock. When providing a scope for the assignment, use
   327  // '/subscriptions/{subscriptionId}' for subscriptions,
   328  // '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for resource groups, and
   329  // '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}'
   330  // for resources.
   331  // lockName - the name of lock.
   332  // parameters - create or update management lock parameters.
   333  func (client ManagementLocksClient) CreateOrUpdateByScope(ctx context.Context, scope string, lockName string, parameters ManagementLockObject) (result ManagementLockObject, err error) {
   334  	if tracing.IsEnabled() {
   335  		ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.CreateOrUpdateByScope")
   336  		defer func() {
   337  			sc := -1
   338  			if result.Response.Response != nil {
   339  				sc = result.Response.Response.StatusCode
   340  			}
   341  			tracing.EndSpan(ctx, sc, err)
   342  		}()
   343  	}
   344  	if err := validation.Validate([]validation.Validation{
   345  		{TargetValue: parameters,
   346  			Constraints: []validation.Constraint{{Target: "parameters.ManagementLockProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
   347  		return result, validation.NewError("locks.ManagementLocksClient", "CreateOrUpdateByScope", err.Error())
   348  	}
   349  
   350  	req, err := client.CreateOrUpdateByScopePreparer(ctx, scope, lockName, parameters)
   351  	if err != nil {
   352  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "CreateOrUpdateByScope", nil, "Failure preparing request")
   353  		return
   354  	}
   355  
   356  	resp, err := client.CreateOrUpdateByScopeSender(req)
   357  	if err != nil {
   358  		result.Response = autorest.Response{Response: resp}
   359  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "CreateOrUpdateByScope", resp, "Failure sending request")
   360  		return
   361  	}
   362  
   363  	result, err = client.CreateOrUpdateByScopeResponder(resp)
   364  	if err != nil {
   365  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "CreateOrUpdateByScope", resp, "Failure responding to request")
   366  		return
   367  	}
   368  
   369  	return
   370  }
   371  
   372  // CreateOrUpdateByScopePreparer prepares the CreateOrUpdateByScope request.
   373  func (client ManagementLocksClient) CreateOrUpdateByScopePreparer(ctx context.Context, scope string, lockName string, parameters ManagementLockObject) (*http.Request, error) {
   374  	pathParameters := map[string]interface{}{
   375  		"lockName": autorest.Encode("path", lockName),
   376  		"scope":    autorest.Encode("path", scope),
   377  	}
   378  
   379  	const APIVersion = "2017-04-01"
   380  	queryParameters := map[string]interface{}{
   381  		"api-version": APIVersion,
   382  	}
   383  
   384  	parameters.ID = nil
   385  	parameters.Type = nil
   386  	parameters.Name = nil
   387  	preparer := autorest.CreatePreparer(
   388  		autorest.AsContentType("application/json; charset=utf-8"),
   389  		autorest.AsPut(),
   390  		autorest.WithBaseURL(client.BaseURI),
   391  		autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/locks/{lockName}", pathParameters),
   392  		autorest.WithJSON(parameters),
   393  		autorest.WithQueryParameters(queryParameters))
   394  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   395  }
   396  
   397  // CreateOrUpdateByScopeSender sends the CreateOrUpdateByScope request. The method will close the
   398  // http.Response Body if it receives an error.
   399  func (client ManagementLocksClient) CreateOrUpdateByScopeSender(req *http.Request) (*http.Response, error) {
   400  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   401  }
   402  
   403  // CreateOrUpdateByScopeResponder handles the response to the CreateOrUpdateByScope request. The method always
   404  // closes the http.Response Body.
   405  func (client ManagementLocksClient) CreateOrUpdateByScopeResponder(resp *http.Response) (result ManagementLockObject, err error) {
   406  	err = autorest.Respond(
   407  		resp,
   408  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   409  		autorest.ByUnmarshallingJSON(&result),
   410  		autorest.ByClosing())
   411  	result.Response = autorest.Response{Response: resp}
   412  	return
   413  }
   414  
   415  // DeleteAtResourceGroupLevel to delete management locks, you must have access to Microsoft.Authorization/* or
   416  // Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted
   417  // those actions.
   418  // Parameters:
   419  // resourceGroupName - the name of the resource group containing the lock.
   420  // lockName - the name of lock to delete.
   421  func (client ManagementLocksClient) DeleteAtResourceGroupLevel(ctx context.Context, resourceGroupName string, lockName string) (result autorest.Response, err error) {
   422  	if tracing.IsEnabled() {
   423  		ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.DeleteAtResourceGroupLevel")
   424  		defer func() {
   425  			sc := -1
   426  			if result.Response != nil {
   427  				sc = result.Response.StatusCode
   428  			}
   429  			tracing.EndSpan(ctx, sc, err)
   430  		}()
   431  	}
   432  	if err := validation.Validate([]validation.Validation{
   433  		{TargetValue: resourceGroupName,
   434  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   435  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   436  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
   437  		return result, validation.NewError("locks.ManagementLocksClient", "DeleteAtResourceGroupLevel", err.Error())
   438  	}
   439  
   440  	req, err := client.DeleteAtResourceGroupLevelPreparer(ctx, resourceGroupName, lockName)
   441  	if err != nil {
   442  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "DeleteAtResourceGroupLevel", nil, "Failure preparing request")
   443  		return
   444  	}
   445  
   446  	resp, err := client.DeleteAtResourceGroupLevelSender(req)
   447  	if err != nil {
   448  		result.Response = resp
   449  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "DeleteAtResourceGroupLevel", resp, "Failure sending request")
   450  		return
   451  	}
   452  
   453  	result, err = client.DeleteAtResourceGroupLevelResponder(resp)
   454  	if err != nil {
   455  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "DeleteAtResourceGroupLevel", resp, "Failure responding to request")
   456  		return
   457  	}
   458  
   459  	return
   460  }
   461  
   462  // DeleteAtResourceGroupLevelPreparer prepares the DeleteAtResourceGroupLevel request.
   463  func (client ManagementLocksClient) DeleteAtResourceGroupLevelPreparer(ctx context.Context, resourceGroupName string, lockName string) (*http.Request, error) {
   464  	pathParameters := map[string]interface{}{
   465  		"lockName":          autorest.Encode("path", lockName),
   466  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   467  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   468  	}
   469  
   470  	const APIVersion = "2017-04-01"
   471  	queryParameters := map[string]interface{}{
   472  		"api-version": APIVersion,
   473  	}
   474  
   475  	preparer := autorest.CreatePreparer(
   476  		autorest.AsDelete(),
   477  		autorest.WithBaseURL(client.BaseURI),
   478  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}", pathParameters),
   479  		autorest.WithQueryParameters(queryParameters))
   480  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   481  }
   482  
   483  // DeleteAtResourceGroupLevelSender sends the DeleteAtResourceGroupLevel request. The method will close the
   484  // http.Response Body if it receives an error.
   485  func (client ManagementLocksClient) DeleteAtResourceGroupLevelSender(req *http.Request) (*http.Response, error) {
   486  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   487  }
   488  
   489  // DeleteAtResourceGroupLevelResponder handles the response to the DeleteAtResourceGroupLevel request. The method always
   490  // closes the http.Response Body.
   491  func (client ManagementLocksClient) DeleteAtResourceGroupLevelResponder(resp *http.Response) (result autorest.Response, err error) {
   492  	err = autorest.Respond(
   493  		resp,
   494  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
   495  		autorest.ByClosing())
   496  	result.Response = resp
   497  	return
   498  }
   499  
   500  // DeleteAtResourceLevel to delete management locks, you must have access to Microsoft.Authorization/* or
   501  // Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted
   502  // those actions.
   503  // Parameters:
   504  // resourceGroupName - the name of the resource group containing the resource with the lock to delete.
   505  // resourceProviderNamespace - the resource provider namespace of the resource with the lock to delete.
   506  // parentResourcePath - the parent resource identity.
   507  // resourceType - the resource type of the resource with the lock to delete.
   508  // resourceName - the name of the resource with the lock to delete.
   509  // lockName - the name of the lock to delete.
   510  func (client ManagementLocksClient) DeleteAtResourceLevel(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, lockName string) (result autorest.Response, err error) {
   511  	if tracing.IsEnabled() {
   512  		ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.DeleteAtResourceLevel")
   513  		defer func() {
   514  			sc := -1
   515  			if result.Response != nil {
   516  				sc = result.Response.StatusCode
   517  			}
   518  			tracing.EndSpan(ctx, sc, err)
   519  		}()
   520  	}
   521  	if err := validation.Validate([]validation.Validation{
   522  		{TargetValue: resourceGroupName,
   523  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   524  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   525  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
   526  		return result, validation.NewError("locks.ManagementLocksClient", "DeleteAtResourceLevel", err.Error())
   527  	}
   528  
   529  	req, err := client.DeleteAtResourceLevelPreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, lockName)
   530  	if err != nil {
   531  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "DeleteAtResourceLevel", nil, "Failure preparing request")
   532  		return
   533  	}
   534  
   535  	resp, err := client.DeleteAtResourceLevelSender(req)
   536  	if err != nil {
   537  		result.Response = resp
   538  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "DeleteAtResourceLevel", resp, "Failure sending request")
   539  		return
   540  	}
   541  
   542  	result, err = client.DeleteAtResourceLevelResponder(resp)
   543  	if err != nil {
   544  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "DeleteAtResourceLevel", resp, "Failure responding to request")
   545  		return
   546  	}
   547  
   548  	return
   549  }
   550  
   551  // DeleteAtResourceLevelPreparer prepares the DeleteAtResourceLevel request.
   552  func (client ManagementLocksClient) DeleteAtResourceLevelPreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, lockName string) (*http.Request, error) {
   553  	pathParameters := map[string]interface{}{
   554  		"lockName":                  autorest.Encode("path", lockName),
   555  		"parentResourcePath":        parentResourcePath,
   556  		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
   557  		"resourceName":              autorest.Encode("path", resourceName),
   558  		"resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace),
   559  		"resourceType":              resourceType,
   560  		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
   561  	}
   562  
   563  	const APIVersion = "2017-04-01"
   564  	queryParameters := map[string]interface{}{
   565  		"api-version": APIVersion,
   566  	}
   567  
   568  	preparer := autorest.CreatePreparer(
   569  		autorest.AsDelete(),
   570  		autorest.WithBaseURL(client.BaseURI),
   571  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}", pathParameters),
   572  		autorest.WithQueryParameters(queryParameters))
   573  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   574  }
   575  
   576  // DeleteAtResourceLevelSender sends the DeleteAtResourceLevel request. The method will close the
   577  // http.Response Body if it receives an error.
   578  func (client ManagementLocksClient) DeleteAtResourceLevelSender(req *http.Request) (*http.Response, error) {
   579  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   580  }
   581  
   582  // DeleteAtResourceLevelResponder handles the response to the DeleteAtResourceLevel request. The method always
   583  // closes the http.Response Body.
   584  func (client ManagementLocksClient) DeleteAtResourceLevelResponder(resp *http.Response) (result autorest.Response, err error) {
   585  	err = autorest.Respond(
   586  		resp,
   587  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
   588  		autorest.ByClosing())
   589  	result.Response = resp
   590  	return
   591  }
   592  
   593  // DeleteAtSubscriptionLevel to delete management locks, you must have access to Microsoft.Authorization/* or
   594  // Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted
   595  // those actions.
   596  // Parameters:
   597  // lockName - the name of lock to delete.
   598  func (client ManagementLocksClient) DeleteAtSubscriptionLevel(ctx context.Context, lockName string) (result autorest.Response, err error) {
   599  	if tracing.IsEnabled() {
   600  		ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.DeleteAtSubscriptionLevel")
   601  		defer func() {
   602  			sc := -1
   603  			if result.Response != nil {
   604  				sc = result.Response.StatusCode
   605  			}
   606  			tracing.EndSpan(ctx, sc, err)
   607  		}()
   608  	}
   609  	req, err := client.DeleteAtSubscriptionLevelPreparer(ctx, lockName)
   610  	if err != nil {
   611  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "DeleteAtSubscriptionLevel", nil, "Failure preparing request")
   612  		return
   613  	}
   614  
   615  	resp, err := client.DeleteAtSubscriptionLevelSender(req)
   616  	if err != nil {
   617  		result.Response = resp
   618  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "DeleteAtSubscriptionLevel", resp, "Failure sending request")
   619  		return
   620  	}
   621  
   622  	result, err = client.DeleteAtSubscriptionLevelResponder(resp)
   623  	if err != nil {
   624  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "DeleteAtSubscriptionLevel", resp, "Failure responding to request")
   625  		return
   626  	}
   627  
   628  	return
   629  }
   630  
   631  // DeleteAtSubscriptionLevelPreparer prepares the DeleteAtSubscriptionLevel request.
   632  func (client ManagementLocksClient) DeleteAtSubscriptionLevelPreparer(ctx context.Context, lockName string) (*http.Request, error) {
   633  	pathParameters := map[string]interface{}{
   634  		"lockName":       autorest.Encode("path", lockName),
   635  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
   636  	}
   637  
   638  	const APIVersion = "2017-04-01"
   639  	queryParameters := map[string]interface{}{
   640  		"api-version": APIVersion,
   641  	}
   642  
   643  	preparer := autorest.CreatePreparer(
   644  		autorest.AsDelete(),
   645  		autorest.WithBaseURL(client.BaseURI),
   646  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}", pathParameters),
   647  		autorest.WithQueryParameters(queryParameters))
   648  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   649  }
   650  
   651  // DeleteAtSubscriptionLevelSender sends the DeleteAtSubscriptionLevel request. The method will close the
   652  // http.Response Body if it receives an error.
   653  func (client ManagementLocksClient) DeleteAtSubscriptionLevelSender(req *http.Request) (*http.Response, error) {
   654  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   655  }
   656  
   657  // DeleteAtSubscriptionLevelResponder handles the response to the DeleteAtSubscriptionLevel request. The method always
   658  // closes the http.Response Body.
   659  func (client ManagementLocksClient) DeleteAtSubscriptionLevelResponder(resp *http.Response) (result autorest.Response, err error) {
   660  	err = autorest.Respond(
   661  		resp,
   662  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
   663  		autorest.ByClosing())
   664  	result.Response = resp
   665  	return
   666  }
   667  
   668  // DeleteByScope delete a management lock by scope.
   669  // Parameters:
   670  // scope - the scope for the lock.
   671  // lockName - the name of lock.
   672  func (client ManagementLocksClient) DeleteByScope(ctx context.Context, scope string, lockName string) (result autorest.Response, err error) {
   673  	if tracing.IsEnabled() {
   674  		ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.DeleteByScope")
   675  		defer func() {
   676  			sc := -1
   677  			if result.Response != nil {
   678  				sc = result.Response.StatusCode
   679  			}
   680  			tracing.EndSpan(ctx, sc, err)
   681  		}()
   682  	}
   683  	req, err := client.DeleteByScopePreparer(ctx, scope, lockName)
   684  	if err != nil {
   685  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "DeleteByScope", nil, "Failure preparing request")
   686  		return
   687  	}
   688  
   689  	resp, err := client.DeleteByScopeSender(req)
   690  	if err != nil {
   691  		result.Response = resp
   692  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "DeleteByScope", resp, "Failure sending request")
   693  		return
   694  	}
   695  
   696  	result, err = client.DeleteByScopeResponder(resp)
   697  	if err != nil {
   698  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "DeleteByScope", resp, "Failure responding to request")
   699  		return
   700  	}
   701  
   702  	return
   703  }
   704  
   705  // DeleteByScopePreparer prepares the DeleteByScope request.
   706  func (client ManagementLocksClient) DeleteByScopePreparer(ctx context.Context, scope string, lockName string) (*http.Request, error) {
   707  	pathParameters := map[string]interface{}{
   708  		"lockName": autorest.Encode("path", lockName),
   709  		"scope":    autorest.Encode("path", scope),
   710  	}
   711  
   712  	const APIVersion = "2017-04-01"
   713  	queryParameters := map[string]interface{}{
   714  		"api-version": APIVersion,
   715  	}
   716  
   717  	preparer := autorest.CreatePreparer(
   718  		autorest.AsDelete(),
   719  		autorest.WithBaseURL(client.BaseURI),
   720  		autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/locks/{lockName}", pathParameters),
   721  		autorest.WithQueryParameters(queryParameters))
   722  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   723  }
   724  
   725  // DeleteByScopeSender sends the DeleteByScope request. The method will close the
   726  // http.Response Body if it receives an error.
   727  func (client ManagementLocksClient) DeleteByScopeSender(req *http.Request) (*http.Response, error) {
   728  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   729  }
   730  
   731  // DeleteByScopeResponder handles the response to the DeleteByScope request. The method always
   732  // closes the http.Response Body.
   733  func (client ManagementLocksClient) DeleteByScopeResponder(resp *http.Response) (result autorest.Response, err error) {
   734  	err = autorest.Respond(
   735  		resp,
   736  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
   737  		autorest.ByClosing())
   738  	result.Response = resp
   739  	return
   740  }
   741  
   742  // GetAtResourceGroupLevel gets a management lock at the resource group level.
   743  // Parameters:
   744  // resourceGroupName - the name of the locked resource group.
   745  // lockName - the name of the lock to get.
   746  func (client ManagementLocksClient) GetAtResourceGroupLevel(ctx context.Context, resourceGroupName string, lockName string) (result ManagementLockObject, err error) {
   747  	if tracing.IsEnabled() {
   748  		ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.GetAtResourceGroupLevel")
   749  		defer func() {
   750  			sc := -1
   751  			if result.Response.Response != nil {
   752  				sc = result.Response.Response.StatusCode
   753  			}
   754  			tracing.EndSpan(ctx, sc, err)
   755  		}()
   756  	}
   757  	if err := validation.Validate([]validation.Validation{
   758  		{TargetValue: resourceGroupName,
   759  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   760  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   761  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
   762  		return result, validation.NewError("locks.ManagementLocksClient", "GetAtResourceGroupLevel", err.Error())
   763  	}
   764  
   765  	req, err := client.GetAtResourceGroupLevelPreparer(ctx, resourceGroupName, lockName)
   766  	if err != nil {
   767  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "GetAtResourceGroupLevel", nil, "Failure preparing request")
   768  		return
   769  	}
   770  
   771  	resp, err := client.GetAtResourceGroupLevelSender(req)
   772  	if err != nil {
   773  		result.Response = autorest.Response{Response: resp}
   774  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "GetAtResourceGroupLevel", resp, "Failure sending request")
   775  		return
   776  	}
   777  
   778  	result, err = client.GetAtResourceGroupLevelResponder(resp)
   779  	if err != nil {
   780  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "GetAtResourceGroupLevel", resp, "Failure responding to request")
   781  		return
   782  	}
   783  
   784  	return
   785  }
   786  
   787  // GetAtResourceGroupLevelPreparer prepares the GetAtResourceGroupLevel request.
   788  func (client ManagementLocksClient) GetAtResourceGroupLevelPreparer(ctx context.Context, resourceGroupName string, lockName string) (*http.Request, error) {
   789  	pathParameters := map[string]interface{}{
   790  		"lockName":          autorest.Encode("path", lockName),
   791  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   792  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   793  	}
   794  
   795  	const APIVersion = "2017-04-01"
   796  	queryParameters := map[string]interface{}{
   797  		"api-version": APIVersion,
   798  	}
   799  
   800  	preparer := autorest.CreatePreparer(
   801  		autorest.AsGet(),
   802  		autorest.WithBaseURL(client.BaseURI),
   803  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}", pathParameters),
   804  		autorest.WithQueryParameters(queryParameters))
   805  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   806  }
   807  
   808  // GetAtResourceGroupLevelSender sends the GetAtResourceGroupLevel request. The method will close the
   809  // http.Response Body if it receives an error.
   810  func (client ManagementLocksClient) GetAtResourceGroupLevelSender(req *http.Request) (*http.Response, error) {
   811  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   812  }
   813  
   814  // GetAtResourceGroupLevelResponder handles the response to the GetAtResourceGroupLevel request. The method always
   815  // closes the http.Response Body.
   816  func (client ManagementLocksClient) GetAtResourceGroupLevelResponder(resp *http.Response) (result ManagementLockObject, err error) {
   817  	err = autorest.Respond(
   818  		resp,
   819  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   820  		autorest.ByUnmarshallingJSON(&result),
   821  		autorest.ByClosing())
   822  	result.Response = autorest.Response{Response: resp}
   823  	return
   824  }
   825  
   826  // GetAtResourceLevel get the management lock of a resource or any level below resource.
   827  // Parameters:
   828  // resourceGroupName - the name of the resource group.
   829  // resourceProviderNamespace - the namespace of the resource provider.
   830  // parentResourcePath - an extra path parameter needed in some services, like SQL Databases.
   831  // resourceType - the type of the resource.
   832  // resourceName - the name of the resource.
   833  // lockName - the name of lock.
   834  func (client ManagementLocksClient) GetAtResourceLevel(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, lockName string) (result ManagementLockObject, err error) {
   835  	if tracing.IsEnabled() {
   836  		ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.GetAtResourceLevel")
   837  		defer func() {
   838  			sc := -1
   839  			if result.Response.Response != nil {
   840  				sc = result.Response.Response.StatusCode
   841  			}
   842  			tracing.EndSpan(ctx, sc, err)
   843  		}()
   844  	}
   845  	if err := validation.Validate([]validation.Validation{
   846  		{TargetValue: resourceGroupName,
   847  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   848  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   849  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
   850  		return result, validation.NewError("locks.ManagementLocksClient", "GetAtResourceLevel", err.Error())
   851  	}
   852  
   853  	req, err := client.GetAtResourceLevelPreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, lockName)
   854  	if err != nil {
   855  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "GetAtResourceLevel", nil, "Failure preparing request")
   856  		return
   857  	}
   858  
   859  	resp, err := client.GetAtResourceLevelSender(req)
   860  	if err != nil {
   861  		result.Response = autorest.Response{Response: resp}
   862  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "GetAtResourceLevel", resp, "Failure sending request")
   863  		return
   864  	}
   865  
   866  	result, err = client.GetAtResourceLevelResponder(resp)
   867  	if err != nil {
   868  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "GetAtResourceLevel", resp, "Failure responding to request")
   869  		return
   870  	}
   871  
   872  	return
   873  }
   874  
   875  // GetAtResourceLevelPreparer prepares the GetAtResourceLevel request.
   876  func (client ManagementLocksClient) GetAtResourceLevelPreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, lockName string) (*http.Request, error) {
   877  	pathParameters := map[string]interface{}{
   878  		"lockName":                  autorest.Encode("path", lockName),
   879  		"parentResourcePath":        parentResourcePath,
   880  		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
   881  		"resourceName":              autorest.Encode("path", resourceName),
   882  		"resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace),
   883  		"resourceType":              resourceType,
   884  		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
   885  	}
   886  
   887  	const APIVersion = "2017-04-01"
   888  	queryParameters := map[string]interface{}{
   889  		"api-version": APIVersion,
   890  	}
   891  
   892  	preparer := autorest.CreatePreparer(
   893  		autorest.AsGet(),
   894  		autorest.WithBaseURL(client.BaseURI),
   895  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}", pathParameters),
   896  		autorest.WithQueryParameters(queryParameters))
   897  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   898  }
   899  
   900  // GetAtResourceLevelSender sends the GetAtResourceLevel request. The method will close the
   901  // http.Response Body if it receives an error.
   902  func (client ManagementLocksClient) GetAtResourceLevelSender(req *http.Request) (*http.Response, error) {
   903  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   904  }
   905  
   906  // GetAtResourceLevelResponder handles the response to the GetAtResourceLevel request. The method always
   907  // closes the http.Response Body.
   908  func (client ManagementLocksClient) GetAtResourceLevelResponder(resp *http.Response) (result ManagementLockObject, err error) {
   909  	err = autorest.Respond(
   910  		resp,
   911  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   912  		autorest.ByUnmarshallingJSON(&result),
   913  		autorest.ByClosing())
   914  	result.Response = autorest.Response{Response: resp}
   915  	return
   916  }
   917  
   918  // GetAtSubscriptionLevel gets a management lock at the subscription level.
   919  // Parameters:
   920  // lockName - the name of the lock to get.
   921  func (client ManagementLocksClient) GetAtSubscriptionLevel(ctx context.Context, lockName string) (result ManagementLockObject, err error) {
   922  	if tracing.IsEnabled() {
   923  		ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.GetAtSubscriptionLevel")
   924  		defer func() {
   925  			sc := -1
   926  			if result.Response.Response != nil {
   927  				sc = result.Response.Response.StatusCode
   928  			}
   929  			tracing.EndSpan(ctx, sc, err)
   930  		}()
   931  	}
   932  	req, err := client.GetAtSubscriptionLevelPreparer(ctx, lockName)
   933  	if err != nil {
   934  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "GetAtSubscriptionLevel", nil, "Failure preparing request")
   935  		return
   936  	}
   937  
   938  	resp, err := client.GetAtSubscriptionLevelSender(req)
   939  	if err != nil {
   940  		result.Response = autorest.Response{Response: resp}
   941  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "GetAtSubscriptionLevel", resp, "Failure sending request")
   942  		return
   943  	}
   944  
   945  	result, err = client.GetAtSubscriptionLevelResponder(resp)
   946  	if err != nil {
   947  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "GetAtSubscriptionLevel", resp, "Failure responding to request")
   948  		return
   949  	}
   950  
   951  	return
   952  }
   953  
   954  // GetAtSubscriptionLevelPreparer prepares the GetAtSubscriptionLevel request.
   955  func (client ManagementLocksClient) GetAtSubscriptionLevelPreparer(ctx context.Context, lockName string) (*http.Request, error) {
   956  	pathParameters := map[string]interface{}{
   957  		"lockName":       autorest.Encode("path", lockName),
   958  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
   959  	}
   960  
   961  	const APIVersion = "2017-04-01"
   962  	queryParameters := map[string]interface{}{
   963  		"api-version": APIVersion,
   964  	}
   965  
   966  	preparer := autorest.CreatePreparer(
   967  		autorest.AsGet(),
   968  		autorest.WithBaseURL(client.BaseURI),
   969  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}", pathParameters),
   970  		autorest.WithQueryParameters(queryParameters))
   971  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   972  }
   973  
   974  // GetAtSubscriptionLevelSender sends the GetAtSubscriptionLevel request. The method will close the
   975  // http.Response Body if it receives an error.
   976  func (client ManagementLocksClient) GetAtSubscriptionLevelSender(req *http.Request) (*http.Response, error) {
   977  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   978  }
   979  
   980  // GetAtSubscriptionLevelResponder handles the response to the GetAtSubscriptionLevel request. The method always
   981  // closes the http.Response Body.
   982  func (client ManagementLocksClient) GetAtSubscriptionLevelResponder(resp *http.Response) (result ManagementLockObject, err error) {
   983  	err = autorest.Respond(
   984  		resp,
   985  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   986  		autorest.ByUnmarshallingJSON(&result),
   987  		autorest.ByClosing())
   988  	result.Response = autorest.Response{Response: resp}
   989  	return
   990  }
   991  
   992  // GetByScope get a management lock by scope.
   993  // Parameters:
   994  // scope - the scope for the lock.
   995  // lockName - the name of lock.
   996  func (client ManagementLocksClient) GetByScope(ctx context.Context, scope string, lockName string) (result ManagementLockObject, err error) {
   997  	if tracing.IsEnabled() {
   998  		ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.GetByScope")
   999  		defer func() {
  1000  			sc := -1
  1001  			if result.Response.Response != nil {
  1002  				sc = result.Response.Response.StatusCode
  1003  			}
  1004  			tracing.EndSpan(ctx, sc, err)
  1005  		}()
  1006  	}
  1007  	req, err := client.GetByScopePreparer(ctx, scope, lockName)
  1008  	if err != nil {
  1009  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "GetByScope", nil, "Failure preparing request")
  1010  		return
  1011  	}
  1012  
  1013  	resp, err := client.GetByScopeSender(req)
  1014  	if err != nil {
  1015  		result.Response = autorest.Response{Response: resp}
  1016  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "GetByScope", resp, "Failure sending request")
  1017  		return
  1018  	}
  1019  
  1020  	result, err = client.GetByScopeResponder(resp)
  1021  	if err != nil {
  1022  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "GetByScope", resp, "Failure responding to request")
  1023  		return
  1024  	}
  1025  
  1026  	return
  1027  }
  1028  
  1029  // GetByScopePreparer prepares the GetByScope request.
  1030  func (client ManagementLocksClient) GetByScopePreparer(ctx context.Context, scope string, lockName string) (*http.Request, error) {
  1031  	pathParameters := map[string]interface{}{
  1032  		"lockName": autorest.Encode("path", lockName),
  1033  		"scope":    autorest.Encode("path", scope),
  1034  	}
  1035  
  1036  	const APIVersion = "2017-04-01"
  1037  	queryParameters := map[string]interface{}{
  1038  		"api-version": APIVersion,
  1039  	}
  1040  
  1041  	preparer := autorest.CreatePreparer(
  1042  		autorest.AsGet(),
  1043  		autorest.WithBaseURL(client.BaseURI),
  1044  		autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/locks/{lockName}", pathParameters),
  1045  		autorest.WithQueryParameters(queryParameters))
  1046  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1047  }
  1048  
  1049  // GetByScopeSender sends the GetByScope request. The method will close the
  1050  // http.Response Body if it receives an error.
  1051  func (client ManagementLocksClient) GetByScopeSender(req *http.Request) (*http.Response, error) {
  1052  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
  1053  }
  1054  
  1055  // GetByScopeResponder handles the response to the GetByScope request. The method always
  1056  // closes the http.Response Body.
  1057  func (client ManagementLocksClient) GetByScopeResponder(resp *http.Response) (result ManagementLockObject, err error) {
  1058  	err = autorest.Respond(
  1059  		resp,
  1060  		azure.WithErrorUnlessStatusCode(http.StatusOK),
  1061  		autorest.ByUnmarshallingJSON(&result),
  1062  		autorest.ByClosing())
  1063  	result.Response = autorest.Response{Response: resp}
  1064  	return
  1065  }
  1066  
  1067  // ListAtResourceGroupLevel gets all the management locks for a resource group.
  1068  // Parameters:
  1069  // resourceGroupName - the name of the resource group containing the locks to get.
  1070  // filter - the filter to apply on the operation.
  1071  func (client ManagementLocksClient) ListAtResourceGroupLevel(ctx context.Context, resourceGroupName string, filter string) (result ManagementLockListResultPage, err error) {
  1072  	if tracing.IsEnabled() {
  1073  		ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.ListAtResourceGroupLevel")
  1074  		defer func() {
  1075  			sc := -1
  1076  			if result.mllr.Response.Response != nil {
  1077  				sc = result.mllr.Response.Response.StatusCode
  1078  			}
  1079  			tracing.EndSpan(ctx, sc, err)
  1080  		}()
  1081  	}
  1082  	if err := validation.Validate([]validation.Validation{
  1083  		{TargetValue: resourceGroupName,
  1084  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
  1085  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
  1086  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
  1087  		return result, validation.NewError("locks.ManagementLocksClient", "ListAtResourceGroupLevel", err.Error())
  1088  	}
  1089  
  1090  	result.fn = client.listAtResourceGroupLevelNextResults
  1091  	req, err := client.ListAtResourceGroupLevelPreparer(ctx, resourceGroupName, filter)
  1092  	if err != nil {
  1093  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "ListAtResourceGroupLevel", nil, "Failure preparing request")
  1094  		return
  1095  	}
  1096  
  1097  	resp, err := client.ListAtResourceGroupLevelSender(req)
  1098  	if err != nil {
  1099  		result.mllr.Response = autorest.Response{Response: resp}
  1100  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "ListAtResourceGroupLevel", resp, "Failure sending request")
  1101  		return
  1102  	}
  1103  
  1104  	result.mllr, err = client.ListAtResourceGroupLevelResponder(resp)
  1105  	if err != nil {
  1106  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "ListAtResourceGroupLevel", resp, "Failure responding to request")
  1107  		return
  1108  	}
  1109  	if result.mllr.hasNextLink() && result.mllr.IsEmpty() {
  1110  		err = result.NextWithContext(ctx)
  1111  		return
  1112  	}
  1113  
  1114  	return
  1115  }
  1116  
  1117  // ListAtResourceGroupLevelPreparer prepares the ListAtResourceGroupLevel request.
  1118  func (client ManagementLocksClient) ListAtResourceGroupLevelPreparer(ctx context.Context, resourceGroupName string, filter string) (*http.Request, error) {
  1119  	pathParameters := map[string]interface{}{
  1120  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
  1121  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
  1122  	}
  1123  
  1124  	const APIVersion = "2017-04-01"
  1125  	queryParameters := map[string]interface{}{
  1126  		"api-version": APIVersion,
  1127  	}
  1128  	if len(filter) > 0 {
  1129  		queryParameters["$filter"] = autorest.Encode("query", filter)
  1130  	}
  1131  
  1132  	preparer := autorest.CreatePreparer(
  1133  		autorest.AsGet(),
  1134  		autorest.WithBaseURL(client.BaseURI),
  1135  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks", pathParameters),
  1136  		autorest.WithQueryParameters(queryParameters))
  1137  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1138  }
  1139  
  1140  // ListAtResourceGroupLevelSender sends the ListAtResourceGroupLevel request. The method will close the
  1141  // http.Response Body if it receives an error.
  1142  func (client ManagementLocksClient) ListAtResourceGroupLevelSender(req *http.Request) (*http.Response, error) {
  1143  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
  1144  }
  1145  
  1146  // ListAtResourceGroupLevelResponder handles the response to the ListAtResourceGroupLevel request. The method always
  1147  // closes the http.Response Body.
  1148  func (client ManagementLocksClient) ListAtResourceGroupLevelResponder(resp *http.Response) (result ManagementLockListResult, err error) {
  1149  	err = autorest.Respond(
  1150  		resp,
  1151  		azure.WithErrorUnlessStatusCode(http.StatusOK),
  1152  		autorest.ByUnmarshallingJSON(&result),
  1153  		autorest.ByClosing())
  1154  	result.Response = autorest.Response{Response: resp}
  1155  	return
  1156  }
  1157  
  1158  // listAtResourceGroupLevelNextResults retrieves the next set of results, if any.
  1159  func (client ManagementLocksClient) listAtResourceGroupLevelNextResults(ctx context.Context, lastResults ManagementLockListResult) (result ManagementLockListResult, err error) {
  1160  	req, err := lastResults.managementLockListResultPreparer(ctx)
  1161  	if err != nil {
  1162  		return result, autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "listAtResourceGroupLevelNextResults", nil, "Failure preparing next results request")
  1163  	}
  1164  	if req == nil {
  1165  		return
  1166  	}
  1167  	resp, err := client.ListAtResourceGroupLevelSender(req)
  1168  	if err != nil {
  1169  		result.Response = autorest.Response{Response: resp}
  1170  		return result, autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "listAtResourceGroupLevelNextResults", resp, "Failure sending next results request")
  1171  	}
  1172  	result, err = client.ListAtResourceGroupLevelResponder(resp)
  1173  	if err != nil {
  1174  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "listAtResourceGroupLevelNextResults", resp, "Failure responding to next results request")
  1175  	}
  1176  	return
  1177  }
  1178  
  1179  // ListAtResourceGroupLevelComplete enumerates all values, automatically crossing page boundaries as required.
  1180  func (client ManagementLocksClient) ListAtResourceGroupLevelComplete(ctx context.Context, resourceGroupName string, filter string) (result ManagementLockListResultIterator, err error) {
  1181  	if tracing.IsEnabled() {
  1182  		ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.ListAtResourceGroupLevel")
  1183  		defer func() {
  1184  			sc := -1
  1185  			if result.Response().Response.Response != nil {
  1186  				sc = result.page.Response().Response.Response.StatusCode
  1187  			}
  1188  			tracing.EndSpan(ctx, sc, err)
  1189  		}()
  1190  	}
  1191  	result.page, err = client.ListAtResourceGroupLevel(ctx, resourceGroupName, filter)
  1192  	return
  1193  }
  1194  
  1195  // ListAtResourceLevel gets all the management locks for a resource or any level below resource.
  1196  // Parameters:
  1197  // resourceGroupName - the name of the resource group containing the locked resource. The name is case
  1198  // insensitive.
  1199  // resourceProviderNamespace - the namespace of the resource provider.
  1200  // parentResourcePath - the parent resource identity.
  1201  // resourceType - the resource type of the locked resource.
  1202  // resourceName - the name of the locked resource.
  1203  // filter - the filter to apply on the operation.
  1204  func (client ManagementLocksClient) ListAtResourceLevel(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, filter string) (result ManagementLockListResultPage, err error) {
  1205  	if tracing.IsEnabled() {
  1206  		ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.ListAtResourceLevel")
  1207  		defer func() {
  1208  			sc := -1
  1209  			if result.mllr.Response.Response != nil {
  1210  				sc = result.mllr.Response.Response.StatusCode
  1211  			}
  1212  			tracing.EndSpan(ctx, sc, err)
  1213  		}()
  1214  	}
  1215  	if err := validation.Validate([]validation.Validation{
  1216  		{TargetValue: resourceGroupName,
  1217  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
  1218  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
  1219  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
  1220  		return result, validation.NewError("locks.ManagementLocksClient", "ListAtResourceLevel", err.Error())
  1221  	}
  1222  
  1223  	result.fn = client.listAtResourceLevelNextResults
  1224  	req, err := client.ListAtResourceLevelPreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter)
  1225  	if err != nil {
  1226  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "ListAtResourceLevel", nil, "Failure preparing request")
  1227  		return
  1228  	}
  1229  
  1230  	resp, err := client.ListAtResourceLevelSender(req)
  1231  	if err != nil {
  1232  		result.mllr.Response = autorest.Response{Response: resp}
  1233  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "ListAtResourceLevel", resp, "Failure sending request")
  1234  		return
  1235  	}
  1236  
  1237  	result.mllr, err = client.ListAtResourceLevelResponder(resp)
  1238  	if err != nil {
  1239  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "ListAtResourceLevel", resp, "Failure responding to request")
  1240  		return
  1241  	}
  1242  	if result.mllr.hasNextLink() && result.mllr.IsEmpty() {
  1243  		err = result.NextWithContext(ctx)
  1244  		return
  1245  	}
  1246  
  1247  	return
  1248  }
  1249  
  1250  // ListAtResourceLevelPreparer prepares the ListAtResourceLevel request.
  1251  func (client ManagementLocksClient) ListAtResourceLevelPreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, filter string) (*http.Request, error) {
  1252  	pathParameters := map[string]interface{}{
  1253  		"parentResourcePath":        parentResourcePath,
  1254  		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
  1255  		"resourceName":              autorest.Encode("path", resourceName),
  1256  		"resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace),
  1257  		"resourceType":              resourceType,
  1258  		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
  1259  	}
  1260  
  1261  	const APIVersion = "2017-04-01"
  1262  	queryParameters := map[string]interface{}{
  1263  		"api-version": APIVersion,
  1264  	}
  1265  	if len(filter) > 0 {
  1266  		queryParameters["$filter"] = autorest.Encode("query", filter)
  1267  	}
  1268  
  1269  	preparer := autorest.CreatePreparer(
  1270  		autorest.AsGet(),
  1271  		autorest.WithBaseURL(client.BaseURI),
  1272  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks", pathParameters),
  1273  		autorest.WithQueryParameters(queryParameters))
  1274  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1275  }
  1276  
  1277  // ListAtResourceLevelSender sends the ListAtResourceLevel request. The method will close the
  1278  // http.Response Body if it receives an error.
  1279  func (client ManagementLocksClient) ListAtResourceLevelSender(req *http.Request) (*http.Response, error) {
  1280  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
  1281  }
  1282  
  1283  // ListAtResourceLevelResponder handles the response to the ListAtResourceLevel request. The method always
  1284  // closes the http.Response Body.
  1285  func (client ManagementLocksClient) ListAtResourceLevelResponder(resp *http.Response) (result ManagementLockListResult, err error) {
  1286  	err = autorest.Respond(
  1287  		resp,
  1288  		azure.WithErrorUnlessStatusCode(http.StatusOK),
  1289  		autorest.ByUnmarshallingJSON(&result),
  1290  		autorest.ByClosing())
  1291  	result.Response = autorest.Response{Response: resp}
  1292  	return
  1293  }
  1294  
  1295  // listAtResourceLevelNextResults retrieves the next set of results, if any.
  1296  func (client ManagementLocksClient) listAtResourceLevelNextResults(ctx context.Context, lastResults ManagementLockListResult) (result ManagementLockListResult, err error) {
  1297  	req, err := lastResults.managementLockListResultPreparer(ctx)
  1298  	if err != nil {
  1299  		return result, autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "listAtResourceLevelNextResults", nil, "Failure preparing next results request")
  1300  	}
  1301  	if req == nil {
  1302  		return
  1303  	}
  1304  	resp, err := client.ListAtResourceLevelSender(req)
  1305  	if err != nil {
  1306  		result.Response = autorest.Response{Response: resp}
  1307  		return result, autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "listAtResourceLevelNextResults", resp, "Failure sending next results request")
  1308  	}
  1309  	result, err = client.ListAtResourceLevelResponder(resp)
  1310  	if err != nil {
  1311  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "listAtResourceLevelNextResults", resp, "Failure responding to next results request")
  1312  	}
  1313  	return
  1314  }
  1315  
  1316  // ListAtResourceLevelComplete enumerates all values, automatically crossing page boundaries as required.
  1317  func (client ManagementLocksClient) ListAtResourceLevelComplete(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, filter string) (result ManagementLockListResultIterator, err error) {
  1318  	if tracing.IsEnabled() {
  1319  		ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.ListAtResourceLevel")
  1320  		defer func() {
  1321  			sc := -1
  1322  			if result.Response().Response.Response != nil {
  1323  				sc = result.page.Response().Response.Response.StatusCode
  1324  			}
  1325  			tracing.EndSpan(ctx, sc, err)
  1326  		}()
  1327  	}
  1328  	result.page, err = client.ListAtResourceLevel(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter)
  1329  	return
  1330  }
  1331  
  1332  // ListAtSubscriptionLevel gets all the management locks for a subscription.
  1333  // Parameters:
  1334  // filter - the filter to apply on the operation.
  1335  func (client ManagementLocksClient) ListAtSubscriptionLevel(ctx context.Context, filter string) (result ManagementLockListResultPage, err error) {
  1336  	if tracing.IsEnabled() {
  1337  		ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.ListAtSubscriptionLevel")
  1338  		defer func() {
  1339  			sc := -1
  1340  			if result.mllr.Response.Response != nil {
  1341  				sc = result.mllr.Response.Response.StatusCode
  1342  			}
  1343  			tracing.EndSpan(ctx, sc, err)
  1344  		}()
  1345  	}
  1346  	result.fn = client.listAtSubscriptionLevelNextResults
  1347  	req, err := client.ListAtSubscriptionLevelPreparer(ctx, filter)
  1348  	if err != nil {
  1349  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "ListAtSubscriptionLevel", nil, "Failure preparing request")
  1350  		return
  1351  	}
  1352  
  1353  	resp, err := client.ListAtSubscriptionLevelSender(req)
  1354  	if err != nil {
  1355  		result.mllr.Response = autorest.Response{Response: resp}
  1356  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "ListAtSubscriptionLevel", resp, "Failure sending request")
  1357  		return
  1358  	}
  1359  
  1360  	result.mllr, err = client.ListAtSubscriptionLevelResponder(resp)
  1361  	if err != nil {
  1362  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "ListAtSubscriptionLevel", resp, "Failure responding to request")
  1363  		return
  1364  	}
  1365  	if result.mllr.hasNextLink() && result.mllr.IsEmpty() {
  1366  		err = result.NextWithContext(ctx)
  1367  		return
  1368  	}
  1369  
  1370  	return
  1371  }
  1372  
  1373  // ListAtSubscriptionLevelPreparer prepares the ListAtSubscriptionLevel request.
  1374  func (client ManagementLocksClient) ListAtSubscriptionLevelPreparer(ctx context.Context, filter string) (*http.Request, error) {
  1375  	pathParameters := map[string]interface{}{
  1376  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
  1377  	}
  1378  
  1379  	const APIVersion = "2017-04-01"
  1380  	queryParameters := map[string]interface{}{
  1381  		"api-version": APIVersion,
  1382  	}
  1383  	if len(filter) > 0 {
  1384  		queryParameters["$filter"] = autorest.Encode("query", filter)
  1385  	}
  1386  
  1387  	preparer := autorest.CreatePreparer(
  1388  		autorest.AsGet(),
  1389  		autorest.WithBaseURL(client.BaseURI),
  1390  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks", pathParameters),
  1391  		autorest.WithQueryParameters(queryParameters))
  1392  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1393  }
  1394  
  1395  // ListAtSubscriptionLevelSender sends the ListAtSubscriptionLevel request. The method will close the
  1396  // http.Response Body if it receives an error.
  1397  func (client ManagementLocksClient) ListAtSubscriptionLevelSender(req *http.Request) (*http.Response, error) {
  1398  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
  1399  }
  1400  
  1401  // ListAtSubscriptionLevelResponder handles the response to the ListAtSubscriptionLevel request. The method always
  1402  // closes the http.Response Body.
  1403  func (client ManagementLocksClient) ListAtSubscriptionLevelResponder(resp *http.Response) (result ManagementLockListResult, err error) {
  1404  	err = autorest.Respond(
  1405  		resp,
  1406  		azure.WithErrorUnlessStatusCode(http.StatusOK),
  1407  		autorest.ByUnmarshallingJSON(&result),
  1408  		autorest.ByClosing())
  1409  	result.Response = autorest.Response{Response: resp}
  1410  	return
  1411  }
  1412  
  1413  // listAtSubscriptionLevelNextResults retrieves the next set of results, if any.
  1414  func (client ManagementLocksClient) listAtSubscriptionLevelNextResults(ctx context.Context, lastResults ManagementLockListResult) (result ManagementLockListResult, err error) {
  1415  	req, err := lastResults.managementLockListResultPreparer(ctx)
  1416  	if err != nil {
  1417  		return result, autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "listAtSubscriptionLevelNextResults", nil, "Failure preparing next results request")
  1418  	}
  1419  	if req == nil {
  1420  		return
  1421  	}
  1422  	resp, err := client.ListAtSubscriptionLevelSender(req)
  1423  	if err != nil {
  1424  		result.Response = autorest.Response{Response: resp}
  1425  		return result, autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "listAtSubscriptionLevelNextResults", resp, "Failure sending next results request")
  1426  	}
  1427  	result, err = client.ListAtSubscriptionLevelResponder(resp)
  1428  	if err != nil {
  1429  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "listAtSubscriptionLevelNextResults", resp, "Failure responding to next results request")
  1430  	}
  1431  	return
  1432  }
  1433  
  1434  // ListAtSubscriptionLevelComplete enumerates all values, automatically crossing page boundaries as required.
  1435  func (client ManagementLocksClient) ListAtSubscriptionLevelComplete(ctx context.Context, filter string) (result ManagementLockListResultIterator, err error) {
  1436  	if tracing.IsEnabled() {
  1437  		ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.ListAtSubscriptionLevel")
  1438  		defer func() {
  1439  			sc := -1
  1440  			if result.Response().Response.Response != nil {
  1441  				sc = result.page.Response().Response.Response.StatusCode
  1442  			}
  1443  			tracing.EndSpan(ctx, sc, err)
  1444  		}()
  1445  	}
  1446  	result.page, err = client.ListAtSubscriptionLevel(ctx, filter)
  1447  	return
  1448  }
  1449  
  1450  // ListByScope gets all the management locks for a scope.
  1451  // Parameters:
  1452  // scope - the scope for the lock. When providing a scope for the assignment, use
  1453  // '/subscriptions/{subscriptionId}' for subscriptions,
  1454  // '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for resource groups, and
  1455  // '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}'
  1456  // for resources.
  1457  // filter - the filter to apply on the operation.
  1458  func (client ManagementLocksClient) ListByScope(ctx context.Context, scope string, filter string) (result ManagementLockListResultPage, err error) {
  1459  	if tracing.IsEnabled() {
  1460  		ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.ListByScope")
  1461  		defer func() {
  1462  			sc := -1
  1463  			if result.mllr.Response.Response != nil {
  1464  				sc = result.mllr.Response.Response.StatusCode
  1465  			}
  1466  			tracing.EndSpan(ctx, sc, err)
  1467  		}()
  1468  	}
  1469  	result.fn = client.listByScopeNextResults
  1470  	req, err := client.ListByScopePreparer(ctx, scope, filter)
  1471  	if err != nil {
  1472  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "ListByScope", nil, "Failure preparing request")
  1473  		return
  1474  	}
  1475  
  1476  	resp, err := client.ListByScopeSender(req)
  1477  	if err != nil {
  1478  		result.mllr.Response = autorest.Response{Response: resp}
  1479  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "ListByScope", resp, "Failure sending request")
  1480  		return
  1481  	}
  1482  
  1483  	result.mllr, err = client.ListByScopeResponder(resp)
  1484  	if err != nil {
  1485  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "ListByScope", resp, "Failure responding to request")
  1486  		return
  1487  	}
  1488  	if result.mllr.hasNextLink() && result.mllr.IsEmpty() {
  1489  		err = result.NextWithContext(ctx)
  1490  		return
  1491  	}
  1492  
  1493  	return
  1494  }
  1495  
  1496  // ListByScopePreparer prepares the ListByScope request.
  1497  func (client ManagementLocksClient) ListByScopePreparer(ctx context.Context, scope string, filter string) (*http.Request, error) {
  1498  	pathParameters := map[string]interface{}{
  1499  		"scope": autorest.Encode("path", scope),
  1500  	}
  1501  
  1502  	const APIVersion = "2017-04-01"
  1503  	queryParameters := map[string]interface{}{
  1504  		"api-version": APIVersion,
  1505  	}
  1506  	if len(filter) > 0 {
  1507  		queryParameters["$filter"] = autorest.Encode("query", filter)
  1508  	}
  1509  
  1510  	preparer := autorest.CreatePreparer(
  1511  		autorest.AsGet(),
  1512  		autorest.WithBaseURL(client.BaseURI),
  1513  		autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/locks", pathParameters),
  1514  		autorest.WithQueryParameters(queryParameters))
  1515  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1516  }
  1517  
  1518  // ListByScopeSender sends the ListByScope request. The method will close the
  1519  // http.Response Body if it receives an error.
  1520  func (client ManagementLocksClient) ListByScopeSender(req *http.Request) (*http.Response, error) {
  1521  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
  1522  }
  1523  
  1524  // ListByScopeResponder handles the response to the ListByScope request. The method always
  1525  // closes the http.Response Body.
  1526  func (client ManagementLocksClient) ListByScopeResponder(resp *http.Response) (result ManagementLockListResult, err error) {
  1527  	err = autorest.Respond(
  1528  		resp,
  1529  		azure.WithErrorUnlessStatusCode(http.StatusOK),
  1530  		autorest.ByUnmarshallingJSON(&result),
  1531  		autorest.ByClosing())
  1532  	result.Response = autorest.Response{Response: resp}
  1533  	return
  1534  }
  1535  
  1536  // listByScopeNextResults retrieves the next set of results, if any.
  1537  func (client ManagementLocksClient) listByScopeNextResults(ctx context.Context, lastResults ManagementLockListResult) (result ManagementLockListResult, err error) {
  1538  	req, err := lastResults.managementLockListResultPreparer(ctx)
  1539  	if err != nil {
  1540  		return result, autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "listByScopeNextResults", nil, "Failure preparing next results request")
  1541  	}
  1542  	if req == nil {
  1543  		return
  1544  	}
  1545  	resp, err := client.ListByScopeSender(req)
  1546  	if err != nil {
  1547  		result.Response = autorest.Response{Response: resp}
  1548  		return result, autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "listByScopeNextResults", resp, "Failure sending next results request")
  1549  	}
  1550  	result, err = client.ListByScopeResponder(resp)
  1551  	if err != nil {
  1552  		err = autorest.NewErrorWithError(err, "locks.ManagementLocksClient", "listByScopeNextResults", resp, "Failure responding to next results request")
  1553  	}
  1554  	return
  1555  }
  1556  
  1557  // ListByScopeComplete enumerates all values, automatically crossing page boundaries as required.
  1558  func (client ManagementLocksClient) ListByScopeComplete(ctx context.Context, scope string, filter string) (result ManagementLockListResultIterator, err error) {
  1559  	if tracing.IsEnabled() {
  1560  		ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLocksClient.ListByScope")
  1561  		defer func() {
  1562  			sc := -1
  1563  			if result.Response().Response.Response != nil {
  1564  				sc = result.page.Response().Response.Response.StatusCode
  1565  			}
  1566  			tracing.EndSpan(ctx, sc, err)
  1567  		}()
  1568  	}
  1569  	result.page, err = client.ListByScope(ctx, scope, filter)
  1570  	return
  1571  }
  1572  

View as plain text