...

Source file src/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2017-09-01/skus/models.go

Documentation: github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2017-09-01/skus

     1  package skus
     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/compute/mgmt/2017-09-01/skus"
    20  
    21  // ResourceSku describes an available Compute SKU.
    22  type ResourceSku struct {
    23  	// ResourceType - READ-ONLY; The type of resource the SKU applies to.
    24  	ResourceType *string `json:"resourceType,omitempty"`
    25  	// Name - READ-ONLY; The name of SKU.
    26  	Name *string `json:"name,omitempty"`
    27  	// Tier - READ-ONLY; Specifies the tier of virtual machines in a scale set.<br /><br /> Possible Values:<br /><br /> **Standard**<br /><br /> **Basic**
    28  	Tier *string `json:"tier,omitempty"`
    29  	// Size - READ-ONLY; The Size of the SKU.
    30  	Size *string `json:"size,omitempty"`
    31  	// Family - READ-ONLY; The Family of this particular SKU.
    32  	Family *string `json:"family,omitempty"`
    33  	// Kind - READ-ONLY; The Kind of resources that are supported in this SKU.
    34  	Kind *string `json:"kind,omitempty"`
    35  	// Capacity - READ-ONLY; Specifies the number of virtual machines in the scale set.
    36  	Capacity *ResourceSkuCapacity `json:"capacity,omitempty"`
    37  	// Locations - READ-ONLY; The set of locations that the SKU is available.
    38  	Locations *[]string `json:"locations,omitempty"`
    39  	// LocationInfo - READ-ONLY; A list of locations and availability zones in those locations where the SKU is available.
    40  	LocationInfo *[]ResourceSkuLocationInfo `json:"locationInfo,omitempty"`
    41  	// APIVersions - READ-ONLY; The api versions that support this SKU.
    42  	APIVersions *[]string `json:"apiVersions,omitempty"`
    43  	// Costs - READ-ONLY; Metadata for retrieving price info.
    44  	Costs *[]ResourceSkuCosts `json:"costs,omitempty"`
    45  	// Capabilities - READ-ONLY; A name value pair to describe the capability.
    46  	Capabilities *[]ResourceSkuCapabilities `json:"capabilities,omitempty"`
    47  	// Restrictions - READ-ONLY; The restrictions because of which SKU cannot be used. This is empty if there are no restrictions.
    48  	Restrictions *[]ResourceSkuRestrictions `json:"restrictions,omitempty"`
    49  }
    50  
    51  // MarshalJSON is the custom marshaler for ResourceSku.
    52  func (rs ResourceSku) MarshalJSON() ([]byte, error) {
    53  	objectMap := make(map[string]interface{})
    54  	return json.Marshal(objectMap)
    55  }
    56  
    57  // ResourceSkuCapabilities describes The SKU capabilities object.
    58  type ResourceSkuCapabilities struct {
    59  	// Name - READ-ONLY; An invariant to describe the feature.
    60  	Name *string `json:"name,omitempty"`
    61  	// Value - READ-ONLY; An invariant if the feature is measured by quantity.
    62  	Value *string `json:"value,omitempty"`
    63  }
    64  
    65  // MarshalJSON is the custom marshaler for ResourceSkuCapabilities.
    66  func (rsc ResourceSkuCapabilities) MarshalJSON() ([]byte, error) {
    67  	objectMap := make(map[string]interface{})
    68  	return json.Marshal(objectMap)
    69  }
    70  
    71  // ResourceSkuCapacity describes scaling information of a SKU.
    72  type ResourceSkuCapacity struct {
    73  	// Minimum - READ-ONLY; The minimum capacity.
    74  	Minimum *int64 `json:"minimum,omitempty"`
    75  	// Maximum - READ-ONLY; The maximum capacity that can be set.
    76  	Maximum *int64 `json:"maximum,omitempty"`
    77  	// Default - READ-ONLY; The default capacity.
    78  	Default *int64 `json:"default,omitempty"`
    79  	// ScaleType - READ-ONLY; The scale type applicable to the sku. Possible values include: 'Automatic', 'Manual', 'None'
    80  	ScaleType ResourceSkuCapacityScaleType `json:"scaleType,omitempty"`
    81  }
    82  
    83  // MarshalJSON is the custom marshaler for ResourceSkuCapacity.
    84  func (rsc ResourceSkuCapacity) MarshalJSON() ([]byte, error) {
    85  	objectMap := make(map[string]interface{})
    86  	return json.Marshal(objectMap)
    87  }
    88  
    89  // ResourceSkuCosts describes metadata for retrieving price info.
    90  type ResourceSkuCosts struct {
    91  	// MeterID - READ-ONLY; Used for querying price from commerce.
    92  	MeterID *string `json:"meterID,omitempty"`
    93  	// Quantity - READ-ONLY; The multiplier is needed to extend the base metered cost.
    94  	Quantity *int64 `json:"quantity,omitempty"`
    95  	// ExtendedUnit - READ-ONLY; An invariant to show the extended unit.
    96  	ExtendedUnit *string `json:"extendedUnit,omitempty"`
    97  }
    98  
    99  // MarshalJSON is the custom marshaler for ResourceSkuCosts.
   100  func (rsc ResourceSkuCosts) MarshalJSON() ([]byte, error) {
   101  	objectMap := make(map[string]interface{})
   102  	return json.Marshal(objectMap)
   103  }
   104  
   105  // ResourceSkuLocationInfo ...
   106  type ResourceSkuLocationInfo struct {
   107  	// Location - READ-ONLY; Location of the SKU
   108  	Location *string `json:"location,omitempty"`
   109  	// Zones - READ-ONLY; List of availability zones where the SKU is supported.
   110  	Zones *[]string `json:"zones,omitempty"`
   111  }
   112  
   113  // MarshalJSON is the custom marshaler for ResourceSkuLocationInfo.
   114  func (rsli ResourceSkuLocationInfo) MarshalJSON() ([]byte, error) {
   115  	objectMap := make(map[string]interface{})
   116  	return json.Marshal(objectMap)
   117  }
   118  
   119  // ResourceSkuRestrictionInfo ...
   120  type ResourceSkuRestrictionInfo struct {
   121  	// Locations - READ-ONLY; Locations where the SKU is restricted
   122  	Locations *[]string `json:"locations,omitempty"`
   123  	// Zones - READ-ONLY; List of availability zones where the SKU is restricted.
   124  	Zones *[]string `json:"zones,omitempty"`
   125  }
   126  
   127  // MarshalJSON is the custom marshaler for ResourceSkuRestrictionInfo.
   128  func (rsri ResourceSkuRestrictionInfo) MarshalJSON() ([]byte, error) {
   129  	objectMap := make(map[string]interface{})
   130  	return json.Marshal(objectMap)
   131  }
   132  
   133  // ResourceSkuRestrictions describes scaling information of a SKU.
   134  type ResourceSkuRestrictions struct {
   135  	// Type - READ-ONLY; The type of restrictions. Possible values include: 'Location', 'Zone'
   136  	Type ResourceSkuRestrictionsType `json:"type,omitempty"`
   137  	// Values - READ-ONLY; The value of restrictions. If the restriction type is set to location. This would be different locations where the SKU is restricted.
   138  	Values *[]string `json:"values,omitempty"`
   139  	// RestrictionInfo - READ-ONLY; The information about the restriction where the SKU cannot be used.
   140  	RestrictionInfo *ResourceSkuRestrictionInfo `json:"restrictionInfo,omitempty"`
   141  	// ReasonCode - READ-ONLY; The reason for restriction. Possible values include: 'QuotaID', 'NotAvailableForSubscription'
   142  	ReasonCode ResourceSkuRestrictionsReasonCode `json:"reasonCode,omitempty"`
   143  }
   144  
   145  // MarshalJSON is the custom marshaler for ResourceSkuRestrictions.
   146  func (rsr ResourceSkuRestrictions) MarshalJSON() ([]byte, error) {
   147  	objectMap := make(map[string]interface{})
   148  	return json.Marshal(objectMap)
   149  }
   150  
   151  // ResourceSkusResult the List Resource Skus operation response.
   152  type ResourceSkusResult struct {
   153  	autorest.Response `json:"-"`
   154  	// Value - The list of skus available for the subscription.
   155  	Value *[]ResourceSku `json:"value,omitempty"`
   156  	// NextLink - The URI to fetch the next page of Resource Skus. Call ListNext() with this URI to fetch the next page of Resource Skus
   157  	NextLink *string `json:"nextLink,omitempty"`
   158  }
   159  
   160  // ResourceSkusResultIterator provides access to a complete listing of ResourceSku values.
   161  type ResourceSkusResultIterator struct {
   162  	i    int
   163  	page ResourceSkusResultPage
   164  }
   165  
   166  // NextWithContext advances to the next value.  If there was an error making
   167  // the request the iterator does not advance and the error is returned.
   168  func (iter *ResourceSkusResultIterator) NextWithContext(ctx context.Context) (err error) {
   169  	if tracing.IsEnabled() {
   170  		ctx = tracing.StartSpan(ctx, fqdn+"/ResourceSkusResultIterator.NextWithContext")
   171  		defer func() {
   172  			sc := -1
   173  			if iter.Response().Response.Response != nil {
   174  				sc = iter.Response().Response.Response.StatusCode
   175  			}
   176  			tracing.EndSpan(ctx, sc, err)
   177  		}()
   178  	}
   179  	iter.i++
   180  	if iter.i < len(iter.page.Values()) {
   181  		return nil
   182  	}
   183  	err = iter.page.NextWithContext(ctx)
   184  	if err != nil {
   185  		iter.i--
   186  		return err
   187  	}
   188  	iter.i = 0
   189  	return nil
   190  }
   191  
   192  // Next advances to the next value.  If there was an error making
   193  // the request the iterator does not advance and the error is returned.
   194  // Deprecated: Use NextWithContext() instead.
   195  func (iter *ResourceSkusResultIterator) Next() error {
   196  	return iter.NextWithContext(context.Background())
   197  }
   198  
   199  // NotDone returns true if the enumeration should be started or is not yet complete.
   200  func (iter ResourceSkusResultIterator) NotDone() bool {
   201  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
   202  }
   203  
   204  // Response returns the raw server response from the last page request.
   205  func (iter ResourceSkusResultIterator) Response() ResourceSkusResult {
   206  	return iter.page.Response()
   207  }
   208  
   209  // Value returns the current value or a zero-initialized value if the
   210  // iterator has advanced beyond the end of the collection.
   211  func (iter ResourceSkusResultIterator) Value() ResourceSku {
   212  	if !iter.page.NotDone() {
   213  		return ResourceSku{}
   214  	}
   215  	return iter.page.Values()[iter.i]
   216  }
   217  
   218  // Creates a new instance of the ResourceSkusResultIterator type.
   219  func NewResourceSkusResultIterator(page ResourceSkusResultPage) ResourceSkusResultIterator {
   220  	return ResourceSkusResultIterator{page: page}
   221  }
   222  
   223  // IsEmpty returns true if the ListResult contains no values.
   224  func (rsr ResourceSkusResult) IsEmpty() bool {
   225  	return rsr.Value == nil || len(*rsr.Value) == 0
   226  }
   227  
   228  // hasNextLink returns true if the NextLink is not empty.
   229  func (rsr ResourceSkusResult) hasNextLink() bool {
   230  	return rsr.NextLink != nil && len(*rsr.NextLink) != 0
   231  }
   232  
   233  // resourceSkusResultPreparer prepares a request to retrieve the next set of results.
   234  // It returns nil if no more results exist.
   235  func (rsr ResourceSkusResult) resourceSkusResultPreparer(ctx context.Context) (*http.Request, error) {
   236  	if !rsr.hasNextLink() {
   237  		return nil, nil
   238  	}
   239  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   240  		autorest.AsJSON(),
   241  		autorest.AsGet(),
   242  		autorest.WithBaseURL(to.String(rsr.NextLink)))
   243  }
   244  
   245  // ResourceSkusResultPage contains a page of ResourceSku values.
   246  type ResourceSkusResultPage struct {
   247  	fn  func(context.Context, ResourceSkusResult) (ResourceSkusResult, error)
   248  	rsr ResourceSkusResult
   249  }
   250  
   251  // NextWithContext advances to the next page of values.  If there was an error making
   252  // the request the page does not advance and the error is returned.
   253  func (page *ResourceSkusResultPage) NextWithContext(ctx context.Context) (err error) {
   254  	if tracing.IsEnabled() {
   255  		ctx = tracing.StartSpan(ctx, fqdn+"/ResourceSkusResultPage.NextWithContext")
   256  		defer func() {
   257  			sc := -1
   258  			if page.Response().Response.Response != nil {
   259  				sc = page.Response().Response.Response.StatusCode
   260  			}
   261  			tracing.EndSpan(ctx, sc, err)
   262  		}()
   263  	}
   264  	for {
   265  		next, err := page.fn(ctx, page.rsr)
   266  		if err != nil {
   267  			return err
   268  		}
   269  		page.rsr = next
   270  		if !next.hasNextLink() || !next.IsEmpty() {
   271  			break
   272  		}
   273  	}
   274  	return nil
   275  }
   276  
   277  // Next advances to the next page of values.  If there was an error making
   278  // the request the page does not advance and the error is returned.
   279  // Deprecated: Use NextWithContext() instead.
   280  func (page *ResourceSkusResultPage) Next() error {
   281  	return page.NextWithContext(context.Background())
   282  }
   283  
   284  // NotDone returns true if the page enumeration should be started or is not yet complete.
   285  func (page ResourceSkusResultPage) NotDone() bool {
   286  	return !page.rsr.IsEmpty()
   287  }
   288  
   289  // Response returns the raw server response from the last page request.
   290  func (page ResourceSkusResultPage) Response() ResourceSkusResult {
   291  	return page.rsr
   292  }
   293  
   294  // Values returns the slice of values for the current page or nil if there are no values.
   295  func (page ResourceSkusResultPage) Values() []ResourceSku {
   296  	if page.rsr.IsEmpty() {
   297  		return nil
   298  	}
   299  	return *page.rsr.Value
   300  }
   301  
   302  // Creates a new instance of the ResourceSkusResultPage type.
   303  func NewResourceSkusResultPage(cur ResourceSkusResult, getNextPage func(context.Context, ResourceSkusResult) (ResourceSkusResult, error)) ResourceSkusResultPage {
   304  	return ResourceSkusResultPage{
   305  		fn:  getNextPage,
   306  		rsr: cur,
   307  	}
   308  }
   309  

View as plain text