1 package subscriptions
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/resources/mgmt/2019-06-01/subscriptions"
20
21
22
23 type CheckResourceNameResult struct {
24 autorest.Response `json:"-"`
25
26 Name *string `json:"name,omitempty"`
27
28 Type *string `json:"type,omitempty"`
29
30 Status ResourceNameStatus `json:"status,omitempty"`
31 }
32
33
34 type ErrorDefinition struct {
35
36 Message *string `json:"message,omitempty"`
37
38 Code *string `json:"code,omitempty"`
39 }
40
41
42 type ErrorResponse struct {
43
44 Error *ErrorDefinition `json:"error,omitempty"`
45 }
46
47
48 type ListResult struct {
49 autorest.Response `json:"-"`
50
51 Value *[]Subscription `json:"value,omitempty"`
52
53 NextLink *string `json:"nextLink,omitempty"`
54 }
55
56
57 type ListResultIterator struct {
58 i int
59 page ListResultPage
60 }
61
62
63
64 func (iter *ListResultIterator) NextWithContext(ctx context.Context) (err error) {
65 if tracing.IsEnabled() {
66 ctx = tracing.StartSpan(ctx, fqdn+"/ListResultIterator.NextWithContext")
67 defer func() {
68 sc := -1
69 if iter.Response().Response.Response != nil {
70 sc = iter.Response().Response.Response.StatusCode
71 }
72 tracing.EndSpan(ctx, sc, err)
73 }()
74 }
75 iter.i++
76 if iter.i < len(iter.page.Values()) {
77 return nil
78 }
79 err = iter.page.NextWithContext(ctx)
80 if err != nil {
81 iter.i--
82 return err
83 }
84 iter.i = 0
85 return nil
86 }
87
88
89
90
91 func (iter *ListResultIterator) Next() error {
92 return iter.NextWithContext(context.Background())
93 }
94
95
96 func (iter ListResultIterator) NotDone() bool {
97 return iter.page.NotDone() && iter.i < len(iter.page.Values())
98 }
99
100
101 func (iter ListResultIterator) Response() ListResult {
102 return iter.page.Response()
103 }
104
105
106
107 func (iter ListResultIterator) Value() Subscription {
108 if !iter.page.NotDone() {
109 return Subscription{}
110 }
111 return iter.page.Values()[iter.i]
112 }
113
114
115 func NewListResultIterator(page ListResultPage) ListResultIterator {
116 return ListResultIterator{page: page}
117 }
118
119
120 func (lr ListResult) IsEmpty() bool {
121 return lr.Value == nil || len(*lr.Value) == 0
122 }
123
124
125 func (lr ListResult) hasNextLink() bool {
126 return lr.NextLink != nil && len(*lr.NextLink) != 0
127 }
128
129
130
131 func (lr ListResult) listResultPreparer(ctx context.Context) (*http.Request, error) {
132 if !lr.hasNextLink() {
133 return nil, nil
134 }
135 return autorest.Prepare((&http.Request{}).WithContext(ctx),
136 autorest.AsJSON(),
137 autorest.AsGet(),
138 autorest.WithBaseURL(to.String(lr.NextLink)))
139 }
140
141
142 type ListResultPage struct {
143 fn func(context.Context, ListResult) (ListResult, error)
144 lr ListResult
145 }
146
147
148
149 func (page *ListResultPage) NextWithContext(ctx context.Context) (err error) {
150 if tracing.IsEnabled() {
151 ctx = tracing.StartSpan(ctx, fqdn+"/ListResultPage.NextWithContext")
152 defer func() {
153 sc := -1
154 if page.Response().Response.Response != nil {
155 sc = page.Response().Response.Response.StatusCode
156 }
157 tracing.EndSpan(ctx, sc, err)
158 }()
159 }
160 for {
161 next, err := page.fn(ctx, page.lr)
162 if err != nil {
163 return err
164 }
165 page.lr = next
166 if !next.hasNextLink() || !next.IsEmpty() {
167 break
168 }
169 }
170 return nil
171 }
172
173
174
175
176 func (page *ListResultPage) Next() error {
177 return page.NextWithContext(context.Background())
178 }
179
180
181 func (page ListResultPage) NotDone() bool {
182 return !page.lr.IsEmpty()
183 }
184
185
186 func (page ListResultPage) Response() ListResult {
187 return page.lr
188 }
189
190
191 func (page ListResultPage) Values() []Subscription {
192 if page.lr.IsEmpty() {
193 return nil
194 }
195 return *page.lr.Value
196 }
197
198
199 func NewListResultPage(cur ListResult, getNextPage func(context.Context, ListResult) (ListResult, error)) ListResultPage {
200 return ListResultPage{
201 fn: getNextPage,
202 lr: cur,
203 }
204 }
205
206
207 type Location struct {
208
209 ID *string `json:"id,omitempty"`
210
211 SubscriptionID *string `json:"subscriptionId,omitempty"`
212
213 Name *string `json:"name,omitempty"`
214
215 DisplayName *string `json:"displayName,omitempty"`
216
217 Latitude *string `json:"latitude,omitempty"`
218
219 Longitude *string `json:"longitude,omitempty"`
220 }
221
222
223 func (l Location) MarshalJSON() ([]byte, error) {
224 objectMap := make(map[string]interface{})
225 return json.Marshal(objectMap)
226 }
227
228
229 type LocationListResult struct {
230 autorest.Response `json:"-"`
231
232 Value *[]Location `json:"value,omitempty"`
233 }
234
235
236 type ManagedByTenant struct {
237
238 TenantID *string `json:"tenantId,omitempty"`
239 }
240
241
242 func (mbt ManagedByTenant) MarshalJSON() ([]byte, error) {
243 objectMap := make(map[string]interface{})
244 return json.Marshal(objectMap)
245 }
246
247
248 type Operation struct {
249
250 Name *string `json:"name,omitempty"`
251
252 Display *OperationDisplay `json:"display,omitempty"`
253 }
254
255
256 type OperationDisplay struct {
257
258 Provider *string `json:"provider,omitempty"`
259
260 Resource *string `json:"resource,omitempty"`
261
262 Operation *string `json:"operation,omitempty"`
263
264 Description *string `json:"description,omitempty"`
265 }
266
267
268
269 type OperationListResult struct {
270 autorest.Response `json:"-"`
271
272 Value *[]Operation `json:"value,omitempty"`
273
274 NextLink *string `json:"nextLink,omitempty"`
275 }
276
277
278 type OperationListResultIterator struct {
279 i int
280 page OperationListResultPage
281 }
282
283
284
285 func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) {
286 if tracing.IsEnabled() {
287 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext")
288 defer func() {
289 sc := -1
290 if iter.Response().Response.Response != nil {
291 sc = iter.Response().Response.Response.StatusCode
292 }
293 tracing.EndSpan(ctx, sc, err)
294 }()
295 }
296 iter.i++
297 if iter.i < len(iter.page.Values()) {
298 return nil
299 }
300 err = iter.page.NextWithContext(ctx)
301 if err != nil {
302 iter.i--
303 return err
304 }
305 iter.i = 0
306 return nil
307 }
308
309
310
311
312 func (iter *OperationListResultIterator) Next() error {
313 return iter.NextWithContext(context.Background())
314 }
315
316
317 func (iter OperationListResultIterator) NotDone() bool {
318 return iter.page.NotDone() && iter.i < len(iter.page.Values())
319 }
320
321
322 func (iter OperationListResultIterator) Response() OperationListResult {
323 return iter.page.Response()
324 }
325
326
327
328 func (iter OperationListResultIterator) Value() Operation {
329 if !iter.page.NotDone() {
330 return Operation{}
331 }
332 return iter.page.Values()[iter.i]
333 }
334
335
336 func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator {
337 return OperationListResultIterator{page: page}
338 }
339
340
341 func (olr OperationListResult) IsEmpty() bool {
342 return olr.Value == nil || len(*olr.Value) == 0
343 }
344
345
346 func (olr OperationListResult) hasNextLink() bool {
347 return olr.NextLink != nil && len(*olr.NextLink) != 0
348 }
349
350
351
352 func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) {
353 if !olr.hasNextLink() {
354 return nil, nil
355 }
356 return autorest.Prepare((&http.Request{}).WithContext(ctx),
357 autorest.AsJSON(),
358 autorest.AsGet(),
359 autorest.WithBaseURL(to.String(olr.NextLink)))
360 }
361
362
363 type OperationListResultPage struct {
364 fn func(context.Context, OperationListResult) (OperationListResult, error)
365 olr OperationListResult
366 }
367
368
369
370 func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) {
371 if tracing.IsEnabled() {
372 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext")
373 defer func() {
374 sc := -1
375 if page.Response().Response.Response != nil {
376 sc = page.Response().Response.Response.StatusCode
377 }
378 tracing.EndSpan(ctx, sc, err)
379 }()
380 }
381 for {
382 next, err := page.fn(ctx, page.olr)
383 if err != nil {
384 return err
385 }
386 page.olr = next
387 if !next.hasNextLink() || !next.IsEmpty() {
388 break
389 }
390 }
391 return nil
392 }
393
394
395
396
397 func (page *OperationListResultPage) Next() error {
398 return page.NextWithContext(context.Background())
399 }
400
401
402 func (page OperationListResultPage) NotDone() bool {
403 return !page.olr.IsEmpty()
404 }
405
406
407 func (page OperationListResultPage) Response() OperationListResult {
408 return page.olr
409 }
410
411
412 func (page OperationListResultPage) Values() []Operation {
413 if page.olr.IsEmpty() {
414 return nil
415 }
416 return *page.olr.Value
417 }
418
419
420 func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage {
421 return OperationListResultPage{
422 fn: getNextPage,
423 olr: cur,
424 }
425 }
426
427
428 type Policies struct {
429
430 LocationPlacementID *string `json:"locationPlacementId,omitempty"`
431
432 QuotaID *string `json:"quotaId,omitempty"`
433
434 SpendingLimit SpendingLimit `json:"spendingLimit,omitempty"`
435 }
436
437
438 func (p Policies) MarshalJSON() ([]byte, error) {
439 objectMap := make(map[string]interface{})
440 return json.Marshal(objectMap)
441 }
442
443
444 type ResourceName struct {
445
446 Name *string `json:"name,omitempty"`
447
448 Type *string `json:"type,omitempty"`
449 }
450
451
452 type Subscription struct {
453 autorest.Response `json:"-"`
454
455 ID *string `json:"id,omitempty"`
456
457 SubscriptionID *string `json:"subscriptionId,omitempty"`
458
459 DisplayName *string `json:"displayName,omitempty"`
460
461 TenantID *string `json:"tenantId,omitempty"`
462
463 State State `json:"state,omitempty"`
464
465 SubscriptionPolicies *Policies `json:"subscriptionPolicies,omitempty"`
466
467 AuthorizationSource *string `json:"authorizationSource,omitempty"`
468
469 ManagedByTenants *[]ManagedByTenant `json:"managedByTenants,omitempty"`
470 }
471
472
473 func (s Subscription) MarshalJSON() ([]byte, error) {
474 objectMap := make(map[string]interface{})
475 if s.SubscriptionPolicies != nil {
476 objectMap["subscriptionPolicies"] = s.SubscriptionPolicies
477 }
478 if s.AuthorizationSource != nil {
479 objectMap["authorizationSource"] = s.AuthorizationSource
480 }
481 if s.ManagedByTenants != nil {
482 objectMap["managedByTenants"] = s.ManagedByTenants
483 }
484 return json.Marshal(objectMap)
485 }
486
487
488 type TenantIDDescription struct {
489
490 ID *string `json:"id,omitempty"`
491
492 TenantID *string `json:"tenantId,omitempty"`
493
494 TenantCategory TenantCategory `json:"tenantCategory,omitempty"`
495
496 Country *string `json:"country,omitempty"`
497
498 CountryCode *string `json:"countryCode,omitempty"`
499
500 DisplayName *string `json:"displayName,omitempty"`
501
502 Domains *[]string `json:"domains,omitempty"`
503 }
504
505
506 func (tid TenantIDDescription) MarshalJSON() ([]byte, error) {
507 objectMap := make(map[string]interface{})
508 return json.Marshal(objectMap)
509 }
510
511
512 type TenantListResult struct {
513 autorest.Response `json:"-"`
514
515 Value *[]TenantIDDescription `json:"value,omitempty"`
516
517 NextLink *string `json:"nextLink,omitempty"`
518 }
519
520
521 type TenantListResultIterator struct {
522 i int
523 page TenantListResultPage
524 }
525
526
527
528 func (iter *TenantListResultIterator) NextWithContext(ctx context.Context) (err error) {
529 if tracing.IsEnabled() {
530 ctx = tracing.StartSpan(ctx, fqdn+"/TenantListResultIterator.NextWithContext")
531 defer func() {
532 sc := -1
533 if iter.Response().Response.Response != nil {
534 sc = iter.Response().Response.Response.StatusCode
535 }
536 tracing.EndSpan(ctx, sc, err)
537 }()
538 }
539 iter.i++
540 if iter.i < len(iter.page.Values()) {
541 return nil
542 }
543 err = iter.page.NextWithContext(ctx)
544 if err != nil {
545 iter.i--
546 return err
547 }
548 iter.i = 0
549 return nil
550 }
551
552
553
554
555 func (iter *TenantListResultIterator) Next() error {
556 return iter.NextWithContext(context.Background())
557 }
558
559
560 func (iter TenantListResultIterator) NotDone() bool {
561 return iter.page.NotDone() && iter.i < len(iter.page.Values())
562 }
563
564
565 func (iter TenantListResultIterator) Response() TenantListResult {
566 return iter.page.Response()
567 }
568
569
570
571 func (iter TenantListResultIterator) Value() TenantIDDescription {
572 if !iter.page.NotDone() {
573 return TenantIDDescription{}
574 }
575 return iter.page.Values()[iter.i]
576 }
577
578
579 func NewTenantListResultIterator(page TenantListResultPage) TenantListResultIterator {
580 return TenantListResultIterator{page: page}
581 }
582
583
584 func (tlr TenantListResult) IsEmpty() bool {
585 return tlr.Value == nil || len(*tlr.Value) == 0
586 }
587
588
589 func (tlr TenantListResult) hasNextLink() bool {
590 return tlr.NextLink != nil && len(*tlr.NextLink) != 0
591 }
592
593
594
595 func (tlr TenantListResult) tenantListResultPreparer(ctx context.Context) (*http.Request, error) {
596 if !tlr.hasNextLink() {
597 return nil, nil
598 }
599 return autorest.Prepare((&http.Request{}).WithContext(ctx),
600 autorest.AsJSON(),
601 autorest.AsGet(),
602 autorest.WithBaseURL(to.String(tlr.NextLink)))
603 }
604
605
606 type TenantListResultPage struct {
607 fn func(context.Context, TenantListResult) (TenantListResult, error)
608 tlr TenantListResult
609 }
610
611
612
613 func (page *TenantListResultPage) NextWithContext(ctx context.Context) (err error) {
614 if tracing.IsEnabled() {
615 ctx = tracing.StartSpan(ctx, fqdn+"/TenantListResultPage.NextWithContext")
616 defer func() {
617 sc := -1
618 if page.Response().Response.Response != nil {
619 sc = page.Response().Response.Response.StatusCode
620 }
621 tracing.EndSpan(ctx, sc, err)
622 }()
623 }
624 for {
625 next, err := page.fn(ctx, page.tlr)
626 if err != nil {
627 return err
628 }
629 page.tlr = next
630 if !next.hasNextLink() || !next.IsEmpty() {
631 break
632 }
633 }
634 return nil
635 }
636
637
638
639
640 func (page *TenantListResultPage) Next() error {
641 return page.NextWithContext(context.Background())
642 }
643
644
645 func (page TenantListResultPage) NotDone() bool {
646 return !page.tlr.IsEmpty()
647 }
648
649
650 func (page TenantListResultPage) Response() TenantListResult {
651 return page.tlr
652 }
653
654
655 func (page TenantListResultPage) Values() []TenantIDDescription {
656 if page.tlr.IsEmpty() {
657 return nil
658 }
659 return *page.tlr.Value
660 }
661
662
663 func NewTenantListResultPage(cur TenantListResult, getNextPage func(context.Context, TenantListResult) (TenantListResult, error)) TenantListResultPage {
664 return TenantListResultPage{
665 fn: getNextPage,
666 tlr: cur,
667 }
668 }
669
View as plain text