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