...

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

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2020-09-01-preview/policy

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

View as plain text