forked from Azure/azure-sdk-for-go
/
models.go
855 lines (768 loc) · 31.9 KB
/
models.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
package subscription
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"context"
"encoding/json"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/to"
"github.com/Azure/go-autorest/tracing"
"net/http"
)
// The package's fully qualified name.
const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/subscription/mgmt/2019-10-01-preview/subscription"
// AdPrincipal active Directory Principal who’ll get owner access on the new subscription.
type AdPrincipal struct {
// ObjectID - Object id of the Principal
ObjectID *string `json:"objectId,omitempty"`
}
// CanceledSubscriptionID the ID of the canceled subscription
type CanceledSubscriptionID struct {
autorest.Response `json:"-"`
// Value - READ-ONLY; The ID of the canceled subscription
Value *string `json:"value,omitempty"`
}
// MarshalJSON is the custom marshaler for CanceledSubscriptionID.
func (csi CanceledSubscriptionID) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
return json.Marshal(objectMap)
}
// CreateAliasFuture an abstraction for monitoring and retrieving the results of a long-running operation.
type CreateAliasFuture struct {
azure.FutureAPI
// Result returns the result of the asynchronous operation.
// If the operation has not completed it will return an error.
Result func(Client) (PutAliasResponse, error)
}
// UnmarshalJSON is the custom unmarshaller for CreateFuture.
func (future *CreateAliasFuture) UnmarshalJSON(body []byte) error {
var azFuture azure.Future
if err := json.Unmarshal(body, &azFuture); err != nil {
return err
}
future.FutureAPI = &azFuture
future.Result = future.result
return nil
}
// result is the default implementation for CreateAliasFuture.Result.
func (future *CreateAliasFuture) result(client Client) (par PutAliasResponse, err error) {
var done bool
done, err = future.DoneWithContext(context.Background(), client)
if err != nil {
err = autorest.NewErrorWithError(err, "subscription.CreateAliasFuture", "Result", future.Response(), "Polling failure")
return
}
if !done {
par.Response.Response = future.Response()
err = azure.NewAsyncOpIncompleteError("subscription.CreateAliasFuture")
return
}
sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
if par.Response.Response, err = future.GetResult(sender); err == nil && par.Response.Response.StatusCode != http.StatusNoContent {
par, err = client.CreateAliasResponder(par.Response.Response)
if err != nil {
err = autorest.NewErrorWithError(err, "subscription.CreateAliasFuture", "Result", par.Response.Response, "Failure responding to request")
}
}
return
}
// CreateCspSubscriptionFuture an abstraction for monitoring and retrieving the results of a long-running
// operation.
type CreateCspSubscriptionFuture struct {
azure.FutureAPI
// Result returns the result of the asynchronous operation.
// If the operation has not completed it will return an error.
Result func(Client) (CreationResult, error)
}
// UnmarshalJSON is the custom unmarshaller for CreateFuture.
func (future *CreateCspSubscriptionFuture) UnmarshalJSON(body []byte) error {
var azFuture azure.Future
if err := json.Unmarshal(body, &azFuture); err != nil {
return err
}
future.FutureAPI = &azFuture
future.Result = future.result
return nil
}
// result is the default implementation for CreateCspSubscriptionFuture.Result.
func (future *CreateCspSubscriptionFuture) result(client Client) (cr CreationResult, err error) {
var done bool
done, err = future.DoneWithContext(context.Background(), client)
if err != nil {
err = autorest.NewErrorWithError(err, "subscription.CreateCspSubscriptionFuture", "Result", future.Response(), "Polling failure")
return
}
if !done {
cr.Response.Response = future.Response()
err = azure.NewAsyncOpIncompleteError("subscription.CreateCspSubscriptionFuture")
return
}
sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
if cr.Response.Response, err = future.GetResult(sender); err == nil && cr.Response.Response.StatusCode != http.StatusNoContent {
cr, err = client.CreateCspSubscriptionResponder(cr.Response.Response)
if err != nil {
err = autorest.NewErrorWithError(err, "subscription.CreateCspSubscriptionFuture", "Result", cr.Response.Response, "Failure responding to request")
}
}
return
}
// CreateSubscriptionFuture an abstraction for monitoring and retrieving the results of a long-running
// operation.
type CreateSubscriptionFuture struct {
azure.FutureAPI
// Result returns the result of the asynchronous operation.
// If the operation has not completed it will return an error.
Result func(Client) (CreationResult, error)
}
// UnmarshalJSON is the custom unmarshaller for CreateFuture.
func (future *CreateSubscriptionFuture) UnmarshalJSON(body []byte) error {
var azFuture azure.Future
if err := json.Unmarshal(body, &azFuture); err != nil {
return err
}
future.FutureAPI = &azFuture
future.Result = future.result
return nil
}
// result is the default implementation for CreateSubscriptionFuture.Result.
func (future *CreateSubscriptionFuture) result(client Client) (cr CreationResult, err error) {
var done bool
done, err = future.DoneWithContext(context.Background(), client)
if err != nil {
err = autorest.NewErrorWithError(err, "subscription.CreateSubscriptionFuture", "Result", future.Response(), "Polling failure")
return
}
if !done {
cr.Response.Response = future.Response()
err = azure.NewAsyncOpIncompleteError("subscription.CreateSubscriptionFuture")
return
}
sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
if cr.Response.Response, err = future.GetResult(sender); err == nil && cr.Response.Response.StatusCode != http.StatusNoContent {
cr, err = client.CreateSubscriptionResponder(cr.Response.Response)
if err != nil {
err = autorest.NewErrorWithError(err, "subscription.CreateSubscriptionFuture", "Result", cr.Response.Response, "Failure responding to request")
}
}
return
}
// CreateSubscriptionInEnrollmentAccountFuture an abstraction for monitoring and retrieving the results of
// a long-running operation.
type CreateSubscriptionInEnrollmentAccountFuture struct {
azure.FutureAPI
// Result returns the result of the asynchronous operation.
// If the operation has not completed it will return an error.
Result func(Client) (CreationResult, error)
}
// UnmarshalJSON is the custom unmarshaller for CreateFuture.
func (future *CreateSubscriptionInEnrollmentAccountFuture) UnmarshalJSON(body []byte) error {
var azFuture azure.Future
if err := json.Unmarshal(body, &azFuture); err != nil {
return err
}
future.FutureAPI = &azFuture
future.Result = future.result
return nil
}
// result is the default implementation for CreateSubscriptionInEnrollmentAccountFuture.Result.
func (future *CreateSubscriptionInEnrollmentAccountFuture) result(client Client) (cr CreationResult, err error) {
var done bool
done, err = future.DoneWithContext(context.Background(), client)
if err != nil {
err = autorest.NewErrorWithError(err, "subscription.CreateSubscriptionInEnrollmentAccountFuture", "Result", future.Response(), "Polling failure")
return
}
if !done {
cr.Response.Response = future.Response()
err = azure.NewAsyncOpIncompleteError("subscription.CreateSubscriptionInEnrollmentAccountFuture")
return
}
sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
if cr.Response.Response, err = future.GetResult(sender); err == nil && cr.Response.Response.StatusCode != http.StatusNoContent {
cr, err = client.CreateSubscriptionInEnrollmentAccountResponder(cr.Response.Response)
if err != nil {
err = autorest.NewErrorWithError(err, "subscription.CreateSubscriptionInEnrollmentAccountFuture", "Result", cr.Response.Response, "Failure responding to request")
}
}
return
}
// CreationParameters subscription Creation Parameters required to create a new Azure subscription.
type CreationParameters struct {
// DisplayName - The display name of the subscription.
DisplayName *string `json:"displayName,omitempty"`
// ManagementGroupID - The Management Group Id.
ManagementGroupID *string `json:"managementGroupId,omitempty"`
// Owners - The list of principals that should be granted Owner access on the subscription. Principals should be of type User, Service Principal or Security Group.
Owners *[]AdPrincipal `json:"owners,omitempty"`
// OfferType - The offer type of the subscription. For example, MS-AZR-0017P (EnterpriseAgreement) and MS-AZR-0148P (EnterpriseAgreement devTest) are available. Only valid when creating a subscription in a enrollment account scope. Possible values include: 'MSAZR0017P', 'MSAZR0148P'
OfferType OfferType `json:"offerType,omitempty"`
// AdditionalParameters - Additional, untyped parameters to support custom subscription creation scenarios.
AdditionalParameters map[string]interface{} `json:"additionalParameters"`
}
// MarshalJSON is the custom marshaler for CreationParameters.
func (cp CreationParameters) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if cp.DisplayName != nil {
objectMap["displayName"] = cp.DisplayName
}
if cp.ManagementGroupID != nil {
objectMap["managementGroupId"] = cp.ManagementGroupID
}
if cp.Owners != nil {
objectMap["owners"] = cp.Owners
}
if cp.OfferType != "" {
objectMap["offerType"] = cp.OfferType
}
if cp.AdditionalParameters != nil {
objectMap["additionalParameters"] = cp.AdditionalParameters
}
return json.Marshal(objectMap)
}
// CreationResult the created subscription object.
type CreationResult struct {
autorest.Response `json:"-"`
// SubscriptionLink - The link to the new subscription. Use this link to check the status of subscription creation operation.
SubscriptionLink *string `json:"subscriptionLink,omitempty"`
}
// EnabledSubscriptionID the ID of the subscriptions that is being enabled
type EnabledSubscriptionID struct {
autorest.Response `json:"-"`
// Value - READ-ONLY; The ID of the subscriptions that is being enabled
Value *string `json:"value,omitempty"`
}
// MarshalJSON is the custom marshaler for EnabledSubscriptionID.
func (esi EnabledSubscriptionID) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
return json.Marshal(objectMap)
}
// ErrorResponse describes the format of Error response.
type ErrorResponse struct {
// Code - Error code
Code *string `json:"code,omitempty"`
// Message - Error message indicating why the operation failed.
Message *string `json:"message,omitempty"`
}
// ErrorResponseBody error response indicates that the service is not able to process the incoming request.
// The reason is provided in the error message.
type ErrorResponseBody struct {
// Error - The details of the error.
Error *ErrorResponse `json:"error,omitempty"`
}
// ListResult subscription list operation response.
type ListResult struct {
autorest.Response `json:"-"`
// Value - An array of subscriptions.
Value *[]Model `json:"value,omitempty"`
// NextLink - The URL to get the next set of results.
NextLink *string `json:"nextLink,omitempty"`
}
// ListResultIterator provides access to a complete listing of Model values.
type ListResultIterator struct {
i int
page ListResultPage
}
// NextWithContext advances to the next value. If there was an error making
// the request the iterator does not advance and the error is returned.
func (iter *ListResultIterator) NextWithContext(ctx context.Context) (err error) {
if tracing.IsEnabled() {
ctx = tracing.StartSpan(ctx, fqdn+"/ListResultIterator.NextWithContext")
defer func() {
sc := -1
if iter.Response().Response.Response != nil {
sc = iter.Response().Response.Response.StatusCode
}
tracing.EndSpan(ctx, sc, err)
}()
}
iter.i++
if iter.i < len(iter.page.Values()) {
return nil
}
err = iter.page.NextWithContext(ctx)
if err != nil {
iter.i--
return err
}
iter.i = 0
return nil
}
// Next advances to the next value. If there was an error making
// the request the iterator does not advance and the error is returned.
// Deprecated: Use NextWithContext() instead.
func (iter *ListResultIterator) Next() error {
return iter.NextWithContext(context.Background())
}
// NotDone returns true if the enumeration should be started or is not yet complete.
func (iter ListResultIterator) NotDone() bool {
return iter.page.NotDone() && iter.i < len(iter.page.Values())
}
// Response returns the raw server response from the last page request.
func (iter ListResultIterator) Response() ListResult {
return iter.page.Response()
}
// Value returns the current value or a zero-initialized value if the
// iterator has advanced beyond the end of the collection.
func (iter ListResultIterator) Value() Model {
if !iter.page.NotDone() {
return Model{}
}
return iter.page.Values()[iter.i]
}
// Creates a new instance of the ListResultIterator type.
func NewListResultIterator(page ListResultPage) ListResultIterator {
return ListResultIterator{page: page}
}
// IsEmpty returns true if the ListResult contains no values.
func (lr ListResult) IsEmpty() bool {
return lr.Value == nil || len(*lr.Value) == 0
}
// hasNextLink returns true if the NextLink is not empty.
func (lr ListResult) hasNextLink() bool {
return lr.NextLink != nil && len(*lr.NextLink) != 0
}
// listResultPreparer prepares a request to retrieve the next set of results.
// It returns nil if no more results exist.
func (lr ListResult) listResultPreparer(ctx context.Context) (*http.Request, error) {
if !lr.hasNextLink() {
return nil, nil
}
return autorest.Prepare((&http.Request{}).WithContext(ctx),
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(lr.NextLink)))
}
// ListResultPage contains a page of Model values.
type ListResultPage struct {
fn func(context.Context, ListResult) (ListResult, error)
lr ListResult
}
// NextWithContext advances to the next page of values. If there was an error making
// the request the page does not advance and the error is returned.
func (page *ListResultPage) NextWithContext(ctx context.Context) (err error) {
if tracing.IsEnabled() {
ctx = tracing.StartSpan(ctx, fqdn+"/ListResultPage.NextWithContext")
defer func() {
sc := -1
if page.Response().Response.Response != nil {
sc = page.Response().Response.Response.StatusCode
}
tracing.EndSpan(ctx, sc, err)
}()
}
for {
next, err := page.fn(ctx, page.lr)
if err != nil {
return err
}
page.lr = next
if !next.hasNextLink() || !next.IsEmpty() {
break
}
}
return nil
}
// Next advances to the next page of values. If there was an error making
// the request the page does not advance and the error is returned.
// Deprecated: Use NextWithContext() instead.
func (page *ListResultPage) Next() error {
return page.NextWithContext(context.Background())
}
// NotDone returns true if the page enumeration should be started or is not yet complete.
func (page ListResultPage) NotDone() bool {
return !page.lr.IsEmpty()
}
// Response returns the raw server response from the last page request.
func (page ListResultPage) Response() ListResult {
return page.lr
}
// Values returns the slice of values for the current page or nil if there are no values.
func (page ListResultPage) Values() []Model {
if page.lr.IsEmpty() {
return nil
}
return *page.lr.Value
}
// Creates a new instance of the ListResultPage type.
func NewListResultPage(cur ListResult, getNextPage func(context.Context, ListResult) (ListResult, error)) ListResultPage {
return ListResultPage{
fn: getNextPage,
lr: cur,
}
}
// Location location information.
type Location struct {
// ID - READ-ONLY; The fully qualified ID of the location. For example, /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus.
ID *string `json:"id,omitempty"`
// SubscriptionID - READ-ONLY; The subscription ID.
SubscriptionID *string `json:"subscriptionId,omitempty"`
// Name - READ-ONLY; The location name.
Name *string `json:"name,omitempty"`
// DisplayName - READ-ONLY; The display name of the location.
DisplayName *string `json:"displayName,omitempty"`
// Latitude - READ-ONLY; The latitude of the location.
Latitude *string `json:"latitude,omitempty"`
// Longitude - READ-ONLY; The longitude of the location.
Longitude *string `json:"longitude,omitempty"`
}
// MarshalJSON is the custom marshaler for Location.
func (l Location) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
return json.Marshal(objectMap)
}
// LocationListResult location list operation response.
type LocationListResult struct {
autorest.Response `json:"-"`
// Value - An array of locations.
Value *[]Location `json:"value,omitempty"`
}
// Model subscription information.
type Model struct {
autorest.Response `json:"-"`
// ID - READ-ONLY; The fully qualified ID for the subscription. For example, /subscriptions/00000000-0000-0000-0000-000000000000.
ID *string `json:"id,omitempty"`
// SubscriptionID - READ-ONLY; The subscription ID.
SubscriptionID *string `json:"subscriptionId,omitempty"`
// DisplayName - READ-ONLY; The subscription display name.
DisplayName *string `json:"displayName,omitempty"`
// State - READ-ONLY; The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. Possible values include: 'Enabled', 'Warned', 'PastDue', 'Disabled', 'Deleted'
State State `json:"state,omitempty"`
// SubscriptionPolicies - The subscription policies.
SubscriptionPolicies *Policies `json:"subscriptionPolicies,omitempty"`
// AuthorizationSource - The authorization source of the request. Valid values are one or more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, RoleBased'.
AuthorizationSource *string `json:"authorizationSource,omitempty"`
}
// MarshalJSON is the custom marshaler for Model.
func (mVar Model) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if mVar.SubscriptionPolicies != nil {
objectMap["subscriptionPolicies"] = mVar.SubscriptionPolicies
}
if mVar.AuthorizationSource != nil {
objectMap["authorizationSource"] = mVar.AuthorizationSource
}
return json.Marshal(objectMap)
}
// ModernCspSubscriptionCreationParameters the parameters required to create a new CSP subscription.
type ModernCspSubscriptionCreationParameters struct {
// DisplayName - The friendly name of the subscription.
DisplayName *string `json:"displayName,omitempty"`
// SkuID - The SKU ID of the Azure plan. Azure plan determines the pricing and service-level agreement of the subscription. Use 001 for Microsoft Azure Plan and 002 for Microsoft Azure Plan for DevTest.
SkuID *string `json:"skuId,omitempty"`
// ResellerID - Reseller ID, basically MPN Id.
ResellerID *string `json:"resellerId,omitempty"`
}
// ModernSubscriptionCreationParameters the parameters required to create a new subscription.
type ModernSubscriptionCreationParameters struct {
// DisplayName - The friendly name of the subscription.
DisplayName *string `json:"displayName,omitempty"`
// SkuID - The SKU ID of the Azure plan. Azure plan determines the pricing and service-level agreement of the subscription. Use 001 for Microsoft Azure Plan and 002 for Microsoft Azure Plan for DevTest.
SkuID *string `json:"skuId,omitempty"`
// CostCenter - If set, the cost center will show up on the Azure usage and charges file.
CostCenter *string `json:"costCenter,omitempty"`
// Owner - If specified, the AD principal will get owner access to the subscription, along with the user who is performing the create subscription operation
Owner *AdPrincipal `json:"owner,omitempty"`
// ManagementGroupID - The identifier of the management group to which this subscription will be associated.
ManagementGroupID *string `json:"managementGroupId,omitempty"`
// AdditionalParameters - Additional, untyped parameters to support custom subscription creation scenarios.
AdditionalParameters map[string]interface{} `json:"additionalParameters"`
}
// MarshalJSON is the custom marshaler for ModernSubscriptionCreationParameters.
func (mscp ModernSubscriptionCreationParameters) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if mscp.DisplayName != nil {
objectMap["displayName"] = mscp.DisplayName
}
if mscp.SkuID != nil {
objectMap["skuId"] = mscp.SkuID
}
if mscp.CostCenter != nil {
objectMap["costCenter"] = mscp.CostCenter
}
if mscp.Owner != nil {
objectMap["owner"] = mscp.Owner
}
if mscp.ManagementGroupID != nil {
objectMap["managementGroupId"] = mscp.ManagementGroupID
}
if mscp.AdditionalParameters != nil {
objectMap["additionalParameters"] = mscp.AdditionalParameters
}
return json.Marshal(objectMap)
}
// Name the new name of the subscription.
type Name struct {
// SubscriptionName - New subscription name
SubscriptionName *string `json:"subscriptionName,omitempty"`
}
// Operation REST API operation
type Operation struct {
// Name - Operation name: {provider}/{resource}/{operation}
Name *string `json:"name,omitempty"`
// Display - The object that represents the operation.
Display *OperationDisplay `json:"display,omitempty"`
}
// OperationDisplay the object that represents the operation.
type OperationDisplay struct {
// Provider - Service provider: Microsoft.Subscription
Provider *string `json:"provider,omitempty"`
// Resource - Resource on which the operation is performed: Profile, endpoint, etc.
Resource *string `json:"resource,omitempty"`
// Operation - Operation type: Read, write, delete, etc.
Operation *string `json:"operation,omitempty"`
}
// OperationListResult result of the request to list operations. It contains a list of operations and a URL
// link to get the next set of results.
type OperationListResult struct {
autorest.Response `json:"-"`
// Value - List of operations.
Value *[]Operation `json:"value,omitempty"`
// NextLink - URL to get the next set of operation list results if there are any.
NextLink *string `json:"nextLink,omitempty"`
}
// Policies subscription policies.
type Policies struct {
// LocationPlacementID - READ-ONLY; The subscription location placement ID. The ID indicates which regions are visible for a subscription. For example, a subscription with a location placement Id of Public_2014-09-01 has access to Azure public regions.
LocationPlacementID *string `json:"locationPlacementId,omitempty"`
// QuotaID - READ-ONLY; The subscription quota ID.
QuotaID *string `json:"quotaId,omitempty"`
// SpendingLimit - READ-ONLY; The subscription spending limit. Possible values include: 'On', 'Off', 'CurrentPeriodOff'
SpendingLimit SpendingLimit `json:"spendingLimit,omitempty"`
}
// MarshalJSON is the custom marshaler for Policies.
func (p Policies) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
return json.Marshal(objectMap)
}
// PutAliasListResult the list of aliases.
type PutAliasListResult struct {
autorest.Response `json:"-"`
// Value - READ-ONLY; The list of alias.
Value *[]PutAliasResponse `json:"value,omitempty"`
// NextLink - READ-ONLY; The link (url) to the next page of results.
NextLink *string `json:"nextLink,omitempty"`
}
// MarshalJSON is the custom marshaler for PutAliasListResult.
func (palr PutAliasListResult) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
return json.Marshal(objectMap)
}
// PutAliasRequest the parameters required to create a new subscription.
type PutAliasRequest struct {
// Properties - Put alias request properties.
Properties *PutAliasRequestProperties `json:"properties,omitempty"`
}
// PutAliasRequestProperties put subscription properties.
type PutAliasRequestProperties struct {
// DisplayName - The friendly name of the subscription.
DisplayName *string `json:"displayName,omitempty"`
// Workload - The workload type of the subscription. It can be either Production or DevTest. Possible values include: 'Production', 'DevTest'
Workload Workload `json:"workload,omitempty"`
// BillingScope - Determines whether subscription is fieldLed, partnerLed or LegacyEA
BillingScope *string `json:"billingScope,omitempty"`
// SubscriptionID - This parameter can be used to create alias for existing subscription Id
SubscriptionID *string `json:"subscriptionId,omitempty"`
}
// PutAliasResponse subscription Information with the alias.
type PutAliasResponse struct {
autorest.Response `json:"-"`
// ID - READ-ONLY; Fully qualified ID for the alias resource.
ID *string `json:"id,omitempty"`
// Name - READ-ONLY; Alias ID.
Name *string `json:"name,omitempty"`
// Type - READ-ONLY; Resource type, Microsoft.Subscription/aliases.
Type *string `json:"type,omitempty"`
// Properties - Put Alias response properties.
Properties *PutAliasResponseProperties `json:"properties,omitempty"`
}
// MarshalJSON is the custom marshaler for PutAliasResponse.
func (par PutAliasResponse) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if par.Properties != nil {
objectMap["properties"] = par.Properties
}
return json.Marshal(objectMap)
}
// PutAliasResponseProperties put subscription creation result properties.
type PutAliasResponseProperties struct {
// SubscriptionID - READ-ONLY; Newly created subscription Id.
SubscriptionID *string `json:"subscriptionId,omitempty"`
// ProvisioningState - The provisioning state of the resource. Possible values include: 'Accepted', 'Succeeded', 'Failed'
ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
}
// MarshalJSON is the custom marshaler for PutAliasResponseProperties.
func (parp PutAliasResponseProperties) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if parp.ProvisioningState != "" {
objectMap["provisioningState"] = parp.ProvisioningState
}
return json.Marshal(objectMap)
}
// RenamedSubscriptionID the ID of the subscriptions that is being renamed
type RenamedSubscriptionID struct {
autorest.Response `json:"-"`
// Value - READ-ONLY; The ID of the subscriptions that is being renamed
Value *string `json:"value,omitempty"`
}
// MarshalJSON is the custom marshaler for RenamedSubscriptionID.
func (rsi RenamedSubscriptionID) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
return json.Marshal(objectMap)
}
// TenantIDDescription tenant Id information.
type TenantIDDescription struct {
// ID - READ-ONLY; The fully qualified ID of the tenant. For example, /tenants/00000000-0000-0000-0000-000000000000.
ID *string `json:"id,omitempty"`
// TenantID - READ-ONLY; The tenant ID. For example, 00000000-0000-0000-0000-000000000000.
TenantID *string `json:"tenantId,omitempty"`
}
// MarshalJSON is the custom marshaler for TenantIDDescription.
func (tid TenantIDDescription) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
return json.Marshal(objectMap)
}
// TenantListResult tenant Ids information.
type TenantListResult struct {
autorest.Response `json:"-"`
// Value - An array of tenants.
Value *[]TenantIDDescription `json:"value,omitempty"`
// NextLink - The URL to use for getting the next set of results.
NextLink *string `json:"nextLink,omitempty"`
}
// TenantListResultIterator provides access to a complete listing of TenantIDDescription values.
type TenantListResultIterator struct {
i int
page TenantListResultPage
}
// NextWithContext advances to the next value. If there was an error making
// the request the iterator does not advance and the error is returned.
func (iter *TenantListResultIterator) NextWithContext(ctx context.Context) (err error) {
if tracing.IsEnabled() {
ctx = tracing.StartSpan(ctx, fqdn+"/TenantListResultIterator.NextWithContext")
defer func() {
sc := -1
if iter.Response().Response.Response != nil {
sc = iter.Response().Response.Response.StatusCode
}
tracing.EndSpan(ctx, sc, err)
}()
}
iter.i++
if iter.i < len(iter.page.Values()) {
return nil
}
err = iter.page.NextWithContext(ctx)
if err != nil {
iter.i--
return err
}
iter.i = 0
return nil
}
// Next advances to the next value. If there was an error making
// the request the iterator does not advance and the error is returned.
// Deprecated: Use NextWithContext() instead.
func (iter *TenantListResultIterator) Next() error {
return iter.NextWithContext(context.Background())
}
// NotDone returns true if the enumeration should be started or is not yet complete.
func (iter TenantListResultIterator) NotDone() bool {
return iter.page.NotDone() && iter.i < len(iter.page.Values())
}
// Response returns the raw server response from the last page request.
func (iter TenantListResultIterator) Response() TenantListResult {
return iter.page.Response()
}
// Value returns the current value or a zero-initialized value if the
// iterator has advanced beyond the end of the collection.
func (iter TenantListResultIterator) Value() TenantIDDescription {
if !iter.page.NotDone() {
return TenantIDDescription{}
}
return iter.page.Values()[iter.i]
}
// Creates a new instance of the TenantListResultIterator type.
func NewTenantListResultIterator(page TenantListResultPage) TenantListResultIterator {
return TenantListResultIterator{page: page}
}
// IsEmpty returns true if the ListResult contains no values.
func (tlr TenantListResult) IsEmpty() bool {
return tlr.Value == nil || len(*tlr.Value) == 0
}
// hasNextLink returns true if the NextLink is not empty.
func (tlr TenantListResult) hasNextLink() bool {
return tlr.NextLink != nil && len(*tlr.NextLink) != 0
}
// tenantListResultPreparer prepares a request to retrieve the next set of results.
// It returns nil if no more results exist.
func (tlr TenantListResult) tenantListResultPreparer(ctx context.Context) (*http.Request, error) {
if !tlr.hasNextLink() {
return nil, nil
}
return autorest.Prepare((&http.Request{}).WithContext(ctx),
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(tlr.NextLink)))
}
// TenantListResultPage contains a page of TenantIDDescription values.
type TenantListResultPage struct {
fn func(context.Context, TenantListResult) (TenantListResult, error)
tlr TenantListResult
}
// NextWithContext advances to the next page of values. If there was an error making
// the request the page does not advance and the error is returned.
func (page *TenantListResultPage) NextWithContext(ctx context.Context) (err error) {
if tracing.IsEnabled() {
ctx = tracing.StartSpan(ctx, fqdn+"/TenantListResultPage.NextWithContext")
defer func() {
sc := -1
if page.Response().Response.Response != nil {
sc = page.Response().Response.Response.StatusCode
}
tracing.EndSpan(ctx, sc, err)
}()
}
for {
next, err := page.fn(ctx, page.tlr)
if err != nil {
return err
}
page.tlr = next
if !next.hasNextLink() || !next.IsEmpty() {
break
}
}
return nil
}
// Next advances to the next page of values. If there was an error making
// the request the page does not advance and the error is returned.
// Deprecated: Use NextWithContext() instead.
func (page *TenantListResultPage) Next() error {
return page.NextWithContext(context.Background())
}
// NotDone returns true if the page enumeration should be started or is not yet complete.
func (page TenantListResultPage) NotDone() bool {
return !page.tlr.IsEmpty()
}
// Response returns the raw server response from the last page request.
func (page TenantListResultPage) Response() TenantListResult {
return page.tlr
}
// Values returns the slice of values for the current page or nil if there are no values.
func (page TenantListResultPage) Values() []TenantIDDescription {
if page.tlr.IsEmpty() {
return nil
}
return *page.tlr.Value
}
// Creates a new instance of the TenantListResultPage type.
func NewTenantListResultPage(cur TenantListResult, getNextPage func(context.Context, TenantListResult) (TenantListResult, error)) TenantListResultPage {
return TenantListResultPage{
fn: getNextPage,
tlr: cur,
}
}