...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2020-03-01-preview/policy/definitions.go

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

View as plain text