1 package subscriptions
2
3
4
5
6
7
8
9 import (
10 "context"
11 "github.com/Azure/go-autorest/autorest"
12 "github.com/Azure/go-autorest/autorest/to"
13 "github.com/Azure/go-autorest/tracing"
14 "net/http"
15 )
16
17
18 const fqdn = "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2015-11-01/subscriptions"
19
20
21
22 type CheckResourceNameResult struct {
23 autorest.Response `json:"-"`
24
25 Name *string `json:"name,omitempty"`
26
27 Type *string `json:"type,omitempty"`
28
29 Status ResourceNameStatus `json:"status,omitempty"`
30 }
31
32
33 type ErrorDefinition struct {
34
35 Message *string `json:"message,omitempty"`
36
37 Code *string `json:"code,omitempty"`
38 }
39
40
41 type ErrorResponse struct {
42
43 Error *ErrorDefinition `json:"error,omitempty"`
44 }
45
46
47 type ListResult struct {
48 autorest.Response `json:"-"`
49
50 Value *[]Subscription `json:"value,omitempty"`
51
52 NextLink *string `json:"nextLink,omitempty"`
53 }
54
55
56 type ListResultIterator struct {
57 i int
58 page ListResultPage
59 }
60
61
62
63 func (iter *ListResultIterator) NextWithContext(ctx context.Context) (err error) {
64 if tracing.IsEnabled() {
65 ctx = tracing.StartSpan(ctx, fqdn+"/ListResultIterator.NextWithContext")
66 defer func() {
67 sc := -1
68 if iter.Response().Response.Response != nil {
69 sc = iter.Response().Response.Response.StatusCode
70 }
71 tracing.EndSpan(ctx, sc, err)
72 }()
73 }
74 iter.i++
75 if iter.i < len(iter.page.Values()) {
76 return nil
77 }
78 err = iter.page.NextWithContext(ctx)
79 if err != nil {
80 iter.i--
81 return err
82 }
83 iter.i = 0
84 return nil
85 }
86
87
88
89
90 func (iter *ListResultIterator) Next() error {
91 return iter.NextWithContext(context.Background())
92 }
93
94
95 func (iter ListResultIterator) NotDone() bool {
96 return iter.page.NotDone() && iter.i < len(iter.page.Values())
97 }
98
99
100 func (iter ListResultIterator) Response() ListResult {
101 return iter.page.Response()
102 }
103
104
105
106 func (iter ListResultIterator) Value() Subscription {
107 if !iter.page.NotDone() {
108 return Subscription{}
109 }
110 return iter.page.Values()[iter.i]
111 }
112
113
114 func NewListResultIterator(page ListResultPage) ListResultIterator {
115 return ListResultIterator{page: page}
116 }
117
118
119 func (lr ListResult) IsEmpty() bool {
120 return lr.Value == nil || len(*lr.Value) == 0
121 }
122
123
124 func (lr ListResult) hasNextLink() bool {
125 return lr.NextLink != nil && len(*lr.NextLink) != 0
126 }
127
128
129
130 func (lr ListResult) listResultPreparer(ctx context.Context) (*http.Request, error) {
131 if !lr.hasNextLink() {
132 return nil, nil
133 }
134 return autorest.Prepare((&http.Request{}).WithContext(ctx),
135 autorest.AsJSON(),
136 autorest.AsGet(),
137 autorest.WithBaseURL(to.String(lr.NextLink)))
138 }
139
140
141 type ListResultPage struct {
142 fn func(context.Context, ListResult) (ListResult, error)
143 lr ListResult
144 }
145
146
147
148 func (page *ListResultPage) NextWithContext(ctx context.Context) (err error) {
149 if tracing.IsEnabled() {
150 ctx = tracing.StartSpan(ctx, fqdn+"/ListResultPage.NextWithContext")
151 defer func() {
152 sc := -1
153 if page.Response().Response.Response != nil {
154 sc = page.Response().Response.Response.StatusCode
155 }
156 tracing.EndSpan(ctx, sc, err)
157 }()
158 }
159 for {
160 next, err := page.fn(ctx, page.lr)
161 if err != nil {
162 return err
163 }
164 page.lr = next
165 if !next.hasNextLink() || !next.IsEmpty() {
166 break
167 }
168 }
169 return nil
170 }
171
172
173
174
175 func (page *ListResultPage) Next() error {
176 return page.NextWithContext(context.Background())
177 }
178
179
180 func (page ListResultPage) NotDone() bool {
181 return !page.lr.IsEmpty()
182 }
183
184
185 func (page ListResultPage) Response() ListResult {
186 return page.lr
187 }
188
189
190 func (page ListResultPage) Values() []Subscription {
191 if page.lr.IsEmpty() {
192 return nil
193 }
194 return *page.lr.Value
195 }
196
197
198 func NewListResultPage(cur ListResult, getNextPage func(context.Context, ListResult) (ListResult, error)) ListResultPage {
199 return ListResultPage{
200 fn: getNextPage,
201 lr: cur,
202 }
203 }
204
205
206 type Location struct {
207
208 ID *string `json:"id,omitempty"`
209
210 SubscriptionID *string `json:"subscriptionId,omitempty"`
211
212 Name *string `json:"name,omitempty"`
213
214 DisplayName *string `json:"displayName,omitempty"`
215
216 Latitude *string `json:"latitude,omitempty"`
217
218 Longitude *string `json:"longitude,omitempty"`
219 }
220
221
222 type LocationListResult struct {
223 autorest.Response `json:"-"`
224
225 Value *[]Location `json:"value,omitempty"`
226 }
227
228
229 type Policies struct {
230
231 LocationPlacementID *string `json:"locationPlacementId,omitempty"`
232
233 QuotaID *string `json:"quotaId,omitempty"`
234 }
235
236
237 type ResourceName struct {
238
239 Name *string `json:"name,omitempty"`
240
241 Type *string `json:"type,omitempty"`
242 }
243
244
245 type Subscription struct {
246 autorest.Response `json:"-"`
247
248 ID *string `json:"id,omitempty"`
249
250 SubscriptionID *string `json:"subscriptionId,omitempty"`
251
252 DisplayName *string `json:"displayName,omitempty"`
253
254 State *string `json:"state,omitempty"`
255
256 SubscriptionPolicies *Policies `json:"subscriptionPolicies,omitempty"`
257 }
258
259
260 type TenantIDDescription struct {
261
262 ID *string `json:"id,omitempty"`
263
264 TenantID *string `json:"tenantId,omitempty"`
265 }
266
267
268 type TenantListResult struct {
269 autorest.Response `json:"-"`
270
271 Value *[]TenantIDDescription `json:"value,omitempty"`
272
273 NextLink *string `json:"nextLink,omitempty"`
274 }
275
276
277 type TenantListResultIterator struct {
278 i int
279 page TenantListResultPage
280 }
281
282
283
284 func (iter *TenantListResultIterator) NextWithContext(ctx context.Context) (err error) {
285 if tracing.IsEnabled() {
286 ctx = tracing.StartSpan(ctx, fqdn+"/TenantListResultIterator.NextWithContext")
287 defer func() {
288 sc := -1
289 if iter.Response().Response.Response != nil {
290 sc = iter.Response().Response.Response.StatusCode
291 }
292 tracing.EndSpan(ctx, sc, err)
293 }()
294 }
295 iter.i++
296 if iter.i < len(iter.page.Values()) {
297 return nil
298 }
299 err = iter.page.NextWithContext(ctx)
300 if err != nil {
301 iter.i--
302 return err
303 }
304 iter.i = 0
305 return nil
306 }
307
308
309
310
311 func (iter *TenantListResultIterator) Next() error {
312 return iter.NextWithContext(context.Background())
313 }
314
315
316 func (iter TenantListResultIterator) NotDone() bool {
317 return iter.page.NotDone() && iter.i < len(iter.page.Values())
318 }
319
320
321 func (iter TenantListResultIterator) Response() TenantListResult {
322 return iter.page.Response()
323 }
324
325
326
327 func (iter TenantListResultIterator) Value() TenantIDDescription {
328 if !iter.page.NotDone() {
329 return TenantIDDescription{}
330 }
331 return iter.page.Values()[iter.i]
332 }
333
334
335 func NewTenantListResultIterator(page TenantListResultPage) TenantListResultIterator {
336 return TenantListResultIterator{page: page}
337 }
338
339
340 func (tlr TenantListResult) IsEmpty() bool {
341 return tlr.Value == nil || len(*tlr.Value) == 0
342 }
343
344
345 func (tlr TenantListResult) hasNextLink() bool {
346 return tlr.NextLink != nil && len(*tlr.NextLink) != 0
347 }
348
349
350
351 func (tlr TenantListResult) tenantListResultPreparer(ctx context.Context) (*http.Request, error) {
352 if !tlr.hasNextLink() {
353 return nil, nil
354 }
355 return autorest.Prepare((&http.Request{}).WithContext(ctx),
356 autorest.AsJSON(),
357 autorest.AsGet(),
358 autorest.WithBaseURL(to.String(tlr.NextLink)))
359 }
360
361
362 type TenantListResultPage struct {
363 fn func(context.Context, TenantListResult) (TenantListResult, error)
364 tlr TenantListResult
365 }
366
367
368
369 func (page *TenantListResultPage) NextWithContext(ctx context.Context) (err error) {
370 if tracing.IsEnabled() {
371 ctx = tracing.StartSpan(ctx, fqdn+"/TenantListResultPage.NextWithContext")
372 defer func() {
373 sc := -1
374 if page.Response().Response.Response != nil {
375 sc = page.Response().Response.Response.StatusCode
376 }
377 tracing.EndSpan(ctx, sc, err)
378 }()
379 }
380 for {
381 next, err := page.fn(ctx, page.tlr)
382 if err != nil {
383 return err
384 }
385 page.tlr = next
386 if !next.hasNextLink() || !next.IsEmpty() {
387 break
388 }
389 }
390 return nil
391 }
392
393
394
395
396 func (page *TenantListResultPage) Next() error {
397 return page.NextWithContext(context.Background())
398 }
399
400
401 func (page TenantListResultPage) NotDone() bool {
402 return !page.tlr.IsEmpty()
403 }
404
405
406 func (page TenantListResultPage) Response() TenantListResult {
407 return page.tlr
408 }
409
410
411 func (page TenantListResultPage) Values() []TenantIDDescription {
412 if page.tlr.IsEmpty() {
413 return nil
414 }
415 return *page.tlr.Value
416 }
417
418
419 func NewTenantListResultPage(cur TenantListResult, getNextPage func(context.Context, TenantListResult) (TenantListResult, error)) TenantListResultPage {
420 return TenantListResultPage{
421 fn: getNextPage,
422 tlr: cur,
423 }
424 }
425
View as plain text