...

Source file src/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-03-01/policy/models.go

Documentation: github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-03-01/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/to"
    14  	"github.com/Azure/go-autorest/tracing"
    15  	"net/http"
    16  )
    17  
    18  // The package's fully qualified name.
    19  const fqdn = "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-03-01/policy"
    20  
    21  // Assignment the policy assignment.
    22  type Assignment struct {
    23  	autorest.Response `json:"-"`
    24  	// AssignmentProperties - Properties for the policy assignment.
    25  	*AssignmentProperties `json:"properties,omitempty"`
    26  	// ID - READ-ONLY; The ID of the policy assignment.
    27  	ID *string `json:"id,omitempty"`
    28  	// Type - READ-ONLY; The type of the policy assignment.
    29  	Type *string `json:"type,omitempty"`
    30  	// Name - READ-ONLY; The name of the policy assignment.
    31  	Name *string `json:"name,omitempty"`
    32  	// Sku - The policy sku. This property is optional, obsolete, and will be ignored.
    33  	Sku *Sku `json:"sku,omitempty"`
    34  }
    35  
    36  // MarshalJSON is the custom marshaler for Assignment.
    37  func (a Assignment) MarshalJSON() ([]byte, error) {
    38  	objectMap := make(map[string]interface{})
    39  	if a.AssignmentProperties != nil {
    40  		objectMap["properties"] = a.AssignmentProperties
    41  	}
    42  	if a.Sku != nil {
    43  		objectMap["sku"] = a.Sku
    44  	}
    45  	return json.Marshal(objectMap)
    46  }
    47  
    48  // UnmarshalJSON is the custom unmarshaler for Assignment struct.
    49  func (a *Assignment) UnmarshalJSON(body []byte) error {
    50  	var m map[string]*json.RawMessage
    51  	err := json.Unmarshal(body, &m)
    52  	if err != nil {
    53  		return err
    54  	}
    55  	for k, v := range m {
    56  		switch k {
    57  		case "properties":
    58  			if v != nil {
    59  				var assignmentProperties AssignmentProperties
    60  				err = json.Unmarshal(*v, &assignmentProperties)
    61  				if err != nil {
    62  					return err
    63  				}
    64  				a.AssignmentProperties = &assignmentProperties
    65  			}
    66  		case "id":
    67  			if v != nil {
    68  				var ID string
    69  				err = json.Unmarshal(*v, &ID)
    70  				if err != nil {
    71  					return err
    72  				}
    73  				a.ID = &ID
    74  			}
    75  		case "type":
    76  			if v != nil {
    77  				var typeVar string
    78  				err = json.Unmarshal(*v, &typeVar)
    79  				if err != nil {
    80  					return err
    81  				}
    82  				a.Type = &typeVar
    83  			}
    84  		case "name":
    85  			if v != nil {
    86  				var name string
    87  				err = json.Unmarshal(*v, &name)
    88  				if err != nil {
    89  					return err
    90  				}
    91  				a.Name = &name
    92  			}
    93  		case "sku":
    94  			if v != nil {
    95  				var sku Sku
    96  				err = json.Unmarshal(*v, &sku)
    97  				if err != nil {
    98  					return err
    99  				}
   100  				a.Sku = &sku
   101  			}
   102  		}
   103  	}
   104  
   105  	return nil
   106  }
   107  
   108  // AssignmentListResult list of policy assignments.
   109  type AssignmentListResult struct {
   110  	autorest.Response `json:"-"`
   111  	// Value - An array of policy assignments.
   112  	Value *[]Assignment `json:"value,omitempty"`
   113  	// NextLink - The URL to use for getting the next set of results.
   114  	NextLink *string `json:"nextLink,omitempty"`
   115  }
   116  
   117  // AssignmentListResultIterator provides access to a complete listing of Assignment values.
   118  type AssignmentListResultIterator struct {
   119  	i    int
   120  	page AssignmentListResultPage
   121  }
   122  
   123  // NextWithContext advances to the next value.  If there was an error making
   124  // the request the iterator does not advance and the error is returned.
   125  func (iter *AssignmentListResultIterator) NextWithContext(ctx context.Context) (err error) {
   126  	if tracing.IsEnabled() {
   127  		ctx = tracing.StartSpan(ctx, fqdn+"/AssignmentListResultIterator.NextWithContext")
   128  		defer func() {
   129  			sc := -1
   130  			if iter.Response().Response.Response != nil {
   131  				sc = iter.Response().Response.Response.StatusCode
   132  			}
   133  			tracing.EndSpan(ctx, sc, err)
   134  		}()
   135  	}
   136  	iter.i++
   137  	if iter.i < len(iter.page.Values()) {
   138  		return nil
   139  	}
   140  	err = iter.page.NextWithContext(ctx)
   141  	if err != nil {
   142  		iter.i--
   143  		return err
   144  	}
   145  	iter.i = 0
   146  	return nil
   147  }
   148  
   149  // Next advances to the next value.  If there was an error making
   150  // the request the iterator does not advance and the error is returned.
   151  // Deprecated: Use NextWithContext() instead.
   152  func (iter *AssignmentListResultIterator) Next() error {
   153  	return iter.NextWithContext(context.Background())
   154  }
   155  
   156  // NotDone returns true if the enumeration should be started or is not yet complete.
   157  func (iter AssignmentListResultIterator) NotDone() bool {
   158  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
   159  }
   160  
   161  // Response returns the raw server response from the last page request.
   162  func (iter AssignmentListResultIterator) Response() AssignmentListResult {
   163  	return iter.page.Response()
   164  }
   165  
   166  // Value returns the current value or a zero-initialized value if the
   167  // iterator has advanced beyond the end of the collection.
   168  func (iter AssignmentListResultIterator) Value() Assignment {
   169  	if !iter.page.NotDone() {
   170  		return Assignment{}
   171  	}
   172  	return iter.page.Values()[iter.i]
   173  }
   174  
   175  // Creates a new instance of the AssignmentListResultIterator type.
   176  func NewAssignmentListResultIterator(page AssignmentListResultPage) AssignmentListResultIterator {
   177  	return AssignmentListResultIterator{page: page}
   178  }
   179  
   180  // IsEmpty returns true if the ListResult contains no values.
   181  func (alr AssignmentListResult) IsEmpty() bool {
   182  	return alr.Value == nil || len(*alr.Value) == 0
   183  }
   184  
   185  // hasNextLink returns true if the NextLink is not empty.
   186  func (alr AssignmentListResult) hasNextLink() bool {
   187  	return alr.NextLink != nil && len(*alr.NextLink) != 0
   188  }
   189  
   190  // assignmentListResultPreparer prepares a request to retrieve the next set of results.
   191  // It returns nil if no more results exist.
   192  func (alr AssignmentListResult) assignmentListResultPreparer(ctx context.Context) (*http.Request, error) {
   193  	if !alr.hasNextLink() {
   194  		return nil, nil
   195  	}
   196  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   197  		autorest.AsJSON(),
   198  		autorest.AsGet(),
   199  		autorest.WithBaseURL(to.String(alr.NextLink)))
   200  }
   201  
   202  // AssignmentListResultPage contains a page of Assignment values.
   203  type AssignmentListResultPage struct {
   204  	fn  func(context.Context, AssignmentListResult) (AssignmentListResult, error)
   205  	alr AssignmentListResult
   206  }
   207  
   208  // NextWithContext advances to the next page of values.  If there was an error making
   209  // the request the page does not advance and the error is returned.
   210  func (page *AssignmentListResultPage) NextWithContext(ctx context.Context) (err error) {
   211  	if tracing.IsEnabled() {
   212  		ctx = tracing.StartSpan(ctx, fqdn+"/AssignmentListResultPage.NextWithContext")
   213  		defer func() {
   214  			sc := -1
   215  			if page.Response().Response.Response != nil {
   216  				sc = page.Response().Response.Response.StatusCode
   217  			}
   218  			tracing.EndSpan(ctx, sc, err)
   219  		}()
   220  	}
   221  	for {
   222  		next, err := page.fn(ctx, page.alr)
   223  		if err != nil {
   224  			return err
   225  		}
   226  		page.alr = next
   227  		if !next.hasNextLink() || !next.IsEmpty() {
   228  			break
   229  		}
   230  	}
   231  	return nil
   232  }
   233  
   234  // Next advances to the next page of values.  If there was an error making
   235  // the request the page does not advance and the error is returned.
   236  // Deprecated: Use NextWithContext() instead.
   237  func (page *AssignmentListResultPage) Next() error {
   238  	return page.NextWithContext(context.Background())
   239  }
   240  
   241  // NotDone returns true if the page enumeration should be started or is not yet complete.
   242  func (page AssignmentListResultPage) NotDone() bool {
   243  	return !page.alr.IsEmpty()
   244  }
   245  
   246  // Response returns the raw server response from the last page request.
   247  func (page AssignmentListResultPage) Response() AssignmentListResult {
   248  	return page.alr
   249  }
   250  
   251  // Values returns the slice of values for the current page or nil if there are no values.
   252  func (page AssignmentListResultPage) Values() []Assignment {
   253  	if page.alr.IsEmpty() {
   254  		return nil
   255  	}
   256  	return *page.alr.Value
   257  }
   258  
   259  // Creates a new instance of the AssignmentListResultPage type.
   260  func NewAssignmentListResultPage(cur AssignmentListResult, getNextPage func(context.Context, AssignmentListResult) (AssignmentListResult, error)) AssignmentListResultPage {
   261  	return AssignmentListResultPage{
   262  		fn:  getNextPage,
   263  		alr: cur,
   264  	}
   265  }
   266  
   267  // AssignmentProperties the policy assignment properties.
   268  type AssignmentProperties struct {
   269  	// DisplayName - The display name of the policy assignment.
   270  	DisplayName *string `json:"displayName,omitempty"`
   271  	// PolicyDefinitionID - The ID of the policy definition or policy set definition being assigned.
   272  	PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"`
   273  	// Scope - The scope for the policy assignment.
   274  	Scope *string `json:"scope,omitempty"`
   275  	// NotScopes - The policy's excluded scopes.
   276  	NotScopes *[]string `json:"notScopes,omitempty"`
   277  	// Parameters - Required if a parameter is used in policy rule.
   278  	Parameters interface{} `json:"parameters,omitempty"`
   279  	// Description - This message will be part of response in case of policy violation.
   280  	Description *string `json:"description,omitempty"`
   281  	// Metadata - The policy assignment metadata.
   282  	Metadata interface{} `json:"metadata,omitempty"`
   283  }
   284  
   285  // Definition the policy definition.
   286  type Definition struct {
   287  	autorest.Response `json:"-"`
   288  	// DefinitionProperties - The policy definition properties.
   289  	*DefinitionProperties `json:"properties,omitempty"`
   290  	// ID - READ-ONLY; The ID of the policy definition.
   291  	ID *string `json:"id,omitempty"`
   292  	// Name - READ-ONLY; The name of the policy definition.
   293  	Name *string `json:"name,omitempty"`
   294  	// Type - READ-ONLY; The type of the resource (Microsoft.Authorization/policyDefinitions).
   295  	Type *string `json:"type,omitempty"`
   296  }
   297  
   298  // MarshalJSON is the custom marshaler for Definition.
   299  func (d Definition) MarshalJSON() ([]byte, error) {
   300  	objectMap := make(map[string]interface{})
   301  	if d.DefinitionProperties != nil {
   302  		objectMap["properties"] = d.DefinitionProperties
   303  	}
   304  	return json.Marshal(objectMap)
   305  }
   306  
   307  // UnmarshalJSON is the custom unmarshaler for Definition struct.
   308  func (d *Definition) UnmarshalJSON(body []byte) error {
   309  	var m map[string]*json.RawMessage
   310  	err := json.Unmarshal(body, &m)
   311  	if err != nil {
   312  		return err
   313  	}
   314  	for k, v := range m {
   315  		switch k {
   316  		case "properties":
   317  			if v != nil {
   318  				var definitionProperties DefinitionProperties
   319  				err = json.Unmarshal(*v, &definitionProperties)
   320  				if err != nil {
   321  					return err
   322  				}
   323  				d.DefinitionProperties = &definitionProperties
   324  			}
   325  		case "id":
   326  			if v != nil {
   327  				var ID string
   328  				err = json.Unmarshal(*v, &ID)
   329  				if err != nil {
   330  					return err
   331  				}
   332  				d.ID = &ID
   333  			}
   334  		case "name":
   335  			if v != nil {
   336  				var name string
   337  				err = json.Unmarshal(*v, &name)
   338  				if err != nil {
   339  					return err
   340  				}
   341  				d.Name = &name
   342  			}
   343  		case "type":
   344  			if v != nil {
   345  				var typeVar string
   346  				err = json.Unmarshal(*v, &typeVar)
   347  				if err != nil {
   348  					return err
   349  				}
   350  				d.Type = &typeVar
   351  			}
   352  		}
   353  	}
   354  
   355  	return nil
   356  }
   357  
   358  // DefinitionListResult list of policy definitions.
   359  type DefinitionListResult struct {
   360  	autorest.Response `json:"-"`
   361  	// Value - An array of policy definitions.
   362  	Value *[]Definition `json:"value,omitempty"`
   363  	// NextLink - The URL to use for getting the next set of results.
   364  	NextLink *string `json:"nextLink,omitempty"`
   365  }
   366  
   367  // DefinitionListResultIterator provides access to a complete listing of Definition values.
   368  type DefinitionListResultIterator struct {
   369  	i    int
   370  	page DefinitionListResultPage
   371  }
   372  
   373  // NextWithContext advances to the next value.  If there was an error making
   374  // the request the iterator does not advance and the error is returned.
   375  func (iter *DefinitionListResultIterator) NextWithContext(ctx context.Context) (err error) {
   376  	if tracing.IsEnabled() {
   377  		ctx = tracing.StartSpan(ctx, fqdn+"/DefinitionListResultIterator.NextWithContext")
   378  		defer func() {
   379  			sc := -1
   380  			if iter.Response().Response.Response != nil {
   381  				sc = iter.Response().Response.Response.StatusCode
   382  			}
   383  			tracing.EndSpan(ctx, sc, err)
   384  		}()
   385  	}
   386  	iter.i++
   387  	if iter.i < len(iter.page.Values()) {
   388  		return nil
   389  	}
   390  	err = iter.page.NextWithContext(ctx)
   391  	if err != nil {
   392  		iter.i--
   393  		return err
   394  	}
   395  	iter.i = 0
   396  	return nil
   397  }
   398  
   399  // Next advances to the next value.  If there was an error making
   400  // the request the iterator does not advance and the error is returned.
   401  // Deprecated: Use NextWithContext() instead.
   402  func (iter *DefinitionListResultIterator) Next() error {
   403  	return iter.NextWithContext(context.Background())
   404  }
   405  
   406  // NotDone returns true if the enumeration should be started or is not yet complete.
   407  func (iter DefinitionListResultIterator) NotDone() bool {
   408  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
   409  }
   410  
   411  // Response returns the raw server response from the last page request.
   412  func (iter DefinitionListResultIterator) Response() DefinitionListResult {
   413  	return iter.page.Response()
   414  }
   415  
   416  // Value returns the current value or a zero-initialized value if the
   417  // iterator has advanced beyond the end of the collection.
   418  func (iter DefinitionListResultIterator) Value() Definition {
   419  	if !iter.page.NotDone() {
   420  		return Definition{}
   421  	}
   422  	return iter.page.Values()[iter.i]
   423  }
   424  
   425  // Creates a new instance of the DefinitionListResultIterator type.
   426  func NewDefinitionListResultIterator(page DefinitionListResultPage) DefinitionListResultIterator {
   427  	return DefinitionListResultIterator{page: page}
   428  }
   429  
   430  // IsEmpty returns true if the ListResult contains no values.
   431  func (dlr DefinitionListResult) IsEmpty() bool {
   432  	return dlr.Value == nil || len(*dlr.Value) == 0
   433  }
   434  
   435  // hasNextLink returns true if the NextLink is not empty.
   436  func (dlr DefinitionListResult) hasNextLink() bool {
   437  	return dlr.NextLink != nil && len(*dlr.NextLink) != 0
   438  }
   439  
   440  // definitionListResultPreparer prepares a request to retrieve the next set of results.
   441  // It returns nil if no more results exist.
   442  func (dlr DefinitionListResult) definitionListResultPreparer(ctx context.Context) (*http.Request, error) {
   443  	if !dlr.hasNextLink() {
   444  		return nil, nil
   445  	}
   446  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   447  		autorest.AsJSON(),
   448  		autorest.AsGet(),
   449  		autorest.WithBaseURL(to.String(dlr.NextLink)))
   450  }
   451  
   452  // DefinitionListResultPage contains a page of Definition values.
   453  type DefinitionListResultPage struct {
   454  	fn  func(context.Context, DefinitionListResult) (DefinitionListResult, error)
   455  	dlr DefinitionListResult
   456  }
   457  
   458  // NextWithContext advances to the next page of values.  If there was an error making
   459  // the request the page does not advance and the error is returned.
   460  func (page *DefinitionListResultPage) NextWithContext(ctx context.Context) (err error) {
   461  	if tracing.IsEnabled() {
   462  		ctx = tracing.StartSpan(ctx, fqdn+"/DefinitionListResultPage.NextWithContext")
   463  		defer func() {
   464  			sc := -1
   465  			if page.Response().Response.Response != nil {
   466  				sc = page.Response().Response.Response.StatusCode
   467  			}
   468  			tracing.EndSpan(ctx, sc, err)
   469  		}()
   470  	}
   471  	for {
   472  		next, err := page.fn(ctx, page.dlr)
   473  		if err != nil {
   474  			return err
   475  		}
   476  		page.dlr = next
   477  		if !next.hasNextLink() || !next.IsEmpty() {
   478  			break
   479  		}
   480  	}
   481  	return nil
   482  }
   483  
   484  // Next advances to the next page of values.  If there was an error making
   485  // the request the page does not advance and the error is returned.
   486  // Deprecated: Use NextWithContext() instead.
   487  func (page *DefinitionListResultPage) Next() error {
   488  	return page.NextWithContext(context.Background())
   489  }
   490  
   491  // NotDone returns true if the page enumeration should be started or is not yet complete.
   492  func (page DefinitionListResultPage) NotDone() bool {
   493  	return !page.dlr.IsEmpty()
   494  }
   495  
   496  // Response returns the raw server response from the last page request.
   497  func (page DefinitionListResultPage) Response() DefinitionListResult {
   498  	return page.dlr
   499  }
   500  
   501  // Values returns the slice of values for the current page or nil if there are no values.
   502  func (page DefinitionListResultPage) Values() []Definition {
   503  	if page.dlr.IsEmpty() {
   504  		return nil
   505  	}
   506  	return *page.dlr.Value
   507  }
   508  
   509  // Creates a new instance of the DefinitionListResultPage type.
   510  func NewDefinitionListResultPage(cur DefinitionListResult, getNextPage func(context.Context, DefinitionListResult) (DefinitionListResult, error)) DefinitionListResultPage {
   511  	return DefinitionListResultPage{
   512  		fn:  getNextPage,
   513  		dlr: cur,
   514  	}
   515  }
   516  
   517  // DefinitionProperties the policy definition properties.
   518  type DefinitionProperties struct {
   519  	// PolicyType - The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: 'TypeNotSpecified', 'TypeBuiltIn', 'TypeCustom'
   520  	PolicyType Type `json:"policyType,omitempty"`
   521  	// Mode - The policy definition mode. Possible values are NotSpecified, Indexed, and All. Possible values include: 'NotSpecified', 'Indexed', 'All'
   522  	Mode Mode `json:"mode,omitempty"`
   523  	// DisplayName - The display name of the policy definition.
   524  	DisplayName *string `json:"displayName,omitempty"`
   525  	// Description - The policy definition description.
   526  	Description *string `json:"description,omitempty"`
   527  	// PolicyRule - The policy rule.
   528  	PolicyRule interface{} `json:"policyRule,omitempty"`
   529  	// Metadata - The policy definition metadata.
   530  	Metadata interface{} `json:"metadata,omitempty"`
   531  	// Parameters - Required if a parameter is used in policy rule.
   532  	Parameters interface{} `json:"parameters,omitempty"`
   533  }
   534  
   535  // DefinitionReference the policy definition reference.
   536  type DefinitionReference struct {
   537  	// PolicyDefinitionID - The ID of the policy definition or policy set definition.
   538  	PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"`
   539  	// Parameters - Required if a parameter is used in policy rule.
   540  	Parameters interface{} `json:"parameters,omitempty"`
   541  }
   542  
   543  // ErrorResponse error response indicates Azure Resource Manager is not able to process the incoming
   544  // request. The reason is provided in the error message.
   545  type ErrorResponse struct {
   546  	// HTTPStatus - Http status code.
   547  	HTTPStatus *string `json:"httpStatus,omitempty"`
   548  	// ErrorCode - Error code.
   549  	ErrorCode *string `json:"errorCode,omitempty"`
   550  	// ErrorMessage - Error message indicating why the operation failed.
   551  	ErrorMessage *string `json:"errorMessage,omitempty"`
   552  }
   553  
   554  // SetDefinition the policy set definition.
   555  type SetDefinition struct {
   556  	autorest.Response `json:"-"`
   557  	// SetDefinitionProperties - The policy definition properties.
   558  	*SetDefinitionProperties `json:"properties,omitempty"`
   559  	// ID - READ-ONLY; The ID of the policy set definition.
   560  	ID *string `json:"id,omitempty"`
   561  	// Name - READ-ONLY; The name of the policy set definition.
   562  	Name *string `json:"name,omitempty"`
   563  	// Type - READ-ONLY; The type of the resource (Microsoft.Authorization/policySetDefinitions).
   564  	Type *string `json:"type,omitempty"`
   565  }
   566  
   567  // MarshalJSON is the custom marshaler for SetDefinition.
   568  func (sd SetDefinition) MarshalJSON() ([]byte, error) {
   569  	objectMap := make(map[string]interface{})
   570  	if sd.SetDefinitionProperties != nil {
   571  		objectMap["properties"] = sd.SetDefinitionProperties
   572  	}
   573  	return json.Marshal(objectMap)
   574  }
   575  
   576  // UnmarshalJSON is the custom unmarshaler for SetDefinition struct.
   577  func (sd *SetDefinition) UnmarshalJSON(body []byte) error {
   578  	var m map[string]*json.RawMessage
   579  	err := json.Unmarshal(body, &m)
   580  	if err != nil {
   581  		return err
   582  	}
   583  	for k, v := range m {
   584  		switch k {
   585  		case "properties":
   586  			if v != nil {
   587  				var setDefinitionProperties SetDefinitionProperties
   588  				err = json.Unmarshal(*v, &setDefinitionProperties)
   589  				if err != nil {
   590  					return err
   591  				}
   592  				sd.SetDefinitionProperties = &setDefinitionProperties
   593  			}
   594  		case "id":
   595  			if v != nil {
   596  				var ID string
   597  				err = json.Unmarshal(*v, &ID)
   598  				if err != nil {
   599  					return err
   600  				}
   601  				sd.ID = &ID
   602  			}
   603  		case "name":
   604  			if v != nil {
   605  				var name string
   606  				err = json.Unmarshal(*v, &name)
   607  				if err != nil {
   608  					return err
   609  				}
   610  				sd.Name = &name
   611  			}
   612  		case "type":
   613  			if v != nil {
   614  				var typeVar string
   615  				err = json.Unmarshal(*v, &typeVar)
   616  				if err != nil {
   617  					return err
   618  				}
   619  				sd.Type = &typeVar
   620  			}
   621  		}
   622  	}
   623  
   624  	return nil
   625  }
   626  
   627  // SetDefinitionListResult list of policy set definitions.
   628  type SetDefinitionListResult struct {
   629  	autorest.Response `json:"-"`
   630  	// Value - An array of policy set definitions.
   631  	Value *[]SetDefinition `json:"value,omitempty"`
   632  	// NextLink - The URL to use for getting the next set of results.
   633  	NextLink *string `json:"nextLink,omitempty"`
   634  }
   635  
   636  // SetDefinitionListResultIterator provides access to a complete listing of SetDefinition values.
   637  type SetDefinitionListResultIterator struct {
   638  	i    int
   639  	page SetDefinitionListResultPage
   640  }
   641  
   642  // NextWithContext advances to the next value.  If there was an error making
   643  // the request the iterator does not advance and the error is returned.
   644  func (iter *SetDefinitionListResultIterator) NextWithContext(ctx context.Context) (err error) {
   645  	if tracing.IsEnabled() {
   646  		ctx = tracing.StartSpan(ctx, fqdn+"/SetDefinitionListResultIterator.NextWithContext")
   647  		defer func() {
   648  			sc := -1
   649  			if iter.Response().Response.Response != nil {
   650  				sc = iter.Response().Response.Response.StatusCode
   651  			}
   652  			tracing.EndSpan(ctx, sc, err)
   653  		}()
   654  	}
   655  	iter.i++
   656  	if iter.i < len(iter.page.Values()) {
   657  		return nil
   658  	}
   659  	err = iter.page.NextWithContext(ctx)
   660  	if err != nil {
   661  		iter.i--
   662  		return err
   663  	}
   664  	iter.i = 0
   665  	return nil
   666  }
   667  
   668  // Next advances to the next value.  If there was an error making
   669  // the request the iterator does not advance and the error is returned.
   670  // Deprecated: Use NextWithContext() instead.
   671  func (iter *SetDefinitionListResultIterator) Next() error {
   672  	return iter.NextWithContext(context.Background())
   673  }
   674  
   675  // NotDone returns true if the enumeration should be started or is not yet complete.
   676  func (iter SetDefinitionListResultIterator) NotDone() bool {
   677  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
   678  }
   679  
   680  // Response returns the raw server response from the last page request.
   681  func (iter SetDefinitionListResultIterator) Response() SetDefinitionListResult {
   682  	return iter.page.Response()
   683  }
   684  
   685  // Value returns the current value or a zero-initialized value if the
   686  // iterator has advanced beyond the end of the collection.
   687  func (iter SetDefinitionListResultIterator) Value() SetDefinition {
   688  	if !iter.page.NotDone() {
   689  		return SetDefinition{}
   690  	}
   691  	return iter.page.Values()[iter.i]
   692  }
   693  
   694  // Creates a new instance of the SetDefinitionListResultIterator type.
   695  func NewSetDefinitionListResultIterator(page SetDefinitionListResultPage) SetDefinitionListResultIterator {
   696  	return SetDefinitionListResultIterator{page: page}
   697  }
   698  
   699  // IsEmpty returns true if the ListResult contains no values.
   700  func (sdlr SetDefinitionListResult) IsEmpty() bool {
   701  	return sdlr.Value == nil || len(*sdlr.Value) == 0
   702  }
   703  
   704  // hasNextLink returns true if the NextLink is not empty.
   705  func (sdlr SetDefinitionListResult) hasNextLink() bool {
   706  	return sdlr.NextLink != nil && len(*sdlr.NextLink) != 0
   707  }
   708  
   709  // setDefinitionListResultPreparer prepares a request to retrieve the next set of results.
   710  // It returns nil if no more results exist.
   711  func (sdlr SetDefinitionListResult) setDefinitionListResultPreparer(ctx context.Context) (*http.Request, error) {
   712  	if !sdlr.hasNextLink() {
   713  		return nil, nil
   714  	}
   715  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   716  		autorest.AsJSON(),
   717  		autorest.AsGet(),
   718  		autorest.WithBaseURL(to.String(sdlr.NextLink)))
   719  }
   720  
   721  // SetDefinitionListResultPage contains a page of SetDefinition values.
   722  type SetDefinitionListResultPage struct {
   723  	fn   func(context.Context, SetDefinitionListResult) (SetDefinitionListResult, error)
   724  	sdlr SetDefinitionListResult
   725  }
   726  
   727  // NextWithContext advances to the next page of values.  If there was an error making
   728  // the request the page does not advance and the error is returned.
   729  func (page *SetDefinitionListResultPage) NextWithContext(ctx context.Context) (err error) {
   730  	if tracing.IsEnabled() {
   731  		ctx = tracing.StartSpan(ctx, fqdn+"/SetDefinitionListResultPage.NextWithContext")
   732  		defer func() {
   733  			sc := -1
   734  			if page.Response().Response.Response != nil {
   735  				sc = page.Response().Response.Response.StatusCode
   736  			}
   737  			tracing.EndSpan(ctx, sc, err)
   738  		}()
   739  	}
   740  	for {
   741  		next, err := page.fn(ctx, page.sdlr)
   742  		if err != nil {
   743  			return err
   744  		}
   745  		page.sdlr = next
   746  		if !next.hasNextLink() || !next.IsEmpty() {
   747  			break
   748  		}
   749  	}
   750  	return nil
   751  }
   752  
   753  // Next advances to the next page of values.  If there was an error making
   754  // the request the page does not advance and the error is returned.
   755  // Deprecated: Use NextWithContext() instead.
   756  func (page *SetDefinitionListResultPage) Next() error {
   757  	return page.NextWithContext(context.Background())
   758  }
   759  
   760  // NotDone returns true if the page enumeration should be started or is not yet complete.
   761  func (page SetDefinitionListResultPage) NotDone() bool {
   762  	return !page.sdlr.IsEmpty()
   763  }
   764  
   765  // Response returns the raw server response from the last page request.
   766  func (page SetDefinitionListResultPage) Response() SetDefinitionListResult {
   767  	return page.sdlr
   768  }
   769  
   770  // Values returns the slice of values for the current page or nil if there are no values.
   771  func (page SetDefinitionListResultPage) Values() []SetDefinition {
   772  	if page.sdlr.IsEmpty() {
   773  		return nil
   774  	}
   775  	return *page.sdlr.Value
   776  }
   777  
   778  // Creates a new instance of the SetDefinitionListResultPage type.
   779  func NewSetDefinitionListResultPage(cur SetDefinitionListResult, getNextPage func(context.Context, SetDefinitionListResult) (SetDefinitionListResult, error)) SetDefinitionListResultPage {
   780  	return SetDefinitionListResultPage{
   781  		fn:   getNextPage,
   782  		sdlr: cur,
   783  	}
   784  }
   785  
   786  // SetDefinitionProperties the policy set definition properties.
   787  type SetDefinitionProperties struct {
   788  	// PolicyType - The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: 'TypeNotSpecified', 'TypeBuiltIn', 'TypeCustom'
   789  	PolicyType Type `json:"policyType,omitempty"`
   790  	// DisplayName - The display name of the policy set definition.
   791  	DisplayName *string `json:"displayName,omitempty"`
   792  	// Description - The policy set definition description.
   793  	Description *string `json:"description,omitempty"`
   794  	// Metadata - The policy set definition metadata.
   795  	Metadata interface{} `json:"metadata,omitempty"`
   796  	// Parameters - The policy set definition parameters that can be used in policy definition references.
   797  	Parameters interface{} `json:"parameters,omitempty"`
   798  	// PolicyDefinitions - An array of policy definition references.
   799  	PolicyDefinitions *[]DefinitionReference `json:"policyDefinitions,omitempty"`
   800  }
   801  
   802  // Sku the policy sku. This property is optional, obsolete, and will be ignored.
   803  type Sku struct {
   804  	// Name - The name of the policy sku. Possible values are A0 and A1.
   805  	Name *string `json:"name,omitempty"`
   806  	// Tier - The policy sku tier. Possible values are Free and Standard.
   807  	Tier *string `json:"tier,omitempty"`
   808  }
   809  

View as plain text