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