...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/windowsesu/mgmt/2019-09-16-preview/windowsesu/models.go

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/windowsesu/mgmt/2019-09-16-preview/windowsesu

     1  package windowsesu
     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/azure"
    14  	"github.com/Azure/go-autorest/autorest/date"
    15  	"github.com/Azure/go-autorest/autorest/to"
    16  	"github.com/Azure/go-autorest/tracing"
    17  	"net/http"
    18  )
    19  
    20  // The package's fully qualified name.
    21  const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/windowsesu/mgmt/2019-09-16-preview/windowsesu"
    22  
    23  // AzureEntityResource the resource model definition for an Azure Resource Manager resource with an etag.
    24  type AzureEntityResource struct {
    25  	// Etag - READ-ONLY; Resource Etag.
    26  	Etag *string `json:"etag,omitempty"`
    27  	// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
    28  	ID *string `json:"id,omitempty"`
    29  	// Name - READ-ONLY; The name of the resource
    30  	Name *string `json:"name,omitempty"`
    31  	// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
    32  	Type *string `json:"type,omitempty"`
    33  }
    34  
    35  // MarshalJSON is the custom marshaler for AzureEntityResource.
    36  func (aer AzureEntityResource) MarshalJSON() ([]byte, error) {
    37  	objectMap := make(map[string]interface{})
    38  	return json.Marshal(objectMap)
    39  }
    40  
    41  // ErrorDefinition error definition.
    42  type ErrorDefinition struct {
    43  	// Code - READ-ONLY; Service specific error code which serves as the substatus for the HTTP error code.
    44  	Code *string `json:"code,omitempty"`
    45  	// Message - READ-ONLY; Description of the error.
    46  	Message *string `json:"message,omitempty"`
    47  	// Details - READ-ONLY; Internal error details.
    48  	Details *[]ErrorDefinition `json:"details,omitempty"`
    49  }
    50  
    51  // MarshalJSON is the custom marshaler for ErrorDefinition.
    52  func (ed ErrorDefinition) MarshalJSON() ([]byte, error) {
    53  	objectMap := make(map[string]interface{})
    54  	return json.Marshal(objectMap)
    55  }
    56  
    57  // ErrorResponse error response.
    58  type ErrorResponse struct {
    59  	// Error - The error details.
    60  	Error *ErrorDefinition `json:"error,omitempty"`
    61  }
    62  
    63  // MultipleActivationKey MAK key details.
    64  type MultipleActivationKey struct {
    65  	autorest.Response `json:"-"`
    66  	// MultipleActivationKeyProperties - MAK key specific properties.
    67  	*MultipleActivationKeyProperties `json:"properties,omitempty"`
    68  	// Tags - Resource tags.
    69  	Tags map[string]*string `json:"tags"`
    70  	// Location - The geo-location where the resource lives
    71  	Location *string `json:"location,omitempty"`
    72  	// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
    73  	ID *string `json:"id,omitempty"`
    74  	// Name - READ-ONLY; The name of the resource
    75  	Name *string `json:"name,omitempty"`
    76  	// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
    77  	Type *string `json:"type,omitempty"`
    78  }
    79  
    80  // MarshalJSON is the custom marshaler for MultipleActivationKey.
    81  func (mak MultipleActivationKey) MarshalJSON() ([]byte, error) {
    82  	objectMap := make(map[string]interface{})
    83  	if mak.MultipleActivationKeyProperties != nil {
    84  		objectMap["properties"] = mak.MultipleActivationKeyProperties
    85  	}
    86  	if mak.Tags != nil {
    87  		objectMap["tags"] = mak.Tags
    88  	}
    89  	if mak.Location != nil {
    90  		objectMap["location"] = mak.Location
    91  	}
    92  	return json.Marshal(objectMap)
    93  }
    94  
    95  // UnmarshalJSON is the custom unmarshaler for MultipleActivationKey struct.
    96  func (mak *MultipleActivationKey) UnmarshalJSON(body []byte) error {
    97  	var m map[string]*json.RawMessage
    98  	err := json.Unmarshal(body, &m)
    99  	if err != nil {
   100  		return err
   101  	}
   102  	for k, v := range m {
   103  		switch k {
   104  		case "properties":
   105  			if v != nil {
   106  				var multipleActivationKeyProperties MultipleActivationKeyProperties
   107  				err = json.Unmarshal(*v, &multipleActivationKeyProperties)
   108  				if err != nil {
   109  					return err
   110  				}
   111  				mak.MultipleActivationKeyProperties = &multipleActivationKeyProperties
   112  			}
   113  		case "tags":
   114  			if v != nil {
   115  				var tags map[string]*string
   116  				err = json.Unmarshal(*v, &tags)
   117  				if err != nil {
   118  					return err
   119  				}
   120  				mak.Tags = tags
   121  			}
   122  		case "location":
   123  			if v != nil {
   124  				var location string
   125  				err = json.Unmarshal(*v, &location)
   126  				if err != nil {
   127  					return err
   128  				}
   129  				mak.Location = &location
   130  			}
   131  		case "id":
   132  			if v != nil {
   133  				var ID string
   134  				err = json.Unmarshal(*v, &ID)
   135  				if err != nil {
   136  					return err
   137  				}
   138  				mak.ID = &ID
   139  			}
   140  		case "name":
   141  			if v != nil {
   142  				var name string
   143  				err = json.Unmarshal(*v, &name)
   144  				if err != nil {
   145  					return err
   146  				}
   147  				mak.Name = &name
   148  			}
   149  		case "type":
   150  			if v != nil {
   151  				var typeVar string
   152  				err = json.Unmarshal(*v, &typeVar)
   153  				if err != nil {
   154  					return err
   155  				}
   156  				mak.Type = &typeVar
   157  			}
   158  		}
   159  	}
   160  
   161  	return nil
   162  }
   163  
   164  // MultipleActivationKeyList list of MAK keys.
   165  type MultipleActivationKeyList struct {
   166  	autorest.Response `json:"-"`
   167  	// Value - List of MAK keys.
   168  	Value *[]MultipleActivationKey `json:"value,omitempty"`
   169  	// NextLink - READ-ONLY; Link to the next page of resources.
   170  	NextLink *string `json:"nextLink,omitempty"`
   171  }
   172  
   173  // MarshalJSON is the custom marshaler for MultipleActivationKeyList.
   174  func (makl MultipleActivationKeyList) MarshalJSON() ([]byte, error) {
   175  	objectMap := make(map[string]interface{})
   176  	if makl.Value != nil {
   177  		objectMap["value"] = makl.Value
   178  	}
   179  	return json.Marshal(objectMap)
   180  }
   181  
   182  // MultipleActivationKeyListIterator provides access to a complete listing of MultipleActivationKey values.
   183  type MultipleActivationKeyListIterator struct {
   184  	i    int
   185  	page MultipleActivationKeyListPage
   186  }
   187  
   188  // NextWithContext advances to the next value.  If there was an error making
   189  // the request the iterator does not advance and the error is returned.
   190  func (iter *MultipleActivationKeyListIterator) NextWithContext(ctx context.Context) (err error) {
   191  	if tracing.IsEnabled() {
   192  		ctx = tracing.StartSpan(ctx, fqdn+"/MultipleActivationKeyListIterator.NextWithContext")
   193  		defer func() {
   194  			sc := -1
   195  			if iter.Response().Response.Response != nil {
   196  				sc = iter.Response().Response.Response.StatusCode
   197  			}
   198  			tracing.EndSpan(ctx, sc, err)
   199  		}()
   200  	}
   201  	iter.i++
   202  	if iter.i < len(iter.page.Values()) {
   203  		return nil
   204  	}
   205  	err = iter.page.NextWithContext(ctx)
   206  	if err != nil {
   207  		iter.i--
   208  		return err
   209  	}
   210  	iter.i = 0
   211  	return nil
   212  }
   213  
   214  // Next advances to the next value.  If there was an error making
   215  // the request the iterator does not advance and the error is returned.
   216  // Deprecated: Use NextWithContext() instead.
   217  func (iter *MultipleActivationKeyListIterator) Next() error {
   218  	return iter.NextWithContext(context.Background())
   219  }
   220  
   221  // NotDone returns true if the enumeration should be started or is not yet complete.
   222  func (iter MultipleActivationKeyListIterator) NotDone() bool {
   223  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
   224  }
   225  
   226  // Response returns the raw server response from the last page request.
   227  func (iter MultipleActivationKeyListIterator) Response() MultipleActivationKeyList {
   228  	return iter.page.Response()
   229  }
   230  
   231  // Value returns the current value or a zero-initialized value if the
   232  // iterator has advanced beyond the end of the collection.
   233  func (iter MultipleActivationKeyListIterator) Value() MultipleActivationKey {
   234  	if !iter.page.NotDone() {
   235  		return MultipleActivationKey{}
   236  	}
   237  	return iter.page.Values()[iter.i]
   238  }
   239  
   240  // Creates a new instance of the MultipleActivationKeyListIterator type.
   241  func NewMultipleActivationKeyListIterator(page MultipleActivationKeyListPage) MultipleActivationKeyListIterator {
   242  	return MultipleActivationKeyListIterator{page: page}
   243  }
   244  
   245  // IsEmpty returns true if the ListResult contains no values.
   246  func (makl MultipleActivationKeyList) IsEmpty() bool {
   247  	return makl.Value == nil || len(*makl.Value) == 0
   248  }
   249  
   250  // hasNextLink returns true if the NextLink is not empty.
   251  func (makl MultipleActivationKeyList) hasNextLink() bool {
   252  	return makl.NextLink != nil && len(*makl.NextLink) != 0
   253  }
   254  
   255  // multipleActivationKeyListPreparer prepares a request to retrieve the next set of results.
   256  // It returns nil if no more results exist.
   257  func (makl MultipleActivationKeyList) multipleActivationKeyListPreparer(ctx context.Context) (*http.Request, error) {
   258  	if !makl.hasNextLink() {
   259  		return nil, nil
   260  	}
   261  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   262  		autorest.AsJSON(),
   263  		autorest.AsGet(),
   264  		autorest.WithBaseURL(to.String(makl.NextLink)))
   265  }
   266  
   267  // MultipleActivationKeyListPage contains a page of MultipleActivationKey values.
   268  type MultipleActivationKeyListPage struct {
   269  	fn   func(context.Context, MultipleActivationKeyList) (MultipleActivationKeyList, error)
   270  	makl MultipleActivationKeyList
   271  }
   272  
   273  // NextWithContext advances to the next page of values.  If there was an error making
   274  // the request the page does not advance and the error is returned.
   275  func (page *MultipleActivationKeyListPage) NextWithContext(ctx context.Context) (err error) {
   276  	if tracing.IsEnabled() {
   277  		ctx = tracing.StartSpan(ctx, fqdn+"/MultipleActivationKeyListPage.NextWithContext")
   278  		defer func() {
   279  			sc := -1
   280  			if page.Response().Response.Response != nil {
   281  				sc = page.Response().Response.Response.StatusCode
   282  			}
   283  			tracing.EndSpan(ctx, sc, err)
   284  		}()
   285  	}
   286  	for {
   287  		next, err := page.fn(ctx, page.makl)
   288  		if err != nil {
   289  			return err
   290  		}
   291  		page.makl = next
   292  		if !next.hasNextLink() || !next.IsEmpty() {
   293  			break
   294  		}
   295  	}
   296  	return nil
   297  }
   298  
   299  // Next advances to the next page of values.  If there was an error making
   300  // the request the page does not advance and the error is returned.
   301  // Deprecated: Use NextWithContext() instead.
   302  func (page *MultipleActivationKeyListPage) Next() error {
   303  	return page.NextWithContext(context.Background())
   304  }
   305  
   306  // NotDone returns true if the page enumeration should be started or is not yet complete.
   307  func (page MultipleActivationKeyListPage) NotDone() bool {
   308  	return !page.makl.IsEmpty()
   309  }
   310  
   311  // Response returns the raw server response from the last page request.
   312  func (page MultipleActivationKeyListPage) Response() MultipleActivationKeyList {
   313  	return page.makl
   314  }
   315  
   316  // Values returns the slice of values for the current page or nil if there are no values.
   317  func (page MultipleActivationKeyListPage) Values() []MultipleActivationKey {
   318  	if page.makl.IsEmpty() {
   319  		return nil
   320  	}
   321  	return *page.makl.Value
   322  }
   323  
   324  // Creates a new instance of the MultipleActivationKeyListPage type.
   325  func NewMultipleActivationKeyListPage(cur MultipleActivationKeyList, getNextPage func(context.Context, MultipleActivationKeyList) (MultipleActivationKeyList, error)) MultipleActivationKeyListPage {
   326  	return MultipleActivationKeyListPage{
   327  		fn:   getNextPage,
   328  		makl: cur,
   329  	}
   330  }
   331  
   332  // MultipleActivationKeyProperties MAK key specific properties.
   333  type MultipleActivationKeyProperties struct {
   334  	// MultipleActivationKey - READ-ONLY; MAK 5x5 key.
   335  	MultipleActivationKey *string `json:"multipleActivationKey,omitempty"`
   336  	// ExpirationDate - READ-ONLY; End of support of security updates activated by the MAK key.
   337  	ExpirationDate *date.Time `json:"expirationDate,omitempty"`
   338  	// OsType - Type of OS for which the key is requested. Possible values include: 'Windows7', 'WindowsServer2008', 'WindowsServer2008R2'
   339  	OsType OsType `json:"osType,omitempty"`
   340  	// SupportType - Type of support. Possible values include: 'SupplementalServicing', 'PremiumAssurance'
   341  	SupportType SupportType `json:"supportType,omitempty"`
   342  	// InstalledServerNumber - Number of activations/servers using the MAK key.
   343  	InstalledServerNumber *int32 `json:"installedServerNumber,omitempty"`
   344  	// AgreementNumber - Agreement number under which the key is requested.
   345  	AgreementNumber *string `json:"agreementNumber,omitempty"`
   346  	// IsEligible - <code> true </code> if user has eligible on-premises Windows physical or virtual machines, and that the requested key will only be used in their organization; <code> false </code> otherwise.
   347  	IsEligible *bool `json:"isEligible,omitempty"`
   348  	// ProvisioningState - READ-ONLY; Possible values include: 'Succeeded', 'Failed', 'Canceled', 'Accepted', 'Provisioning'
   349  	ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
   350  }
   351  
   352  // MarshalJSON is the custom marshaler for MultipleActivationKeyProperties.
   353  func (mak MultipleActivationKeyProperties) MarshalJSON() ([]byte, error) {
   354  	objectMap := make(map[string]interface{})
   355  	if mak.OsType != "" {
   356  		objectMap["osType"] = mak.OsType
   357  	}
   358  	if mak.SupportType != "" {
   359  		objectMap["supportType"] = mak.SupportType
   360  	}
   361  	if mak.InstalledServerNumber != nil {
   362  		objectMap["installedServerNumber"] = mak.InstalledServerNumber
   363  	}
   364  	if mak.AgreementNumber != nil {
   365  		objectMap["agreementNumber"] = mak.AgreementNumber
   366  	}
   367  	if mak.IsEligible != nil {
   368  		objectMap["isEligible"] = mak.IsEligible
   369  	}
   370  	return json.Marshal(objectMap)
   371  }
   372  
   373  // MultipleActivationKeysCreateFuture an abstraction for monitoring and retrieving the results of a
   374  // long-running operation.
   375  type MultipleActivationKeysCreateFuture struct {
   376  	azure.FutureAPI
   377  	// Result returns the result of the asynchronous operation.
   378  	// If the operation has not completed it will return an error.
   379  	Result func(MultipleActivationKeysClient) (MultipleActivationKey, error)
   380  }
   381  
   382  // UnmarshalJSON is the custom unmarshaller for CreateFuture.
   383  func (future *MultipleActivationKeysCreateFuture) UnmarshalJSON(body []byte) error {
   384  	var azFuture azure.Future
   385  	if err := json.Unmarshal(body, &azFuture); err != nil {
   386  		return err
   387  	}
   388  	future.FutureAPI = &azFuture
   389  	future.Result = future.result
   390  	return nil
   391  }
   392  
   393  // result is the default implementation for MultipleActivationKeysCreateFuture.Result.
   394  func (future *MultipleActivationKeysCreateFuture) result(client MultipleActivationKeysClient) (mak MultipleActivationKey, err error) {
   395  	var done bool
   396  	done, err = future.DoneWithContext(context.Background(), client)
   397  	if err != nil {
   398  		err = autorest.NewErrorWithError(err, "windowsesu.MultipleActivationKeysCreateFuture", "Result", future.Response(), "Polling failure")
   399  		return
   400  	}
   401  	if !done {
   402  		mak.Response.Response = future.Response()
   403  		err = azure.NewAsyncOpIncompleteError("windowsesu.MultipleActivationKeysCreateFuture")
   404  		return
   405  	}
   406  	sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   407  	if mak.Response.Response, err = future.GetResult(sender); err == nil && mak.Response.Response.StatusCode != http.StatusNoContent {
   408  		mak, err = client.CreateResponder(mak.Response.Response)
   409  		if err != nil {
   410  			err = autorest.NewErrorWithError(err, "windowsesu.MultipleActivationKeysCreateFuture", "Result", mak.Response.Response, "Failure responding to request")
   411  		}
   412  	}
   413  	return
   414  }
   415  
   416  // MultipleActivationKeyUpdate MAK key details.
   417  type MultipleActivationKeyUpdate struct {
   418  	// Tags - Resource tags.
   419  	Tags map[string]*string `json:"tags"`
   420  }
   421  
   422  // MarshalJSON is the custom marshaler for MultipleActivationKeyUpdate.
   423  func (maku MultipleActivationKeyUpdate) MarshalJSON() ([]byte, error) {
   424  	objectMap := make(map[string]interface{})
   425  	if maku.Tags != nil {
   426  		objectMap["tags"] = maku.Tags
   427  	}
   428  	return json.Marshal(objectMap)
   429  }
   430  
   431  // Operation REST API operation details.
   432  type Operation struct {
   433  	// Name - READ-ONLY; Name of the operation.
   434  	Name    *string           `json:"name,omitempty"`
   435  	Display *OperationDisplay `json:"display,omitempty"`
   436  }
   437  
   438  // MarshalJSON is the custom marshaler for Operation.
   439  func (o Operation) MarshalJSON() ([]byte, error) {
   440  	objectMap := make(map[string]interface{})
   441  	if o.Display != nil {
   442  		objectMap["display"] = o.Display
   443  	}
   444  	return json.Marshal(objectMap)
   445  }
   446  
   447  // OperationDisplay meta data about operation used for display in portal.
   448  type OperationDisplay struct {
   449  	Provider    *string `json:"provider,omitempty"`
   450  	Resource    *string `json:"resource,omitempty"`
   451  	Operation   *string `json:"operation,omitempty"`
   452  	Description *string `json:"description,omitempty"`
   453  }
   454  
   455  // OperationList list of available REST API operations.
   456  type OperationList struct {
   457  	autorest.Response `json:"-"`
   458  	// Value - List of operations.
   459  	Value *[]Operation `json:"value,omitempty"`
   460  	// NextLink - READ-ONLY; Link to the next page of resources.
   461  	NextLink *string `json:"nextLink,omitempty"`
   462  }
   463  
   464  // MarshalJSON is the custom marshaler for OperationList.
   465  func (ol OperationList) MarshalJSON() ([]byte, error) {
   466  	objectMap := make(map[string]interface{})
   467  	if ol.Value != nil {
   468  		objectMap["value"] = ol.Value
   469  	}
   470  	return json.Marshal(objectMap)
   471  }
   472  
   473  // OperationListIterator provides access to a complete listing of Operation values.
   474  type OperationListIterator struct {
   475  	i    int
   476  	page OperationListPage
   477  }
   478  
   479  // NextWithContext advances to the next value.  If there was an error making
   480  // the request the iterator does not advance and the error is returned.
   481  func (iter *OperationListIterator) NextWithContext(ctx context.Context) (err error) {
   482  	if tracing.IsEnabled() {
   483  		ctx = tracing.StartSpan(ctx, fqdn+"/OperationListIterator.NextWithContext")
   484  		defer func() {
   485  			sc := -1
   486  			if iter.Response().Response.Response != nil {
   487  				sc = iter.Response().Response.Response.StatusCode
   488  			}
   489  			tracing.EndSpan(ctx, sc, err)
   490  		}()
   491  	}
   492  	iter.i++
   493  	if iter.i < len(iter.page.Values()) {
   494  		return nil
   495  	}
   496  	err = iter.page.NextWithContext(ctx)
   497  	if err != nil {
   498  		iter.i--
   499  		return err
   500  	}
   501  	iter.i = 0
   502  	return nil
   503  }
   504  
   505  // Next advances to the next value.  If there was an error making
   506  // the request the iterator does not advance and the error is returned.
   507  // Deprecated: Use NextWithContext() instead.
   508  func (iter *OperationListIterator) Next() error {
   509  	return iter.NextWithContext(context.Background())
   510  }
   511  
   512  // NotDone returns true if the enumeration should be started or is not yet complete.
   513  func (iter OperationListIterator) NotDone() bool {
   514  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
   515  }
   516  
   517  // Response returns the raw server response from the last page request.
   518  func (iter OperationListIterator) Response() OperationList {
   519  	return iter.page.Response()
   520  }
   521  
   522  // Value returns the current value or a zero-initialized value if the
   523  // iterator has advanced beyond the end of the collection.
   524  func (iter OperationListIterator) Value() Operation {
   525  	if !iter.page.NotDone() {
   526  		return Operation{}
   527  	}
   528  	return iter.page.Values()[iter.i]
   529  }
   530  
   531  // Creates a new instance of the OperationListIterator type.
   532  func NewOperationListIterator(page OperationListPage) OperationListIterator {
   533  	return OperationListIterator{page: page}
   534  }
   535  
   536  // IsEmpty returns true if the ListResult contains no values.
   537  func (ol OperationList) IsEmpty() bool {
   538  	return ol.Value == nil || len(*ol.Value) == 0
   539  }
   540  
   541  // hasNextLink returns true if the NextLink is not empty.
   542  func (ol OperationList) hasNextLink() bool {
   543  	return ol.NextLink != nil && len(*ol.NextLink) != 0
   544  }
   545  
   546  // operationListPreparer prepares a request to retrieve the next set of results.
   547  // It returns nil if no more results exist.
   548  func (ol OperationList) operationListPreparer(ctx context.Context) (*http.Request, error) {
   549  	if !ol.hasNextLink() {
   550  		return nil, nil
   551  	}
   552  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   553  		autorest.AsJSON(),
   554  		autorest.AsGet(),
   555  		autorest.WithBaseURL(to.String(ol.NextLink)))
   556  }
   557  
   558  // OperationListPage contains a page of Operation values.
   559  type OperationListPage struct {
   560  	fn func(context.Context, OperationList) (OperationList, error)
   561  	ol OperationList
   562  }
   563  
   564  // NextWithContext advances to the next page of values.  If there was an error making
   565  // the request the page does not advance and the error is returned.
   566  func (page *OperationListPage) NextWithContext(ctx context.Context) (err error) {
   567  	if tracing.IsEnabled() {
   568  		ctx = tracing.StartSpan(ctx, fqdn+"/OperationListPage.NextWithContext")
   569  		defer func() {
   570  			sc := -1
   571  			if page.Response().Response.Response != nil {
   572  				sc = page.Response().Response.Response.StatusCode
   573  			}
   574  			tracing.EndSpan(ctx, sc, err)
   575  		}()
   576  	}
   577  	for {
   578  		next, err := page.fn(ctx, page.ol)
   579  		if err != nil {
   580  			return err
   581  		}
   582  		page.ol = next
   583  		if !next.hasNextLink() || !next.IsEmpty() {
   584  			break
   585  		}
   586  	}
   587  	return nil
   588  }
   589  
   590  // Next advances to the next page of values.  If there was an error making
   591  // the request the page does not advance and the error is returned.
   592  // Deprecated: Use NextWithContext() instead.
   593  func (page *OperationListPage) Next() error {
   594  	return page.NextWithContext(context.Background())
   595  }
   596  
   597  // NotDone returns true if the page enumeration should be started or is not yet complete.
   598  func (page OperationListPage) NotDone() bool {
   599  	return !page.ol.IsEmpty()
   600  }
   601  
   602  // Response returns the raw server response from the last page request.
   603  func (page OperationListPage) Response() OperationList {
   604  	return page.ol
   605  }
   606  
   607  // Values returns the slice of values for the current page or nil if there are no values.
   608  func (page OperationListPage) Values() []Operation {
   609  	if page.ol.IsEmpty() {
   610  		return nil
   611  	}
   612  	return *page.ol.Value
   613  }
   614  
   615  // Creates a new instance of the OperationListPage type.
   616  func NewOperationListPage(cur OperationList, getNextPage func(context.Context, OperationList) (OperationList, error)) OperationListPage {
   617  	return OperationListPage{
   618  		fn: getNextPage,
   619  		ol: cur,
   620  	}
   621  }
   622  
   623  // ProxyResource the resource model definition for a Azure Resource Manager proxy resource. It will not
   624  // have tags and a location
   625  type ProxyResource struct {
   626  	// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
   627  	ID *string `json:"id,omitempty"`
   628  	// Name - READ-ONLY; The name of the resource
   629  	Name *string `json:"name,omitempty"`
   630  	// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
   631  	Type *string `json:"type,omitempty"`
   632  }
   633  
   634  // MarshalJSON is the custom marshaler for ProxyResource.
   635  func (pr ProxyResource) MarshalJSON() ([]byte, error) {
   636  	objectMap := make(map[string]interface{})
   637  	return json.Marshal(objectMap)
   638  }
   639  
   640  // Resource common fields that are returned in the response for all Azure Resource Manager resources
   641  type Resource struct {
   642  	// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
   643  	ID *string `json:"id,omitempty"`
   644  	// Name - READ-ONLY; The name of the resource
   645  	Name *string `json:"name,omitempty"`
   646  	// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
   647  	Type *string `json:"type,omitempty"`
   648  }
   649  
   650  // MarshalJSON is the custom marshaler for Resource.
   651  func (r Resource) MarshalJSON() ([]byte, error) {
   652  	objectMap := make(map[string]interface{})
   653  	return json.Marshal(objectMap)
   654  }
   655  
   656  // TrackedResource the resource model definition for an Azure Resource Manager tracked top level resource
   657  // which has 'tags' and a 'location'
   658  type TrackedResource struct {
   659  	// Tags - Resource tags.
   660  	Tags map[string]*string `json:"tags"`
   661  	// Location - The geo-location where the resource lives
   662  	Location *string `json:"location,omitempty"`
   663  	// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
   664  	ID *string `json:"id,omitempty"`
   665  	// Name - READ-ONLY; The name of the resource
   666  	Name *string `json:"name,omitempty"`
   667  	// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
   668  	Type *string `json:"type,omitempty"`
   669  }
   670  
   671  // MarshalJSON is the custom marshaler for TrackedResource.
   672  func (tr TrackedResource) MarshalJSON() ([]byte, error) {
   673  	objectMap := make(map[string]interface{})
   674  	if tr.Tags != nil {
   675  		objectMap["tags"] = tr.Tags
   676  	}
   677  	if tr.Location != nil {
   678  		objectMap["location"] = tr.Location
   679  	}
   680  	return json.Marshal(objectMap)
   681  }
   682  

View as plain text