...

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

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

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

View as plain text