1 package skus
2
3
4
5
6
7
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
19 const fqdn = "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2017-09-01/skus"
20
21
22 type ResourceSku struct {
23
24 ResourceType *string `json:"resourceType,omitempty"`
25
26 Name *string `json:"name,omitempty"`
27
28 Tier *string `json:"tier,omitempty"`
29
30 Size *string `json:"size,omitempty"`
31
32 Family *string `json:"family,omitempty"`
33
34 Kind *string `json:"kind,omitempty"`
35
36 Capacity *ResourceSkuCapacity `json:"capacity,omitempty"`
37
38 Locations *[]string `json:"locations,omitempty"`
39
40 LocationInfo *[]ResourceSkuLocationInfo `json:"locationInfo,omitempty"`
41
42 APIVersions *[]string `json:"apiVersions,omitempty"`
43
44 Costs *[]ResourceSkuCosts `json:"costs,omitempty"`
45
46 Capabilities *[]ResourceSkuCapabilities `json:"capabilities,omitempty"`
47
48 Restrictions *[]ResourceSkuRestrictions `json:"restrictions,omitempty"`
49 }
50
51
52 func (rs ResourceSku) MarshalJSON() ([]byte, error) {
53 objectMap := make(map[string]interface{})
54 return json.Marshal(objectMap)
55 }
56
57
58 type ResourceSkuCapabilities struct {
59
60 Name *string `json:"name,omitempty"`
61
62 Value *string `json:"value,omitempty"`
63 }
64
65
66 func (rsc ResourceSkuCapabilities) MarshalJSON() ([]byte, error) {
67 objectMap := make(map[string]interface{})
68 return json.Marshal(objectMap)
69 }
70
71
72 type ResourceSkuCapacity struct {
73
74 Minimum *int64 `json:"minimum,omitempty"`
75
76 Maximum *int64 `json:"maximum,omitempty"`
77
78 Default *int64 `json:"default,omitempty"`
79
80 ScaleType ResourceSkuCapacityScaleType `json:"scaleType,omitempty"`
81 }
82
83
84 func (rsc ResourceSkuCapacity) MarshalJSON() ([]byte, error) {
85 objectMap := make(map[string]interface{})
86 return json.Marshal(objectMap)
87 }
88
89
90 type ResourceSkuCosts struct {
91
92 MeterID *string `json:"meterID,omitempty"`
93
94 Quantity *int64 `json:"quantity,omitempty"`
95
96 ExtendedUnit *string `json:"extendedUnit,omitempty"`
97 }
98
99
100 func (rsc ResourceSkuCosts) MarshalJSON() ([]byte, error) {
101 objectMap := make(map[string]interface{})
102 return json.Marshal(objectMap)
103 }
104
105
106 type ResourceSkuLocationInfo struct {
107
108 Location *string `json:"location,omitempty"`
109
110 Zones *[]string `json:"zones,omitempty"`
111 }
112
113
114 func (rsli ResourceSkuLocationInfo) MarshalJSON() ([]byte, error) {
115 objectMap := make(map[string]interface{})
116 return json.Marshal(objectMap)
117 }
118
119
120 type ResourceSkuRestrictionInfo struct {
121
122 Locations *[]string `json:"locations,omitempty"`
123
124 Zones *[]string `json:"zones,omitempty"`
125 }
126
127
128 func (rsri ResourceSkuRestrictionInfo) MarshalJSON() ([]byte, error) {
129 objectMap := make(map[string]interface{})
130 return json.Marshal(objectMap)
131 }
132
133
134 type ResourceSkuRestrictions struct {
135
136 Type ResourceSkuRestrictionsType `json:"type,omitempty"`
137
138 Values *[]string `json:"values,omitempty"`
139
140 RestrictionInfo *ResourceSkuRestrictionInfo `json:"restrictionInfo,omitempty"`
141
142 ReasonCode ResourceSkuRestrictionsReasonCode `json:"reasonCode,omitempty"`
143 }
144
145
146 func (rsr ResourceSkuRestrictions) MarshalJSON() ([]byte, error) {
147 objectMap := make(map[string]interface{})
148 return json.Marshal(objectMap)
149 }
150
151
152 type ResourceSkusResult struct {
153 autorest.Response `json:"-"`
154
155 Value *[]ResourceSku `json:"value,omitempty"`
156
157 NextLink *string `json:"nextLink,omitempty"`
158 }
159
160
161 type ResourceSkusResultIterator struct {
162 i int
163 page ResourceSkusResultPage
164 }
165
166
167
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
193
194
195 func (iter *ResourceSkusResultIterator) Next() error {
196 return iter.NextWithContext(context.Background())
197 }
198
199
200 func (iter ResourceSkusResultIterator) NotDone() bool {
201 return iter.page.NotDone() && iter.i < len(iter.page.Values())
202 }
203
204
205 func (iter ResourceSkusResultIterator) Response() ResourceSkusResult {
206 return iter.page.Response()
207 }
208
209
210
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
219 func NewResourceSkusResultIterator(page ResourceSkusResultPage) ResourceSkusResultIterator {
220 return ResourceSkusResultIterator{page: page}
221 }
222
223
224 func (rsr ResourceSkusResult) IsEmpty() bool {
225 return rsr.Value == nil || len(*rsr.Value) == 0
226 }
227
228
229 func (rsr ResourceSkusResult) hasNextLink() bool {
230 return rsr.NextLink != nil && len(*rsr.NextLink) != 0
231 }
232
233
234
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
246 type ResourceSkusResultPage struct {
247 fn func(context.Context, ResourceSkusResult) (ResourceSkusResult, error)
248 rsr ResourceSkusResult
249 }
250
251
252
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
278
279
280 func (page *ResourceSkusResultPage) Next() error {
281 return page.NextWithContext(context.Background())
282 }
283
284
285 func (page ResourceSkusResultPage) NotDone() bool {
286 return !page.rsr.IsEmpty()
287 }
288
289
290 func (page ResourceSkusResultPage) Response() ResourceSkusResult {
291 return page.rsr
292 }
293
294
295 func (page ResourceSkusResultPage) Values() []ResourceSku {
296 if page.rsr.IsEmpty() {
297 return nil
298 }
299 return *page.rsr.Value
300 }
301
302
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