...

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

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

View as plain text