...

Source file src/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/policy/assignments.go

Documentation: github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/policy

     1  package policy
     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  // AssignmentsClient is the to manage and control access to your resources, you can define customized policies and
    19  // assign them at a scope.
    20  type AssignmentsClient struct {
    21  	BaseClient
    22  }
    23  
    24  // NewAssignmentsClient creates an instance of the AssignmentsClient client.
    25  func NewAssignmentsClient(subscriptionID string) AssignmentsClient {
    26  	return NewAssignmentsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    27  }
    28  
    29  // NewAssignmentsClientWithBaseURI creates an instance of the AssignmentsClient client using a custom endpoint.  Use
    30  // this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    31  func NewAssignmentsClientWithBaseURI(baseURI string, subscriptionID string) AssignmentsClient {
    32  	return AssignmentsClient{NewWithBaseURI(baseURI, subscriptionID)}
    33  }
    34  
    35  // Create this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply
    36  // to all resources contained within their scope. For example, when you assign a policy at resource group scope, that
    37  // policy applies to all resources in the group.
    38  // Parameters:
    39  // scope - the scope of the policy assignment. Valid scopes are: management group (format:
    40  // '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format:
    41  // '/subscriptions/{subscriptionId}'), resource group (format:
    42  // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format:
    43  // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
    44  // policyAssignmentName - the name of the policy assignment.
    45  // parameters - parameters for the policy assignment.
    46  func (client AssignmentsClient) Create(ctx context.Context, scope string, policyAssignmentName string, parameters Assignment) (result Assignment, err error) {
    47  	if tracing.IsEnabled() {
    48  		ctx = tracing.StartSpan(ctx, fqdn+"/AssignmentsClient.Create")
    49  		defer func() {
    50  			sc := -1
    51  			if result.Response.Response != nil {
    52  				sc = result.Response.Response.StatusCode
    53  			}
    54  			tracing.EndSpan(ctx, sc, err)
    55  		}()
    56  	}
    57  	if err := validation.Validate([]validation.Validation{
    58  		{TargetValue: parameters,
    59  			Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: false,
    60  				Chain: []validation.Constraint{{Target: "parameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
    61  		return result, validation.NewError("policy.AssignmentsClient", "Create", err.Error())
    62  	}
    63  
    64  	req, err := client.CreatePreparer(ctx, scope, policyAssignmentName, parameters)
    65  	if err != nil {
    66  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "Create", nil, "Failure preparing request")
    67  		return
    68  	}
    69  
    70  	resp, err := client.CreateSender(req)
    71  	if err != nil {
    72  		result.Response = autorest.Response{Response: resp}
    73  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "Create", resp, "Failure sending request")
    74  		return
    75  	}
    76  
    77  	result, err = client.CreateResponder(resp)
    78  	if err != nil {
    79  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "Create", resp, "Failure responding to request")
    80  		return
    81  	}
    82  
    83  	return
    84  }
    85  
    86  // CreatePreparer prepares the Create request.
    87  func (client AssignmentsClient) CreatePreparer(ctx context.Context, scope string, policyAssignmentName string, parameters Assignment) (*http.Request, error) {
    88  	pathParameters := map[string]interface{}{
    89  		"policyAssignmentName": autorest.Encode("path", policyAssignmentName),
    90  		"scope":                scope,
    91  	}
    92  
    93  	const APIVersion = "2018-05-01"
    94  	queryParameters := map[string]interface{}{
    95  		"api-version": APIVersion,
    96  	}
    97  
    98  	parameters.ID = nil
    99  	parameters.Type = nil
   100  	parameters.Name = nil
   101  	preparer := autorest.CreatePreparer(
   102  		autorest.AsContentType("application/json; charset=utf-8"),
   103  		autorest.AsPut(),
   104  		autorest.WithBaseURL(client.BaseURI),
   105  		autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}", pathParameters),
   106  		autorest.WithJSON(parameters),
   107  		autorest.WithQueryParameters(queryParameters))
   108  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   109  }
   110  
   111  // CreateSender sends the Create request. The method will close the
   112  // http.Response Body if it receives an error.
   113  func (client AssignmentsClient) CreateSender(req *http.Request) (*http.Response, error) {
   114  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   115  }
   116  
   117  // CreateResponder handles the response to the Create request. The method always
   118  // closes the http.Response Body.
   119  func (client AssignmentsClient) CreateResponder(resp *http.Response) (result Assignment, err error) {
   120  	err = autorest.Respond(
   121  		resp,
   122  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   123  		autorest.ByUnmarshallingJSON(&result),
   124  		autorest.ByClosing())
   125  	result.Response = autorest.Response{Response: resp}
   126  	return
   127  }
   128  
   129  // CreateByID this operation creates or updates the policy assignment with the given ID. Policy assignments made on a
   130  // scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that
   131  // policy applies to all resources in the group. Policy assignment IDs have this format:
   132  // '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management
   133  // group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format:
   134  // '/subscriptions/{subscriptionId}'), resource group (format:
   135  // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format:
   136  // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'.
   137  // Parameters:
   138  // policyAssignmentID - the ID of the policy assignment to create. Use the format
   139  // '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
   140  // parameters - parameters for policy assignment.
   141  func (client AssignmentsClient) CreateByID(ctx context.Context, policyAssignmentID string, parameters Assignment) (result Assignment, err error) {
   142  	if tracing.IsEnabled() {
   143  		ctx = tracing.StartSpan(ctx, fqdn+"/AssignmentsClient.CreateByID")
   144  		defer func() {
   145  			sc := -1
   146  			if result.Response.Response != nil {
   147  				sc = result.Response.Response.StatusCode
   148  			}
   149  			tracing.EndSpan(ctx, sc, err)
   150  		}()
   151  	}
   152  	if err := validation.Validate([]validation.Validation{
   153  		{TargetValue: parameters,
   154  			Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: false,
   155  				Chain: []validation.Constraint{{Target: "parameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
   156  		return result, validation.NewError("policy.AssignmentsClient", "CreateByID", err.Error())
   157  	}
   158  
   159  	req, err := client.CreateByIDPreparer(ctx, policyAssignmentID, parameters)
   160  	if err != nil {
   161  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "CreateByID", nil, "Failure preparing request")
   162  		return
   163  	}
   164  
   165  	resp, err := client.CreateByIDSender(req)
   166  	if err != nil {
   167  		result.Response = autorest.Response{Response: resp}
   168  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "CreateByID", resp, "Failure sending request")
   169  		return
   170  	}
   171  
   172  	result, err = client.CreateByIDResponder(resp)
   173  	if err != nil {
   174  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "CreateByID", resp, "Failure responding to request")
   175  		return
   176  	}
   177  
   178  	return
   179  }
   180  
   181  // CreateByIDPreparer prepares the CreateByID request.
   182  func (client AssignmentsClient) CreateByIDPreparer(ctx context.Context, policyAssignmentID string, parameters Assignment) (*http.Request, error) {
   183  	pathParameters := map[string]interface{}{
   184  		"policyAssignmentId": policyAssignmentID,
   185  	}
   186  
   187  	const APIVersion = "2018-05-01"
   188  	queryParameters := map[string]interface{}{
   189  		"api-version": APIVersion,
   190  	}
   191  
   192  	parameters.ID = nil
   193  	parameters.Type = nil
   194  	parameters.Name = nil
   195  	preparer := autorest.CreatePreparer(
   196  		autorest.AsContentType("application/json; charset=utf-8"),
   197  		autorest.AsPut(),
   198  		autorest.WithBaseURL(client.BaseURI),
   199  		autorest.WithPathParameters("/{policyAssignmentId}", pathParameters),
   200  		autorest.WithJSON(parameters),
   201  		autorest.WithQueryParameters(queryParameters))
   202  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   203  }
   204  
   205  // CreateByIDSender sends the CreateByID request. The method will close the
   206  // http.Response Body if it receives an error.
   207  func (client AssignmentsClient) CreateByIDSender(req *http.Request) (*http.Response, error) {
   208  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   209  }
   210  
   211  // CreateByIDResponder handles the response to the CreateByID request. The method always
   212  // closes the http.Response Body.
   213  func (client AssignmentsClient) CreateByIDResponder(resp *http.Response) (result Assignment, err error) {
   214  	err = autorest.Respond(
   215  		resp,
   216  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   217  		autorest.ByUnmarshallingJSON(&result),
   218  		autorest.ByClosing())
   219  	result.Response = autorest.Response{Response: resp}
   220  	return
   221  }
   222  
   223  // Delete this operation deletes a policy assignment, given its name and the scope it was created in. The scope of a
   224  // policy assignment is the part of its ID preceding
   225  // '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
   226  // Parameters:
   227  // scope - the scope of the policy assignment. Valid scopes are: management group (format:
   228  // '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format:
   229  // '/subscriptions/{subscriptionId}'), resource group (format:
   230  // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format:
   231  // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
   232  // policyAssignmentName - the name of the policy assignment to delete.
   233  func (client AssignmentsClient) Delete(ctx context.Context, scope string, policyAssignmentName string) (result Assignment, err error) {
   234  	if tracing.IsEnabled() {
   235  		ctx = tracing.StartSpan(ctx, fqdn+"/AssignmentsClient.Delete")
   236  		defer func() {
   237  			sc := -1
   238  			if result.Response.Response != nil {
   239  				sc = result.Response.Response.StatusCode
   240  			}
   241  			tracing.EndSpan(ctx, sc, err)
   242  		}()
   243  	}
   244  	req, err := client.DeletePreparer(ctx, scope, policyAssignmentName)
   245  	if err != nil {
   246  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "Delete", nil, "Failure preparing request")
   247  		return
   248  	}
   249  
   250  	resp, err := client.DeleteSender(req)
   251  	if err != nil {
   252  		result.Response = autorest.Response{Response: resp}
   253  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "Delete", resp, "Failure sending request")
   254  		return
   255  	}
   256  
   257  	result, err = client.DeleteResponder(resp)
   258  	if err != nil {
   259  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "Delete", resp, "Failure responding to request")
   260  		return
   261  	}
   262  
   263  	return
   264  }
   265  
   266  // DeletePreparer prepares the Delete request.
   267  func (client AssignmentsClient) DeletePreparer(ctx context.Context, scope string, policyAssignmentName string) (*http.Request, error) {
   268  	pathParameters := map[string]interface{}{
   269  		"policyAssignmentName": autorest.Encode("path", policyAssignmentName),
   270  		"scope":                scope,
   271  	}
   272  
   273  	const APIVersion = "2018-05-01"
   274  	queryParameters := map[string]interface{}{
   275  		"api-version": APIVersion,
   276  	}
   277  
   278  	preparer := autorest.CreatePreparer(
   279  		autorest.AsDelete(),
   280  		autorest.WithBaseURL(client.BaseURI),
   281  		autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}", pathParameters),
   282  		autorest.WithQueryParameters(queryParameters))
   283  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   284  }
   285  
   286  // DeleteSender sends the Delete request. The method will close the
   287  // http.Response Body if it receives an error.
   288  func (client AssignmentsClient) DeleteSender(req *http.Request) (*http.Response, error) {
   289  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   290  }
   291  
   292  // DeleteResponder handles the response to the Delete request. The method always
   293  // closes the http.Response Body.
   294  func (client AssignmentsClient) DeleteResponder(resp *http.Response) (result Assignment, err error) {
   295  	err = autorest.Respond(
   296  		resp,
   297  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
   298  		autorest.ByUnmarshallingJSON(&result),
   299  		autorest.ByClosing())
   300  	result.Response = autorest.Response{Response: resp}
   301  	return
   302  }
   303  
   304  // DeleteByID this operation deletes the policy with the given ID. Policy assignment IDs have this format:
   305  // '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are:
   306  // '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group),
   307  // '/subscriptions/{subscriptionId}' (subscription),
   308  // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or
   309  // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
   310  // (resource).
   311  // Parameters:
   312  // policyAssignmentID - the ID of the policy assignment to delete. Use the format
   313  // '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
   314  func (client AssignmentsClient) DeleteByID(ctx context.Context, policyAssignmentID string) (result Assignment, err error) {
   315  	if tracing.IsEnabled() {
   316  		ctx = tracing.StartSpan(ctx, fqdn+"/AssignmentsClient.DeleteByID")
   317  		defer func() {
   318  			sc := -1
   319  			if result.Response.Response != nil {
   320  				sc = result.Response.Response.StatusCode
   321  			}
   322  			tracing.EndSpan(ctx, sc, err)
   323  		}()
   324  	}
   325  	req, err := client.DeleteByIDPreparer(ctx, policyAssignmentID)
   326  	if err != nil {
   327  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "DeleteByID", nil, "Failure preparing request")
   328  		return
   329  	}
   330  
   331  	resp, err := client.DeleteByIDSender(req)
   332  	if err != nil {
   333  		result.Response = autorest.Response{Response: resp}
   334  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "DeleteByID", resp, "Failure sending request")
   335  		return
   336  	}
   337  
   338  	result, err = client.DeleteByIDResponder(resp)
   339  	if err != nil {
   340  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "DeleteByID", resp, "Failure responding to request")
   341  		return
   342  	}
   343  
   344  	return
   345  }
   346  
   347  // DeleteByIDPreparer prepares the DeleteByID request.
   348  func (client AssignmentsClient) DeleteByIDPreparer(ctx context.Context, policyAssignmentID string) (*http.Request, error) {
   349  	pathParameters := map[string]interface{}{
   350  		"policyAssignmentId": policyAssignmentID,
   351  	}
   352  
   353  	const APIVersion = "2018-05-01"
   354  	queryParameters := map[string]interface{}{
   355  		"api-version": APIVersion,
   356  	}
   357  
   358  	preparer := autorest.CreatePreparer(
   359  		autorest.AsDelete(),
   360  		autorest.WithBaseURL(client.BaseURI),
   361  		autorest.WithPathParameters("/{policyAssignmentId}", pathParameters),
   362  		autorest.WithQueryParameters(queryParameters))
   363  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   364  }
   365  
   366  // DeleteByIDSender sends the DeleteByID request. The method will close the
   367  // http.Response Body if it receives an error.
   368  func (client AssignmentsClient) DeleteByIDSender(req *http.Request) (*http.Response, error) {
   369  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   370  }
   371  
   372  // DeleteByIDResponder handles the response to the DeleteByID request. The method always
   373  // closes the http.Response Body.
   374  func (client AssignmentsClient) DeleteByIDResponder(resp *http.Response) (result Assignment, err error) {
   375  	err = autorest.Respond(
   376  		resp,
   377  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
   378  		autorest.ByUnmarshallingJSON(&result),
   379  		autorest.ByClosing())
   380  	result.Response = autorest.Response{Response: resp}
   381  	return
   382  }
   383  
   384  // Get this operation retrieves a single policy assignment, given its name and the scope it was created at.
   385  // Parameters:
   386  // scope - the scope of the policy assignment. Valid scopes are: management group (format:
   387  // '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format:
   388  // '/subscriptions/{subscriptionId}'), resource group (format:
   389  // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format:
   390  // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
   391  // policyAssignmentName - the name of the policy assignment to get.
   392  func (client AssignmentsClient) Get(ctx context.Context, scope string, policyAssignmentName string) (result Assignment, err error) {
   393  	if tracing.IsEnabled() {
   394  		ctx = tracing.StartSpan(ctx, fqdn+"/AssignmentsClient.Get")
   395  		defer func() {
   396  			sc := -1
   397  			if result.Response.Response != nil {
   398  				sc = result.Response.Response.StatusCode
   399  			}
   400  			tracing.EndSpan(ctx, sc, err)
   401  		}()
   402  	}
   403  	req, err := client.GetPreparer(ctx, scope, policyAssignmentName)
   404  	if err != nil {
   405  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "Get", nil, "Failure preparing request")
   406  		return
   407  	}
   408  
   409  	resp, err := client.GetSender(req)
   410  	if err != nil {
   411  		result.Response = autorest.Response{Response: resp}
   412  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "Get", resp, "Failure sending request")
   413  		return
   414  	}
   415  
   416  	result, err = client.GetResponder(resp)
   417  	if err != nil {
   418  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "Get", resp, "Failure responding to request")
   419  		return
   420  	}
   421  
   422  	return
   423  }
   424  
   425  // GetPreparer prepares the Get request.
   426  func (client AssignmentsClient) GetPreparer(ctx context.Context, scope string, policyAssignmentName string) (*http.Request, error) {
   427  	pathParameters := map[string]interface{}{
   428  		"policyAssignmentName": autorest.Encode("path", policyAssignmentName),
   429  		"scope":                scope,
   430  	}
   431  
   432  	const APIVersion = "2018-05-01"
   433  	queryParameters := map[string]interface{}{
   434  		"api-version": APIVersion,
   435  	}
   436  
   437  	preparer := autorest.CreatePreparer(
   438  		autorest.AsGet(),
   439  		autorest.WithBaseURL(client.BaseURI),
   440  		autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}", pathParameters),
   441  		autorest.WithQueryParameters(queryParameters))
   442  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   443  }
   444  
   445  // GetSender sends the Get request. The method will close the
   446  // http.Response Body if it receives an error.
   447  func (client AssignmentsClient) GetSender(req *http.Request) (*http.Response, error) {
   448  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   449  }
   450  
   451  // GetResponder handles the response to the Get request. The method always
   452  // closes the http.Response Body.
   453  func (client AssignmentsClient) GetResponder(resp *http.Response) (result Assignment, err error) {
   454  	err = autorest.Respond(
   455  		resp,
   456  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   457  		autorest.ByUnmarshallingJSON(&result),
   458  		autorest.ByClosing())
   459  	result.Response = autorest.Response{Response: resp}
   460  	return
   461  }
   462  
   463  // GetByID the operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format:
   464  // '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management
   465  // group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format:
   466  // '/subscriptions/{subscriptionId}'), resource group (format:
   467  // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format:
   468  // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'.
   469  // Parameters:
   470  // policyAssignmentID - the ID of the policy assignment to get. Use the format
   471  // '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
   472  func (client AssignmentsClient) GetByID(ctx context.Context, policyAssignmentID string) (result Assignment, err error) {
   473  	if tracing.IsEnabled() {
   474  		ctx = tracing.StartSpan(ctx, fqdn+"/AssignmentsClient.GetByID")
   475  		defer func() {
   476  			sc := -1
   477  			if result.Response.Response != nil {
   478  				sc = result.Response.Response.StatusCode
   479  			}
   480  			tracing.EndSpan(ctx, sc, err)
   481  		}()
   482  	}
   483  	req, err := client.GetByIDPreparer(ctx, policyAssignmentID)
   484  	if err != nil {
   485  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "GetByID", nil, "Failure preparing request")
   486  		return
   487  	}
   488  
   489  	resp, err := client.GetByIDSender(req)
   490  	if err != nil {
   491  		result.Response = autorest.Response{Response: resp}
   492  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "GetByID", resp, "Failure sending request")
   493  		return
   494  	}
   495  
   496  	result, err = client.GetByIDResponder(resp)
   497  	if err != nil {
   498  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "GetByID", resp, "Failure responding to request")
   499  		return
   500  	}
   501  
   502  	return
   503  }
   504  
   505  // GetByIDPreparer prepares the GetByID request.
   506  func (client AssignmentsClient) GetByIDPreparer(ctx context.Context, policyAssignmentID string) (*http.Request, error) {
   507  	pathParameters := map[string]interface{}{
   508  		"policyAssignmentId": policyAssignmentID,
   509  	}
   510  
   511  	const APIVersion = "2018-05-01"
   512  	queryParameters := map[string]interface{}{
   513  		"api-version": APIVersion,
   514  	}
   515  
   516  	preparer := autorest.CreatePreparer(
   517  		autorest.AsGet(),
   518  		autorest.WithBaseURL(client.BaseURI),
   519  		autorest.WithPathParameters("/{policyAssignmentId}", pathParameters),
   520  		autorest.WithQueryParameters(queryParameters))
   521  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   522  }
   523  
   524  // GetByIDSender sends the GetByID request. The method will close the
   525  // http.Response Body if it receives an error.
   526  func (client AssignmentsClient) GetByIDSender(req *http.Request) (*http.Response, error) {
   527  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   528  }
   529  
   530  // GetByIDResponder handles the response to the GetByID request. The method always
   531  // closes the http.Response Body.
   532  func (client AssignmentsClient) GetByIDResponder(resp *http.Response) (result Assignment, err error) {
   533  	err = autorest.Respond(
   534  		resp,
   535  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   536  		autorest.ByUnmarshallingJSON(&result),
   537  		autorest.ByClosing())
   538  	result.Response = autorest.Response{Response: resp}
   539  	return
   540  }
   541  
   542  // List this operation retrieves the list of all policy assignments associated with the given subscription that match
   543  // the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If
   544  // $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription,
   545  // including those that apply directly or from management groups that contain the given subscription, as well as any
   546  // applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes
   547  // all policy assignments that apply to the subscription, which is everything in the unfiltered list except those
   548  // applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the
   549  // returned list includes all policy assignments of the policy definition whose id is {value}.
   550  // Parameters:
   551  // filter - the filter to apply on the operation. Valid values for $filter are: 'atScope()' or
   552  // 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed.
   553  func (client AssignmentsClient) List(ctx context.Context, filter string) (result AssignmentListResultPage, err error) {
   554  	if tracing.IsEnabled() {
   555  		ctx = tracing.StartSpan(ctx, fqdn+"/AssignmentsClient.List")
   556  		defer func() {
   557  			sc := -1
   558  			if result.alr.Response.Response != nil {
   559  				sc = result.alr.Response.Response.StatusCode
   560  			}
   561  			tracing.EndSpan(ctx, sc, err)
   562  		}()
   563  	}
   564  	result.fn = client.listNextResults
   565  	req, err := client.ListPreparer(ctx, filter)
   566  	if err != nil {
   567  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "List", nil, "Failure preparing request")
   568  		return
   569  	}
   570  
   571  	resp, err := client.ListSender(req)
   572  	if err != nil {
   573  		result.alr.Response = autorest.Response{Response: resp}
   574  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "List", resp, "Failure sending request")
   575  		return
   576  	}
   577  
   578  	result.alr, err = client.ListResponder(resp)
   579  	if err != nil {
   580  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "List", resp, "Failure responding to request")
   581  		return
   582  	}
   583  	if result.alr.hasNextLink() && result.alr.IsEmpty() {
   584  		err = result.NextWithContext(ctx)
   585  		return
   586  	}
   587  
   588  	return
   589  }
   590  
   591  // ListPreparer prepares the List request.
   592  func (client AssignmentsClient) ListPreparer(ctx context.Context, filter string) (*http.Request, error) {
   593  	pathParameters := map[string]interface{}{
   594  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
   595  	}
   596  
   597  	const APIVersion = "2018-05-01"
   598  	queryParameters := map[string]interface{}{
   599  		"api-version": APIVersion,
   600  	}
   601  	if len(filter) > 0 {
   602  		queryParameters["$filter"] = autorest.Encode("query", filter)
   603  	}
   604  
   605  	preparer := autorest.CreatePreparer(
   606  		autorest.AsGet(),
   607  		autorest.WithBaseURL(client.BaseURI),
   608  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments", pathParameters),
   609  		autorest.WithQueryParameters(queryParameters))
   610  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   611  }
   612  
   613  // ListSender sends the List request. The method will close the
   614  // http.Response Body if it receives an error.
   615  func (client AssignmentsClient) ListSender(req *http.Request) (*http.Response, error) {
   616  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   617  }
   618  
   619  // ListResponder handles the response to the List request. The method always
   620  // closes the http.Response Body.
   621  func (client AssignmentsClient) ListResponder(resp *http.Response) (result AssignmentListResult, err error) {
   622  	err = autorest.Respond(
   623  		resp,
   624  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   625  		autorest.ByUnmarshallingJSON(&result),
   626  		autorest.ByClosing())
   627  	result.Response = autorest.Response{Response: resp}
   628  	return
   629  }
   630  
   631  // listNextResults retrieves the next set of results, if any.
   632  func (client AssignmentsClient) listNextResults(ctx context.Context, lastResults AssignmentListResult) (result AssignmentListResult, err error) {
   633  	req, err := lastResults.assignmentListResultPreparer(ctx)
   634  	if err != nil {
   635  		return result, autorest.NewErrorWithError(err, "policy.AssignmentsClient", "listNextResults", nil, "Failure preparing next results request")
   636  	}
   637  	if req == nil {
   638  		return
   639  	}
   640  	resp, err := client.ListSender(req)
   641  	if err != nil {
   642  		result.Response = autorest.Response{Response: resp}
   643  		return result, autorest.NewErrorWithError(err, "policy.AssignmentsClient", "listNextResults", resp, "Failure sending next results request")
   644  	}
   645  	result, err = client.ListResponder(resp)
   646  	if err != nil {
   647  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "listNextResults", resp, "Failure responding to next results request")
   648  	}
   649  	return
   650  }
   651  
   652  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   653  func (client AssignmentsClient) ListComplete(ctx context.Context, filter string) (result AssignmentListResultIterator, err error) {
   654  	if tracing.IsEnabled() {
   655  		ctx = tracing.StartSpan(ctx, fqdn+"/AssignmentsClient.List")
   656  		defer func() {
   657  			sc := -1
   658  			if result.Response().Response.Response != nil {
   659  				sc = result.page.Response().Response.Response.StatusCode
   660  			}
   661  			tracing.EndSpan(ctx, sc, err)
   662  		}()
   663  	}
   664  	result.page, err = client.List(ctx, filter)
   665  	return
   666  }
   667  
   668  // ListForResource this operation retrieves the list of all policy assignments associated with the specified resource
   669  // in the given resource group and subscription that match the optional given $filter. Valid values for $filter are:
   670  // 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all
   671  // policy assignments associated with the resource, including those that apply directly or from all containing scopes,
   672  // as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned
   673  // list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except
   674  // those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided,
   675  // the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the
   676  // resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not
   677  // part of a parent resource (the more common case), the parent resource path should not be provided (or provided as
   678  // ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web',
   679  // {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a
   680  // parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified
   681  // as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine',
   682  // {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the
   683  // namespace and type name separately is to provide both in the {resourceType} parameter, format:
   684  // ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites',
   685  // {resourceName} == 'MyWebApp').
   686  // Parameters:
   687  // resourceGroupName - the name of the resource group containing the resource.
   688  // resourceProviderNamespace - the namespace of the resource provider. For example, the namespace of a virtual
   689  // machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines)
   690  // parentResourcePath - the parent resource path. Use empty string if there is none.
   691  // resourceType - the resource type name. For example the type name of a web app is 'sites' (from
   692  // Microsoft.Web/sites).
   693  // resourceName - the name of the resource.
   694  // filter - the filter to apply on the operation. Valid values for $filter are: 'atScope()' or
   695  // 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed.
   696  func (client AssignmentsClient) ListForResource(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, filter string) (result AssignmentListResultPage, err error) {
   697  	if tracing.IsEnabled() {
   698  		ctx = tracing.StartSpan(ctx, fqdn+"/AssignmentsClient.ListForResource")
   699  		defer func() {
   700  			sc := -1
   701  			if result.alr.Response.Response != nil {
   702  				sc = result.alr.Response.Response.StatusCode
   703  			}
   704  			tracing.EndSpan(ctx, sc, err)
   705  		}()
   706  	}
   707  	if err := validation.Validate([]validation.Validation{
   708  		{TargetValue: resourceGroupName,
   709  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   710  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   711  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
   712  		return result, validation.NewError("policy.AssignmentsClient", "ListForResource", err.Error())
   713  	}
   714  
   715  	result.fn = client.listForResourceNextResults
   716  	req, err := client.ListForResourcePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter)
   717  	if err != nil {
   718  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "ListForResource", nil, "Failure preparing request")
   719  		return
   720  	}
   721  
   722  	resp, err := client.ListForResourceSender(req)
   723  	if err != nil {
   724  		result.alr.Response = autorest.Response{Response: resp}
   725  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "ListForResource", resp, "Failure sending request")
   726  		return
   727  	}
   728  
   729  	result.alr, err = client.ListForResourceResponder(resp)
   730  	if err != nil {
   731  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "ListForResource", resp, "Failure responding to request")
   732  		return
   733  	}
   734  	if result.alr.hasNextLink() && result.alr.IsEmpty() {
   735  		err = result.NextWithContext(ctx)
   736  		return
   737  	}
   738  
   739  	return
   740  }
   741  
   742  // ListForResourcePreparer prepares the ListForResource request.
   743  func (client AssignmentsClient) ListForResourcePreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, filter string) (*http.Request, error) {
   744  	pathParameters := map[string]interface{}{
   745  		"parentResourcePath":        parentResourcePath,
   746  		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
   747  		"resourceName":              autorest.Encode("path", resourceName),
   748  		"resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace),
   749  		"resourceType":              resourceType,
   750  		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
   751  	}
   752  
   753  	const APIVersion = "2018-05-01"
   754  	queryParameters := map[string]interface{}{
   755  		"api-version": APIVersion,
   756  	}
   757  	if len(filter) > 0 {
   758  		queryParameters["$filter"] = autorest.Encode("query", filter)
   759  	}
   760  
   761  	preparer := autorest.CreatePreparer(
   762  		autorest.AsGet(),
   763  		autorest.WithBaseURL(client.BaseURI),
   764  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments", pathParameters),
   765  		autorest.WithQueryParameters(queryParameters))
   766  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   767  }
   768  
   769  // ListForResourceSender sends the ListForResource request. The method will close the
   770  // http.Response Body if it receives an error.
   771  func (client AssignmentsClient) ListForResourceSender(req *http.Request) (*http.Response, error) {
   772  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   773  }
   774  
   775  // ListForResourceResponder handles the response to the ListForResource request. The method always
   776  // closes the http.Response Body.
   777  func (client AssignmentsClient) ListForResourceResponder(resp *http.Response) (result AssignmentListResult, err error) {
   778  	err = autorest.Respond(
   779  		resp,
   780  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   781  		autorest.ByUnmarshallingJSON(&result),
   782  		autorest.ByClosing())
   783  	result.Response = autorest.Response{Response: resp}
   784  	return
   785  }
   786  
   787  // listForResourceNextResults retrieves the next set of results, if any.
   788  func (client AssignmentsClient) listForResourceNextResults(ctx context.Context, lastResults AssignmentListResult) (result AssignmentListResult, err error) {
   789  	req, err := lastResults.assignmentListResultPreparer(ctx)
   790  	if err != nil {
   791  		return result, autorest.NewErrorWithError(err, "policy.AssignmentsClient", "listForResourceNextResults", nil, "Failure preparing next results request")
   792  	}
   793  	if req == nil {
   794  		return
   795  	}
   796  	resp, err := client.ListForResourceSender(req)
   797  	if err != nil {
   798  		result.Response = autorest.Response{Response: resp}
   799  		return result, autorest.NewErrorWithError(err, "policy.AssignmentsClient", "listForResourceNextResults", resp, "Failure sending next results request")
   800  	}
   801  	result, err = client.ListForResourceResponder(resp)
   802  	if err != nil {
   803  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "listForResourceNextResults", resp, "Failure responding to next results request")
   804  	}
   805  	return
   806  }
   807  
   808  // ListForResourceComplete enumerates all values, automatically crossing page boundaries as required.
   809  func (client AssignmentsClient) ListForResourceComplete(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, filter string) (result AssignmentListResultIterator, err error) {
   810  	if tracing.IsEnabled() {
   811  		ctx = tracing.StartSpan(ctx, fqdn+"/AssignmentsClient.ListForResource")
   812  		defer func() {
   813  			sc := -1
   814  			if result.Response().Response.Response != nil {
   815  				sc = result.page.Response().Response.Response.StatusCode
   816  			}
   817  			tracing.EndSpan(ctx, sc, err)
   818  		}()
   819  	}
   820  	result.page, err = client.ListForResource(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter)
   821  	return
   822  }
   823  
   824  // ListForResourceGroup this operation retrieves the list of all policy assignments associated with the given resource
   825  // group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or
   826  // 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments
   827  // associated with the resource group, including those that apply directly or apply from containing scopes, as well as
   828  // any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list
   829  // includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except
   830  // those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is
   831  // provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply
   832  // to the resource group.
   833  // Parameters:
   834  // resourceGroupName - the name of the resource group that contains policy assignments.
   835  // filter - the filter to apply on the operation. Valid values for $filter are: 'atScope()' or
   836  // 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed.
   837  func (client AssignmentsClient) ListForResourceGroup(ctx context.Context, resourceGroupName string, filter string) (result AssignmentListResultPage, err error) {
   838  	if tracing.IsEnabled() {
   839  		ctx = tracing.StartSpan(ctx, fqdn+"/AssignmentsClient.ListForResourceGroup")
   840  		defer func() {
   841  			sc := -1
   842  			if result.alr.Response.Response != nil {
   843  				sc = result.alr.Response.Response.StatusCode
   844  			}
   845  			tracing.EndSpan(ctx, sc, err)
   846  		}()
   847  	}
   848  	if err := validation.Validate([]validation.Validation{
   849  		{TargetValue: resourceGroupName,
   850  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   851  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   852  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
   853  		return result, validation.NewError("policy.AssignmentsClient", "ListForResourceGroup", err.Error())
   854  	}
   855  
   856  	result.fn = client.listForResourceGroupNextResults
   857  	req, err := client.ListForResourceGroupPreparer(ctx, resourceGroupName, filter)
   858  	if err != nil {
   859  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "ListForResourceGroup", nil, "Failure preparing request")
   860  		return
   861  	}
   862  
   863  	resp, err := client.ListForResourceGroupSender(req)
   864  	if err != nil {
   865  		result.alr.Response = autorest.Response{Response: resp}
   866  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "ListForResourceGroup", resp, "Failure sending request")
   867  		return
   868  	}
   869  
   870  	result.alr, err = client.ListForResourceGroupResponder(resp)
   871  	if err != nil {
   872  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "ListForResourceGroup", resp, "Failure responding to request")
   873  		return
   874  	}
   875  	if result.alr.hasNextLink() && result.alr.IsEmpty() {
   876  		err = result.NextWithContext(ctx)
   877  		return
   878  	}
   879  
   880  	return
   881  }
   882  
   883  // ListForResourceGroupPreparer prepares the ListForResourceGroup request.
   884  func (client AssignmentsClient) ListForResourceGroupPreparer(ctx context.Context, resourceGroupName string, filter string) (*http.Request, error) {
   885  	pathParameters := map[string]interface{}{
   886  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   887  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   888  	}
   889  
   890  	const APIVersion = "2018-05-01"
   891  	queryParameters := map[string]interface{}{
   892  		"api-version": APIVersion,
   893  	}
   894  	if len(filter) > 0 {
   895  		queryParameters["$filter"] = filter
   896  	}
   897  
   898  	preparer := autorest.CreatePreparer(
   899  		autorest.AsGet(),
   900  		autorest.WithBaseURL(client.BaseURI),
   901  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments", pathParameters),
   902  		autorest.WithQueryParameters(queryParameters))
   903  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   904  }
   905  
   906  // ListForResourceGroupSender sends the ListForResourceGroup request. The method will close the
   907  // http.Response Body if it receives an error.
   908  func (client AssignmentsClient) ListForResourceGroupSender(req *http.Request) (*http.Response, error) {
   909  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   910  }
   911  
   912  // ListForResourceGroupResponder handles the response to the ListForResourceGroup request. The method always
   913  // closes the http.Response Body.
   914  func (client AssignmentsClient) ListForResourceGroupResponder(resp *http.Response) (result AssignmentListResult, err error) {
   915  	err = autorest.Respond(
   916  		resp,
   917  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   918  		autorest.ByUnmarshallingJSON(&result),
   919  		autorest.ByClosing())
   920  	result.Response = autorest.Response{Response: resp}
   921  	return
   922  }
   923  
   924  // listForResourceGroupNextResults retrieves the next set of results, if any.
   925  func (client AssignmentsClient) listForResourceGroupNextResults(ctx context.Context, lastResults AssignmentListResult) (result AssignmentListResult, err error) {
   926  	req, err := lastResults.assignmentListResultPreparer(ctx)
   927  	if err != nil {
   928  		return result, autorest.NewErrorWithError(err, "policy.AssignmentsClient", "listForResourceGroupNextResults", nil, "Failure preparing next results request")
   929  	}
   930  	if req == nil {
   931  		return
   932  	}
   933  	resp, err := client.ListForResourceGroupSender(req)
   934  	if err != nil {
   935  		result.Response = autorest.Response{Response: resp}
   936  		return result, autorest.NewErrorWithError(err, "policy.AssignmentsClient", "listForResourceGroupNextResults", resp, "Failure sending next results request")
   937  	}
   938  	result, err = client.ListForResourceGroupResponder(resp)
   939  	if err != nil {
   940  		err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "listForResourceGroupNextResults", resp, "Failure responding to next results request")
   941  	}
   942  	return
   943  }
   944  
   945  // ListForResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
   946  func (client AssignmentsClient) ListForResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string) (result AssignmentListResultIterator, err error) {
   947  	if tracing.IsEnabled() {
   948  		ctx = tracing.StartSpan(ctx, fqdn+"/AssignmentsClient.ListForResourceGroup")
   949  		defer func() {
   950  			sc := -1
   951  			if result.Response().Response.Response != nil {
   952  				sc = result.page.Response().Response.Response.StatusCode
   953  			}
   954  			tracing.EndSpan(ctx, sc, err)
   955  		}()
   956  	}
   957  	result.page, err = client.ListForResourceGroup(ctx, resourceGroupName, filter)
   958  	return
   959  }
   960  

View as plain text