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