...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2020-03-01-preview/policy/models.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  	"encoding/json"
    12  	"github.com/Azure/go-autorest/autorest"
    13  	"github.com/Azure/go-autorest/autorest/date"
    14  	"github.com/Azure/go-autorest/autorest/to"
    15  	"github.com/Azure/go-autorest/tracing"
    16  	"net/http"
    17  )
    18  
    19  // The package's fully qualified name.
    20  const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2020-03-01-preview/policy"
    21  
    22  // Assignment the policy assignment.
    23  type Assignment struct {
    24  	autorest.Response `json:"-"`
    25  	// AssignmentProperties - Properties for the policy assignment.
    26  	*AssignmentProperties `json:"properties,omitempty"`
    27  	// ID - READ-ONLY; The ID of the policy assignment.
    28  	ID *string `json:"id,omitempty"`
    29  	// Type - READ-ONLY; The type of the policy assignment.
    30  	Type *string `json:"type,omitempty"`
    31  	// Name - READ-ONLY; The name of the policy assignment.
    32  	Name *string `json:"name,omitempty"`
    33  	// Sku - The policy sku. This property is optional, obsolete, and will be ignored.
    34  	Sku *Sku `json:"sku,omitempty"`
    35  	// Location - The location of the policy assignment. Only required when utilizing managed identity.
    36  	Location *string `json:"location,omitempty"`
    37  	// Identity - The managed identity associated with the policy assignment.
    38  	Identity *Identity `json:"identity,omitempty"`
    39  }
    40  
    41  // MarshalJSON is the custom marshaler for Assignment.
    42  func (a Assignment) MarshalJSON() ([]byte, error) {
    43  	objectMap := make(map[string]interface{})
    44  	if a.AssignmentProperties != nil {
    45  		objectMap["properties"] = a.AssignmentProperties
    46  	}
    47  	if a.Sku != nil {
    48  		objectMap["sku"] = a.Sku
    49  	}
    50  	if a.Location != nil {
    51  		objectMap["location"] = a.Location
    52  	}
    53  	if a.Identity != nil {
    54  		objectMap["identity"] = a.Identity
    55  	}
    56  	return json.Marshal(objectMap)
    57  }
    58  
    59  // UnmarshalJSON is the custom unmarshaler for Assignment struct.
    60  func (a *Assignment) UnmarshalJSON(body []byte) error {
    61  	var m map[string]*json.RawMessage
    62  	err := json.Unmarshal(body, &m)
    63  	if err != nil {
    64  		return err
    65  	}
    66  	for k, v := range m {
    67  		switch k {
    68  		case "properties":
    69  			if v != nil {
    70  				var assignmentProperties AssignmentProperties
    71  				err = json.Unmarshal(*v, &assignmentProperties)
    72  				if err != nil {
    73  					return err
    74  				}
    75  				a.AssignmentProperties = &assignmentProperties
    76  			}
    77  		case "id":
    78  			if v != nil {
    79  				var ID string
    80  				err = json.Unmarshal(*v, &ID)
    81  				if err != nil {
    82  					return err
    83  				}
    84  				a.ID = &ID
    85  			}
    86  		case "type":
    87  			if v != nil {
    88  				var typeVar string
    89  				err = json.Unmarshal(*v, &typeVar)
    90  				if err != nil {
    91  					return err
    92  				}
    93  				a.Type = &typeVar
    94  			}
    95  		case "name":
    96  			if v != nil {
    97  				var name string
    98  				err = json.Unmarshal(*v, &name)
    99  				if err != nil {
   100  					return err
   101  				}
   102  				a.Name = &name
   103  			}
   104  		case "sku":
   105  			if v != nil {
   106  				var sku Sku
   107  				err = json.Unmarshal(*v, &sku)
   108  				if err != nil {
   109  					return err
   110  				}
   111  				a.Sku = &sku
   112  			}
   113  		case "location":
   114  			if v != nil {
   115  				var location string
   116  				err = json.Unmarshal(*v, &location)
   117  				if err != nil {
   118  					return err
   119  				}
   120  				a.Location = &location
   121  			}
   122  		case "identity":
   123  			if v != nil {
   124  				var identity Identity
   125  				err = json.Unmarshal(*v, &identity)
   126  				if err != nil {
   127  					return err
   128  				}
   129  				a.Identity = &identity
   130  			}
   131  		}
   132  	}
   133  
   134  	return nil
   135  }
   136  
   137  // AssignmentListResult list of policy assignments.
   138  type AssignmentListResult struct {
   139  	autorest.Response `json:"-"`
   140  	// Value - An array of policy assignments.
   141  	Value *[]Assignment `json:"value,omitempty"`
   142  	// NextLink - The URL to use for getting the next set of results.
   143  	NextLink *string `json:"nextLink,omitempty"`
   144  }
   145  
   146  // AssignmentListResultIterator provides access to a complete listing of Assignment values.
   147  type AssignmentListResultIterator struct {
   148  	i    int
   149  	page AssignmentListResultPage
   150  }
   151  
   152  // NextWithContext advances to the next value.  If there was an error making
   153  // the request the iterator does not advance and the error is returned.
   154  func (iter *AssignmentListResultIterator) NextWithContext(ctx context.Context) (err error) {
   155  	if tracing.IsEnabled() {
   156  		ctx = tracing.StartSpan(ctx, fqdn+"/AssignmentListResultIterator.NextWithContext")
   157  		defer func() {
   158  			sc := -1
   159  			if iter.Response().Response.Response != nil {
   160  				sc = iter.Response().Response.Response.StatusCode
   161  			}
   162  			tracing.EndSpan(ctx, sc, err)
   163  		}()
   164  	}
   165  	iter.i++
   166  	if iter.i < len(iter.page.Values()) {
   167  		return nil
   168  	}
   169  	err = iter.page.NextWithContext(ctx)
   170  	if err != nil {
   171  		iter.i--
   172  		return err
   173  	}
   174  	iter.i = 0
   175  	return nil
   176  }
   177  
   178  // Next advances to the next value.  If there was an error making
   179  // the request the iterator does not advance and the error is returned.
   180  // Deprecated: Use NextWithContext() instead.
   181  func (iter *AssignmentListResultIterator) Next() error {
   182  	return iter.NextWithContext(context.Background())
   183  }
   184  
   185  // NotDone returns true if the enumeration should be started or is not yet complete.
   186  func (iter AssignmentListResultIterator) NotDone() bool {
   187  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
   188  }
   189  
   190  // Response returns the raw server response from the last page request.
   191  func (iter AssignmentListResultIterator) Response() AssignmentListResult {
   192  	return iter.page.Response()
   193  }
   194  
   195  // Value returns the current value or a zero-initialized value if the
   196  // iterator has advanced beyond the end of the collection.
   197  func (iter AssignmentListResultIterator) Value() Assignment {
   198  	if !iter.page.NotDone() {
   199  		return Assignment{}
   200  	}
   201  	return iter.page.Values()[iter.i]
   202  }
   203  
   204  // Creates a new instance of the AssignmentListResultIterator type.
   205  func NewAssignmentListResultIterator(page AssignmentListResultPage) AssignmentListResultIterator {
   206  	return AssignmentListResultIterator{page: page}
   207  }
   208  
   209  // IsEmpty returns true if the ListResult contains no values.
   210  func (alr AssignmentListResult) IsEmpty() bool {
   211  	return alr.Value == nil || len(*alr.Value) == 0
   212  }
   213  
   214  // hasNextLink returns true if the NextLink is not empty.
   215  func (alr AssignmentListResult) hasNextLink() bool {
   216  	return alr.NextLink != nil && len(*alr.NextLink) != 0
   217  }
   218  
   219  // assignmentListResultPreparer prepares a request to retrieve the next set of results.
   220  // It returns nil if no more results exist.
   221  func (alr AssignmentListResult) assignmentListResultPreparer(ctx context.Context) (*http.Request, error) {
   222  	if !alr.hasNextLink() {
   223  		return nil, nil
   224  	}
   225  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   226  		autorest.AsJSON(),
   227  		autorest.AsGet(),
   228  		autorest.WithBaseURL(to.String(alr.NextLink)))
   229  }
   230  
   231  // AssignmentListResultPage contains a page of Assignment values.
   232  type AssignmentListResultPage struct {
   233  	fn  func(context.Context, AssignmentListResult) (AssignmentListResult, error)
   234  	alr AssignmentListResult
   235  }
   236  
   237  // NextWithContext advances to the next page of values.  If there was an error making
   238  // the request the page does not advance and the error is returned.
   239  func (page *AssignmentListResultPage) NextWithContext(ctx context.Context) (err error) {
   240  	if tracing.IsEnabled() {
   241  		ctx = tracing.StartSpan(ctx, fqdn+"/AssignmentListResultPage.NextWithContext")
   242  		defer func() {
   243  			sc := -1
   244  			if page.Response().Response.Response != nil {
   245  				sc = page.Response().Response.Response.StatusCode
   246  			}
   247  			tracing.EndSpan(ctx, sc, err)
   248  		}()
   249  	}
   250  	for {
   251  		next, err := page.fn(ctx, page.alr)
   252  		if err != nil {
   253  			return err
   254  		}
   255  		page.alr = next
   256  		if !next.hasNextLink() || !next.IsEmpty() {
   257  			break
   258  		}
   259  	}
   260  	return nil
   261  }
   262  
   263  // Next advances to the next page of values.  If there was an error making
   264  // the request the page does not advance and the error is returned.
   265  // Deprecated: Use NextWithContext() instead.
   266  func (page *AssignmentListResultPage) Next() error {
   267  	return page.NextWithContext(context.Background())
   268  }
   269  
   270  // NotDone returns true if the page enumeration should be started or is not yet complete.
   271  func (page AssignmentListResultPage) NotDone() bool {
   272  	return !page.alr.IsEmpty()
   273  }
   274  
   275  // Response returns the raw server response from the last page request.
   276  func (page AssignmentListResultPage) Response() AssignmentListResult {
   277  	return page.alr
   278  }
   279  
   280  // Values returns the slice of values for the current page or nil if there are no values.
   281  func (page AssignmentListResultPage) Values() []Assignment {
   282  	if page.alr.IsEmpty() {
   283  		return nil
   284  	}
   285  	return *page.alr.Value
   286  }
   287  
   288  // Creates a new instance of the AssignmentListResultPage type.
   289  func NewAssignmentListResultPage(cur AssignmentListResult, getNextPage func(context.Context, AssignmentListResult) (AssignmentListResult, error)) AssignmentListResultPage {
   290  	return AssignmentListResultPage{
   291  		fn:  getNextPage,
   292  		alr: cur,
   293  	}
   294  }
   295  
   296  // AssignmentProperties the policy assignment properties.
   297  type AssignmentProperties struct {
   298  	// DisplayName - The display name of the policy assignment.
   299  	DisplayName *string `json:"displayName,omitempty"`
   300  	// PolicyDefinitionID - The ID of the policy definition or policy set definition being assigned.
   301  	PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"`
   302  	// Scope - The scope for the policy assignment.
   303  	Scope *string `json:"scope,omitempty"`
   304  	// NotScopes - The policy's excluded scopes.
   305  	NotScopes *[]string `json:"notScopes,omitempty"`
   306  	// Parameters - The parameter values for the assigned policy rule. The keys are the parameter names.
   307  	Parameters map[string]*ParameterValuesValue `json:"parameters"`
   308  	// Description - This message will be part of response in case of policy violation.
   309  	Description *string `json:"description,omitempty"`
   310  	// Metadata - The policy assignment metadata. Metadata is an open ended object and is typically a collection of key value pairs.
   311  	Metadata interface{} `json:"metadata,omitempty"`
   312  	// EnforcementMode - The policy assignment enforcement mode. Possible values are Default and DoNotEnforce. Possible values include: 'Default', 'DoNotEnforce'
   313  	EnforcementMode EnforcementMode `json:"enforcementMode,omitempty"`
   314  }
   315  
   316  // MarshalJSON is the custom marshaler for AssignmentProperties.
   317  func (ap AssignmentProperties) MarshalJSON() ([]byte, error) {
   318  	objectMap := make(map[string]interface{})
   319  	if ap.DisplayName != nil {
   320  		objectMap["displayName"] = ap.DisplayName
   321  	}
   322  	if ap.PolicyDefinitionID != nil {
   323  		objectMap["policyDefinitionId"] = ap.PolicyDefinitionID
   324  	}
   325  	if ap.Scope != nil {
   326  		objectMap["scope"] = ap.Scope
   327  	}
   328  	if ap.NotScopes != nil {
   329  		objectMap["notScopes"] = ap.NotScopes
   330  	}
   331  	if ap.Parameters != nil {
   332  		objectMap["parameters"] = ap.Parameters
   333  	}
   334  	if ap.Description != nil {
   335  		objectMap["description"] = ap.Description
   336  	}
   337  	if ap.Metadata != nil {
   338  		objectMap["metadata"] = ap.Metadata
   339  	}
   340  	if ap.EnforcementMode != "" {
   341  		objectMap["enforcementMode"] = ap.EnforcementMode
   342  	}
   343  	return json.Marshal(objectMap)
   344  }
   345  
   346  // AzureEntityResource the resource model definition for an Azure Resource Manager resource with an etag.
   347  type AzureEntityResource struct {
   348  	// Etag - READ-ONLY; Resource Etag.
   349  	Etag *string `json:"etag,omitempty"`
   350  	// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
   351  	ID *string `json:"id,omitempty"`
   352  	// Name - READ-ONLY; The name of the resource
   353  	Name *string `json:"name,omitempty"`
   354  	// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
   355  	Type *string `json:"type,omitempty"`
   356  }
   357  
   358  // MarshalJSON is the custom marshaler for AzureEntityResource.
   359  func (aer AzureEntityResource) MarshalJSON() ([]byte, error) {
   360  	objectMap := make(map[string]interface{})
   361  	return json.Marshal(objectMap)
   362  }
   363  
   364  // CloudError common error response for all Azure Resource Manager APIs to return error details for failed
   365  // operations. (This also follows the OData error response format.).
   366  type CloudError struct {
   367  	// Error - The error object.
   368  	Error *ErrorDetail `json:"error,omitempty"`
   369  }
   370  
   371  // Definition the policy definition.
   372  type Definition struct {
   373  	autorest.Response `json:"-"`
   374  	// DefinitionProperties - The policy definition properties.
   375  	*DefinitionProperties `json:"properties,omitempty"`
   376  	// ID - READ-ONLY; The ID of the policy definition.
   377  	ID *string `json:"id,omitempty"`
   378  	// Name - READ-ONLY; The name of the policy definition.
   379  	Name *string `json:"name,omitempty"`
   380  	// Type - READ-ONLY; The type of the resource (Microsoft.Authorization/policyDefinitions).
   381  	Type *string `json:"type,omitempty"`
   382  }
   383  
   384  // MarshalJSON is the custom marshaler for Definition.
   385  func (d Definition) MarshalJSON() ([]byte, error) {
   386  	objectMap := make(map[string]interface{})
   387  	if d.DefinitionProperties != nil {
   388  		objectMap["properties"] = d.DefinitionProperties
   389  	}
   390  	return json.Marshal(objectMap)
   391  }
   392  
   393  // UnmarshalJSON is the custom unmarshaler for Definition struct.
   394  func (d *Definition) UnmarshalJSON(body []byte) error {
   395  	var m map[string]*json.RawMessage
   396  	err := json.Unmarshal(body, &m)
   397  	if err != nil {
   398  		return err
   399  	}
   400  	for k, v := range m {
   401  		switch k {
   402  		case "properties":
   403  			if v != nil {
   404  				var definitionProperties DefinitionProperties
   405  				err = json.Unmarshal(*v, &definitionProperties)
   406  				if err != nil {
   407  					return err
   408  				}
   409  				d.DefinitionProperties = &definitionProperties
   410  			}
   411  		case "id":
   412  			if v != nil {
   413  				var ID string
   414  				err = json.Unmarshal(*v, &ID)
   415  				if err != nil {
   416  					return err
   417  				}
   418  				d.ID = &ID
   419  			}
   420  		case "name":
   421  			if v != nil {
   422  				var name string
   423  				err = json.Unmarshal(*v, &name)
   424  				if err != nil {
   425  					return err
   426  				}
   427  				d.Name = &name
   428  			}
   429  		case "type":
   430  			if v != nil {
   431  				var typeVar string
   432  				err = json.Unmarshal(*v, &typeVar)
   433  				if err != nil {
   434  					return err
   435  				}
   436  				d.Type = &typeVar
   437  			}
   438  		}
   439  	}
   440  
   441  	return nil
   442  }
   443  
   444  // DefinitionGroup the policy definition group.
   445  type DefinitionGroup struct {
   446  	// Name - The name of the group.
   447  	Name *string `json:"name,omitempty"`
   448  	// DisplayName - The group's display name.
   449  	DisplayName *string `json:"displayName,omitempty"`
   450  	// Category - The group's category.
   451  	Category *string `json:"category,omitempty"`
   452  	// Description - The group's description.
   453  	Description *string `json:"description,omitempty"`
   454  	// AdditionalMetadataID - A resource ID of a resource that contains additional metadata about the group.
   455  	AdditionalMetadataID *string `json:"additionalMetadataId,omitempty"`
   456  }
   457  
   458  // DefinitionListResult list of policy definitions.
   459  type DefinitionListResult struct {
   460  	autorest.Response `json:"-"`
   461  	// Value - An array of policy definitions.
   462  	Value *[]Definition `json:"value,omitempty"`
   463  	// NextLink - The URL to use for getting the next set of results.
   464  	NextLink *string `json:"nextLink,omitempty"`
   465  }
   466  
   467  // DefinitionListResultIterator provides access to a complete listing of Definition values.
   468  type DefinitionListResultIterator struct {
   469  	i    int
   470  	page DefinitionListResultPage
   471  }
   472  
   473  // NextWithContext advances to the next value.  If there was an error making
   474  // the request the iterator does not advance and the error is returned.
   475  func (iter *DefinitionListResultIterator) NextWithContext(ctx context.Context) (err error) {
   476  	if tracing.IsEnabled() {
   477  		ctx = tracing.StartSpan(ctx, fqdn+"/DefinitionListResultIterator.NextWithContext")
   478  		defer func() {
   479  			sc := -1
   480  			if iter.Response().Response.Response != nil {
   481  				sc = iter.Response().Response.Response.StatusCode
   482  			}
   483  			tracing.EndSpan(ctx, sc, err)
   484  		}()
   485  	}
   486  	iter.i++
   487  	if iter.i < len(iter.page.Values()) {
   488  		return nil
   489  	}
   490  	err = iter.page.NextWithContext(ctx)
   491  	if err != nil {
   492  		iter.i--
   493  		return err
   494  	}
   495  	iter.i = 0
   496  	return nil
   497  }
   498  
   499  // Next advances to the next value.  If there was an error making
   500  // the request the iterator does not advance and the error is returned.
   501  // Deprecated: Use NextWithContext() instead.
   502  func (iter *DefinitionListResultIterator) Next() error {
   503  	return iter.NextWithContext(context.Background())
   504  }
   505  
   506  // NotDone returns true if the enumeration should be started or is not yet complete.
   507  func (iter DefinitionListResultIterator) NotDone() bool {
   508  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
   509  }
   510  
   511  // Response returns the raw server response from the last page request.
   512  func (iter DefinitionListResultIterator) Response() DefinitionListResult {
   513  	return iter.page.Response()
   514  }
   515  
   516  // Value returns the current value or a zero-initialized value if the
   517  // iterator has advanced beyond the end of the collection.
   518  func (iter DefinitionListResultIterator) Value() Definition {
   519  	if !iter.page.NotDone() {
   520  		return Definition{}
   521  	}
   522  	return iter.page.Values()[iter.i]
   523  }
   524  
   525  // Creates a new instance of the DefinitionListResultIterator type.
   526  func NewDefinitionListResultIterator(page DefinitionListResultPage) DefinitionListResultIterator {
   527  	return DefinitionListResultIterator{page: page}
   528  }
   529  
   530  // IsEmpty returns true if the ListResult contains no values.
   531  func (dlr DefinitionListResult) IsEmpty() bool {
   532  	return dlr.Value == nil || len(*dlr.Value) == 0
   533  }
   534  
   535  // hasNextLink returns true if the NextLink is not empty.
   536  func (dlr DefinitionListResult) hasNextLink() bool {
   537  	return dlr.NextLink != nil && len(*dlr.NextLink) != 0
   538  }
   539  
   540  // definitionListResultPreparer prepares a request to retrieve the next set of results.
   541  // It returns nil if no more results exist.
   542  func (dlr DefinitionListResult) definitionListResultPreparer(ctx context.Context) (*http.Request, error) {
   543  	if !dlr.hasNextLink() {
   544  		return nil, nil
   545  	}
   546  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   547  		autorest.AsJSON(),
   548  		autorest.AsGet(),
   549  		autorest.WithBaseURL(to.String(dlr.NextLink)))
   550  }
   551  
   552  // DefinitionListResultPage contains a page of Definition values.
   553  type DefinitionListResultPage struct {
   554  	fn  func(context.Context, DefinitionListResult) (DefinitionListResult, error)
   555  	dlr DefinitionListResult
   556  }
   557  
   558  // NextWithContext advances to the next page of values.  If there was an error making
   559  // the request the page does not advance and the error is returned.
   560  func (page *DefinitionListResultPage) NextWithContext(ctx context.Context) (err error) {
   561  	if tracing.IsEnabled() {
   562  		ctx = tracing.StartSpan(ctx, fqdn+"/DefinitionListResultPage.NextWithContext")
   563  		defer func() {
   564  			sc := -1
   565  			if page.Response().Response.Response != nil {
   566  				sc = page.Response().Response.Response.StatusCode
   567  			}
   568  			tracing.EndSpan(ctx, sc, err)
   569  		}()
   570  	}
   571  	for {
   572  		next, err := page.fn(ctx, page.dlr)
   573  		if err != nil {
   574  			return err
   575  		}
   576  		page.dlr = next
   577  		if !next.hasNextLink() || !next.IsEmpty() {
   578  			break
   579  		}
   580  	}
   581  	return nil
   582  }
   583  
   584  // Next advances to the next page of values.  If there was an error making
   585  // the request the page does not advance and the error is returned.
   586  // Deprecated: Use NextWithContext() instead.
   587  func (page *DefinitionListResultPage) Next() error {
   588  	return page.NextWithContext(context.Background())
   589  }
   590  
   591  // NotDone returns true if the page enumeration should be started or is not yet complete.
   592  func (page DefinitionListResultPage) NotDone() bool {
   593  	return !page.dlr.IsEmpty()
   594  }
   595  
   596  // Response returns the raw server response from the last page request.
   597  func (page DefinitionListResultPage) Response() DefinitionListResult {
   598  	return page.dlr
   599  }
   600  
   601  // Values returns the slice of values for the current page or nil if there are no values.
   602  func (page DefinitionListResultPage) Values() []Definition {
   603  	if page.dlr.IsEmpty() {
   604  		return nil
   605  	}
   606  	return *page.dlr.Value
   607  }
   608  
   609  // Creates a new instance of the DefinitionListResultPage type.
   610  func NewDefinitionListResultPage(cur DefinitionListResult, getNextPage func(context.Context, DefinitionListResult) (DefinitionListResult, error)) DefinitionListResultPage {
   611  	return DefinitionListResultPage{
   612  		fn:  getNextPage,
   613  		dlr: cur,
   614  	}
   615  }
   616  
   617  // DefinitionProperties the policy definition properties.
   618  type DefinitionProperties struct {
   619  	// PolicyType - The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. Possible values include: 'NotSpecified', 'BuiltIn', 'Custom', 'Static'
   620  	PolicyType Type `json:"policyType,omitempty"`
   621  	// Mode - The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data.
   622  	Mode *string `json:"mode,omitempty"`
   623  	// DisplayName - The display name of the policy definition.
   624  	DisplayName *string `json:"displayName,omitempty"`
   625  	// Description - The policy definition description.
   626  	Description *string `json:"description,omitempty"`
   627  	// PolicyRule - The policy rule.
   628  	PolicyRule interface{} `json:"policyRule,omitempty"`
   629  	// Metadata - The policy definition metadata.  Metadata is an open ended object and is typically a collection of key value pairs.
   630  	Metadata interface{} `json:"metadata,omitempty"`
   631  	// Parameters - The parameter definitions for parameters used in the policy rule. The keys are the parameter names.
   632  	Parameters map[string]*ParameterDefinitionsValue `json:"parameters"`
   633  }
   634  
   635  // MarshalJSON is the custom marshaler for DefinitionProperties.
   636  func (dp DefinitionProperties) MarshalJSON() ([]byte, error) {
   637  	objectMap := make(map[string]interface{})
   638  	if dp.PolicyType != "" {
   639  		objectMap["policyType"] = dp.PolicyType
   640  	}
   641  	if dp.Mode != nil {
   642  		objectMap["mode"] = dp.Mode
   643  	}
   644  	if dp.DisplayName != nil {
   645  		objectMap["displayName"] = dp.DisplayName
   646  	}
   647  	if dp.Description != nil {
   648  		objectMap["description"] = dp.Description
   649  	}
   650  	if dp.PolicyRule != nil {
   651  		objectMap["policyRule"] = dp.PolicyRule
   652  	}
   653  	if dp.Metadata != nil {
   654  		objectMap["metadata"] = dp.Metadata
   655  	}
   656  	if dp.Parameters != nil {
   657  		objectMap["parameters"] = dp.Parameters
   658  	}
   659  	return json.Marshal(objectMap)
   660  }
   661  
   662  // DefinitionReference the policy definition reference.
   663  type DefinitionReference struct {
   664  	// PolicyDefinitionID - The ID of the policy definition or policy set definition.
   665  	PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"`
   666  	// Parameters - The parameter values for the referenced policy rule. The keys are the parameter names.
   667  	Parameters map[string]*ParameterValuesValue `json:"parameters"`
   668  	// PolicyDefinitionReferenceID - A unique id (within the policy set definition) for this policy definition reference.
   669  	PolicyDefinitionReferenceID *string `json:"policyDefinitionReferenceId,omitempty"`
   670  	// GroupNames - The name of the groups that this policy definition reference belongs to.
   671  	GroupNames *[]string `json:"groupNames,omitempty"`
   672  }
   673  
   674  // MarshalJSON is the custom marshaler for DefinitionReference.
   675  func (dr DefinitionReference) MarshalJSON() ([]byte, error) {
   676  	objectMap := make(map[string]interface{})
   677  	if dr.PolicyDefinitionID != nil {
   678  		objectMap["policyDefinitionId"] = dr.PolicyDefinitionID
   679  	}
   680  	if dr.Parameters != nil {
   681  		objectMap["parameters"] = dr.Parameters
   682  	}
   683  	if dr.PolicyDefinitionReferenceID != nil {
   684  		objectMap["policyDefinitionReferenceId"] = dr.PolicyDefinitionReferenceID
   685  	}
   686  	if dr.GroupNames != nil {
   687  		objectMap["groupNames"] = dr.GroupNames
   688  	}
   689  	return json.Marshal(objectMap)
   690  }
   691  
   692  // ErrorAdditionalInfo the resource management error additional info.
   693  type ErrorAdditionalInfo struct {
   694  	// Type - READ-ONLY; The additional info type.
   695  	Type *string `json:"type,omitempty"`
   696  	// Info - READ-ONLY; The additional info.
   697  	Info interface{} `json:"info,omitempty"`
   698  }
   699  
   700  // MarshalJSON is the custom marshaler for ErrorAdditionalInfo.
   701  func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) {
   702  	objectMap := make(map[string]interface{})
   703  	return json.Marshal(objectMap)
   704  }
   705  
   706  // ErrorDetail the error detail.
   707  type ErrorDetail struct {
   708  	// Code - READ-ONLY; The error code.
   709  	Code *string `json:"code,omitempty"`
   710  	// Message - READ-ONLY; The error message.
   711  	Message *string `json:"message,omitempty"`
   712  	// Target - READ-ONLY; The error target.
   713  	Target *string `json:"target,omitempty"`
   714  	// Details - READ-ONLY; The error details.
   715  	Details *[]ErrorDetail `json:"details,omitempty"`
   716  	// AdditionalInfo - READ-ONLY; The error additional info.
   717  	AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"`
   718  }
   719  
   720  // MarshalJSON is the custom marshaler for ErrorDetail.
   721  func (ed ErrorDetail) MarshalJSON() ([]byte, error) {
   722  	objectMap := make(map[string]interface{})
   723  	return json.Marshal(objectMap)
   724  }
   725  
   726  // Exemption the policy exemption.
   727  type Exemption struct {
   728  	autorest.Response `json:"-"`
   729  	// ExemptionProperties - Properties for the policy exemption.
   730  	*ExemptionProperties `json:"properties,omitempty"`
   731  	// SystemData - READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information.
   732  	SystemData *SystemData `json:"systemData,omitempty"`
   733  	// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
   734  	ID *string `json:"id,omitempty"`
   735  	// Name - READ-ONLY; The name of the resource
   736  	Name *string `json:"name,omitempty"`
   737  	// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
   738  	Type *string `json:"type,omitempty"`
   739  }
   740  
   741  // MarshalJSON is the custom marshaler for Exemption.
   742  func (e Exemption) MarshalJSON() ([]byte, error) {
   743  	objectMap := make(map[string]interface{})
   744  	if e.ExemptionProperties != nil {
   745  		objectMap["properties"] = e.ExemptionProperties
   746  	}
   747  	return json.Marshal(objectMap)
   748  }
   749  
   750  // UnmarshalJSON is the custom unmarshaler for Exemption struct.
   751  func (e *Exemption) UnmarshalJSON(body []byte) error {
   752  	var m map[string]*json.RawMessage
   753  	err := json.Unmarshal(body, &m)
   754  	if err != nil {
   755  		return err
   756  	}
   757  	for k, v := range m {
   758  		switch k {
   759  		case "properties":
   760  			if v != nil {
   761  				var exemptionProperties ExemptionProperties
   762  				err = json.Unmarshal(*v, &exemptionProperties)
   763  				if err != nil {
   764  					return err
   765  				}
   766  				e.ExemptionProperties = &exemptionProperties
   767  			}
   768  		case "systemData":
   769  			if v != nil {
   770  				var systemData SystemData
   771  				err = json.Unmarshal(*v, &systemData)
   772  				if err != nil {
   773  					return err
   774  				}
   775  				e.SystemData = &systemData
   776  			}
   777  		case "id":
   778  			if v != nil {
   779  				var ID string
   780  				err = json.Unmarshal(*v, &ID)
   781  				if err != nil {
   782  					return err
   783  				}
   784  				e.ID = &ID
   785  			}
   786  		case "name":
   787  			if v != nil {
   788  				var name string
   789  				err = json.Unmarshal(*v, &name)
   790  				if err != nil {
   791  					return err
   792  				}
   793  				e.Name = &name
   794  			}
   795  		case "type":
   796  			if v != nil {
   797  				var typeVar string
   798  				err = json.Unmarshal(*v, &typeVar)
   799  				if err != nil {
   800  					return err
   801  				}
   802  				e.Type = &typeVar
   803  			}
   804  		}
   805  	}
   806  
   807  	return nil
   808  }
   809  
   810  // ExemptionListResult list of policy exemptions.
   811  type ExemptionListResult struct {
   812  	autorest.Response `json:"-"`
   813  	// Value - An array of policy exemptions.
   814  	Value *[]Exemption `json:"value,omitempty"`
   815  	// NextLink - READ-ONLY; The URL to use for getting the next set of results.
   816  	NextLink *string `json:"nextLink,omitempty"`
   817  }
   818  
   819  // MarshalJSON is the custom marshaler for ExemptionListResult.
   820  func (elr ExemptionListResult) MarshalJSON() ([]byte, error) {
   821  	objectMap := make(map[string]interface{})
   822  	if elr.Value != nil {
   823  		objectMap["value"] = elr.Value
   824  	}
   825  	return json.Marshal(objectMap)
   826  }
   827  
   828  // ExemptionListResultIterator provides access to a complete listing of Exemption values.
   829  type ExemptionListResultIterator struct {
   830  	i    int
   831  	page ExemptionListResultPage
   832  }
   833  
   834  // NextWithContext advances to the next value.  If there was an error making
   835  // the request the iterator does not advance and the error is returned.
   836  func (iter *ExemptionListResultIterator) NextWithContext(ctx context.Context) (err error) {
   837  	if tracing.IsEnabled() {
   838  		ctx = tracing.StartSpan(ctx, fqdn+"/ExemptionListResultIterator.NextWithContext")
   839  		defer func() {
   840  			sc := -1
   841  			if iter.Response().Response.Response != nil {
   842  				sc = iter.Response().Response.Response.StatusCode
   843  			}
   844  			tracing.EndSpan(ctx, sc, err)
   845  		}()
   846  	}
   847  	iter.i++
   848  	if iter.i < len(iter.page.Values()) {
   849  		return nil
   850  	}
   851  	err = iter.page.NextWithContext(ctx)
   852  	if err != nil {
   853  		iter.i--
   854  		return err
   855  	}
   856  	iter.i = 0
   857  	return nil
   858  }
   859  
   860  // Next advances to the next value.  If there was an error making
   861  // the request the iterator does not advance and the error is returned.
   862  // Deprecated: Use NextWithContext() instead.
   863  func (iter *ExemptionListResultIterator) Next() error {
   864  	return iter.NextWithContext(context.Background())
   865  }
   866  
   867  // NotDone returns true if the enumeration should be started or is not yet complete.
   868  func (iter ExemptionListResultIterator) NotDone() bool {
   869  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
   870  }
   871  
   872  // Response returns the raw server response from the last page request.
   873  func (iter ExemptionListResultIterator) Response() ExemptionListResult {
   874  	return iter.page.Response()
   875  }
   876  
   877  // Value returns the current value or a zero-initialized value if the
   878  // iterator has advanced beyond the end of the collection.
   879  func (iter ExemptionListResultIterator) Value() Exemption {
   880  	if !iter.page.NotDone() {
   881  		return Exemption{}
   882  	}
   883  	return iter.page.Values()[iter.i]
   884  }
   885  
   886  // Creates a new instance of the ExemptionListResultIterator type.
   887  func NewExemptionListResultIterator(page ExemptionListResultPage) ExemptionListResultIterator {
   888  	return ExemptionListResultIterator{page: page}
   889  }
   890  
   891  // IsEmpty returns true if the ListResult contains no values.
   892  func (elr ExemptionListResult) IsEmpty() bool {
   893  	return elr.Value == nil || len(*elr.Value) == 0
   894  }
   895  
   896  // hasNextLink returns true if the NextLink is not empty.
   897  func (elr ExemptionListResult) hasNextLink() bool {
   898  	return elr.NextLink != nil && len(*elr.NextLink) != 0
   899  }
   900  
   901  // exemptionListResultPreparer prepares a request to retrieve the next set of results.
   902  // It returns nil if no more results exist.
   903  func (elr ExemptionListResult) exemptionListResultPreparer(ctx context.Context) (*http.Request, error) {
   904  	if !elr.hasNextLink() {
   905  		return nil, nil
   906  	}
   907  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   908  		autorest.AsJSON(),
   909  		autorest.AsGet(),
   910  		autorest.WithBaseURL(to.String(elr.NextLink)))
   911  }
   912  
   913  // ExemptionListResultPage contains a page of Exemption values.
   914  type ExemptionListResultPage struct {
   915  	fn  func(context.Context, ExemptionListResult) (ExemptionListResult, error)
   916  	elr ExemptionListResult
   917  }
   918  
   919  // NextWithContext advances to the next page of values.  If there was an error making
   920  // the request the page does not advance and the error is returned.
   921  func (page *ExemptionListResultPage) NextWithContext(ctx context.Context) (err error) {
   922  	if tracing.IsEnabled() {
   923  		ctx = tracing.StartSpan(ctx, fqdn+"/ExemptionListResultPage.NextWithContext")
   924  		defer func() {
   925  			sc := -1
   926  			if page.Response().Response.Response != nil {
   927  				sc = page.Response().Response.Response.StatusCode
   928  			}
   929  			tracing.EndSpan(ctx, sc, err)
   930  		}()
   931  	}
   932  	for {
   933  		next, err := page.fn(ctx, page.elr)
   934  		if err != nil {
   935  			return err
   936  		}
   937  		page.elr = next
   938  		if !next.hasNextLink() || !next.IsEmpty() {
   939  			break
   940  		}
   941  	}
   942  	return nil
   943  }
   944  
   945  // Next advances to the next page of values.  If there was an error making
   946  // the request the page does not advance and the error is returned.
   947  // Deprecated: Use NextWithContext() instead.
   948  func (page *ExemptionListResultPage) Next() error {
   949  	return page.NextWithContext(context.Background())
   950  }
   951  
   952  // NotDone returns true if the page enumeration should be started or is not yet complete.
   953  func (page ExemptionListResultPage) NotDone() bool {
   954  	return !page.elr.IsEmpty()
   955  }
   956  
   957  // Response returns the raw server response from the last page request.
   958  func (page ExemptionListResultPage) Response() ExemptionListResult {
   959  	return page.elr
   960  }
   961  
   962  // Values returns the slice of values for the current page or nil if there are no values.
   963  func (page ExemptionListResultPage) Values() []Exemption {
   964  	if page.elr.IsEmpty() {
   965  		return nil
   966  	}
   967  	return *page.elr.Value
   968  }
   969  
   970  // Creates a new instance of the ExemptionListResultPage type.
   971  func NewExemptionListResultPage(cur ExemptionListResult, getNextPage func(context.Context, ExemptionListResult) (ExemptionListResult, error)) ExemptionListResultPage {
   972  	return ExemptionListResultPage{
   973  		fn:  getNextPage,
   974  		elr: cur,
   975  	}
   976  }
   977  
   978  // ExemptionProperties the policy exemption properties.
   979  type ExemptionProperties struct {
   980  	// PolicyAssignmentID - The ID of the policy assignment that is being exempted.
   981  	PolicyAssignmentID *string `json:"policyAssignmentId,omitempty"`
   982  	// PolicyDefinitionReferenceIds - The policy definition reference ID list when the associated policy assignment is an assignment of a policy set definition.
   983  	PolicyDefinitionReferenceIds *[]string `json:"policyDefinitionReferenceIds,omitempty"`
   984  	// ExemptionCategory - The policy exemption category. Possible values are Waiver and Mitigated. Possible values include: 'Waiver', 'Mitigated'
   985  	ExemptionCategory ExemptionCategory `json:"exemptionCategory,omitempty"`
   986  	// ExpiresOn - The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) of the policy exemption.
   987  	ExpiresOn *date.Time `json:"expiresOn,omitempty"`
   988  	// DisplayName - The display name of the policy exemption.
   989  	DisplayName *string `json:"displayName,omitempty"`
   990  	// Description - The description of the policy exemption.
   991  	Description *string `json:"description,omitempty"`
   992  	// Metadata - The policy exemption metadata. Metadata is an open ended object and is typically a collection of key value pairs.
   993  	Metadata interface{} `json:"metadata,omitempty"`
   994  }
   995  
   996  // Identity identity for the resource.
   997  type Identity struct {
   998  	// PrincipalID - READ-ONLY; The principal ID of the resource identity.
   999  	PrincipalID *string `json:"principalId,omitempty"`
  1000  	// TenantID - READ-ONLY; The tenant ID of the resource identity.
  1001  	TenantID *string `json:"tenantId,omitempty"`
  1002  	// Type - The identity type. This is the only required field when adding a system assigned identity to a resource. Possible values include: 'SystemAssigned', 'None'
  1003  	Type ResourceIdentityType `json:"type,omitempty"`
  1004  }
  1005  
  1006  // MarshalJSON is the custom marshaler for Identity.
  1007  func (i Identity) MarshalJSON() ([]byte, error) {
  1008  	objectMap := make(map[string]interface{})
  1009  	if i.Type != "" {
  1010  		objectMap["type"] = i.Type
  1011  	}
  1012  	return json.Marshal(objectMap)
  1013  }
  1014  
  1015  // ParameterDefinitionsValue the definition of a parameter that can be provided to the policy.
  1016  type ParameterDefinitionsValue struct {
  1017  	// Type - The data type of the parameter. Possible values include: 'String', 'Array', 'Object', 'Boolean', 'Integer', 'Float', 'DateTime'
  1018  	Type ParameterType `json:"type,omitempty"`
  1019  	// AllowedValues - The allowed values for the parameter.
  1020  	AllowedValues *[]interface{} `json:"allowedValues,omitempty"`
  1021  	// DefaultValue - The default value for the parameter if no value is provided.
  1022  	DefaultValue interface{} `json:"defaultValue,omitempty"`
  1023  	// Metadata - General metadata for the parameter.
  1024  	Metadata *ParameterDefinitionsValueMetadata `json:"metadata,omitempty"`
  1025  }
  1026  
  1027  // ParameterDefinitionsValueMetadata general metadata for the parameter.
  1028  type ParameterDefinitionsValueMetadata struct {
  1029  	// AdditionalProperties - Unmatched properties from the message are deserialized this collection
  1030  	AdditionalProperties map[string]interface{} `json:""`
  1031  	// DisplayName - The display name for the parameter.
  1032  	DisplayName *string `json:"displayName,omitempty"`
  1033  	// Description - The description of the parameter.
  1034  	Description *string `json:"description,omitempty"`
  1035  }
  1036  
  1037  // MarshalJSON is the custom marshaler for ParameterDefinitionsValueMetadata.
  1038  func (pdv ParameterDefinitionsValueMetadata) MarshalJSON() ([]byte, error) {
  1039  	objectMap := make(map[string]interface{})
  1040  	if pdv.DisplayName != nil {
  1041  		objectMap["displayName"] = pdv.DisplayName
  1042  	}
  1043  	if pdv.Description != nil {
  1044  		objectMap["description"] = pdv.Description
  1045  	}
  1046  	for k, v := range pdv.AdditionalProperties {
  1047  		objectMap[k] = v
  1048  	}
  1049  	return json.Marshal(objectMap)
  1050  }
  1051  
  1052  // UnmarshalJSON is the custom unmarshaler for ParameterDefinitionsValueMetadata struct.
  1053  func (pdv *ParameterDefinitionsValueMetadata) UnmarshalJSON(body []byte) error {
  1054  	var m map[string]*json.RawMessage
  1055  	err := json.Unmarshal(body, &m)
  1056  	if err != nil {
  1057  		return err
  1058  	}
  1059  	for k, v := range m {
  1060  		switch k {
  1061  		default:
  1062  			if v != nil {
  1063  				var additionalProperties interface{}
  1064  				err = json.Unmarshal(*v, &additionalProperties)
  1065  				if err != nil {
  1066  					return err
  1067  				}
  1068  				if pdv.AdditionalProperties == nil {
  1069  					pdv.AdditionalProperties = make(map[string]interface{})
  1070  				}
  1071  				pdv.AdditionalProperties[k] = additionalProperties
  1072  			}
  1073  		case "displayName":
  1074  			if v != nil {
  1075  				var displayName string
  1076  				err = json.Unmarshal(*v, &displayName)
  1077  				if err != nil {
  1078  					return err
  1079  				}
  1080  				pdv.DisplayName = &displayName
  1081  			}
  1082  		case "description":
  1083  			if v != nil {
  1084  				var description string
  1085  				err = json.Unmarshal(*v, &description)
  1086  				if err != nil {
  1087  					return err
  1088  				}
  1089  				pdv.Description = &description
  1090  			}
  1091  		}
  1092  	}
  1093  
  1094  	return nil
  1095  }
  1096  
  1097  // ParameterValuesValue the value of a parameter.
  1098  type ParameterValuesValue struct {
  1099  	// Value - The value of the parameter.
  1100  	Value interface{} `json:"value,omitempty"`
  1101  }
  1102  
  1103  // ProxyResource the resource model definition for an Azure Resource Manager proxy resource. It will have
  1104  // everything other than required location and tags
  1105  type ProxyResource struct {
  1106  	// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
  1107  	ID *string `json:"id,omitempty"`
  1108  	// Name - READ-ONLY; The name of the resource
  1109  	Name *string `json:"name,omitempty"`
  1110  	// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
  1111  	Type *string `json:"type,omitempty"`
  1112  }
  1113  
  1114  // MarshalJSON is the custom marshaler for ProxyResource.
  1115  func (pr ProxyResource) MarshalJSON() ([]byte, error) {
  1116  	objectMap := make(map[string]interface{})
  1117  	return json.Marshal(objectMap)
  1118  }
  1119  
  1120  // Resource common fields that are returned in the response for all Azure Resource Manager resources
  1121  type Resource struct {
  1122  	// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
  1123  	ID *string `json:"id,omitempty"`
  1124  	// Name - READ-ONLY; The name of the resource
  1125  	Name *string `json:"name,omitempty"`
  1126  	// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
  1127  	Type *string `json:"type,omitempty"`
  1128  }
  1129  
  1130  // MarshalJSON is the custom marshaler for Resource.
  1131  func (r Resource) MarshalJSON() ([]byte, error) {
  1132  	objectMap := make(map[string]interface{})
  1133  	return json.Marshal(objectMap)
  1134  }
  1135  
  1136  // SetDefinition the policy set definition.
  1137  type SetDefinition struct {
  1138  	autorest.Response `json:"-"`
  1139  	// SetDefinitionProperties - The policy definition properties.
  1140  	*SetDefinitionProperties `json:"properties,omitempty"`
  1141  	// ID - READ-ONLY; The ID of the policy set definition.
  1142  	ID *string `json:"id,omitempty"`
  1143  	// Name - READ-ONLY; The name of the policy set definition.
  1144  	Name *string `json:"name,omitempty"`
  1145  	// Type - READ-ONLY; The type of the resource (Microsoft.Authorization/policySetDefinitions).
  1146  	Type *string `json:"type,omitempty"`
  1147  }
  1148  
  1149  // MarshalJSON is the custom marshaler for SetDefinition.
  1150  func (sd SetDefinition) MarshalJSON() ([]byte, error) {
  1151  	objectMap := make(map[string]interface{})
  1152  	if sd.SetDefinitionProperties != nil {
  1153  		objectMap["properties"] = sd.SetDefinitionProperties
  1154  	}
  1155  	return json.Marshal(objectMap)
  1156  }
  1157  
  1158  // UnmarshalJSON is the custom unmarshaler for SetDefinition struct.
  1159  func (sd *SetDefinition) UnmarshalJSON(body []byte) error {
  1160  	var m map[string]*json.RawMessage
  1161  	err := json.Unmarshal(body, &m)
  1162  	if err != nil {
  1163  		return err
  1164  	}
  1165  	for k, v := range m {
  1166  		switch k {
  1167  		case "properties":
  1168  			if v != nil {
  1169  				var setDefinitionProperties SetDefinitionProperties
  1170  				err = json.Unmarshal(*v, &setDefinitionProperties)
  1171  				if err != nil {
  1172  					return err
  1173  				}
  1174  				sd.SetDefinitionProperties = &setDefinitionProperties
  1175  			}
  1176  		case "id":
  1177  			if v != nil {
  1178  				var ID string
  1179  				err = json.Unmarshal(*v, &ID)
  1180  				if err != nil {
  1181  					return err
  1182  				}
  1183  				sd.ID = &ID
  1184  			}
  1185  		case "name":
  1186  			if v != nil {
  1187  				var name string
  1188  				err = json.Unmarshal(*v, &name)
  1189  				if err != nil {
  1190  					return err
  1191  				}
  1192  				sd.Name = &name
  1193  			}
  1194  		case "type":
  1195  			if v != nil {
  1196  				var typeVar string
  1197  				err = json.Unmarshal(*v, &typeVar)
  1198  				if err != nil {
  1199  					return err
  1200  				}
  1201  				sd.Type = &typeVar
  1202  			}
  1203  		}
  1204  	}
  1205  
  1206  	return nil
  1207  }
  1208  
  1209  // SetDefinitionListResult list of policy set definitions.
  1210  type SetDefinitionListResult struct {
  1211  	autorest.Response `json:"-"`
  1212  	// Value - An array of policy set definitions.
  1213  	Value *[]SetDefinition `json:"value,omitempty"`
  1214  	// NextLink - The URL to use for getting the next set of results.
  1215  	NextLink *string `json:"nextLink,omitempty"`
  1216  }
  1217  
  1218  // SetDefinitionListResultIterator provides access to a complete listing of SetDefinition values.
  1219  type SetDefinitionListResultIterator struct {
  1220  	i    int
  1221  	page SetDefinitionListResultPage
  1222  }
  1223  
  1224  // NextWithContext advances to the next value.  If there was an error making
  1225  // the request the iterator does not advance and the error is returned.
  1226  func (iter *SetDefinitionListResultIterator) NextWithContext(ctx context.Context) (err error) {
  1227  	if tracing.IsEnabled() {
  1228  		ctx = tracing.StartSpan(ctx, fqdn+"/SetDefinitionListResultIterator.NextWithContext")
  1229  		defer func() {
  1230  			sc := -1
  1231  			if iter.Response().Response.Response != nil {
  1232  				sc = iter.Response().Response.Response.StatusCode
  1233  			}
  1234  			tracing.EndSpan(ctx, sc, err)
  1235  		}()
  1236  	}
  1237  	iter.i++
  1238  	if iter.i < len(iter.page.Values()) {
  1239  		return nil
  1240  	}
  1241  	err = iter.page.NextWithContext(ctx)
  1242  	if err != nil {
  1243  		iter.i--
  1244  		return err
  1245  	}
  1246  	iter.i = 0
  1247  	return nil
  1248  }
  1249  
  1250  // Next advances to the next value.  If there was an error making
  1251  // the request the iterator does not advance and the error is returned.
  1252  // Deprecated: Use NextWithContext() instead.
  1253  func (iter *SetDefinitionListResultIterator) Next() error {
  1254  	return iter.NextWithContext(context.Background())
  1255  }
  1256  
  1257  // NotDone returns true if the enumeration should be started or is not yet complete.
  1258  func (iter SetDefinitionListResultIterator) NotDone() bool {
  1259  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
  1260  }
  1261  
  1262  // Response returns the raw server response from the last page request.
  1263  func (iter SetDefinitionListResultIterator) Response() SetDefinitionListResult {
  1264  	return iter.page.Response()
  1265  }
  1266  
  1267  // Value returns the current value or a zero-initialized value if the
  1268  // iterator has advanced beyond the end of the collection.
  1269  func (iter SetDefinitionListResultIterator) Value() SetDefinition {
  1270  	if !iter.page.NotDone() {
  1271  		return SetDefinition{}
  1272  	}
  1273  	return iter.page.Values()[iter.i]
  1274  }
  1275  
  1276  // Creates a new instance of the SetDefinitionListResultIterator type.
  1277  func NewSetDefinitionListResultIterator(page SetDefinitionListResultPage) SetDefinitionListResultIterator {
  1278  	return SetDefinitionListResultIterator{page: page}
  1279  }
  1280  
  1281  // IsEmpty returns true if the ListResult contains no values.
  1282  func (sdlr SetDefinitionListResult) IsEmpty() bool {
  1283  	return sdlr.Value == nil || len(*sdlr.Value) == 0
  1284  }
  1285  
  1286  // hasNextLink returns true if the NextLink is not empty.
  1287  func (sdlr SetDefinitionListResult) hasNextLink() bool {
  1288  	return sdlr.NextLink != nil && len(*sdlr.NextLink) != 0
  1289  }
  1290  
  1291  // setDefinitionListResultPreparer prepares a request to retrieve the next set of results.
  1292  // It returns nil if no more results exist.
  1293  func (sdlr SetDefinitionListResult) setDefinitionListResultPreparer(ctx context.Context) (*http.Request, error) {
  1294  	if !sdlr.hasNextLink() {
  1295  		return nil, nil
  1296  	}
  1297  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
  1298  		autorest.AsJSON(),
  1299  		autorest.AsGet(),
  1300  		autorest.WithBaseURL(to.String(sdlr.NextLink)))
  1301  }
  1302  
  1303  // SetDefinitionListResultPage contains a page of SetDefinition values.
  1304  type SetDefinitionListResultPage struct {
  1305  	fn   func(context.Context, SetDefinitionListResult) (SetDefinitionListResult, error)
  1306  	sdlr SetDefinitionListResult
  1307  }
  1308  
  1309  // NextWithContext advances to the next page of values.  If there was an error making
  1310  // the request the page does not advance and the error is returned.
  1311  func (page *SetDefinitionListResultPage) NextWithContext(ctx context.Context) (err error) {
  1312  	if tracing.IsEnabled() {
  1313  		ctx = tracing.StartSpan(ctx, fqdn+"/SetDefinitionListResultPage.NextWithContext")
  1314  		defer func() {
  1315  			sc := -1
  1316  			if page.Response().Response.Response != nil {
  1317  				sc = page.Response().Response.Response.StatusCode
  1318  			}
  1319  			tracing.EndSpan(ctx, sc, err)
  1320  		}()
  1321  	}
  1322  	for {
  1323  		next, err := page.fn(ctx, page.sdlr)
  1324  		if err != nil {
  1325  			return err
  1326  		}
  1327  		page.sdlr = next
  1328  		if !next.hasNextLink() || !next.IsEmpty() {
  1329  			break
  1330  		}
  1331  	}
  1332  	return nil
  1333  }
  1334  
  1335  // Next advances to the next page of values.  If there was an error making
  1336  // the request the page does not advance and the error is returned.
  1337  // Deprecated: Use NextWithContext() instead.
  1338  func (page *SetDefinitionListResultPage) Next() error {
  1339  	return page.NextWithContext(context.Background())
  1340  }
  1341  
  1342  // NotDone returns true if the page enumeration should be started or is not yet complete.
  1343  func (page SetDefinitionListResultPage) NotDone() bool {
  1344  	return !page.sdlr.IsEmpty()
  1345  }
  1346  
  1347  // Response returns the raw server response from the last page request.
  1348  func (page SetDefinitionListResultPage) Response() SetDefinitionListResult {
  1349  	return page.sdlr
  1350  }
  1351  
  1352  // Values returns the slice of values for the current page or nil if there are no values.
  1353  func (page SetDefinitionListResultPage) Values() []SetDefinition {
  1354  	if page.sdlr.IsEmpty() {
  1355  		return nil
  1356  	}
  1357  	return *page.sdlr.Value
  1358  }
  1359  
  1360  // Creates a new instance of the SetDefinitionListResultPage type.
  1361  func NewSetDefinitionListResultPage(cur SetDefinitionListResult, getNextPage func(context.Context, SetDefinitionListResult) (SetDefinitionListResult, error)) SetDefinitionListResultPage {
  1362  	return SetDefinitionListResultPage{
  1363  		fn:   getNextPage,
  1364  		sdlr: cur,
  1365  	}
  1366  }
  1367  
  1368  // SetDefinitionProperties the policy set definition properties.
  1369  type SetDefinitionProperties struct {
  1370  	// PolicyType - The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. Possible values include: 'NotSpecified', 'BuiltIn', 'Custom', 'Static'
  1371  	PolicyType Type `json:"policyType,omitempty"`
  1372  	// DisplayName - The display name of the policy set definition.
  1373  	DisplayName *string `json:"displayName,omitempty"`
  1374  	// Description - The policy set definition description.
  1375  	Description *string `json:"description,omitempty"`
  1376  	// Metadata - The policy set definition metadata.  Metadata is an open ended object and is typically a collection of key value pairs.
  1377  	Metadata interface{} `json:"metadata,omitempty"`
  1378  	// Parameters - The policy set definition parameters that can be used in policy definition references.
  1379  	Parameters map[string]*ParameterDefinitionsValue `json:"parameters"`
  1380  	// PolicyDefinitions - An array of policy definition references.
  1381  	PolicyDefinitions *[]DefinitionReference `json:"policyDefinitions,omitempty"`
  1382  	// PolicyDefinitionGroups - The metadata describing groups of policy definition references within the policy set definition.
  1383  	PolicyDefinitionGroups *[]DefinitionGroup `json:"policyDefinitionGroups,omitempty"`
  1384  }
  1385  
  1386  // MarshalJSON is the custom marshaler for SetDefinitionProperties.
  1387  func (sdp SetDefinitionProperties) MarshalJSON() ([]byte, error) {
  1388  	objectMap := make(map[string]interface{})
  1389  	if sdp.PolicyType != "" {
  1390  		objectMap["policyType"] = sdp.PolicyType
  1391  	}
  1392  	if sdp.DisplayName != nil {
  1393  		objectMap["displayName"] = sdp.DisplayName
  1394  	}
  1395  	if sdp.Description != nil {
  1396  		objectMap["description"] = sdp.Description
  1397  	}
  1398  	if sdp.Metadata != nil {
  1399  		objectMap["metadata"] = sdp.Metadata
  1400  	}
  1401  	if sdp.Parameters != nil {
  1402  		objectMap["parameters"] = sdp.Parameters
  1403  	}
  1404  	if sdp.PolicyDefinitions != nil {
  1405  		objectMap["policyDefinitions"] = sdp.PolicyDefinitions
  1406  	}
  1407  	if sdp.PolicyDefinitionGroups != nil {
  1408  		objectMap["policyDefinitionGroups"] = sdp.PolicyDefinitionGroups
  1409  	}
  1410  	return json.Marshal(objectMap)
  1411  }
  1412  
  1413  // Sku the policy sku. This property is optional, obsolete, and will be ignored.
  1414  type Sku struct {
  1415  	// Name - The name of the policy sku. Possible values are A0 and A1.
  1416  	Name *string `json:"name,omitempty"`
  1417  	// Tier - The policy sku tier. Possible values are Free and Standard.
  1418  	Tier *string `json:"tier,omitempty"`
  1419  }
  1420  
  1421  // SystemData metadata pertaining to creation and last modification of the resource.
  1422  type SystemData struct {
  1423  	// CreatedBy - The identity that created the resource.
  1424  	CreatedBy *string `json:"createdBy,omitempty"`
  1425  	// CreatedByType - The type of identity that created the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key'
  1426  	CreatedByType CreatedByType `json:"createdByType,omitempty"`
  1427  	// CreatedAt - The timestamp of resource creation (UTC).
  1428  	CreatedAt *date.Time `json:"createdAt,omitempty"`
  1429  	// LastModifiedBy - The identity that last modified the resource.
  1430  	LastModifiedBy *string `json:"lastModifiedBy,omitempty"`
  1431  	// LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key'
  1432  	LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"`
  1433  	// LastModifiedAt - The type of identity that last modified the resource.
  1434  	LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"`
  1435  }
  1436  
  1437  // TrackedResource the resource model definition for an Azure Resource Manager tracked top level resource
  1438  type TrackedResource struct {
  1439  	// Tags - Resource tags.
  1440  	Tags map[string]*string `json:"tags"`
  1441  	// Location - The geo-location where the resource lives
  1442  	Location *string `json:"location,omitempty"`
  1443  	// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
  1444  	ID *string `json:"id,omitempty"`
  1445  	// Name - READ-ONLY; The name of the resource
  1446  	Name *string `json:"name,omitempty"`
  1447  	// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
  1448  	Type *string `json:"type,omitempty"`
  1449  }
  1450  
  1451  // MarshalJSON is the custom marshaler for TrackedResource.
  1452  func (tr TrackedResource) MarshalJSON() ([]byte, error) {
  1453  	objectMap := make(map[string]interface{})
  1454  	if tr.Tags != nil {
  1455  		objectMap["tags"] = tr.Tags
  1456  	}
  1457  	if tr.Location != nil {
  1458  		objectMap["location"] = tr.Location
  1459  	}
  1460  	return json.Marshal(objectMap)
  1461  }
  1462  

View as plain text