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/2016-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 State State `json:"state,omitempty"`
450
451 SubscriptionPolicies *Policies `json:"subscriptionPolicies,omitempty"`
452
453 AuthorizationSource *string `json:"authorizationSource,omitempty"`
454 }
455
456
457 func (s Subscription) MarshalJSON() ([]byte, error) {
458 objectMap := make(map[string]interface{})
459 if s.SubscriptionPolicies != nil {
460 objectMap["subscriptionPolicies"] = s.SubscriptionPolicies
461 }
462 if s.AuthorizationSource != nil {
463 objectMap["authorizationSource"] = s.AuthorizationSource
464 }
465 return json.Marshal(objectMap)
466 }
467
468
469 type TenantIDDescription struct {
470
471 ID *string `json:"id,omitempty"`
472
473 TenantID *string `json:"tenantId,omitempty"`
474 }
475
476
477 func (tid TenantIDDescription) MarshalJSON() ([]byte, error) {
478 objectMap := make(map[string]interface{})
479 return json.Marshal(objectMap)
480 }
481
482
483 type TenantListResult struct {
484 autorest.Response `json:"-"`
485
486 Value *[]TenantIDDescription `json:"value,omitempty"`
487
488 NextLink *string `json:"nextLink,omitempty"`
489 }
490
491
492 type TenantListResultIterator struct {
493 i int
494 page TenantListResultPage
495 }
496
497
498
499 func (iter *TenantListResultIterator) NextWithContext(ctx context.Context) (err error) {
500 if tracing.IsEnabled() {
501 ctx = tracing.StartSpan(ctx, fqdn+"/TenantListResultIterator.NextWithContext")
502 defer func() {
503 sc := -1
504 if iter.Response().Response.Response != nil {
505 sc = iter.Response().Response.Response.StatusCode
506 }
507 tracing.EndSpan(ctx, sc, err)
508 }()
509 }
510 iter.i++
511 if iter.i < len(iter.page.Values()) {
512 return nil
513 }
514 err = iter.page.NextWithContext(ctx)
515 if err != nil {
516 iter.i--
517 return err
518 }
519 iter.i = 0
520 return nil
521 }
522
523
524
525
526 func (iter *TenantListResultIterator) Next() error {
527 return iter.NextWithContext(context.Background())
528 }
529
530
531 func (iter TenantListResultIterator) NotDone() bool {
532 return iter.page.NotDone() && iter.i < len(iter.page.Values())
533 }
534
535
536 func (iter TenantListResultIterator) Response() TenantListResult {
537 return iter.page.Response()
538 }
539
540
541
542 func (iter TenantListResultIterator) Value() TenantIDDescription {
543 if !iter.page.NotDone() {
544 return TenantIDDescription{}
545 }
546 return iter.page.Values()[iter.i]
547 }
548
549
550 func NewTenantListResultIterator(page TenantListResultPage) TenantListResultIterator {
551 return TenantListResultIterator{page: page}
552 }
553
554
555 func (tlr TenantListResult) IsEmpty() bool {
556 return tlr.Value == nil || len(*tlr.Value) == 0
557 }
558
559
560 func (tlr TenantListResult) hasNextLink() bool {
561 return tlr.NextLink != nil && len(*tlr.NextLink) != 0
562 }
563
564
565
566 func (tlr TenantListResult) tenantListResultPreparer(ctx context.Context) (*http.Request, error) {
567 if !tlr.hasNextLink() {
568 return nil, nil
569 }
570 return autorest.Prepare((&http.Request{}).WithContext(ctx),
571 autorest.AsJSON(),
572 autorest.AsGet(),
573 autorest.WithBaseURL(to.String(tlr.NextLink)))
574 }
575
576
577 type TenantListResultPage struct {
578 fn func(context.Context, TenantListResult) (TenantListResult, error)
579 tlr TenantListResult
580 }
581
582
583
584 func (page *TenantListResultPage) NextWithContext(ctx context.Context) (err error) {
585 if tracing.IsEnabled() {
586 ctx = tracing.StartSpan(ctx, fqdn+"/TenantListResultPage.NextWithContext")
587 defer func() {
588 sc := -1
589 if page.Response().Response.Response != nil {
590 sc = page.Response().Response.Response.StatusCode
591 }
592 tracing.EndSpan(ctx, sc, err)
593 }()
594 }
595 for {
596 next, err := page.fn(ctx, page.tlr)
597 if err != nil {
598 return err
599 }
600 page.tlr = next
601 if !next.hasNextLink() || !next.IsEmpty() {
602 break
603 }
604 }
605 return nil
606 }
607
608
609
610
611 func (page *TenantListResultPage) Next() error {
612 return page.NextWithContext(context.Background())
613 }
614
615
616 func (page TenantListResultPage) NotDone() bool {
617 return !page.tlr.IsEmpty()
618 }
619
620
621 func (page TenantListResultPage) Response() TenantListResult {
622 return page.tlr
623 }
624
625
626 func (page TenantListResultPage) Values() []TenantIDDescription {
627 if page.tlr.IsEmpty() {
628 return nil
629 }
630 return *page.tlr.Value
631 }
632
633
634 func NewTenantListResultPage(cur TenantListResult, getNextPage func(context.Context, TenantListResult) (TenantListResult, error)) TenantListResultPage {
635 return TenantListResultPage{
636 fn: getNextPage,
637 tlr: cur,
638 }
639 }
640
View as plain text