...

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

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2021-06-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 = "2021-06-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  	parameters.SystemData = 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 = "2021-06-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  	parameters.SystemData = nil
   170  	preparer := autorest.CreatePreparer(
   171  		autorest.AsContentType("application/json; charset=utf-8"),
   172  		autorest.AsPut(),
   173  		autorest.WithBaseURL(client.BaseURI),
   174  		autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", pathParameters),
   175  		autorest.WithJSON(parameters),
   176  		autorest.WithQueryParameters(queryParameters))
   177  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   178  }
   179  
   180  // CreateOrUpdateAtManagementGroupSender sends the CreateOrUpdateAtManagementGroup request. The method will close the
   181  // http.Response Body if it receives an error.
   182  func (client DefinitionsClient) CreateOrUpdateAtManagementGroupSender(req *http.Request) (*http.Response, error) {
   183  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   184  }
   185  
   186  // CreateOrUpdateAtManagementGroupResponder handles the response to the CreateOrUpdateAtManagementGroup request. The method always
   187  // closes the http.Response Body.
   188  func (client DefinitionsClient) CreateOrUpdateAtManagementGroupResponder(resp *http.Response) (result Definition, err error) {
   189  	err = autorest.Respond(
   190  		resp,
   191  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   192  		autorest.ByUnmarshallingJSON(&result),
   193  		autorest.ByClosing())
   194  	result.Response = autorest.Response{Response: resp}
   195  	return
   196  }
   197  
   198  // Delete this operation deletes the policy definition in the given subscription with the given name.
   199  // Parameters:
   200  // policyDefinitionName - the name of the policy definition to delete.
   201  func (client DefinitionsClient) Delete(ctx context.Context, policyDefinitionName 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)
   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) (*http.Request, error) {
   236  	pathParameters := map[string]interface{}{
   237  		"policyDefinitionName": autorest.Encode("path", policyDefinitionName),
   238  		"subscriptionId":       autorest.Encode("path", client.SubscriptionID),
   239  	}
   240  
   241  	const APIVersion = "2021-06-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 = "2021-06-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  func (client DefinitionsClient) Get(ctx context.Context, policyDefinitionName string) (result Definition, err error) {
   350  	if tracing.IsEnabled() {
   351  		ctx = tracing.StartSpan(ctx, fqdn+"/DefinitionsClient.Get")
   352  		defer func() {
   353  			sc := -1
   354  			if result.Response.Response != nil {
   355  				sc = result.Response.Response.StatusCode
   356  			}
   357  			tracing.EndSpan(ctx, sc, err)
   358  		}()
   359  	}
   360  	req, err := client.GetPreparer(ctx, policyDefinitionName)
   361  	if err != nil {
   362  		err = autorest.NewErrorWithError(err, "policy.DefinitionsClient", "Get", nil, "Failure preparing request")
   363  		return
   364  	}
   365  
   366  	resp, err := client.GetSender(req)
   367  	if err != nil {
   368  		result.Response = autorest.Response{Response: resp}
   369  		err = autorest.NewErrorWithError(err, "policy.DefinitionsClient", "Get", resp, "Failure sending request")
   370  		return
   371  	}
   372  
   373  	result, err = client.GetResponder(resp)
   374  	if err != nil {
   375  		err = autorest.NewErrorWithError(err, "policy.DefinitionsClient", "Get", resp, "Failure responding to request")
   376  		return
   377  	}
   378  
   379  	return
   380  }
   381  
   382  // GetPreparer prepares the Get request.
   383  func (client DefinitionsClient) GetPreparer(ctx context.Context, policyDefinitionName string) (*http.Request, error) {
   384  	pathParameters := map[string]interface{}{
   385  		"policyDefinitionName": autorest.Encode("path", policyDefinitionName),
   386  		"subscriptionId":       autorest.Encode("path", client.SubscriptionID),
   387  	}
   388  
   389  	const APIVersion = "2021-06-01"
   390  	queryParameters := map[string]interface{}{
   391  		"api-version": APIVersion,
   392  	}
   393  
   394  	preparer := autorest.CreatePreparer(
   395  		autorest.AsGet(),
   396  		autorest.WithBaseURL(client.BaseURI),
   397  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", pathParameters),
   398  		autorest.WithQueryParameters(queryParameters))
   399  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   400  }
   401  
   402  // GetSender sends the Get request. The method will close the
   403  // http.Response Body if it receives an error.
   404  func (client DefinitionsClient) GetSender(req *http.Request) (*http.Response, error) {
   405  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   406  }
   407  
   408  // GetResponder handles the response to the Get request. The method always
   409  // closes the http.Response Body.
   410  func (client DefinitionsClient) GetResponder(resp *http.Response) (result Definition, err error) {
   411  	err = autorest.Respond(
   412  		resp,
   413  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   414  		autorest.ByUnmarshallingJSON(&result),
   415  		autorest.ByClosing())
   416  	result.Response = autorest.Response{Response: resp}
   417  	return
   418  }
   419  
   420  // GetAtManagementGroup this operation retrieves the policy definition in the given management group with the given
   421  // name.
   422  // Parameters:
   423  // policyDefinitionName - the name of the policy definition to get.
   424  // managementGroupID - the ID of the management group.
   425  func (client DefinitionsClient) GetAtManagementGroup(ctx context.Context, policyDefinitionName string, managementGroupID string) (result Definition, err error) {
   426  	if tracing.IsEnabled() {
   427  		ctx = tracing.StartSpan(ctx, fqdn+"/DefinitionsClient.GetAtManagementGroup")
   428  		defer func() {
   429  			sc := -1
   430  			if result.Response.Response != nil {
   431  				sc = result.Response.Response.StatusCode
   432  			}
   433  			tracing.EndSpan(ctx, sc, err)
   434  		}()
   435  	}
   436  	req, err := client.GetAtManagementGroupPreparer(ctx, policyDefinitionName, managementGroupID)
   437  	if err != nil {
   438  		err = autorest.NewErrorWithError(err, "policy.DefinitionsClient", "GetAtManagementGroup", nil, "Failure preparing request")
   439  		return
   440  	}
   441  
   442  	resp, err := client.GetAtManagementGroupSender(req)
   443  	if err != nil {
   444  		result.Response = autorest.Response{Response: resp}
   445  		err = autorest.NewErrorWithError(err, "policy.DefinitionsClient", "GetAtManagementGroup", resp, "Failure sending request")
   446  		return
   447  	}
   448  
   449  	result, err = client.GetAtManagementGroupResponder(resp)
   450  	if err != nil {
   451  		err = autorest.NewErrorWithError(err, "policy.DefinitionsClient", "GetAtManagementGroup", resp, "Failure responding to request")
   452  		return
   453  	}
   454  
   455  	return
   456  }
   457  
   458  // GetAtManagementGroupPreparer prepares the GetAtManagementGroup request.
   459  func (client DefinitionsClient) GetAtManagementGroupPreparer(ctx context.Context, policyDefinitionName string, managementGroupID string) (*http.Request, error) {
   460  	pathParameters := map[string]interface{}{
   461  		"managementGroupId":    autorest.Encode("path", managementGroupID),
   462  		"policyDefinitionName": autorest.Encode("path", policyDefinitionName),
   463  	}
   464  
   465  	const APIVersion = "2021-06-01"
   466  	queryParameters := map[string]interface{}{
   467  		"api-version": APIVersion,
   468  	}
   469  
   470  	preparer := autorest.CreatePreparer(
   471  		autorest.AsGet(),
   472  		autorest.WithBaseURL(client.BaseURI),
   473  		autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", pathParameters),
   474  		autorest.WithQueryParameters(queryParameters))
   475  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   476  }
   477  
   478  // GetAtManagementGroupSender sends the GetAtManagementGroup request. The method will close the
   479  // http.Response Body if it receives an error.
   480  func (client DefinitionsClient) GetAtManagementGroupSender(req *http.Request) (*http.Response, error) {
   481  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   482  }
   483  
   484  // GetAtManagementGroupResponder handles the response to the GetAtManagementGroup request. The method always
   485  // closes the http.Response Body.
   486  func (client DefinitionsClient) GetAtManagementGroupResponder(resp *http.Response) (result Definition, err error) {
   487  	err = autorest.Respond(
   488  		resp,
   489  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   490  		autorest.ByUnmarshallingJSON(&result),
   491  		autorest.ByClosing())
   492  	result.Response = autorest.Response{Response: resp}
   493  	return
   494  }
   495  
   496  // GetBuiltIn this operation retrieves the built-in policy definition with the given name.
   497  // Parameters:
   498  // policyDefinitionName - the name of the built-in policy definition to get.
   499  func (client DefinitionsClient) GetBuiltIn(ctx context.Context, policyDefinitionName string) (result Definition, err error) {
   500  	if tracing.IsEnabled() {
   501  		ctx = tracing.StartSpan(ctx, fqdn+"/DefinitionsClient.GetBuiltIn")
   502  		defer func() {
   503  			sc := -1
   504  			if result.Response.Response != nil {
   505  				sc = result.Response.Response.StatusCode
   506  			}
   507  			tracing.EndSpan(ctx, sc, err)
   508  		}()
   509  	}
   510  	req, err := client.GetBuiltInPreparer(ctx, policyDefinitionName)
   511  	if err != nil {
   512  		err = autorest.NewErrorWithError(err, "policy.DefinitionsClient", "GetBuiltIn", nil, "Failure preparing request")
   513  		return
   514  	}
   515  
   516  	resp, err := client.GetBuiltInSender(req)
   517  	if err != nil {
   518  		result.Response = autorest.Response{Response: resp}
   519  		err = autorest.NewErrorWithError(err, "policy.DefinitionsClient", "GetBuiltIn", resp, "Failure sending request")
   520  		return
   521  	}
   522  
   523  	result, err = client.GetBuiltInResponder(resp)
   524  	if err != nil {
   525  		err = autorest.NewErrorWithError(err, "policy.DefinitionsClient", "GetBuiltIn", resp, "Failure responding to request")
   526  		return
   527  	}
   528  
   529  	return
   530  }
   531  
   532  // GetBuiltInPreparer prepares the GetBuiltIn request.
   533  func (client DefinitionsClient) GetBuiltInPreparer(ctx context.Context, policyDefinitionName string) (*http.Request, error) {
   534  	pathParameters := map[string]interface{}{
   535  		"policyDefinitionName": autorest.Encode("path", policyDefinitionName),
   536  	}
   537  
   538  	const APIVersion = "2021-06-01"
   539  	queryParameters := map[string]interface{}{
   540  		"api-version": APIVersion,
   541  	}
   542  
   543  	preparer := autorest.CreatePreparer(
   544  		autorest.AsGet(),
   545  		autorest.WithBaseURL(client.BaseURI),
   546  		autorest.WithPathParameters("/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", pathParameters),
   547  		autorest.WithQueryParameters(queryParameters))
   548  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   549  }
   550  
   551  // GetBuiltInSender sends the GetBuiltIn request. The method will close the
   552  // http.Response Body if it receives an error.
   553  func (client DefinitionsClient) GetBuiltInSender(req *http.Request) (*http.Response, error) {
   554  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   555  }
   556  
   557  // GetBuiltInResponder handles the response to the GetBuiltIn request. The method always
   558  // closes the http.Response Body.
   559  func (client DefinitionsClient) GetBuiltInResponder(resp *http.Response) (result Definition, err error) {
   560  	err = autorest.Respond(
   561  		resp,
   562  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   563  		autorest.ByUnmarshallingJSON(&result),
   564  		autorest.ByClosing())
   565  	result.Response = autorest.Response{Response: resp}
   566  	return
   567  }
   568  
   569  // List this operation retrieves a list of all the policy definitions in a given subscription that match the optional
   570  // given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}”.
   571  // If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription,
   572  // including those that apply directly or from management groups that contain the given subscription. If
   573  // $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given
   574  // subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy
   575  // definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static.
   576  // If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category
   577  // match the {value}.
   578  // Parameters:
   579  // filter - the filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType
   580  // -eq {value}' or 'category eq '{value}”. If $filter is not provided, no filtering is performed. If
   581  // $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given
   582  // scope. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy
   583  // definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and
   584  // Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy
   585  // definitions whose category match the {value}.
   586  // top - maximum number of records to return. When the $top filter is not provided, it will return 500 records.
   587  func (client DefinitionsClient) List(ctx context.Context, filter string, top *int32) (result DefinitionListResultPage, err error) {
   588  	if tracing.IsEnabled() {
   589  		ctx = tracing.StartSpan(ctx, fqdn+"/DefinitionsClient.List")
   590  		defer func() {
   591  			sc := -1
   592  			if result.dlr.Response.Response != nil {
   593  				sc = result.dlr.Response.Response.StatusCode
   594  			}
   595  			tracing.EndSpan(ctx, sc, err)
   596  		}()
   597  	}
   598  	if err := validation.Validate([]validation.Validation{
   599  		{TargetValue: top,
   600  			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
   601  				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil},
   602  					{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil},
   603  				}}}}}); err != nil {
   604  		return result, validation.NewError("policy.DefinitionsClient", "List", err.Error())
   605  	}
   606  
   607  	result.fn = client.listNextResults
   608  	req, err := client.ListPreparer(ctx, filter, top)
   609  	if err != nil {
   610  		err = autorest.NewErrorWithError(err, "policy.DefinitionsClient", "List", nil, "Failure preparing request")
   611  		return
   612  	}
   613  
   614  	resp, err := client.ListSender(req)
   615  	if err != nil {
   616  		result.dlr.Response = autorest.Response{Response: resp}
   617  		err = autorest.NewErrorWithError(err, "policy.DefinitionsClient", "List", resp, "Failure sending request")
   618  		return
   619  	}
   620  
   621  	result.dlr, err = client.ListResponder(resp)
   622  	if err != nil {
   623  		err = autorest.NewErrorWithError(err, "policy.DefinitionsClient", "List", resp, "Failure responding to request")
   624  		return
   625  	}
   626  	if result.dlr.hasNextLink() && result.dlr.IsEmpty() {
   627  		err = result.NextWithContext(ctx)
   628  		return
   629  	}
   630  
   631  	return
   632  }
   633  
   634  // ListPreparer prepares the List request.
   635  func (client DefinitionsClient) ListPreparer(ctx context.Context, filter string, top *int32) (*http.Request, error) {
   636  	pathParameters := map[string]interface{}{
   637  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
   638  	}
   639  
   640  	const APIVersion = "2021-06-01"
   641  	queryParameters := map[string]interface{}{
   642  		"api-version": APIVersion,
   643  	}
   644  	if len(filter) > 0 {
   645  		queryParameters["$filter"] = filter
   646  	}
   647  	if top != nil {
   648  		queryParameters["$top"] = autorest.Encode("query", *top)
   649  	}
   650  
   651  	preparer := autorest.CreatePreparer(
   652  		autorest.AsGet(),
   653  		autorest.WithBaseURL(client.BaseURI),
   654  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions", pathParameters),
   655  		autorest.WithQueryParameters(queryParameters))
   656  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   657  }
   658  
   659  // ListSender sends the List request. The method will close the
   660  // http.Response Body if it receives an error.
   661  func (client DefinitionsClient) ListSender(req *http.Request) (*http.Response, error) {
   662  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   663  }
   664  
   665  // ListResponder handles the response to the List request. The method always
   666  // closes the http.Response Body.
   667  func (client DefinitionsClient) ListResponder(resp *http.Response) (result DefinitionListResult, err error) {
   668  	err = autorest.Respond(
   669  		resp,
   670  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   671  		autorest.ByUnmarshallingJSON(&result),
   672  		autorest.ByClosing())
   673  	result.Response = autorest.Response{Response: resp}
   674  	return
   675  }
   676  
   677  // listNextResults retrieves the next set of results, if any.
   678  func (client DefinitionsClient) listNextResults(ctx context.Context, lastResults DefinitionListResult) (result DefinitionListResult, err error) {
   679  	req, err := lastResults.definitionListResultPreparer(ctx)
   680  	if err != nil {
   681  		return result, autorest.NewErrorWithError(err, "policy.DefinitionsClient", "listNextResults", nil, "Failure preparing next results request")
   682  	}
   683  	if req == nil {
   684  		return
   685  	}
   686  	resp, err := client.ListSender(req)
   687  	if err != nil {
   688  		result.Response = autorest.Response{Response: resp}
   689  		return result, autorest.NewErrorWithError(err, "policy.DefinitionsClient", "listNextResults", resp, "Failure sending next results request")
   690  	}
   691  	result, err = client.ListResponder(resp)
   692  	if err != nil {
   693  		err = autorest.NewErrorWithError(err, "policy.DefinitionsClient", "listNextResults", resp, "Failure responding to next results request")
   694  	}
   695  	return
   696  }
   697  
   698  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   699  func (client DefinitionsClient) ListComplete(ctx context.Context, filter string, top *int32) (result DefinitionListResultIterator, err error) {
   700  	if tracing.IsEnabled() {
   701  		ctx = tracing.StartSpan(ctx, fqdn+"/DefinitionsClient.List")
   702  		defer func() {
   703  			sc := -1
   704  			if result.Response().Response.Response != nil {
   705  				sc = result.page.Response().Response.Response.StatusCode
   706  			}
   707  			tracing.EndSpan(ctx, sc, err)
   708  		}()
   709  	}
   710  	result.page, err = client.List(ctx, filter, top)
   711  	return
   712  }
   713  
   714  // ListBuiltIn this operation retrieves a list of all the built-in policy definitions that match the optional given
   715  // $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy
   716  // definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static.
   717  // If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose
   718  // category match the {value}.
   719  // Parameters:
   720  // filter - the filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType
   721  // -eq {value}' or 'category eq '{value}”. If $filter is not provided, no filtering is performed. If
   722  // $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given
   723  // scope. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy
   724  // definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and
   725  // Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy
   726  // definitions whose category match the {value}.
   727  // top - maximum number of records to return. When the $top filter is not provided, it will return 500 records.
   728  func (client DefinitionsClient) ListBuiltIn(ctx context.Context, filter string, top *int32) (result DefinitionListResultPage, err error) {
   729  	if tracing.IsEnabled() {
   730  		ctx = tracing.StartSpan(ctx, fqdn+"/DefinitionsClient.ListBuiltIn")
   731  		defer func() {
   732  			sc := -1
   733  			if result.dlr.Response.Response != nil {
   734  				sc = result.dlr.Response.Response.StatusCode
   735  			}
   736  			tracing.EndSpan(ctx, sc, err)
   737  		}()
   738  	}
   739  	if err := validation.Validate([]validation.Validation{
   740  		{TargetValue: top,
   741  			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
   742  				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil},
   743  					{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil},
   744  				}}}}}); err != nil {
   745  		return result, validation.NewError("policy.DefinitionsClient", "ListBuiltIn", err.Error())
   746  	}
   747  
   748  	result.fn = client.listBuiltInNextResults
   749  	req, err := client.ListBuiltInPreparer(ctx, filter, top)
   750  	if err != nil {
   751  		err = autorest.NewErrorWithError(err, "policy.DefinitionsClient", "ListBuiltIn", nil, "Failure preparing request")
   752  		return
   753  	}
   754  
   755  	resp, err := client.ListBuiltInSender(req)
   756  	if err != nil {
   757  		result.dlr.Response = autorest.Response{Response: resp}
   758  		err = autorest.NewErrorWithError(err, "policy.DefinitionsClient", "ListBuiltIn", resp, "Failure sending request")
   759  		return
   760  	}
   761  
   762  	result.dlr, err = client.ListBuiltInResponder(resp)
   763  	if err != nil {
   764  		err = autorest.NewErrorWithError(err, "policy.DefinitionsClient", "ListBuiltIn", resp, "Failure responding to request")
   765  		return
   766  	}
   767  	if result.dlr.hasNextLink() && result.dlr.IsEmpty() {
   768  		err = result.NextWithContext(ctx)
   769  		return
   770  	}
   771  
   772  	return
   773  }
   774  
   775  // ListBuiltInPreparer prepares the ListBuiltIn request.
   776  func (client DefinitionsClient) ListBuiltInPreparer(ctx context.Context, filter string, top *int32) (*http.Request, error) {
   777  	const APIVersion = "2021-06-01"
   778  	queryParameters := map[string]interface{}{
   779  		"api-version": APIVersion,
   780  	}
   781  	if len(filter) > 0 {
   782  		queryParameters["$filter"] = filter
   783  	}
   784  	if top != nil {
   785  		queryParameters["$top"] = autorest.Encode("query", *top)
   786  	}
   787  
   788  	preparer := autorest.CreatePreparer(
   789  		autorest.AsGet(),
   790  		autorest.WithBaseURL(client.BaseURI),
   791  		autorest.WithPath("/providers/Microsoft.Authorization/policyDefinitions"),
   792  		autorest.WithQueryParameters(queryParameters))
   793  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   794  }
   795  
   796  // ListBuiltInSender sends the ListBuiltIn request. The method will close the
   797  // http.Response Body if it receives an error.
   798  func (client DefinitionsClient) ListBuiltInSender(req *http.Request) (*http.Response, error) {
   799  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   800  }
   801  
   802  // ListBuiltInResponder handles the response to the ListBuiltIn request. The method always
   803  // closes the http.Response Body.
   804  func (client DefinitionsClient) ListBuiltInResponder(resp *http.Response) (result DefinitionListResult, err error) {
   805  	err = autorest.Respond(
   806  		resp,
   807  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   808  		autorest.ByUnmarshallingJSON(&result),
   809  		autorest.ByClosing())
   810  	result.Response = autorest.Response{Response: resp}
   811  	return
   812  }
   813  
   814  // listBuiltInNextResults retrieves the next set of results, if any.
   815  func (client DefinitionsClient) listBuiltInNextResults(ctx context.Context, lastResults DefinitionListResult) (result DefinitionListResult, err error) {
   816  	req, err := lastResults.definitionListResultPreparer(ctx)
   817  	if err != nil {
   818  		return result, autorest.NewErrorWithError(err, "policy.DefinitionsClient", "listBuiltInNextResults", nil, "Failure preparing next results request")
   819  	}
   820  	if req == nil {
   821  		return
   822  	}
   823  	resp, err := client.ListBuiltInSender(req)
   824  	if err != nil {
   825  		result.Response = autorest.Response{Response: resp}
   826  		return result, autorest.NewErrorWithError(err, "policy.DefinitionsClient", "listBuiltInNextResults", resp, "Failure sending next results request")
   827  	}
   828  	result, err = client.ListBuiltInResponder(resp)
   829  	if err != nil {
   830  		err = autorest.NewErrorWithError(err, "policy.DefinitionsClient", "listBuiltInNextResults", resp, "Failure responding to next results request")
   831  	}
   832  	return
   833  }
   834  
   835  // ListBuiltInComplete enumerates all values, automatically crossing page boundaries as required.
   836  func (client DefinitionsClient) ListBuiltInComplete(ctx context.Context, filter string, top *int32) (result DefinitionListResultIterator, err error) {
   837  	if tracing.IsEnabled() {
   838  		ctx = tracing.StartSpan(ctx, fqdn+"/DefinitionsClient.ListBuiltIn")
   839  		defer func() {
   840  			sc := -1
   841  			if result.Response().Response.Response != nil {
   842  				sc = result.page.Response().Response.Response.StatusCode
   843  			}
   844  			tracing.EndSpan(ctx, sc, err)
   845  		}()
   846  	}
   847  	result.page, err = client.ListBuiltIn(ctx, filter, top)
   848  	return
   849  }
   850  
   851  // ListByManagementGroup this operation retrieves a list of all the policy definitions in a given management group that
   852  // match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or
   853  // 'category eq '{value}”. If $filter is not provided, the unfiltered list includes all policy definitions associated
   854  // with the management group, including those that apply directly or from management groups that contain the given
   855  // management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that
   856  // at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all
   857  // policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and
   858  // Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose
   859  // category match the {value}.
   860  // Parameters:
   861  // managementGroupID - the ID of the management group.
   862  // filter - the filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType
   863  // -eq {value}' or 'category eq '{value}”. If $filter is not provided, no filtering is performed. If
   864  // $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given
   865  // scope. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy
   866  // definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and
   867  // Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy
   868  // definitions whose category match the {value}.
   869  // top - maximum number of records to return. When the $top filter is not provided, it will return 500 records.
   870  func (client DefinitionsClient) ListByManagementGroup(ctx context.Context, managementGroupID string, filter string, top *int32) (result DefinitionListResultPage, err error) {
   871  	if tracing.IsEnabled() {
   872  		ctx = tracing.StartSpan(ctx, fqdn+"/DefinitionsClient.ListByManagementGroup")
   873  		defer func() {
   874  			sc := -1
   875  			if result.dlr.Response.Response != nil {
   876  				sc = result.dlr.Response.Response.StatusCode
   877  			}
   878  			tracing.EndSpan(ctx, sc, err)
   879  		}()
   880  	}
   881  	if err := validation.Validate([]validation.Validation{
   882  		{TargetValue: top,
   883  			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
   884  				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil},
   885  					{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil},
   886  				}}}}}); err != nil {
   887  		return result, validation.NewError("policy.DefinitionsClient", "ListByManagementGroup", err.Error())
   888  	}
   889  
   890  	result.fn = client.listByManagementGroupNextResults
   891  	req, err := client.ListByManagementGroupPreparer(ctx, managementGroupID, filter, top)
   892  	if err != nil {
   893  		err = autorest.NewErrorWithError(err, "policy.DefinitionsClient", "ListByManagementGroup", nil, "Failure preparing request")
   894  		return
   895  	}
   896  
   897  	resp, err := client.ListByManagementGroupSender(req)
   898  	if err != nil {
   899  		result.dlr.Response = autorest.Response{Response: resp}
   900  		err = autorest.NewErrorWithError(err, "policy.DefinitionsClient", "ListByManagementGroup", resp, "Failure sending request")
   901  		return
   902  	}
   903  
   904  	result.dlr, err = client.ListByManagementGroupResponder(resp)
   905  	if err != nil {
   906  		err = autorest.NewErrorWithError(err, "policy.DefinitionsClient", "ListByManagementGroup", resp, "Failure responding to request")
   907  		return
   908  	}
   909  	if result.dlr.hasNextLink() && result.dlr.IsEmpty() {
   910  		err = result.NextWithContext(ctx)
   911  		return
   912  	}
   913  
   914  	return
   915  }
   916  
   917  // ListByManagementGroupPreparer prepares the ListByManagementGroup request.
   918  func (client DefinitionsClient) ListByManagementGroupPreparer(ctx context.Context, managementGroupID string, filter string, top *int32) (*http.Request, error) {
   919  	pathParameters := map[string]interface{}{
   920  		"managementGroupId": autorest.Encode("path", managementGroupID),
   921  	}
   922  
   923  	const APIVersion = "2021-06-01"
   924  	queryParameters := map[string]interface{}{
   925  		"api-version": APIVersion,
   926  	}
   927  	if len(filter) > 0 {
   928  		queryParameters["$filter"] = filter
   929  	}
   930  	if top != nil {
   931  		queryParameters["$top"] = autorest.Encode("query", *top)
   932  	}
   933  
   934  	preparer := autorest.CreatePreparer(
   935  		autorest.AsGet(),
   936  		autorest.WithBaseURL(client.BaseURI),
   937  		autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions", pathParameters),
   938  		autorest.WithQueryParameters(queryParameters))
   939  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   940  }
   941  
   942  // ListByManagementGroupSender sends the ListByManagementGroup request. The method will close the
   943  // http.Response Body if it receives an error.
   944  func (client DefinitionsClient) ListByManagementGroupSender(req *http.Request) (*http.Response, error) {
   945  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   946  }
   947  
   948  // ListByManagementGroupResponder handles the response to the ListByManagementGroup request. The method always
   949  // closes the http.Response Body.
   950  func (client DefinitionsClient) ListByManagementGroupResponder(resp *http.Response) (result DefinitionListResult, err error) {
   951  	err = autorest.Respond(
   952  		resp,
   953  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   954  		autorest.ByUnmarshallingJSON(&result),
   955  		autorest.ByClosing())
   956  	result.Response = autorest.Response{Response: resp}
   957  	return
   958  }
   959  
   960  // listByManagementGroupNextResults retrieves the next set of results, if any.
   961  func (client DefinitionsClient) listByManagementGroupNextResults(ctx context.Context, lastResults DefinitionListResult) (result DefinitionListResult, err error) {
   962  	req, err := lastResults.definitionListResultPreparer(ctx)
   963  	if err != nil {
   964  		return result, autorest.NewErrorWithError(err, "policy.DefinitionsClient", "listByManagementGroupNextResults", nil, "Failure preparing next results request")
   965  	}
   966  	if req == nil {
   967  		return
   968  	}
   969  	resp, err := client.ListByManagementGroupSender(req)
   970  	if err != nil {
   971  		result.Response = autorest.Response{Response: resp}
   972  		return result, autorest.NewErrorWithError(err, "policy.DefinitionsClient", "listByManagementGroupNextResults", resp, "Failure sending next results request")
   973  	}
   974  	result, err = client.ListByManagementGroupResponder(resp)
   975  	if err != nil {
   976  		err = autorest.NewErrorWithError(err, "policy.DefinitionsClient", "listByManagementGroupNextResults", resp, "Failure responding to next results request")
   977  	}
   978  	return
   979  }
   980  
   981  // ListByManagementGroupComplete enumerates all values, automatically crossing page boundaries as required.
   982  func (client DefinitionsClient) ListByManagementGroupComplete(ctx context.Context, managementGroupID string, filter string, top *int32) (result DefinitionListResultIterator, err error) {
   983  	if tracing.IsEnabled() {
   984  		ctx = tracing.StartSpan(ctx, fqdn+"/DefinitionsClient.ListByManagementGroup")
   985  		defer func() {
   986  			sc := -1
   987  			if result.Response().Response.Response != nil {
   988  				sc = result.page.Response().Response.Response.StatusCode
   989  			}
   990  			tracing.EndSpan(ctx, sc, err)
   991  		}()
   992  	}
   993  	result.page, err = client.ListByManagementGroup(ctx, managementGroupID, filter, top)
   994  	return
   995  }
   996  

View as plain text