...

Source file src/github.com/Azure/azure-sdk-for-go/services/provisioningservices/mgmt/2017-11-15/iothub/models.go

Documentation: github.com/Azure/azure-sdk-for-go/services/provisioningservices/mgmt/2017-11-15/iothub

     1  package iothub
     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/provisioningservices/mgmt/2017-11-15/iothub"
    22  
    23  // AsyncOperationResult result of a long running operation.
    24  type AsyncOperationResult struct {
    25  	autorest.Response `json:"-"`
    26  	// Status - current status of a long running operation.
    27  	Status *string `json:"status,omitempty"`
    28  	// Error - Error message containing code, description and details
    29  	Error *ErrorMesssage `json:"error,omitempty"`
    30  }
    31  
    32  // CertificateBodyDescription the JSON-serialized X509 Certificate.
    33  type CertificateBodyDescription struct {
    34  	// Certificate - Base-64 representation of the X509 leaf certificate .cer file or just .pem file content.
    35  	Certificate *string `json:"certificate,omitempty"`
    36  }
    37  
    38  // CertificateListDescription the JSON-serialized array of Certificate objects.
    39  type CertificateListDescription struct {
    40  	autorest.Response `json:"-"`
    41  	// Value - The array of Certificate objects.
    42  	Value *[]CertificateResponse `json:"value,omitempty"`
    43  }
    44  
    45  // CertificateProperties the description of an X509 CA Certificate.
    46  type CertificateProperties struct {
    47  	// Subject - READ-ONLY; The certificate's subject name.
    48  	Subject *string `json:"subject,omitempty"`
    49  	// Expiry - READ-ONLY; The certificate's expiration date and time.
    50  	Expiry *date.TimeRFC1123 `json:"expiry,omitempty"`
    51  	// Thumbprint - READ-ONLY; The certificate's thumbprint.
    52  	Thumbprint *string `json:"thumbprint,omitempty"`
    53  	// IsVerified - READ-ONLY; Determines whether certificate has been verified.
    54  	IsVerified *bool `json:"isVerified,omitempty"`
    55  	// Created - READ-ONLY; The certificate's creation date and time.
    56  	Created *date.TimeRFC1123 `json:"created,omitempty"`
    57  	// Updated - READ-ONLY; The certificate's last update date and time.
    58  	Updated *date.TimeRFC1123 `json:"updated,omitempty"`
    59  }
    60  
    61  // MarshalJSON is the custom marshaler for CertificateProperties.
    62  func (cp CertificateProperties) MarshalJSON() ([]byte, error) {
    63  	objectMap := make(map[string]interface{})
    64  	return json.Marshal(objectMap)
    65  }
    66  
    67  // CertificateResponse the X509 Certificate.
    68  type CertificateResponse struct {
    69  	autorest.Response `json:"-"`
    70  	// Properties - properties of a certificate
    71  	Properties *CertificateProperties `json:"properties,omitempty"`
    72  	// ID - READ-ONLY; The resource identifier.
    73  	ID *string `json:"id,omitempty"`
    74  	// Name - READ-ONLY; The name of the certificate.
    75  	Name *string `json:"name,omitempty"`
    76  	// Etag - READ-ONLY; The entity tag.
    77  	Etag *string `json:"etag,omitempty"`
    78  	// Type - READ-ONLY; The resource type.
    79  	Type *string `json:"type,omitempty"`
    80  }
    81  
    82  // MarshalJSON is the custom marshaler for CertificateResponse.
    83  func (cr CertificateResponse) MarshalJSON() ([]byte, error) {
    84  	objectMap := make(map[string]interface{})
    85  	if cr.Properties != nil {
    86  		objectMap["properties"] = cr.Properties
    87  	}
    88  	return json.Marshal(objectMap)
    89  }
    90  
    91  // DefinitionDescription description of the IoT hub.
    92  type DefinitionDescription struct {
    93  	// ApplyAllocationPolicy - Flag for applying allocationPolicy or not for a given IoT hub.
    94  	ApplyAllocationPolicy *bool `json:"applyAllocationPolicy,omitempty"`
    95  	// AllocationWeight - Weight to apply for a given IoT hub.
    96  	AllocationWeight *int32 `json:"allocationWeight,omitempty"`
    97  	// Name - READ-ONLY; Host name of the IoT hub.
    98  	Name *string `json:"name,omitempty"`
    99  	// ConnectionString - Connection string of the IoT hub.
   100  	ConnectionString *string `json:"connectionString,omitempty"`
   101  	// Location - ARM region of the IoT hub.
   102  	Location *string `json:"location,omitempty"`
   103  }
   104  
   105  // MarshalJSON is the custom marshaler for DefinitionDescription.
   106  func (dd DefinitionDescription) MarshalJSON() ([]byte, error) {
   107  	objectMap := make(map[string]interface{})
   108  	if dd.ApplyAllocationPolicy != nil {
   109  		objectMap["applyAllocationPolicy"] = dd.ApplyAllocationPolicy
   110  	}
   111  	if dd.AllocationWeight != nil {
   112  		objectMap["allocationWeight"] = dd.AllocationWeight
   113  	}
   114  	if dd.ConnectionString != nil {
   115  		objectMap["connectionString"] = dd.ConnectionString
   116  	}
   117  	if dd.Location != nil {
   118  		objectMap["location"] = dd.Location
   119  	}
   120  	return json.Marshal(objectMap)
   121  }
   122  
   123  // ErrorDetails error details.
   124  type ErrorDetails struct {
   125  	// Code - READ-ONLY; The error code.
   126  	Code *string `json:"Code,omitempty"`
   127  	// HTTPStatusCode - READ-ONLY; The HTTP status code.
   128  	HTTPStatusCode *string `json:"HttpStatusCode,omitempty"`
   129  	// Message - READ-ONLY; The error message.
   130  	Message *string `json:"Message,omitempty"`
   131  	// Details - READ-ONLY; The error details.
   132  	Details *string `json:"Details,omitempty"`
   133  }
   134  
   135  // MarshalJSON is the custom marshaler for ErrorDetails.
   136  func (ed ErrorDetails) MarshalJSON() ([]byte, error) {
   137  	objectMap := make(map[string]interface{})
   138  	return json.Marshal(objectMap)
   139  }
   140  
   141  // ErrorMesssage error response containing message and code.
   142  type ErrorMesssage struct {
   143  	// Code - standard error code
   144  	Code *string `json:"code,omitempty"`
   145  	// Message - standard error description
   146  	Message *string `json:"message,omitempty"`
   147  	// Details - detailed summary of error
   148  	Details *string `json:"details,omitempty"`
   149  }
   150  
   151  // IotDpsPropertiesDescription the service specific properties of a provisioning service, including keys,
   152  // linked iot hubs, current state, and system generated properties such as hostname and idScope
   153  type IotDpsPropertiesDescription struct {
   154  	// State - Current state of the provisioning service. Possible values include: 'Activating', 'Active', 'Deleting', 'Deleted', 'ActivationFailed', 'DeletionFailed', 'Transitioning', 'Suspending', 'Suspended', 'Resuming', 'FailingOver', 'FailoverFailed'
   155  	State State `json:"state,omitempty"`
   156  	// ProvisioningState - The ARM provisioning state of the provisioning service.
   157  	ProvisioningState *string `json:"provisioningState,omitempty"`
   158  	// IotHubs - List of IoT hubs associated with this provisioning service.
   159  	IotHubs *[]DefinitionDescription `json:"iotHubs,omitempty"`
   160  	// AllocationPolicy - Allocation policy to be used by this provisioning service. Possible values include: 'Hashed', 'GeoLatency', 'Static'
   161  	AllocationPolicy AllocationPolicy `json:"allocationPolicy,omitempty"`
   162  	// ServiceOperationsHostName - READ-ONLY; Service endpoint for provisioning service.
   163  	ServiceOperationsHostName *string `json:"serviceOperationsHostName,omitempty"`
   164  	// DeviceProvisioningHostName - READ-ONLY; Device endpoint for this provisioning service.
   165  	DeviceProvisioningHostName *string `json:"deviceProvisioningHostName,omitempty"`
   166  	// IDScope - READ-ONLY; Unique identifier of this provisioning service.
   167  	IDScope *string `json:"idScope,omitempty"`
   168  	// AuthorizationPolicies - List of authorization keys for a provisioning service.
   169  	AuthorizationPolicies *[]SharedAccessSignatureAuthorizationRuleAccessRightsDescription `json:"authorizationPolicies,omitempty"`
   170  }
   171  
   172  // MarshalJSON is the custom marshaler for IotDpsPropertiesDescription.
   173  func (idpd IotDpsPropertiesDescription) MarshalJSON() ([]byte, error) {
   174  	objectMap := make(map[string]interface{})
   175  	if idpd.State != "" {
   176  		objectMap["state"] = idpd.State
   177  	}
   178  	if idpd.ProvisioningState != nil {
   179  		objectMap["provisioningState"] = idpd.ProvisioningState
   180  	}
   181  	if idpd.IotHubs != nil {
   182  		objectMap["iotHubs"] = idpd.IotHubs
   183  	}
   184  	if idpd.AllocationPolicy != "" {
   185  		objectMap["allocationPolicy"] = idpd.AllocationPolicy
   186  	}
   187  	if idpd.AuthorizationPolicies != nil {
   188  		objectMap["authorizationPolicies"] = idpd.AuthorizationPolicies
   189  	}
   190  	return json.Marshal(objectMap)
   191  }
   192  
   193  // IotDpsResourceCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a
   194  // long-running operation.
   195  type IotDpsResourceCreateOrUpdateFuture struct {
   196  	azure.FutureAPI
   197  	// Result returns the result of the asynchronous operation.
   198  	// If the operation has not completed it will return an error.
   199  	Result func(IotDpsResourceClient) (ProvisioningServiceDescription, error)
   200  }
   201  
   202  // UnmarshalJSON is the custom unmarshaller for CreateFuture.
   203  func (future *IotDpsResourceCreateOrUpdateFuture) UnmarshalJSON(body []byte) error {
   204  	var azFuture azure.Future
   205  	if err := json.Unmarshal(body, &azFuture); err != nil {
   206  		return err
   207  	}
   208  	future.FutureAPI = &azFuture
   209  	future.Result = future.result
   210  	return nil
   211  }
   212  
   213  // result is the default implementation for IotDpsResourceCreateOrUpdateFuture.Result.
   214  func (future *IotDpsResourceCreateOrUpdateFuture) result(client IotDpsResourceClient) (psd ProvisioningServiceDescription, err error) {
   215  	var done bool
   216  	done, err = future.DoneWithContext(context.Background(), client)
   217  	if err != nil {
   218  		err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceCreateOrUpdateFuture", "Result", future.Response(), "Polling failure")
   219  		return
   220  	}
   221  	if !done {
   222  		psd.Response.Response = future.Response()
   223  		err = azure.NewAsyncOpIncompleteError("iothub.IotDpsResourceCreateOrUpdateFuture")
   224  		return
   225  	}
   226  	sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   227  	if psd.Response.Response, err = future.GetResult(sender); err == nil && psd.Response.Response.StatusCode != http.StatusNoContent {
   228  		psd, err = client.CreateOrUpdateResponder(psd.Response.Response)
   229  		if err != nil {
   230  			err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceCreateOrUpdateFuture", "Result", psd.Response.Response, "Failure responding to request")
   231  		}
   232  	}
   233  	return
   234  }
   235  
   236  // IotDpsResourceDeleteFuture an abstraction for monitoring and retrieving the results of a long-running
   237  // operation.
   238  type IotDpsResourceDeleteFuture struct {
   239  	azure.FutureAPI
   240  	// Result returns the result of the asynchronous operation.
   241  	// If the operation has not completed it will return an error.
   242  	Result func(IotDpsResourceClient) (autorest.Response, error)
   243  }
   244  
   245  // UnmarshalJSON is the custom unmarshaller for CreateFuture.
   246  func (future *IotDpsResourceDeleteFuture) UnmarshalJSON(body []byte) error {
   247  	var azFuture azure.Future
   248  	if err := json.Unmarshal(body, &azFuture); err != nil {
   249  		return err
   250  	}
   251  	future.FutureAPI = &azFuture
   252  	future.Result = future.result
   253  	return nil
   254  }
   255  
   256  // result is the default implementation for IotDpsResourceDeleteFuture.Result.
   257  func (future *IotDpsResourceDeleteFuture) result(client IotDpsResourceClient) (ar autorest.Response, err error) {
   258  	var done bool
   259  	done, err = future.DoneWithContext(context.Background(), client)
   260  	if err != nil {
   261  		err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceDeleteFuture", "Result", future.Response(), "Polling failure")
   262  		return
   263  	}
   264  	if !done {
   265  		ar.Response = future.Response()
   266  		err = azure.NewAsyncOpIncompleteError("iothub.IotDpsResourceDeleteFuture")
   267  		return
   268  	}
   269  	ar.Response = future.Response()
   270  	return
   271  }
   272  
   273  // IotDpsResourceUpdateFuture an abstraction for monitoring and retrieving the results of a long-running
   274  // operation.
   275  type IotDpsResourceUpdateFuture struct {
   276  	azure.FutureAPI
   277  	// Result returns the result of the asynchronous operation.
   278  	// If the operation has not completed it will return an error.
   279  	Result func(IotDpsResourceClient) (ProvisioningServiceDescription, error)
   280  }
   281  
   282  // UnmarshalJSON is the custom unmarshaller for CreateFuture.
   283  func (future *IotDpsResourceUpdateFuture) UnmarshalJSON(body []byte) error {
   284  	var azFuture azure.Future
   285  	if err := json.Unmarshal(body, &azFuture); err != nil {
   286  		return err
   287  	}
   288  	future.FutureAPI = &azFuture
   289  	future.Result = future.result
   290  	return nil
   291  }
   292  
   293  // result is the default implementation for IotDpsResourceUpdateFuture.Result.
   294  func (future *IotDpsResourceUpdateFuture) result(client IotDpsResourceClient) (psd ProvisioningServiceDescription, err error) {
   295  	var done bool
   296  	done, err = future.DoneWithContext(context.Background(), client)
   297  	if err != nil {
   298  		err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceUpdateFuture", "Result", future.Response(), "Polling failure")
   299  		return
   300  	}
   301  	if !done {
   302  		psd.Response.Response = future.Response()
   303  		err = azure.NewAsyncOpIncompleteError("iothub.IotDpsResourceUpdateFuture")
   304  		return
   305  	}
   306  	sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   307  	if psd.Response.Response, err = future.GetResult(sender); err == nil && psd.Response.Response.StatusCode != http.StatusNoContent {
   308  		psd, err = client.UpdateResponder(psd.Response.Response)
   309  		if err != nil {
   310  			err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceUpdateFuture", "Result", psd.Response.Response, "Failure responding to request")
   311  		}
   312  	}
   313  	return
   314  }
   315  
   316  // IotDpsSkuDefinition available SKUs of tier and units.
   317  type IotDpsSkuDefinition struct {
   318  	// Name - SKU name. Possible values include: 'S1'
   319  	Name IotDpsSku `json:"name,omitempty"`
   320  }
   321  
   322  // IotDpsSkuDefinitionListResult list of available SKUs.
   323  type IotDpsSkuDefinitionListResult struct {
   324  	autorest.Response `json:"-"`
   325  	// Value - The list of SKUs
   326  	Value *[]IotDpsSkuDefinition `json:"value,omitempty"`
   327  	// NextLink - READ-ONLY; The next link.
   328  	NextLink *string `json:"nextLink,omitempty"`
   329  }
   330  
   331  // MarshalJSON is the custom marshaler for IotDpsSkuDefinitionListResult.
   332  func (idsdlr IotDpsSkuDefinitionListResult) MarshalJSON() ([]byte, error) {
   333  	objectMap := make(map[string]interface{})
   334  	if idsdlr.Value != nil {
   335  		objectMap["value"] = idsdlr.Value
   336  	}
   337  	return json.Marshal(objectMap)
   338  }
   339  
   340  // IotDpsSkuDefinitionListResultIterator provides access to a complete listing of IotDpsSkuDefinition
   341  // values.
   342  type IotDpsSkuDefinitionListResultIterator struct {
   343  	i    int
   344  	page IotDpsSkuDefinitionListResultPage
   345  }
   346  
   347  // NextWithContext advances to the next value.  If there was an error making
   348  // the request the iterator does not advance and the error is returned.
   349  func (iter *IotDpsSkuDefinitionListResultIterator) NextWithContext(ctx context.Context) (err error) {
   350  	if tracing.IsEnabled() {
   351  		ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsSkuDefinitionListResultIterator.NextWithContext")
   352  		defer func() {
   353  			sc := -1
   354  			if iter.Response().Response.Response != nil {
   355  				sc = iter.Response().Response.Response.StatusCode
   356  			}
   357  			tracing.EndSpan(ctx, sc, err)
   358  		}()
   359  	}
   360  	iter.i++
   361  	if iter.i < len(iter.page.Values()) {
   362  		return nil
   363  	}
   364  	err = iter.page.NextWithContext(ctx)
   365  	if err != nil {
   366  		iter.i--
   367  		return err
   368  	}
   369  	iter.i = 0
   370  	return nil
   371  }
   372  
   373  // Next 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  // Deprecated: Use NextWithContext() instead.
   376  func (iter *IotDpsSkuDefinitionListResultIterator) Next() error {
   377  	return iter.NextWithContext(context.Background())
   378  }
   379  
   380  // NotDone returns true if the enumeration should be started or is not yet complete.
   381  func (iter IotDpsSkuDefinitionListResultIterator) NotDone() bool {
   382  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
   383  }
   384  
   385  // Response returns the raw server response from the last page request.
   386  func (iter IotDpsSkuDefinitionListResultIterator) Response() IotDpsSkuDefinitionListResult {
   387  	return iter.page.Response()
   388  }
   389  
   390  // Value returns the current value or a zero-initialized value if the
   391  // iterator has advanced beyond the end of the collection.
   392  func (iter IotDpsSkuDefinitionListResultIterator) Value() IotDpsSkuDefinition {
   393  	if !iter.page.NotDone() {
   394  		return IotDpsSkuDefinition{}
   395  	}
   396  	return iter.page.Values()[iter.i]
   397  }
   398  
   399  // Creates a new instance of the IotDpsSkuDefinitionListResultIterator type.
   400  func NewIotDpsSkuDefinitionListResultIterator(page IotDpsSkuDefinitionListResultPage) IotDpsSkuDefinitionListResultIterator {
   401  	return IotDpsSkuDefinitionListResultIterator{page: page}
   402  }
   403  
   404  // IsEmpty returns true if the ListResult contains no values.
   405  func (idsdlr IotDpsSkuDefinitionListResult) IsEmpty() bool {
   406  	return idsdlr.Value == nil || len(*idsdlr.Value) == 0
   407  }
   408  
   409  // hasNextLink returns true if the NextLink is not empty.
   410  func (idsdlr IotDpsSkuDefinitionListResult) hasNextLink() bool {
   411  	return idsdlr.NextLink != nil && len(*idsdlr.NextLink) != 0
   412  }
   413  
   414  // iotDpsSkuDefinitionListResultPreparer prepares a request to retrieve the next set of results.
   415  // It returns nil if no more results exist.
   416  func (idsdlr IotDpsSkuDefinitionListResult) iotDpsSkuDefinitionListResultPreparer(ctx context.Context) (*http.Request, error) {
   417  	if !idsdlr.hasNextLink() {
   418  		return nil, nil
   419  	}
   420  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   421  		autorest.AsJSON(),
   422  		autorest.AsGet(),
   423  		autorest.WithBaseURL(to.String(idsdlr.NextLink)))
   424  }
   425  
   426  // IotDpsSkuDefinitionListResultPage contains a page of IotDpsSkuDefinition values.
   427  type IotDpsSkuDefinitionListResultPage struct {
   428  	fn     func(context.Context, IotDpsSkuDefinitionListResult) (IotDpsSkuDefinitionListResult, error)
   429  	idsdlr IotDpsSkuDefinitionListResult
   430  }
   431  
   432  // NextWithContext advances to the next page of values.  If there was an error making
   433  // the request the page does not advance and the error is returned.
   434  func (page *IotDpsSkuDefinitionListResultPage) NextWithContext(ctx context.Context) (err error) {
   435  	if tracing.IsEnabled() {
   436  		ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsSkuDefinitionListResultPage.NextWithContext")
   437  		defer func() {
   438  			sc := -1
   439  			if page.Response().Response.Response != nil {
   440  				sc = page.Response().Response.Response.StatusCode
   441  			}
   442  			tracing.EndSpan(ctx, sc, err)
   443  		}()
   444  	}
   445  	for {
   446  		next, err := page.fn(ctx, page.idsdlr)
   447  		if err != nil {
   448  			return err
   449  		}
   450  		page.idsdlr = next
   451  		if !next.hasNextLink() || !next.IsEmpty() {
   452  			break
   453  		}
   454  	}
   455  	return nil
   456  }
   457  
   458  // Next 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  // Deprecated: Use NextWithContext() instead.
   461  func (page *IotDpsSkuDefinitionListResultPage) Next() error {
   462  	return page.NextWithContext(context.Background())
   463  }
   464  
   465  // NotDone returns true if the page enumeration should be started or is not yet complete.
   466  func (page IotDpsSkuDefinitionListResultPage) NotDone() bool {
   467  	return !page.idsdlr.IsEmpty()
   468  }
   469  
   470  // Response returns the raw server response from the last page request.
   471  func (page IotDpsSkuDefinitionListResultPage) Response() IotDpsSkuDefinitionListResult {
   472  	return page.idsdlr
   473  }
   474  
   475  // Values returns the slice of values for the current page or nil if there are no values.
   476  func (page IotDpsSkuDefinitionListResultPage) Values() []IotDpsSkuDefinition {
   477  	if page.idsdlr.IsEmpty() {
   478  		return nil
   479  	}
   480  	return *page.idsdlr.Value
   481  }
   482  
   483  // Creates a new instance of the IotDpsSkuDefinitionListResultPage type.
   484  func NewIotDpsSkuDefinitionListResultPage(cur IotDpsSkuDefinitionListResult, getNextPage func(context.Context, IotDpsSkuDefinitionListResult) (IotDpsSkuDefinitionListResult, error)) IotDpsSkuDefinitionListResultPage {
   485  	return IotDpsSkuDefinitionListResultPage{
   486  		fn:     getNextPage,
   487  		idsdlr: cur,
   488  	}
   489  }
   490  
   491  // IotDpsSkuInfo list of possible provisioning service SKUs.
   492  type IotDpsSkuInfo struct {
   493  	// Name - Sku name. Possible values include: 'S1'
   494  	Name IotDpsSku `json:"name,omitempty"`
   495  	// Tier - READ-ONLY; Pricing tier name of the provisioning service.
   496  	Tier *string `json:"tier,omitempty"`
   497  	// Capacity - The number of units to provision
   498  	Capacity *int64 `json:"capacity,omitempty"`
   499  }
   500  
   501  // MarshalJSON is the custom marshaler for IotDpsSkuInfo.
   502  func (idsi IotDpsSkuInfo) MarshalJSON() ([]byte, error) {
   503  	objectMap := make(map[string]interface{})
   504  	if idsi.Name != "" {
   505  		objectMap["name"] = idsi.Name
   506  	}
   507  	if idsi.Capacity != nil {
   508  		objectMap["capacity"] = idsi.Capacity
   509  	}
   510  	return json.Marshal(objectMap)
   511  }
   512  
   513  // NameAvailabilityInfo description of name availability.
   514  type NameAvailabilityInfo struct {
   515  	autorest.Response `json:"-"`
   516  	// NameAvailable - specifies if a name is available or not
   517  	NameAvailable *bool `json:"nameAvailable,omitempty"`
   518  	// Reason - specifies the reason a name is unavailable. Possible values include: 'Invalid', 'AlreadyExists'
   519  	Reason NameUnavailabilityReason `json:"reason,omitempty"`
   520  	// Message - message containing a detailed reason name is unavailable
   521  	Message *string `json:"message,omitempty"`
   522  }
   523  
   524  // Operation ioT Hub REST API operation.
   525  type Operation struct {
   526  	// Name - READ-ONLY; Operation name: {provider}/{resource}/{read | write | action | delete}
   527  	Name *string `json:"name,omitempty"`
   528  	// Display - The object that represents the operation.
   529  	Display *OperationDisplay `json:"display,omitempty"`
   530  }
   531  
   532  // MarshalJSON is the custom marshaler for Operation.
   533  func (o Operation) MarshalJSON() ([]byte, error) {
   534  	objectMap := make(map[string]interface{})
   535  	if o.Display != nil {
   536  		objectMap["display"] = o.Display
   537  	}
   538  	return json.Marshal(objectMap)
   539  }
   540  
   541  // OperationDisplay the object that represents the operation.
   542  type OperationDisplay struct {
   543  	// Provider - READ-ONLY; Service provider: Microsoft Devices.
   544  	Provider *string `json:"provider,omitempty"`
   545  	// Resource - READ-ONLY; Resource Type: ProvisioningServices.
   546  	Resource *string `json:"resource,omitempty"`
   547  	// Operation - READ-ONLY; Name of the operation.
   548  	Operation *string `json:"operation,omitempty"`
   549  }
   550  
   551  // MarshalJSON is the custom marshaler for OperationDisplay.
   552  func (o OperationDisplay) MarshalJSON() ([]byte, error) {
   553  	objectMap := make(map[string]interface{})
   554  	return json.Marshal(objectMap)
   555  }
   556  
   557  // OperationInputs input values for operation results call.
   558  type OperationInputs struct {
   559  	// Name - The name of the Provisioning Service to check.
   560  	Name *string `json:"name,omitempty"`
   561  }
   562  
   563  // OperationListResult result of the request to list IoT Hub operations. It contains a list of operations
   564  // and a URL link to get the next set of results.
   565  type OperationListResult struct {
   566  	autorest.Response `json:"-"`
   567  	// Value - READ-ONLY; List of IoT Hub operations supported by the Microsoft.Devices resource provider.
   568  	Value *[]Operation `json:"value,omitempty"`
   569  	// NextLink - READ-ONLY; URL to get the next set of operation list results if there are any.
   570  	NextLink *string `json:"nextLink,omitempty"`
   571  }
   572  
   573  // MarshalJSON is the custom marshaler for OperationListResult.
   574  func (olr OperationListResult) MarshalJSON() ([]byte, error) {
   575  	objectMap := make(map[string]interface{})
   576  	return json.Marshal(objectMap)
   577  }
   578  
   579  // OperationListResultIterator provides access to a complete listing of Operation values.
   580  type OperationListResultIterator struct {
   581  	i    int
   582  	page OperationListResultPage
   583  }
   584  
   585  // NextWithContext advances to the next value.  If there was an error making
   586  // the request the iterator does not advance and the error is returned.
   587  func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) {
   588  	if tracing.IsEnabled() {
   589  		ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext")
   590  		defer func() {
   591  			sc := -1
   592  			if iter.Response().Response.Response != nil {
   593  				sc = iter.Response().Response.Response.StatusCode
   594  			}
   595  			tracing.EndSpan(ctx, sc, err)
   596  		}()
   597  	}
   598  	iter.i++
   599  	if iter.i < len(iter.page.Values()) {
   600  		return nil
   601  	}
   602  	err = iter.page.NextWithContext(ctx)
   603  	if err != nil {
   604  		iter.i--
   605  		return err
   606  	}
   607  	iter.i = 0
   608  	return nil
   609  }
   610  
   611  // Next advances to the next value.  If there was an error making
   612  // the request the iterator does not advance and the error is returned.
   613  // Deprecated: Use NextWithContext() instead.
   614  func (iter *OperationListResultIterator) Next() error {
   615  	return iter.NextWithContext(context.Background())
   616  }
   617  
   618  // NotDone returns true if the enumeration should be started or is not yet complete.
   619  func (iter OperationListResultIterator) NotDone() bool {
   620  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
   621  }
   622  
   623  // Response returns the raw server response from the last page request.
   624  func (iter OperationListResultIterator) Response() OperationListResult {
   625  	return iter.page.Response()
   626  }
   627  
   628  // Value returns the current value or a zero-initialized value if the
   629  // iterator has advanced beyond the end of the collection.
   630  func (iter OperationListResultIterator) Value() Operation {
   631  	if !iter.page.NotDone() {
   632  		return Operation{}
   633  	}
   634  	return iter.page.Values()[iter.i]
   635  }
   636  
   637  // Creates a new instance of the OperationListResultIterator type.
   638  func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator {
   639  	return OperationListResultIterator{page: page}
   640  }
   641  
   642  // IsEmpty returns true if the ListResult contains no values.
   643  func (olr OperationListResult) IsEmpty() bool {
   644  	return olr.Value == nil || len(*olr.Value) == 0
   645  }
   646  
   647  // hasNextLink returns true if the NextLink is not empty.
   648  func (olr OperationListResult) hasNextLink() bool {
   649  	return olr.NextLink != nil && len(*olr.NextLink) != 0
   650  }
   651  
   652  // operationListResultPreparer prepares a request to retrieve the next set of results.
   653  // It returns nil if no more results exist.
   654  func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) {
   655  	if !olr.hasNextLink() {
   656  		return nil, nil
   657  	}
   658  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   659  		autorest.AsJSON(),
   660  		autorest.AsGet(),
   661  		autorest.WithBaseURL(to.String(olr.NextLink)))
   662  }
   663  
   664  // OperationListResultPage contains a page of Operation values.
   665  type OperationListResultPage struct {
   666  	fn  func(context.Context, OperationListResult) (OperationListResult, error)
   667  	olr OperationListResult
   668  }
   669  
   670  // NextWithContext advances to the next page of values.  If there was an error making
   671  // the request the page does not advance and the error is returned.
   672  func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) {
   673  	if tracing.IsEnabled() {
   674  		ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext")
   675  		defer func() {
   676  			sc := -1
   677  			if page.Response().Response.Response != nil {
   678  				sc = page.Response().Response.Response.StatusCode
   679  			}
   680  			tracing.EndSpan(ctx, sc, err)
   681  		}()
   682  	}
   683  	for {
   684  		next, err := page.fn(ctx, page.olr)
   685  		if err != nil {
   686  			return err
   687  		}
   688  		page.olr = next
   689  		if !next.hasNextLink() || !next.IsEmpty() {
   690  			break
   691  		}
   692  	}
   693  	return nil
   694  }
   695  
   696  // Next advances to the next page of values.  If there was an error making
   697  // the request the page does not advance and the error is returned.
   698  // Deprecated: Use NextWithContext() instead.
   699  func (page *OperationListResultPage) Next() error {
   700  	return page.NextWithContext(context.Background())
   701  }
   702  
   703  // NotDone returns true if the page enumeration should be started or is not yet complete.
   704  func (page OperationListResultPage) NotDone() bool {
   705  	return !page.olr.IsEmpty()
   706  }
   707  
   708  // Response returns the raw server response from the last page request.
   709  func (page OperationListResultPage) Response() OperationListResult {
   710  	return page.olr
   711  }
   712  
   713  // Values returns the slice of values for the current page or nil if there are no values.
   714  func (page OperationListResultPage) Values() []Operation {
   715  	if page.olr.IsEmpty() {
   716  		return nil
   717  	}
   718  	return *page.olr.Value
   719  }
   720  
   721  // Creates a new instance of the OperationListResultPage type.
   722  func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage {
   723  	return OperationListResultPage{
   724  		fn:  getNextPage,
   725  		olr: cur,
   726  	}
   727  }
   728  
   729  // ProvisioningServiceDescription the description of the provisioning service.
   730  type ProvisioningServiceDescription struct {
   731  	autorest.Response `json:"-"`
   732  	// Etag - The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention.
   733  	Etag *string `json:"etag,omitempty"`
   734  	// Properties - Service specific properties for a provisioning service
   735  	Properties *IotDpsPropertiesDescription `json:"properties,omitempty"`
   736  	// Sku - SKU info for a provisioning service.
   737  	Sku *IotDpsSkuInfo `json:"sku,omitempty"`
   738  	// ID - READ-ONLY; The resource identifier.
   739  	ID *string `json:"id,omitempty"`
   740  	// Name - READ-ONLY; The resource name.
   741  	Name *string `json:"name,omitempty"`
   742  	// Type - READ-ONLY; The resource type.
   743  	Type *string `json:"type,omitempty"`
   744  	// Location - The resource location.
   745  	Location *string `json:"location,omitempty"`
   746  	// Tags - The resource tags.
   747  	Tags map[string]*string `json:"tags"`
   748  }
   749  
   750  // MarshalJSON is the custom marshaler for ProvisioningServiceDescription.
   751  func (psd ProvisioningServiceDescription) MarshalJSON() ([]byte, error) {
   752  	objectMap := make(map[string]interface{})
   753  	if psd.Etag != nil {
   754  		objectMap["etag"] = psd.Etag
   755  	}
   756  	if psd.Properties != nil {
   757  		objectMap["properties"] = psd.Properties
   758  	}
   759  	if psd.Sku != nil {
   760  		objectMap["sku"] = psd.Sku
   761  	}
   762  	if psd.Location != nil {
   763  		objectMap["location"] = psd.Location
   764  	}
   765  	if psd.Tags != nil {
   766  		objectMap["tags"] = psd.Tags
   767  	}
   768  	return json.Marshal(objectMap)
   769  }
   770  
   771  // ProvisioningServiceDescriptionListResult list of provisioning service descriptions.
   772  type ProvisioningServiceDescriptionListResult struct {
   773  	autorest.Response `json:"-"`
   774  	// Value - List of provisioning service descriptions.
   775  	Value *[]ProvisioningServiceDescription `json:"value,omitempty"`
   776  	// NextLink - READ-ONLY; the next link
   777  	NextLink *string `json:"nextLink,omitempty"`
   778  }
   779  
   780  // MarshalJSON is the custom marshaler for ProvisioningServiceDescriptionListResult.
   781  func (psdlr ProvisioningServiceDescriptionListResult) MarshalJSON() ([]byte, error) {
   782  	objectMap := make(map[string]interface{})
   783  	if psdlr.Value != nil {
   784  		objectMap["value"] = psdlr.Value
   785  	}
   786  	return json.Marshal(objectMap)
   787  }
   788  
   789  // ProvisioningServiceDescriptionListResultIterator provides access to a complete listing of
   790  // ProvisioningServiceDescription values.
   791  type ProvisioningServiceDescriptionListResultIterator struct {
   792  	i    int
   793  	page ProvisioningServiceDescriptionListResultPage
   794  }
   795  
   796  // NextWithContext advances to the next value.  If there was an error making
   797  // the request the iterator does not advance and the error is returned.
   798  func (iter *ProvisioningServiceDescriptionListResultIterator) NextWithContext(ctx context.Context) (err error) {
   799  	if tracing.IsEnabled() {
   800  		ctx = tracing.StartSpan(ctx, fqdn+"/ProvisioningServiceDescriptionListResultIterator.NextWithContext")
   801  		defer func() {
   802  			sc := -1
   803  			if iter.Response().Response.Response != nil {
   804  				sc = iter.Response().Response.Response.StatusCode
   805  			}
   806  			tracing.EndSpan(ctx, sc, err)
   807  		}()
   808  	}
   809  	iter.i++
   810  	if iter.i < len(iter.page.Values()) {
   811  		return nil
   812  	}
   813  	err = iter.page.NextWithContext(ctx)
   814  	if err != nil {
   815  		iter.i--
   816  		return err
   817  	}
   818  	iter.i = 0
   819  	return nil
   820  }
   821  
   822  // Next advances to the next value.  If there was an error making
   823  // the request the iterator does not advance and the error is returned.
   824  // Deprecated: Use NextWithContext() instead.
   825  func (iter *ProvisioningServiceDescriptionListResultIterator) Next() error {
   826  	return iter.NextWithContext(context.Background())
   827  }
   828  
   829  // NotDone returns true if the enumeration should be started or is not yet complete.
   830  func (iter ProvisioningServiceDescriptionListResultIterator) NotDone() bool {
   831  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
   832  }
   833  
   834  // Response returns the raw server response from the last page request.
   835  func (iter ProvisioningServiceDescriptionListResultIterator) Response() ProvisioningServiceDescriptionListResult {
   836  	return iter.page.Response()
   837  }
   838  
   839  // Value returns the current value or a zero-initialized value if the
   840  // iterator has advanced beyond the end of the collection.
   841  func (iter ProvisioningServiceDescriptionListResultIterator) Value() ProvisioningServiceDescription {
   842  	if !iter.page.NotDone() {
   843  		return ProvisioningServiceDescription{}
   844  	}
   845  	return iter.page.Values()[iter.i]
   846  }
   847  
   848  // Creates a new instance of the ProvisioningServiceDescriptionListResultIterator type.
   849  func NewProvisioningServiceDescriptionListResultIterator(page ProvisioningServiceDescriptionListResultPage) ProvisioningServiceDescriptionListResultIterator {
   850  	return ProvisioningServiceDescriptionListResultIterator{page: page}
   851  }
   852  
   853  // IsEmpty returns true if the ListResult contains no values.
   854  func (psdlr ProvisioningServiceDescriptionListResult) IsEmpty() bool {
   855  	return psdlr.Value == nil || len(*psdlr.Value) == 0
   856  }
   857  
   858  // hasNextLink returns true if the NextLink is not empty.
   859  func (psdlr ProvisioningServiceDescriptionListResult) hasNextLink() bool {
   860  	return psdlr.NextLink != nil && len(*psdlr.NextLink) != 0
   861  }
   862  
   863  // provisioningServiceDescriptionListResultPreparer prepares a request to retrieve the next set of results.
   864  // It returns nil if no more results exist.
   865  func (psdlr ProvisioningServiceDescriptionListResult) provisioningServiceDescriptionListResultPreparer(ctx context.Context) (*http.Request, error) {
   866  	if !psdlr.hasNextLink() {
   867  		return nil, nil
   868  	}
   869  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   870  		autorest.AsJSON(),
   871  		autorest.AsGet(),
   872  		autorest.WithBaseURL(to.String(psdlr.NextLink)))
   873  }
   874  
   875  // ProvisioningServiceDescriptionListResultPage contains a page of ProvisioningServiceDescription values.
   876  type ProvisioningServiceDescriptionListResultPage struct {
   877  	fn    func(context.Context, ProvisioningServiceDescriptionListResult) (ProvisioningServiceDescriptionListResult, error)
   878  	psdlr ProvisioningServiceDescriptionListResult
   879  }
   880  
   881  // NextWithContext advances to the next page of values.  If there was an error making
   882  // the request the page does not advance and the error is returned.
   883  func (page *ProvisioningServiceDescriptionListResultPage) NextWithContext(ctx context.Context) (err error) {
   884  	if tracing.IsEnabled() {
   885  		ctx = tracing.StartSpan(ctx, fqdn+"/ProvisioningServiceDescriptionListResultPage.NextWithContext")
   886  		defer func() {
   887  			sc := -1
   888  			if page.Response().Response.Response != nil {
   889  				sc = page.Response().Response.Response.StatusCode
   890  			}
   891  			tracing.EndSpan(ctx, sc, err)
   892  		}()
   893  	}
   894  	for {
   895  		next, err := page.fn(ctx, page.psdlr)
   896  		if err != nil {
   897  			return err
   898  		}
   899  		page.psdlr = next
   900  		if !next.hasNextLink() || !next.IsEmpty() {
   901  			break
   902  		}
   903  	}
   904  	return nil
   905  }
   906  
   907  // Next advances to the next page of values.  If there was an error making
   908  // the request the page does not advance and the error is returned.
   909  // Deprecated: Use NextWithContext() instead.
   910  func (page *ProvisioningServiceDescriptionListResultPage) Next() error {
   911  	return page.NextWithContext(context.Background())
   912  }
   913  
   914  // NotDone returns true if the page enumeration should be started or is not yet complete.
   915  func (page ProvisioningServiceDescriptionListResultPage) NotDone() bool {
   916  	return !page.psdlr.IsEmpty()
   917  }
   918  
   919  // Response returns the raw server response from the last page request.
   920  func (page ProvisioningServiceDescriptionListResultPage) Response() ProvisioningServiceDescriptionListResult {
   921  	return page.psdlr
   922  }
   923  
   924  // Values returns the slice of values for the current page or nil if there are no values.
   925  func (page ProvisioningServiceDescriptionListResultPage) Values() []ProvisioningServiceDescription {
   926  	if page.psdlr.IsEmpty() {
   927  		return nil
   928  	}
   929  	return *page.psdlr.Value
   930  }
   931  
   932  // Creates a new instance of the ProvisioningServiceDescriptionListResultPage type.
   933  func NewProvisioningServiceDescriptionListResultPage(cur ProvisioningServiceDescriptionListResult, getNextPage func(context.Context, ProvisioningServiceDescriptionListResult) (ProvisioningServiceDescriptionListResult, error)) ProvisioningServiceDescriptionListResultPage {
   934  	return ProvisioningServiceDescriptionListResultPage{
   935  		fn:    getNextPage,
   936  		psdlr: cur,
   937  	}
   938  }
   939  
   940  // Resource the common properties of an Azure resource.
   941  type Resource struct {
   942  	// ID - READ-ONLY; The resource identifier.
   943  	ID *string `json:"id,omitempty"`
   944  	// Name - READ-ONLY; The resource name.
   945  	Name *string `json:"name,omitempty"`
   946  	// Type - READ-ONLY; The resource type.
   947  	Type *string `json:"type,omitempty"`
   948  	// Location - The resource location.
   949  	Location *string `json:"location,omitempty"`
   950  	// Tags - The resource tags.
   951  	Tags map[string]*string `json:"tags"`
   952  }
   953  
   954  // MarshalJSON is the custom marshaler for Resource.
   955  func (r Resource) MarshalJSON() ([]byte, error) {
   956  	objectMap := make(map[string]interface{})
   957  	if r.Location != nil {
   958  		objectMap["location"] = r.Location
   959  	}
   960  	if r.Tags != nil {
   961  		objectMap["tags"] = r.Tags
   962  	}
   963  	return json.Marshal(objectMap)
   964  }
   965  
   966  // SharedAccessSignatureAuthorizationRuleAccessRightsDescription description of the shared access key.
   967  type SharedAccessSignatureAuthorizationRuleAccessRightsDescription struct {
   968  	autorest.Response `json:"-"`
   969  	// KeyName - Name of the key.
   970  	KeyName *string `json:"keyName,omitempty"`
   971  	// PrimaryKey - Primary SAS key value.
   972  	PrimaryKey *string `json:"primaryKey,omitempty"`
   973  	// SecondaryKey - Secondary SAS key value.
   974  	SecondaryKey *string `json:"secondaryKey,omitempty"`
   975  	// Rights - Rights that this key has. Possible values include: 'ServiceConfig', 'EnrollmentRead', 'EnrollmentWrite', 'DeviceConnect', 'RegistrationStatusRead', 'RegistrationStatusWrite'
   976  	Rights AccessRightsDescription `json:"rights,omitempty"`
   977  }
   978  
   979  // SharedAccessSignatureAuthorizationRuleListResult list of shared access keys.
   980  type SharedAccessSignatureAuthorizationRuleListResult struct {
   981  	autorest.Response `json:"-"`
   982  	// Value - The list of shared access policies.
   983  	Value *[]SharedAccessSignatureAuthorizationRuleAccessRightsDescription `json:"value,omitempty"`
   984  	// NextLink - READ-ONLY; The next link.
   985  	NextLink *string `json:"nextLink,omitempty"`
   986  }
   987  
   988  // MarshalJSON is the custom marshaler for SharedAccessSignatureAuthorizationRuleListResult.
   989  func (sasarlr SharedAccessSignatureAuthorizationRuleListResult) MarshalJSON() ([]byte, error) {
   990  	objectMap := make(map[string]interface{})
   991  	if sasarlr.Value != nil {
   992  		objectMap["value"] = sasarlr.Value
   993  	}
   994  	return json.Marshal(objectMap)
   995  }
   996  
   997  // SharedAccessSignatureAuthorizationRuleListResultIterator provides access to a complete listing of
   998  // SharedAccessSignatureAuthorizationRuleAccessRightsDescription values.
   999  type SharedAccessSignatureAuthorizationRuleListResultIterator struct {
  1000  	i    int
  1001  	page SharedAccessSignatureAuthorizationRuleListResultPage
  1002  }
  1003  
  1004  // NextWithContext advances to the next value.  If there was an error making
  1005  // the request the iterator does not advance and the error is returned.
  1006  func (iter *SharedAccessSignatureAuthorizationRuleListResultIterator) NextWithContext(ctx context.Context) (err error) {
  1007  	if tracing.IsEnabled() {
  1008  		ctx = tracing.StartSpan(ctx, fqdn+"/SharedAccessSignatureAuthorizationRuleListResultIterator.NextWithContext")
  1009  		defer func() {
  1010  			sc := -1
  1011  			if iter.Response().Response.Response != nil {
  1012  				sc = iter.Response().Response.Response.StatusCode
  1013  			}
  1014  			tracing.EndSpan(ctx, sc, err)
  1015  		}()
  1016  	}
  1017  	iter.i++
  1018  	if iter.i < len(iter.page.Values()) {
  1019  		return nil
  1020  	}
  1021  	err = iter.page.NextWithContext(ctx)
  1022  	if err != nil {
  1023  		iter.i--
  1024  		return err
  1025  	}
  1026  	iter.i = 0
  1027  	return nil
  1028  }
  1029  
  1030  // Next advances to the next value.  If there was an error making
  1031  // the request the iterator does not advance and the error is returned.
  1032  // Deprecated: Use NextWithContext() instead.
  1033  func (iter *SharedAccessSignatureAuthorizationRuleListResultIterator) Next() error {
  1034  	return iter.NextWithContext(context.Background())
  1035  }
  1036  
  1037  // NotDone returns true if the enumeration should be started or is not yet complete.
  1038  func (iter SharedAccessSignatureAuthorizationRuleListResultIterator) NotDone() bool {
  1039  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
  1040  }
  1041  
  1042  // Response returns the raw server response from the last page request.
  1043  func (iter SharedAccessSignatureAuthorizationRuleListResultIterator) Response() SharedAccessSignatureAuthorizationRuleListResult {
  1044  	return iter.page.Response()
  1045  }
  1046  
  1047  // Value returns the current value or a zero-initialized value if the
  1048  // iterator has advanced beyond the end of the collection.
  1049  func (iter SharedAccessSignatureAuthorizationRuleListResultIterator) Value() SharedAccessSignatureAuthorizationRuleAccessRightsDescription {
  1050  	if !iter.page.NotDone() {
  1051  		return SharedAccessSignatureAuthorizationRuleAccessRightsDescription{}
  1052  	}
  1053  	return iter.page.Values()[iter.i]
  1054  }
  1055  
  1056  // Creates a new instance of the SharedAccessSignatureAuthorizationRuleListResultIterator type.
  1057  func NewSharedAccessSignatureAuthorizationRuleListResultIterator(page SharedAccessSignatureAuthorizationRuleListResultPage) SharedAccessSignatureAuthorizationRuleListResultIterator {
  1058  	return SharedAccessSignatureAuthorizationRuleListResultIterator{page: page}
  1059  }
  1060  
  1061  // IsEmpty returns true if the ListResult contains no values.
  1062  func (sasarlr SharedAccessSignatureAuthorizationRuleListResult) IsEmpty() bool {
  1063  	return sasarlr.Value == nil || len(*sasarlr.Value) == 0
  1064  }
  1065  
  1066  // hasNextLink returns true if the NextLink is not empty.
  1067  func (sasarlr SharedAccessSignatureAuthorizationRuleListResult) hasNextLink() bool {
  1068  	return sasarlr.NextLink != nil && len(*sasarlr.NextLink) != 0
  1069  }
  1070  
  1071  // sharedAccessSignatureAuthorizationRuleListResultPreparer prepares a request to retrieve the next set of results.
  1072  // It returns nil if no more results exist.
  1073  func (sasarlr SharedAccessSignatureAuthorizationRuleListResult) sharedAccessSignatureAuthorizationRuleListResultPreparer(ctx context.Context) (*http.Request, error) {
  1074  	if !sasarlr.hasNextLink() {
  1075  		return nil, nil
  1076  	}
  1077  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
  1078  		autorest.AsJSON(),
  1079  		autorest.AsGet(),
  1080  		autorest.WithBaseURL(to.String(sasarlr.NextLink)))
  1081  }
  1082  
  1083  // SharedAccessSignatureAuthorizationRuleListResultPage contains a page of
  1084  // SharedAccessSignatureAuthorizationRuleAccessRightsDescription values.
  1085  type SharedAccessSignatureAuthorizationRuleListResultPage struct {
  1086  	fn      func(context.Context, SharedAccessSignatureAuthorizationRuleListResult) (SharedAccessSignatureAuthorizationRuleListResult, error)
  1087  	sasarlr SharedAccessSignatureAuthorizationRuleListResult
  1088  }
  1089  
  1090  // NextWithContext advances to the next page of values.  If there was an error making
  1091  // the request the page does not advance and the error is returned.
  1092  func (page *SharedAccessSignatureAuthorizationRuleListResultPage) NextWithContext(ctx context.Context) (err error) {
  1093  	if tracing.IsEnabled() {
  1094  		ctx = tracing.StartSpan(ctx, fqdn+"/SharedAccessSignatureAuthorizationRuleListResultPage.NextWithContext")
  1095  		defer func() {
  1096  			sc := -1
  1097  			if page.Response().Response.Response != nil {
  1098  				sc = page.Response().Response.Response.StatusCode
  1099  			}
  1100  			tracing.EndSpan(ctx, sc, err)
  1101  		}()
  1102  	}
  1103  	for {
  1104  		next, err := page.fn(ctx, page.sasarlr)
  1105  		if err != nil {
  1106  			return err
  1107  		}
  1108  		page.sasarlr = next
  1109  		if !next.hasNextLink() || !next.IsEmpty() {
  1110  			break
  1111  		}
  1112  	}
  1113  	return nil
  1114  }
  1115  
  1116  // Next advances to the next page of values.  If there was an error making
  1117  // the request the page does not advance and the error is returned.
  1118  // Deprecated: Use NextWithContext() instead.
  1119  func (page *SharedAccessSignatureAuthorizationRuleListResultPage) Next() error {
  1120  	return page.NextWithContext(context.Background())
  1121  }
  1122  
  1123  // NotDone returns true if the page enumeration should be started or is not yet complete.
  1124  func (page SharedAccessSignatureAuthorizationRuleListResultPage) NotDone() bool {
  1125  	return !page.sasarlr.IsEmpty()
  1126  }
  1127  
  1128  // Response returns the raw server response from the last page request.
  1129  func (page SharedAccessSignatureAuthorizationRuleListResultPage) Response() SharedAccessSignatureAuthorizationRuleListResult {
  1130  	return page.sasarlr
  1131  }
  1132  
  1133  // Values returns the slice of values for the current page or nil if there are no values.
  1134  func (page SharedAccessSignatureAuthorizationRuleListResultPage) Values() []SharedAccessSignatureAuthorizationRuleAccessRightsDescription {
  1135  	if page.sasarlr.IsEmpty() {
  1136  		return nil
  1137  	}
  1138  	return *page.sasarlr.Value
  1139  }
  1140  
  1141  // Creates a new instance of the SharedAccessSignatureAuthorizationRuleListResultPage type.
  1142  func NewSharedAccessSignatureAuthorizationRuleListResultPage(cur SharedAccessSignatureAuthorizationRuleListResult, getNextPage func(context.Context, SharedAccessSignatureAuthorizationRuleListResult) (SharedAccessSignatureAuthorizationRuleListResult, error)) SharedAccessSignatureAuthorizationRuleListResultPage {
  1143  	return SharedAccessSignatureAuthorizationRuleListResultPage{
  1144  		fn:      getNextPage,
  1145  		sasarlr: cur,
  1146  	}
  1147  }
  1148  
  1149  // TagsResource a container holding only the Tags for a resource, allowing the user to update the tags on a
  1150  // Provisioning Service instance.
  1151  type TagsResource struct {
  1152  	// Tags - Resource tags
  1153  	Tags map[string]*string `json:"tags"`
  1154  }
  1155  
  1156  // MarshalJSON is the custom marshaler for TagsResource.
  1157  func (tr TagsResource) MarshalJSON() ([]byte, error) {
  1158  	objectMap := make(map[string]interface{})
  1159  	if tr.Tags != nil {
  1160  		objectMap["tags"] = tr.Tags
  1161  	}
  1162  	return json.Marshal(objectMap)
  1163  }
  1164  
  1165  // VerificationCodeRequest the JSON-serialized leaf certificate
  1166  type VerificationCodeRequest struct {
  1167  	// Certificate - base-64 representation of X509 certificate .cer file or just .pem file content.
  1168  	Certificate *string `json:"certificate,omitempty"`
  1169  }
  1170  
  1171  // VerificationCodeResponse description of the response of the verification code.
  1172  type VerificationCodeResponse struct {
  1173  	autorest.Response `json:"-"`
  1174  	// Name - READ-ONLY; Name of certificate.
  1175  	Name *string `json:"name,omitempty"`
  1176  	// Etag - READ-ONLY; Request etag.
  1177  	Etag *string `json:"etag,omitempty"`
  1178  	// ID - READ-ONLY; The resource identifier.
  1179  	ID *string `json:"id,omitempty"`
  1180  	// Type - READ-ONLY; The resource type.
  1181  	Type       *string                             `json:"type,omitempty"`
  1182  	Properties *VerificationCodeResponseProperties `json:"properties,omitempty"`
  1183  }
  1184  
  1185  // MarshalJSON is the custom marshaler for VerificationCodeResponse.
  1186  func (vcr VerificationCodeResponse) MarshalJSON() ([]byte, error) {
  1187  	objectMap := make(map[string]interface{})
  1188  	if vcr.Properties != nil {
  1189  		objectMap["properties"] = vcr.Properties
  1190  	}
  1191  	return json.Marshal(objectMap)
  1192  }
  1193  
  1194  // VerificationCodeResponseProperties ...
  1195  type VerificationCodeResponseProperties struct {
  1196  	// VerificationCode - Verification code.
  1197  	VerificationCode *string `json:"verificationCode,omitempty"`
  1198  	// Subject - Certificate subject.
  1199  	Subject *string `json:"subject,omitempty"`
  1200  	// Expiry - Code expiry.
  1201  	Expiry *string `json:"expiry,omitempty"`
  1202  	// Thumbprint - Certificate thumbprint.
  1203  	Thumbprint *string `json:"thumbprint,omitempty"`
  1204  	// IsVerified - Indicate if the certificate is verified by owner of private key.
  1205  	IsVerified *bool `json:"isVerified,omitempty"`
  1206  	// Created - Certificate created time.
  1207  	Created *string `json:"created,omitempty"`
  1208  	// Updated - Certificate updated time.
  1209  	Updated *string `json:"updated,omitempty"`
  1210  }
  1211  

View as plain text