...

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

View as plain text