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-11-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 RegionalDisplayName *string `json:"regionalDisplayName,omitempty"`
218
219 Metadata *LocationMetadata `json:"metadata,omitempty"`
220 }
221
222
223 func (l Location) MarshalJSON() ([]byte, error) {
224 objectMap := make(map[string]interface{})
225 if l.Metadata != nil {
226 objectMap["metadata"] = l.Metadata
227 }
228 return json.Marshal(objectMap)
229 }
230
231
232 type LocationListResult struct {
233 autorest.Response `json:"-"`
234
235 Value *[]Location `json:"value,omitempty"`
236 }
237
238
239 type LocationMetadata struct {
240
241 RegionType RegionType `json:"regionType,omitempty"`
242
243 RegionCategory RegionCategory `json:"regionCategory,omitempty"`
244
245 GeographyGroup *string `json:"geographyGroup,omitempty"`
246
247 Longitude *string `json:"longitude,omitempty"`
248
249 Latitude *string `json:"latitude,omitempty"`
250
251 PhysicalLocation *string `json:"physicalLocation,omitempty"`
252
253 PairedRegion *[]PairedRegion `json:"pairedRegion,omitempty"`
254 }
255
256
257 func (lm LocationMetadata) MarshalJSON() ([]byte, error) {
258 objectMap := make(map[string]interface{})
259 if lm.PairedRegion != nil {
260 objectMap["pairedRegion"] = lm.PairedRegion
261 }
262 return json.Marshal(objectMap)
263 }
264
265
266 type ManagedByTenant struct {
267
268 TenantID *string `json:"tenantId,omitempty"`
269 }
270
271
272 func (mbt ManagedByTenant) MarshalJSON() ([]byte, error) {
273 objectMap := make(map[string]interface{})
274 return json.Marshal(objectMap)
275 }
276
277
278 type Operation struct {
279
280 Name *string `json:"name,omitempty"`
281
282 Display *OperationDisplay `json:"display,omitempty"`
283 }
284
285
286 type OperationDisplay struct {
287
288 Provider *string `json:"provider,omitempty"`
289
290 Resource *string `json:"resource,omitempty"`
291
292 Operation *string `json:"operation,omitempty"`
293
294 Description *string `json:"description,omitempty"`
295 }
296
297
298
299 type OperationListResult struct {
300 autorest.Response `json:"-"`
301
302 Value *[]Operation `json:"value,omitempty"`
303
304 NextLink *string `json:"nextLink,omitempty"`
305 }
306
307
308 type OperationListResultIterator struct {
309 i int
310 page OperationListResultPage
311 }
312
313
314
315 func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) {
316 if tracing.IsEnabled() {
317 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext")
318 defer func() {
319 sc := -1
320 if iter.Response().Response.Response != nil {
321 sc = iter.Response().Response.Response.StatusCode
322 }
323 tracing.EndSpan(ctx, sc, err)
324 }()
325 }
326 iter.i++
327 if iter.i < len(iter.page.Values()) {
328 return nil
329 }
330 err = iter.page.NextWithContext(ctx)
331 if err != nil {
332 iter.i--
333 return err
334 }
335 iter.i = 0
336 return nil
337 }
338
339
340
341
342 func (iter *OperationListResultIterator) Next() error {
343 return iter.NextWithContext(context.Background())
344 }
345
346
347 func (iter OperationListResultIterator) NotDone() bool {
348 return iter.page.NotDone() && iter.i < len(iter.page.Values())
349 }
350
351
352 func (iter OperationListResultIterator) Response() OperationListResult {
353 return iter.page.Response()
354 }
355
356
357
358 func (iter OperationListResultIterator) Value() Operation {
359 if !iter.page.NotDone() {
360 return Operation{}
361 }
362 return iter.page.Values()[iter.i]
363 }
364
365
366 func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator {
367 return OperationListResultIterator{page: page}
368 }
369
370
371 func (olr OperationListResult) IsEmpty() bool {
372 return olr.Value == nil || len(*olr.Value) == 0
373 }
374
375
376 func (olr OperationListResult) hasNextLink() bool {
377 return olr.NextLink != nil && len(*olr.NextLink) != 0
378 }
379
380
381
382 func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) {
383 if !olr.hasNextLink() {
384 return nil, nil
385 }
386 return autorest.Prepare((&http.Request{}).WithContext(ctx),
387 autorest.AsJSON(),
388 autorest.AsGet(),
389 autorest.WithBaseURL(to.String(olr.NextLink)))
390 }
391
392
393 type OperationListResultPage struct {
394 fn func(context.Context, OperationListResult) (OperationListResult, error)
395 olr OperationListResult
396 }
397
398
399
400 func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) {
401 if tracing.IsEnabled() {
402 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext")
403 defer func() {
404 sc := -1
405 if page.Response().Response.Response != nil {
406 sc = page.Response().Response.Response.StatusCode
407 }
408 tracing.EndSpan(ctx, sc, err)
409 }()
410 }
411 for {
412 next, err := page.fn(ctx, page.olr)
413 if err != nil {
414 return err
415 }
416 page.olr = next
417 if !next.hasNextLink() || !next.IsEmpty() {
418 break
419 }
420 }
421 return nil
422 }
423
424
425
426
427 func (page *OperationListResultPage) Next() error {
428 return page.NextWithContext(context.Background())
429 }
430
431
432 func (page OperationListResultPage) NotDone() bool {
433 return !page.olr.IsEmpty()
434 }
435
436
437 func (page OperationListResultPage) Response() OperationListResult {
438 return page.olr
439 }
440
441
442 func (page OperationListResultPage) Values() []Operation {
443 if page.olr.IsEmpty() {
444 return nil
445 }
446 return *page.olr.Value
447 }
448
449
450 func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage {
451 return OperationListResultPage{
452 fn: getNextPage,
453 olr: cur,
454 }
455 }
456
457
458 type PairedRegion struct {
459
460 Name *string `json:"name,omitempty"`
461
462 ID *string `json:"id,omitempty"`
463
464 SubscriptionID *string `json:"subscriptionId,omitempty"`
465 }
466
467
468 func (pr PairedRegion) MarshalJSON() ([]byte, error) {
469 objectMap := make(map[string]interface{})
470 return json.Marshal(objectMap)
471 }
472
473
474 type Policies struct {
475
476 LocationPlacementID *string `json:"locationPlacementId,omitempty"`
477
478 QuotaID *string `json:"quotaId,omitempty"`
479
480 SpendingLimit SpendingLimit `json:"spendingLimit,omitempty"`
481 }
482
483
484 func (p Policies) MarshalJSON() ([]byte, error) {
485 objectMap := make(map[string]interface{})
486 return json.Marshal(objectMap)
487 }
488
489
490 type ResourceName struct {
491
492 Name *string `json:"name,omitempty"`
493
494 Type *string `json:"type,omitempty"`
495 }
496
497
498 type Subscription struct {
499 autorest.Response `json:"-"`
500
501 ID *string `json:"id,omitempty"`
502
503 SubscriptionID *string `json:"subscriptionId,omitempty"`
504
505 DisplayName *string `json:"displayName,omitempty"`
506
507 TenantID *string `json:"tenantId,omitempty"`
508
509 State State `json:"state,omitempty"`
510
511 SubscriptionPolicies *Policies `json:"subscriptionPolicies,omitempty"`
512
513 AuthorizationSource *string `json:"authorizationSource,omitempty"`
514
515 ManagedByTenants *[]ManagedByTenant `json:"managedByTenants,omitempty"`
516
517 Tags map[string]*string `json:"tags"`
518 }
519
520
521 func (s Subscription) MarshalJSON() ([]byte, error) {
522 objectMap := make(map[string]interface{})
523 if s.SubscriptionPolicies != nil {
524 objectMap["subscriptionPolicies"] = s.SubscriptionPolicies
525 }
526 if s.AuthorizationSource != nil {
527 objectMap["authorizationSource"] = s.AuthorizationSource
528 }
529 if s.ManagedByTenants != nil {
530 objectMap["managedByTenants"] = s.ManagedByTenants
531 }
532 if s.Tags != nil {
533 objectMap["tags"] = s.Tags
534 }
535 return json.Marshal(objectMap)
536 }
537
538
539 type TenantIDDescription struct {
540
541 ID *string `json:"id,omitempty"`
542
543 TenantID *string `json:"tenantId,omitempty"`
544
545 TenantCategory TenantCategory `json:"tenantCategory,omitempty"`
546
547 Country *string `json:"country,omitempty"`
548
549 CountryCode *string `json:"countryCode,omitempty"`
550
551 DisplayName *string `json:"displayName,omitempty"`
552
553 Domains *[]string `json:"domains,omitempty"`
554 }
555
556
557 func (tid TenantIDDescription) MarshalJSON() ([]byte, error) {
558 objectMap := make(map[string]interface{})
559 return json.Marshal(objectMap)
560 }
561
562
563 type TenantListResult struct {
564 autorest.Response `json:"-"`
565
566 Value *[]TenantIDDescription `json:"value,omitempty"`
567
568 NextLink *string `json:"nextLink,omitempty"`
569 }
570
571
572 type TenantListResultIterator struct {
573 i int
574 page TenantListResultPage
575 }
576
577
578
579 func (iter *TenantListResultIterator) NextWithContext(ctx context.Context) (err error) {
580 if tracing.IsEnabled() {
581 ctx = tracing.StartSpan(ctx, fqdn+"/TenantListResultIterator.NextWithContext")
582 defer func() {
583 sc := -1
584 if iter.Response().Response.Response != nil {
585 sc = iter.Response().Response.Response.StatusCode
586 }
587 tracing.EndSpan(ctx, sc, err)
588 }()
589 }
590 iter.i++
591 if iter.i < len(iter.page.Values()) {
592 return nil
593 }
594 err = iter.page.NextWithContext(ctx)
595 if err != nil {
596 iter.i--
597 return err
598 }
599 iter.i = 0
600 return nil
601 }
602
603
604
605
606 func (iter *TenantListResultIterator) Next() error {
607 return iter.NextWithContext(context.Background())
608 }
609
610
611 func (iter TenantListResultIterator) NotDone() bool {
612 return iter.page.NotDone() && iter.i < len(iter.page.Values())
613 }
614
615
616 func (iter TenantListResultIterator) Response() TenantListResult {
617 return iter.page.Response()
618 }
619
620
621
622 func (iter TenantListResultIterator) Value() TenantIDDescription {
623 if !iter.page.NotDone() {
624 return TenantIDDescription{}
625 }
626 return iter.page.Values()[iter.i]
627 }
628
629
630 func NewTenantListResultIterator(page TenantListResultPage) TenantListResultIterator {
631 return TenantListResultIterator{page: page}
632 }
633
634
635 func (tlr TenantListResult) IsEmpty() bool {
636 return tlr.Value == nil || len(*tlr.Value) == 0
637 }
638
639
640 func (tlr TenantListResult) hasNextLink() bool {
641 return tlr.NextLink != nil && len(*tlr.NextLink) != 0
642 }
643
644
645
646 func (tlr TenantListResult) tenantListResultPreparer(ctx context.Context) (*http.Request, error) {
647 if !tlr.hasNextLink() {
648 return nil, nil
649 }
650 return autorest.Prepare((&http.Request{}).WithContext(ctx),
651 autorest.AsJSON(),
652 autorest.AsGet(),
653 autorest.WithBaseURL(to.String(tlr.NextLink)))
654 }
655
656
657 type TenantListResultPage struct {
658 fn func(context.Context, TenantListResult) (TenantListResult, error)
659 tlr TenantListResult
660 }
661
662
663
664 func (page *TenantListResultPage) NextWithContext(ctx context.Context) (err error) {
665 if tracing.IsEnabled() {
666 ctx = tracing.StartSpan(ctx, fqdn+"/TenantListResultPage.NextWithContext")
667 defer func() {
668 sc := -1
669 if page.Response().Response.Response != nil {
670 sc = page.Response().Response.Response.StatusCode
671 }
672 tracing.EndSpan(ctx, sc, err)
673 }()
674 }
675 for {
676 next, err := page.fn(ctx, page.tlr)
677 if err != nil {
678 return err
679 }
680 page.tlr = next
681 if !next.hasNextLink() || !next.IsEmpty() {
682 break
683 }
684 }
685 return nil
686 }
687
688
689
690
691 func (page *TenantListResultPage) Next() error {
692 return page.NextWithContext(context.Background())
693 }
694
695
696 func (page TenantListResultPage) NotDone() bool {
697 return !page.tlr.IsEmpty()
698 }
699
700
701 func (page TenantListResultPage) Response() TenantListResult {
702 return page.tlr
703 }
704
705
706 func (page TenantListResultPage) Values() []TenantIDDescription {
707 if page.tlr.IsEmpty() {
708 return nil
709 }
710 return *page.tlr.Value
711 }
712
713
714 func NewTenantListResultPage(cur TenantListResult, getNextPage func(context.Context, TenantListResult) (TenantListResult, error)) TenantListResultPage {
715 return TenantListResultPage{
716 fn: getNextPage,
717 tlr: cur,
718 }
719 }
720
View as plain text