1 package policy
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/date"
14 "github.com/Azure/go-autorest/autorest/to"
15 "github.com/Azure/go-autorest/tracing"
16 "net/http"
17 )
18
19
20 const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2020-03-01-preview/policy"
21
22
23 type Assignment struct {
24 autorest.Response `json:"-"`
25
26 *AssignmentProperties `json:"properties,omitempty"`
27
28 ID *string `json:"id,omitempty"`
29
30 Type *string `json:"type,omitempty"`
31
32 Name *string `json:"name,omitempty"`
33
34 Sku *Sku `json:"sku,omitempty"`
35
36 Location *string `json:"location,omitempty"`
37
38 Identity *Identity `json:"identity,omitempty"`
39 }
40
41
42 func (a Assignment) MarshalJSON() ([]byte, error) {
43 objectMap := make(map[string]interface{})
44 if a.AssignmentProperties != nil {
45 objectMap["properties"] = a.AssignmentProperties
46 }
47 if a.Sku != nil {
48 objectMap["sku"] = a.Sku
49 }
50 if a.Location != nil {
51 objectMap["location"] = a.Location
52 }
53 if a.Identity != nil {
54 objectMap["identity"] = a.Identity
55 }
56 return json.Marshal(objectMap)
57 }
58
59
60 func (a *Assignment) UnmarshalJSON(body []byte) error {
61 var m map[string]*json.RawMessage
62 err := json.Unmarshal(body, &m)
63 if err != nil {
64 return err
65 }
66 for k, v := range m {
67 switch k {
68 case "properties":
69 if v != nil {
70 var assignmentProperties AssignmentProperties
71 err = json.Unmarshal(*v, &assignmentProperties)
72 if err != nil {
73 return err
74 }
75 a.AssignmentProperties = &assignmentProperties
76 }
77 case "id":
78 if v != nil {
79 var ID string
80 err = json.Unmarshal(*v, &ID)
81 if err != nil {
82 return err
83 }
84 a.ID = &ID
85 }
86 case "type":
87 if v != nil {
88 var typeVar string
89 err = json.Unmarshal(*v, &typeVar)
90 if err != nil {
91 return err
92 }
93 a.Type = &typeVar
94 }
95 case "name":
96 if v != nil {
97 var name string
98 err = json.Unmarshal(*v, &name)
99 if err != nil {
100 return err
101 }
102 a.Name = &name
103 }
104 case "sku":
105 if v != nil {
106 var sku Sku
107 err = json.Unmarshal(*v, &sku)
108 if err != nil {
109 return err
110 }
111 a.Sku = &sku
112 }
113 case "location":
114 if v != nil {
115 var location string
116 err = json.Unmarshal(*v, &location)
117 if err != nil {
118 return err
119 }
120 a.Location = &location
121 }
122 case "identity":
123 if v != nil {
124 var identity Identity
125 err = json.Unmarshal(*v, &identity)
126 if err != nil {
127 return err
128 }
129 a.Identity = &identity
130 }
131 }
132 }
133
134 return nil
135 }
136
137
138 type AssignmentListResult struct {
139 autorest.Response `json:"-"`
140
141 Value *[]Assignment `json:"value,omitempty"`
142
143 NextLink *string `json:"nextLink,omitempty"`
144 }
145
146
147 type AssignmentListResultIterator struct {
148 i int
149 page AssignmentListResultPage
150 }
151
152
153
154 func (iter *AssignmentListResultIterator) NextWithContext(ctx context.Context) (err error) {
155 if tracing.IsEnabled() {
156 ctx = tracing.StartSpan(ctx, fqdn+"/AssignmentListResultIterator.NextWithContext")
157 defer func() {
158 sc := -1
159 if iter.Response().Response.Response != nil {
160 sc = iter.Response().Response.Response.StatusCode
161 }
162 tracing.EndSpan(ctx, sc, err)
163 }()
164 }
165 iter.i++
166 if iter.i < len(iter.page.Values()) {
167 return nil
168 }
169 err = iter.page.NextWithContext(ctx)
170 if err != nil {
171 iter.i--
172 return err
173 }
174 iter.i = 0
175 return nil
176 }
177
178
179
180
181 func (iter *AssignmentListResultIterator) Next() error {
182 return iter.NextWithContext(context.Background())
183 }
184
185
186 func (iter AssignmentListResultIterator) NotDone() bool {
187 return iter.page.NotDone() && iter.i < len(iter.page.Values())
188 }
189
190
191 func (iter AssignmentListResultIterator) Response() AssignmentListResult {
192 return iter.page.Response()
193 }
194
195
196
197 func (iter AssignmentListResultIterator) Value() Assignment {
198 if !iter.page.NotDone() {
199 return Assignment{}
200 }
201 return iter.page.Values()[iter.i]
202 }
203
204
205 func NewAssignmentListResultIterator(page AssignmentListResultPage) AssignmentListResultIterator {
206 return AssignmentListResultIterator{page: page}
207 }
208
209
210 func (alr AssignmentListResult) IsEmpty() bool {
211 return alr.Value == nil || len(*alr.Value) == 0
212 }
213
214
215 func (alr AssignmentListResult) hasNextLink() bool {
216 return alr.NextLink != nil && len(*alr.NextLink) != 0
217 }
218
219
220
221 func (alr AssignmentListResult) assignmentListResultPreparer(ctx context.Context) (*http.Request, error) {
222 if !alr.hasNextLink() {
223 return nil, nil
224 }
225 return autorest.Prepare((&http.Request{}).WithContext(ctx),
226 autorest.AsJSON(),
227 autorest.AsGet(),
228 autorest.WithBaseURL(to.String(alr.NextLink)))
229 }
230
231
232 type AssignmentListResultPage struct {
233 fn func(context.Context, AssignmentListResult) (AssignmentListResult, error)
234 alr AssignmentListResult
235 }
236
237
238
239 func (page *AssignmentListResultPage) NextWithContext(ctx context.Context) (err error) {
240 if tracing.IsEnabled() {
241 ctx = tracing.StartSpan(ctx, fqdn+"/AssignmentListResultPage.NextWithContext")
242 defer func() {
243 sc := -1
244 if page.Response().Response.Response != nil {
245 sc = page.Response().Response.Response.StatusCode
246 }
247 tracing.EndSpan(ctx, sc, err)
248 }()
249 }
250 for {
251 next, err := page.fn(ctx, page.alr)
252 if err != nil {
253 return err
254 }
255 page.alr = next
256 if !next.hasNextLink() || !next.IsEmpty() {
257 break
258 }
259 }
260 return nil
261 }
262
263
264
265
266 func (page *AssignmentListResultPage) Next() error {
267 return page.NextWithContext(context.Background())
268 }
269
270
271 func (page AssignmentListResultPage) NotDone() bool {
272 return !page.alr.IsEmpty()
273 }
274
275
276 func (page AssignmentListResultPage) Response() AssignmentListResult {
277 return page.alr
278 }
279
280
281 func (page AssignmentListResultPage) Values() []Assignment {
282 if page.alr.IsEmpty() {
283 return nil
284 }
285 return *page.alr.Value
286 }
287
288
289 func NewAssignmentListResultPage(cur AssignmentListResult, getNextPage func(context.Context, AssignmentListResult) (AssignmentListResult, error)) AssignmentListResultPage {
290 return AssignmentListResultPage{
291 fn: getNextPage,
292 alr: cur,
293 }
294 }
295
296
297 type AssignmentProperties struct {
298
299 DisplayName *string `json:"displayName,omitempty"`
300
301 PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"`
302
303 Scope *string `json:"scope,omitempty"`
304
305 NotScopes *[]string `json:"notScopes,omitempty"`
306
307 Parameters map[string]*ParameterValuesValue `json:"parameters"`
308
309 Description *string `json:"description,omitempty"`
310
311 Metadata interface{} `json:"metadata,omitempty"`
312
313 EnforcementMode EnforcementMode `json:"enforcementMode,omitempty"`
314 }
315
316
317 func (ap AssignmentProperties) MarshalJSON() ([]byte, error) {
318 objectMap := make(map[string]interface{})
319 if ap.DisplayName != nil {
320 objectMap["displayName"] = ap.DisplayName
321 }
322 if ap.PolicyDefinitionID != nil {
323 objectMap["policyDefinitionId"] = ap.PolicyDefinitionID
324 }
325 if ap.Scope != nil {
326 objectMap["scope"] = ap.Scope
327 }
328 if ap.NotScopes != nil {
329 objectMap["notScopes"] = ap.NotScopes
330 }
331 if ap.Parameters != nil {
332 objectMap["parameters"] = ap.Parameters
333 }
334 if ap.Description != nil {
335 objectMap["description"] = ap.Description
336 }
337 if ap.Metadata != nil {
338 objectMap["metadata"] = ap.Metadata
339 }
340 if ap.EnforcementMode != "" {
341 objectMap["enforcementMode"] = ap.EnforcementMode
342 }
343 return json.Marshal(objectMap)
344 }
345
346
347 type AzureEntityResource struct {
348
349 Etag *string `json:"etag,omitempty"`
350
351 ID *string `json:"id,omitempty"`
352
353 Name *string `json:"name,omitempty"`
354
355 Type *string `json:"type,omitempty"`
356 }
357
358
359 func (aer AzureEntityResource) MarshalJSON() ([]byte, error) {
360 objectMap := make(map[string]interface{})
361 return json.Marshal(objectMap)
362 }
363
364
365
366 type CloudError struct {
367
368 Error *ErrorDetail `json:"error,omitempty"`
369 }
370
371
372 type Definition struct {
373 autorest.Response `json:"-"`
374
375 *DefinitionProperties `json:"properties,omitempty"`
376
377 ID *string `json:"id,omitempty"`
378
379 Name *string `json:"name,omitempty"`
380
381 Type *string `json:"type,omitempty"`
382 }
383
384
385 func (d Definition) MarshalJSON() ([]byte, error) {
386 objectMap := make(map[string]interface{})
387 if d.DefinitionProperties != nil {
388 objectMap["properties"] = d.DefinitionProperties
389 }
390 return json.Marshal(objectMap)
391 }
392
393
394 func (d *Definition) UnmarshalJSON(body []byte) error {
395 var m map[string]*json.RawMessage
396 err := json.Unmarshal(body, &m)
397 if err != nil {
398 return err
399 }
400 for k, v := range m {
401 switch k {
402 case "properties":
403 if v != nil {
404 var definitionProperties DefinitionProperties
405 err = json.Unmarshal(*v, &definitionProperties)
406 if err != nil {
407 return err
408 }
409 d.DefinitionProperties = &definitionProperties
410 }
411 case "id":
412 if v != nil {
413 var ID string
414 err = json.Unmarshal(*v, &ID)
415 if err != nil {
416 return err
417 }
418 d.ID = &ID
419 }
420 case "name":
421 if v != nil {
422 var name string
423 err = json.Unmarshal(*v, &name)
424 if err != nil {
425 return err
426 }
427 d.Name = &name
428 }
429 case "type":
430 if v != nil {
431 var typeVar string
432 err = json.Unmarshal(*v, &typeVar)
433 if err != nil {
434 return err
435 }
436 d.Type = &typeVar
437 }
438 }
439 }
440
441 return nil
442 }
443
444
445 type DefinitionGroup struct {
446
447 Name *string `json:"name,omitempty"`
448
449 DisplayName *string `json:"displayName,omitempty"`
450
451 Category *string `json:"category,omitempty"`
452
453 Description *string `json:"description,omitempty"`
454
455 AdditionalMetadataID *string `json:"additionalMetadataId,omitempty"`
456 }
457
458
459 type DefinitionListResult struct {
460 autorest.Response `json:"-"`
461
462 Value *[]Definition `json:"value,omitempty"`
463
464 NextLink *string `json:"nextLink,omitempty"`
465 }
466
467
468 type DefinitionListResultIterator struct {
469 i int
470 page DefinitionListResultPage
471 }
472
473
474
475 func (iter *DefinitionListResultIterator) NextWithContext(ctx context.Context) (err error) {
476 if tracing.IsEnabled() {
477 ctx = tracing.StartSpan(ctx, fqdn+"/DefinitionListResultIterator.NextWithContext")
478 defer func() {
479 sc := -1
480 if iter.Response().Response.Response != nil {
481 sc = iter.Response().Response.Response.StatusCode
482 }
483 tracing.EndSpan(ctx, sc, err)
484 }()
485 }
486 iter.i++
487 if iter.i < len(iter.page.Values()) {
488 return nil
489 }
490 err = iter.page.NextWithContext(ctx)
491 if err != nil {
492 iter.i--
493 return err
494 }
495 iter.i = 0
496 return nil
497 }
498
499
500
501
502 func (iter *DefinitionListResultIterator) Next() error {
503 return iter.NextWithContext(context.Background())
504 }
505
506
507 func (iter DefinitionListResultIterator) NotDone() bool {
508 return iter.page.NotDone() && iter.i < len(iter.page.Values())
509 }
510
511
512 func (iter DefinitionListResultIterator) Response() DefinitionListResult {
513 return iter.page.Response()
514 }
515
516
517
518 func (iter DefinitionListResultIterator) Value() Definition {
519 if !iter.page.NotDone() {
520 return Definition{}
521 }
522 return iter.page.Values()[iter.i]
523 }
524
525
526 func NewDefinitionListResultIterator(page DefinitionListResultPage) DefinitionListResultIterator {
527 return DefinitionListResultIterator{page: page}
528 }
529
530
531 func (dlr DefinitionListResult) IsEmpty() bool {
532 return dlr.Value == nil || len(*dlr.Value) == 0
533 }
534
535
536 func (dlr DefinitionListResult) hasNextLink() bool {
537 return dlr.NextLink != nil && len(*dlr.NextLink) != 0
538 }
539
540
541
542 func (dlr DefinitionListResult) definitionListResultPreparer(ctx context.Context) (*http.Request, error) {
543 if !dlr.hasNextLink() {
544 return nil, nil
545 }
546 return autorest.Prepare((&http.Request{}).WithContext(ctx),
547 autorest.AsJSON(),
548 autorest.AsGet(),
549 autorest.WithBaseURL(to.String(dlr.NextLink)))
550 }
551
552
553 type DefinitionListResultPage struct {
554 fn func(context.Context, DefinitionListResult) (DefinitionListResult, error)
555 dlr DefinitionListResult
556 }
557
558
559
560 func (page *DefinitionListResultPage) NextWithContext(ctx context.Context) (err error) {
561 if tracing.IsEnabled() {
562 ctx = tracing.StartSpan(ctx, fqdn+"/DefinitionListResultPage.NextWithContext")
563 defer func() {
564 sc := -1
565 if page.Response().Response.Response != nil {
566 sc = page.Response().Response.Response.StatusCode
567 }
568 tracing.EndSpan(ctx, sc, err)
569 }()
570 }
571 for {
572 next, err := page.fn(ctx, page.dlr)
573 if err != nil {
574 return err
575 }
576 page.dlr = next
577 if !next.hasNextLink() || !next.IsEmpty() {
578 break
579 }
580 }
581 return nil
582 }
583
584
585
586
587 func (page *DefinitionListResultPage) Next() error {
588 return page.NextWithContext(context.Background())
589 }
590
591
592 func (page DefinitionListResultPage) NotDone() bool {
593 return !page.dlr.IsEmpty()
594 }
595
596
597 func (page DefinitionListResultPage) Response() DefinitionListResult {
598 return page.dlr
599 }
600
601
602 func (page DefinitionListResultPage) Values() []Definition {
603 if page.dlr.IsEmpty() {
604 return nil
605 }
606 return *page.dlr.Value
607 }
608
609
610 func NewDefinitionListResultPage(cur DefinitionListResult, getNextPage func(context.Context, DefinitionListResult) (DefinitionListResult, error)) DefinitionListResultPage {
611 return DefinitionListResultPage{
612 fn: getNextPage,
613 dlr: cur,
614 }
615 }
616
617
618 type DefinitionProperties struct {
619
620 PolicyType Type `json:"policyType,omitempty"`
621
622 Mode *string `json:"mode,omitempty"`
623
624 DisplayName *string `json:"displayName,omitempty"`
625
626 Description *string `json:"description,omitempty"`
627
628 PolicyRule interface{} `json:"policyRule,omitempty"`
629
630 Metadata interface{} `json:"metadata,omitempty"`
631
632 Parameters map[string]*ParameterDefinitionsValue `json:"parameters"`
633 }
634
635
636 func (dp DefinitionProperties) MarshalJSON() ([]byte, error) {
637 objectMap := make(map[string]interface{})
638 if dp.PolicyType != "" {
639 objectMap["policyType"] = dp.PolicyType
640 }
641 if dp.Mode != nil {
642 objectMap["mode"] = dp.Mode
643 }
644 if dp.DisplayName != nil {
645 objectMap["displayName"] = dp.DisplayName
646 }
647 if dp.Description != nil {
648 objectMap["description"] = dp.Description
649 }
650 if dp.PolicyRule != nil {
651 objectMap["policyRule"] = dp.PolicyRule
652 }
653 if dp.Metadata != nil {
654 objectMap["metadata"] = dp.Metadata
655 }
656 if dp.Parameters != nil {
657 objectMap["parameters"] = dp.Parameters
658 }
659 return json.Marshal(objectMap)
660 }
661
662
663 type DefinitionReference struct {
664
665 PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"`
666
667 Parameters map[string]*ParameterValuesValue `json:"parameters"`
668
669 PolicyDefinitionReferenceID *string `json:"policyDefinitionReferenceId,omitempty"`
670
671 GroupNames *[]string `json:"groupNames,omitempty"`
672 }
673
674
675 func (dr DefinitionReference) MarshalJSON() ([]byte, error) {
676 objectMap := make(map[string]interface{})
677 if dr.PolicyDefinitionID != nil {
678 objectMap["policyDefinitionId"] = dr.PolicyDefinitionID
679 }
680 if dr.Parameters != nil {
681 objectMap["parameters"] = dr.Parameters
682 }
683 if dr.PolicyDefinitionReferenceID != nil {
684 objectMap["policyDefinitionReferenceId"] = dr.PolicyDefinitionReferenceID
685 }
686 if dr.GroupNames != nil {
687 objectMap["groupNames"] = dr.GroupNames
688 }
689 return json.Marshal(objectMap)
690 }
691
692
693 type ErrorAdditionalInfo struct {
694
695 Type *string `json:"type,omitempty"`
696
697 Info interface{} `json:"info,omitempty"`
698 }
699
700
701 func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) {
702 objectMap := make(map[string]interface{})
703 return json.Marshal(objectMap)
704 }
705
706
707 type ErrorDetail struct {
708
709 Code *string `json:"code,omitempty"`
710
711 Message *string `json:"message,omitempty"`
712
713 Target *string `json:"target,omitempty"`
714
715 Details *[]ErrorDetail `json:"details,omitempty"`
716
717 AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"`
718 }
719
720
721 func (ed ErrorDetail) MarshalJSON() ([]byte, error) {
722 objectMap := make(map[string]interface{})
723 return json.Marshal(objectMap)
724 }
725
726
727 type Exemption struct {
728 autorest.Response `json:"-"`
729
730 *ExemptionProperties `json:"properties,omitempty"`
731
732 SystemData *SystemData `json:"systemData,omitempty"`
733
734 ID *string `json:"id,omitempty"`
735
736 Name *string `json:"name,omitempty"`
737
738 Type *string `json:"type,omitempty"`
739 }
740
741
742 func (e Exemption) MarshalJSON() ([]byte, error) {
743 objectMap := make(map[string]interface{})
744 if e.ExemptionProperties != nil {
745 objectMap["properties"] = e.ExemptionProperties
746 }
747 return json.Marshal(objectMap)
748 }
749
750
751 func (e *Exemption) UnmarshalJSON(body []byte) error {
752 var m map[string]*json.RawMessage
753 err := json.Unmarshal(body, &m)
754 if err != nil {
755 return err
756 }
757 for k, v := range m {
758 switch k {
759 case "properties":
760 if v != nil {
761 var exemptionProperties ExemptionProperties
762 err = json.Unmarshal(*v, &exemptionProperties)
763 if err != nil {
764 return err
765 }
766 e.ExemptionProperties = &exemptionProperties
767 }
768 case "systemData":
769 if v != nil {
770 var systemData SystemData
771 err = json.Unmarshal(*v, &systemData)
772 if err != nil {
773 return err
774 }
775 e.SystemData = &systemData
776 }
777 case "id":
778 if v != nil {
779 var ID string
780 err = json.Unmarshal(*v, &ID)
781 if err != nil {
782 return err
783 }
784 e.ID = &ID
785 }
786 case "name":
787 if v != nil {
788 var name string
789 err = json.Unmarshal(*v, &name)
790 if err != nil {
791 return err
792 }
793 e.Name = &name
794 }
795 case "type":
796 if v != nil {
797 var typeVar string
798 err = json.Unmarshal(*v, &typeVar)
799 if err != nil {
800 return err
801 }
802 e.Type = &typeVar
803 }
804 }
805 }
806
807 return nil
808 }
809
810
811 type ExemptionListResult struct {
812 autorest.Response `json:"-"`
813
814 Value *[]Exemption `json:"value,omitempty"`
815
816 NextLink *string `json:"nextLink,omitempty"`
817 }
818
819
820 func (elr ExemptionListResult) MarshalJSON() ([]byte, error) {
821 objectMap := make(map[string]interface{})
822 if elr.Value != nil {
823 objectMap["value"] = elr.Value
824 }
825 return json.Marshal(objectMap)
826 }
827
828
829 type ExemptionListResultIterator struct {
830 i int
831 page ExemptionListResultPage
832 }
833
834
835
836 func (iter *ExemptionListResultIterator) NextWithContext(ctx context.Context) (err error) {
837 if tracing.IsEnabled() {
838 ctx = tracing.StartSpan(ctx, fqdn+"/ExemptionListResultIterator.NextWithContext")
839 defer func() {
840 sc := -1
841 if iter.Response().Response.Response != nil {
842 sc = iter.Response().Response.Response.StatusCode
843 }
844 tracing.EndSpan(ctx, sc, err)
845 }()
846 }
847 iter.i++
848 if iter.i < len(iter.page.Values()) {
849 return nil
850 }
851 err = iter.page.NextWithContext(ctx)
852 if err != nil {
853 iter.i--
854 return err
855 }
856 iter.i = 0
857 return nil
858 }
859
860
861
862
863 func (iter *ExemptionListResultIterator) Next() error {
864 return iter.NextWithContext(context.Background())
865 }
866
867
868 func (iter ExemptionListResultIterator) NotDone() bool {
869 return iter.page.NotDone() && iter.i < len(iter.page.Values())
870 }
871
872
873 func (iter ExemptionListResultIterator) Response() ExemptionListResult {
874 return iter.page.Response()
875 }
876
877
878
879 func (iter ExemptionListResultIterator) Value() Exemption {
880 if !iter.page.NotDone() {
881 return Exemption{}
882 }
883 return iter.page.Values()[iter.i]
884 }
885
886
887 func NewExemptionListResultIterator(page ExemptionListResultPage) ExemptionListResultIterator {
888 return ExemptionListResultIterator{page: page}
889 }
890
891
892 func (elr ExemptionListResult) IsEmpty() bool {
893 return elr.Value == nil || len(*elr.Value) == 0
894 }
895
896
897 func (elr ExemptionListResult) hasNextLink() bool {
898 return elr.NextLink != nil && len(*elr.NextLink) != 0
899 }
900
901
902
903 func (elr ExemptionListResult) exemptionListResultPreparer(ctx context.Context) (*http.Request, error) {
904 if !elr.hasNextLink() {
905 return nil, nil
906 }
907 return autorest.Prepare((&http.Request{}).WithContext(ctx),
908 autorest.AsJSON(),
909 autorest.AsGet(),
910 autorest.WithBaseURL(to.String(elr.NextLink)))
911 }
912
913
914 type ExemptionListResultPage struct {
915 fn func(context.Context, ExemptionListResult) (ExemptionListResult, error)
916 elr ExemptionListResult
917 }
918
919
920
921 func (page *ExemptionListResultPage) NextWithContext(ctx context.Context) (err error) {
922 if tracing.IsEnabled() {
923 ctx = tracing.StartSpan(ctx, fqdn+"/ExemptionListResultPage.NextWithContext")
924 defer func() {
925 sc := -1
926 if page.Response().Response.Response != nil {
927 sc = page.Response().Response.Response.StatusCode
928 }
929 tracing.EndSpan(ctx, sc, err)
930 }()
931 }
932 for {
933 next, err := page.fn(ctx, page.elr)
934 if err != nil {
935 return err
936 }
937 page.elr = next
938 if !next.hasNextLink() || !next.IsEmpty() {
939 break
940 }
941 }
942 return nil
943 }
944
945
946
947
948 func (page *ExemptionListResultPage) Next() error {
949 return page.NextWithContext(context.Background())
950 }
951
952
953 func (page ExemptionListResultPage) NotDone() bool {
954 return !page.elr.IsEmpty()
955 }
956
957
958 func (page ExemptionListResultPage) Response() ExemptionListResult {
959 return page.elr
960 }
961
962
963 func (page ExemptionListResultPage) Values() []Exemption {
964 if page.elr.IsEmpty() {
965 return nil
966 }
967 return *page.elr.Value
968 }
969
970
971 func NewExemptionListResultPage(cur ExemptionListResult, getNextPage func(context.Context, ExemptionListResult) (ExemptionListResult, error)) ExemptionListResultPage {
972 return ExemptionListResultPage{
973 fn: getNextPage,
974 elr: cur,
975 }
976 }
977
978
979 type ExemptionProperties struct {
980
981 PolicyAssignmentID *string `json:"policyAssignmentId,omitempty"`
982
983 PolicyDefinitionReferenceIds *[]string `json:"policyDefinitionReferenceIds,omitempty"`
984
985 ExemptionCategory ExemptionCategory `json:"exemptionCategory,omitempty"`
986
987 ExpiresOn *date.Time `json:"expiresOn,omitempty"`
988
989 DisplayName *string `json:"displayName,omitempty"`
990
991 Description *string `json:"description,omitempty"`
992
993 Metadata interface{} `json:"metadata,omitempty"`
994 }
995
996
997 type Identity struct {
998
999 PrincipalID *string `json:"principalId,omitempty"`
1000
1001 TenantID *string `json:"tenantId,omitempty"`
1002
1003 Type ResourceIdentityType `json:"type,omitempty"`
1004 }
1005
1006
1007 func (i Identity) MarshalJSON() ([]byte, error) {
1008 objectMap := make(map[string]interface{})
1009 if i.Type != "" {
1010 objectMap["type"] = i.Type
1011 }
1012 return json.Marshal(objectMap)
1013 }
1014
1015
1016 type ParameterDefinitionsValue struct {
1017
1018 Type ParameterType `json:"type,omitempty"`
1019
1020 AllowedValues *[]interface{} `json:"allowedValues,omitempty"`
1021
1022 DefaultValue interface{} `json:"defaultValue,omitempty"`
1023
1024 Metadata *ParameterDefinitionsValueMetadata `json:"metadata,omitempty"`
1025 }
1026
1027
1028 type ParameterDefinitionsValueMetadata struct {
1029
1030 AdditionalProperties map[string]interface{} `json:""`
1031
1032 DisplayName *string `json:"displayName,omitempty"`
1033
1034 Description *string `json:"description,omitempty"`
1035 }
1036
1037
1038 func (pdv ParameterDefinitionsValueMetadata) MarshalJSON() ([]byte, error) {
1039 objectMap := make(map[string]interface{})
1040 if pdv.DisplayName != nil {
1041 objectMap["displayName"] = pdv.DisplayName
1042 }
1043 if pdv.Description != nil {
1044 objectMap["description"] = pdv.Description
1045 }
1046 for k, v := range pdv.AdditionalProperties {
1047 objectMap[k] = v
1048 }
1049 return json.Marshal(objectMap)
1050 }
1051
1052
1053 func (pdv *ParameterDefinitionsValueMetadata) UnmarshalJSON(body []byte) error {
1054 var m map[string]*json.RawMessage
1055 err := json.Unmarshal(body, &m)
1056 if err != nil {
1057 return err
1058 }
1059 for k, v := range m {
1060 switch k {
1061 default:
1062 if v != nil {
1063 var additionalProperties interface{}
1064 err = json.Unmarshal(*v, &additionalProperties)
1065 if err != nil {
1066 return err
1067 }
1068 if pdv.AdditionalProperties == nil {
1069 pdv.AdditionalProperties = make(map[string]interface{})
1070 }
1071 pdv.AdditionalProperties[k] = additionalProperties
1072 }
1073 case "displayName":
1074 if v != nil {
1075 var displayName string
1076 err = json.Unmarshal(*v, &displayName)
1077 if err != nil {
1078 return err
1079 }
1080 pdv.DisplayName = &displayName
1081 }
1082 case "description":
1083 if v != nil {
1084 var description string
1085 err = json.Unmarshal(*v, &description)
1086 if err != nil {
1087 return err
1088 }
1089 pdv.Description = &description
1090 }
1091 }
1092 }
1093
1094 return nil
1095 }
1096
1097
1098 type ParameterValuesValue struct {
1099
1100 Value interface{} `json:"value,omitempty"`
1101 }
1102
1103
1104
1105 type ProxyResource struct {
1106
1107 ID *string `json:"id,omitempty"`
1108
1109 Name *string `json:"name,omitempty"`
1110
1111 Type *string `json:"type,omitempty"`
1112 }
1113
1114
1115 func (pr ProxyResource) MarshalJSON() ([]byte, error) {
1116 objectMap := make(map[string]interface{})
1117 return json.Marshal(objectMap)
1118 }
1119
1120
1121 type Resource struct {
1122
1123 ID *string `json:"id,omitempty"`
1124
1125 Name *string `json:"name,omitempty"`
1126
1127 Type *string `json:"type,omitempty"`
1128 }
1129
1130
1131 func (r Resource) MarshalJSON() ([]byte, error) {
1132 objectMap := make(map[string]interface{})
1133 return json.Marshal(objectMap)
1134 }
1135
1136
1137 type SetDefinition struct {
1138 autorest.Response `json:"-"`
1139
1140 *SetDefinitionProperties `json:"properties,omitempty"`
1141
1142 ID *string `json:"id,omitempty"`
1143
1144 Name *string `json:"name,omitempty"`
1145
1146 Type *string `json:"type,omitempty"`
1147 }
1148
1149
1150 func (sd SetDefinition) MarshalJSON() ([]byte, error) {
1151 objectMap := make(map[string]interface{})
1152 if sd.SetDefinitionProperties != nil {
1153 objectMap["properties"] = sd.SetDefinitionProperties
1154 }
1155 return json.Marshal(objectMap)
1156 }
1157
1158
1159 func (sd *SetDefinition) UnmarshalJSON(body []byte) error {
1160 var m map[string]*json.RawMessage
1161 err := json.Unmarshal(body, &m)
1162 if err != nil {
1163 return err
1164 }
1165 for k, v := range m {
1166 switch k {
1167 case "properties":
1168 if v != nil {
1169 var setDefinitionProperties SetDefinitionProperties
1170 err = json.Unmarshal(*v, &setDefinitionProperties)
1171 if err != nil {
1172 return err
1173 }
1174 sd.SetDefinitionProperties = &setDefinitionProperties
1175 }
1176 case "id":
1177 if v != nil {
1178 var ID string
1179 err = json.Unmarshal(*v, &ID)
1180 if err != nil {
1181 return err
1182 }
1183 sd.ID = &ID
1184 }
1185 case "name":
1186 if v != nil {
1187 var name string
1188 err = json.Unmarshal(*v, &name)
1189 if err != nil {
1190 return err
1191 }
1192 sd.Name = &name
1193 }
1194 case "type":
1195 if v != nil {
1196 var typeVar string
1197 err = json.Unmarshal(*v, &typeVar)
1198 if err != nil {
1199 return err
1200 }
1201 sd.Type = &typeVar
1202 }
1203 }
1204 }
1205
1206 return nil
1207 }
1208
1209
1210 type SetDefinitionListResult struct {
1211 autorest.Response `json:"-"`
1212
1213 Value *[]SetDefinition `json:"value,omitempty"`
1214
1215 NextLink *string `json:"nextLink,omitempty"`
1216 }
1217
1218
1219 type SetDefinitionListResultIterator struct {
1220 i int
1221 page SetDefinitionListResultPage
1222 }
1223
1224
1225
1226 func (iter *SetDefinitionListResultIterator) NextWithContext(ctx context.Context) (err error) {
1227 if tracing.IsEnabled() {
1228 ctx = tracing.StartSpan(ctx, fqdn+"/SetDefinitionListResultIterator.NextWithContext")
1229 defer func() {
1230 sc := -1
1231 if iter.Response().Response.Response != nil {
1232 sc = iter.Response().Response.Response.StatusCode
1233 }
1234 tracing.EndSpan(ctx, sc, err)
1235 }()
1236 }
1237 iter.i++
1238 if iter.i < len(iter.page.Values()) {
1239 return nil
1240 }
1241 err = iter.page.NextWithContext(ctx)
1242 if err != nil {
1243 iter.i--
1244 return err
1245 }
1246 iter.i = 0
1247 return nil
1248 }
1249
1250
1251
1252
1253 func (iter *SetDefinitionListResultIterator) Next() error {
1254 return iter.NextWithContext(context.Background())
1255 }
1256
1257
1258 func (iter SetDefinitionListResultIterator) NotDone() bool {
1259 return iter.page.NotDone() && iter.i < len(iter.page.Values())
1260 }
1261
1262
1263 func (iter SetDefinitionListResultIterator) Response() SetDefinitionListResult {
1264 return iter.page.Response()
1265 }
1266
1267
1268
1269 func (iter SetDefinitionListResultIterator) Value() SetDefinition {
1270 if !iter.page.NotDone() {
1271 return SetDefinition{}
1272 }
1273 return iter.page.Values()[iter.i]
1274 }
1275
1276
1277 func NewSetDefinitionListResultIterator(page SetDefinitionListResultPage) SetDefinitionListResultIterator {
1278 return SetDefinitionListResultIterator{page: page}
1279 }
1280
1281
1282 func (sdlr SetDefinitionListResult) IsEmpty() bool {
1283 return sdlr.Value == nil || len(*sdlr.Value) == 0
1284 }
1285
1286
1287 func (sdlr SetDefinitionListResult) hasNextLink() bool {
1288 return sdlr.NextLink != nil && len(*sdlr.NextLink) != 0
1289 }
1290
1291
1292
1293 func (sdlr SetDefinitionListResult) setDefinitionListResultPreparer(ctx context.Context) (*http.Request, error) {
1294 if !sdlr.hasNextLink() {
1295 return nil, nil
1296 }
1297 return autorest.Prepare((&http.Request{}).WithContext(ctx),
1298 autorest.AsJSON(),
1299 autorest.AsGet(),
1300 autorest.WithBaseURL(to.String(sdlr.NextLink)))
1301 }
1302
1303
1304 type SetDefinitionListResultPage struct {
1305 fn func(context.Context, SetDefinitionListResult) (SetDefinitionListResult, error)
1306 sdlr SetDefinitionListResult
1307 }
1308
1309
1310
1311 func (page *SetDefinitionListResultPage) NextWithContext(ctx context.Context) (err error) {
1312 if tracing.IsEnabled() {
1313 ctx = tracing.StartSpan(ctx, fqdn+"/SetDefinitionListResultPage.NextWithContext")
1314 defer func() {
1315 sc := -1
1316 if page.Response().Response.Response != nil {
1317 sc = page.Response().Response.Response.StatusCode
1318 }
1319 tracing.EndSpan(ctx, sc, err)
1320 }()
1321 }
1322 for {
1323 next, err := page.fn(ctx, page.sdlr)
1324 if err != nil {
1325 return err
1326 }
1327 page.sdlr = next
1328 if !next.hasNextLink() || !next.IsEmpty() {
1329 break
1330 }
1331 }
1332 return nil
1333 }
1334
1335
1336
1337
1338 func (page *SetDefinitionListResultPage) Next() error {
1339 return page.NextWithContext(context.Background())
1340 }
1341
1342
1343 func (page SetDefinitionListResultPage) NotDone() bool {
1344 return !page.sdlr.IsEmpty()
1345 }
1346
1347
1348 func (page SetDefinitionListResultPage) Response() SetDefinitionListResult {
1349 return page.sdlr
1350 }
1351
1352
1353 func (page SetDefinitionListResultPage) Values() []SetDefinition {
1354 if page.sdlr.IsEmpty() {
1355 return nil
1356 }
1357 return *page.sdlr.Value
1358 }
1359
1360
1361 func NewSetDefinitionListResultPage(cur SetDefinitionListResult, getNextPage func(context.Context, SetDefinitionListResult) (SetDefinitionListResult, error)) SetDefinitionListResultPage {
1362 return SetDefinitionListResultPage{
1363 fn: getNextPage,
1364 sdlr: cur,
1365 }
1366 }
1367
1368
1369 type SetDefinitionProperties struct {
1370
1371 PolicyType Type `json:"policyType,omitempty"`
1372
1373 DisplayName *string `json:"displayName,omitempty"`
1374
1375 Description *string `json:"description,omitempty"`
1376
1377 Metadata interface{} `json:"metadata,omitempty"`
1378
1379 Parameters map[string]*ParameterDefinitionsValue `json:"parameters"`
1380
1381 PolicyDefinitions *[]DefinitionReference `json:"policyDefinitions,omitempty"`
1382
1383 PolicyDefinitionGroups *[]DefinitionGroup `json:"policyDefinitionGroups,omitempty"`
1384 }
1385
1386
1387 func (sdp SetDefinitionProperties) MarshalJSON() ([]byte, error) {
1388 objectMap := make(map[string]interface{})
1389 if sdp.PolicyType != "" {
1390 objectMap["policyType"] = sdp.PolicyType
1391 }
1392 if sdp.DisplayName != nil {
1393 objectMap["displayName"] = sdp.DisplayName
1394 }
1395 if sdp.Description != nil {
1396 objectMap["description"] = sdp.Description
1397 }
1398 if sdp.Metadata != nil {
1399 objectMap["metadata"] = sdp.Metadata
1400 }
1401 if sdp.Parameters != nil {
1402 objectMap["parameters"] = sdp.Parameters
1403 }
1404 if sdp.PolicyDefinitions != nil {
1405 objectMap["policyDefinitions"] = sdp.PolicyDefinitions
1406 }
1407 if sdp.PolicyDefinitionGroups != nil {
1408 objectMap["policyDefinitionGroups"] = sdp.PolicyDefinitionGroups
1409 }
1410 return json.Marshal(objectMap)
1411 }
1412
1413
1414 type Sku struct {
1415
1416 Name *string `json:"name,omitempty"`
1417
1418 Tier *string `json:"tier,omitempty"`
1419 }
1420
1421
1422 type SystemData struct {
1423
1424 CreatedBy *string `json:"createdBy,omitempty"`
1425
1426 CreatedByType CreatedByType `json:"createdByType,omitempty"`
1427
1428 CreatedAt *date.Time `json:"createdAt,omitempty"`
1429
1430 LastModifiedBy *string `json:"lastModifiedBy,omitempty"`
1431
1432 LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"`
1433
1434 LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"`
1435 }
1436
1437
1438 type TrackedResource struct {
1439
1440 Tags map[string]*string `json:"tags"`
1441
1442 Location *string `json:"location,omitempty"`
1443
1444 ID *string `json:"id,omitempty"`
1445
1446 Name *string `json:"name,omitempty"`
1447
1448 Type *string `json:"type,omitempty"`
1449 }
1450
1451
1452 func (tr TrackedResource) MarshalJSON() ([]byte, error) {
1453 objectMap := make(map[string]interface{})
1454 if tr.Tags != nil {
1455 objectMap["tags"] = tr.Tags
1456 }
1457 if tr.Location != nil {
1458 objectMap["location"] = tr.Location
1459 }
1460 return json.Marshal(objectMap)
1461 }
1462
View as plain text