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/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/2019-09-01/policy"
20
21
22 type Assignment struct {
23 autorest.Response `json:"-"`
24
25 *AssignmentProperties `json:"properties,omitempty"`
26
27 ID *string `json:"id,omitempty"`
28
29 Type *string `json:"type,omitempty"`
30
31 Name *string `json:"name,omitempty"`
32
33 Sku *Sku `json:"sku,omitempty"`
34
35 Location *string `json:"location,omitempty"`
36
37 Identity *Identity `json:"identity,omitempty"`
38 }
39
40
41 func (a Assignment) MarshalJSON() ([]byte, error) {
42 objectMap := make(map[string]interface{})
43 if a.AssignmentProperties != nil {
44 objectMap["properties"] = a.AssignmentProperties
45 }
46 if a.Sku != nil {
47 objectMap["sku"] = a.Sku
48 }
49 if a.Location != nil {
50 objectMap["location"] = a.Location
51 }
52 if a.Identity != nil {
53 objectMap["identity"] = a.Identity
54 }
55 return json.Marshal(objectMap)
56 }
57
58
59 func (a *Assignment) UnmarshalJSON(body []byte) error {
60 var m map[string]*json.RawMessage
61 err := json.Unmarshal(body, &m)
62 if err != nil {
63 return err
64 }
65 for k, v := range m {
66 switch k {
67 case "properties":
68 if v != nil {
69 var assignmentProperties AssignmentProperties
70 err = json.Unmarshal(*v, &assignmentProperties)
71 if err != nil {
72 return err
73 }
74 a.AssignmentProperties = &assignmentProperties
75 }
76 case "id":
77 if v != nil {
78 var ID string
79 err = json.Unmarshal(*v, &ID)
80 if err != nil {
81 return err
82 }
83 a.ID = &ID
84 }
85 case "type":
86 if v != nil {
87 var typeVar string
88 err = json.Unmarshal(*v, &typeVar)
89 if err != nil {
90 return err
91 }
92 a.Type = &typeVar
93 }
94 case "name":
95 if v != nil {
96 var name string
97 err = json.Unmarshal(*v, &name)
98 if err != nil {
99 return err
100 }
101 a.Name = &name
102 }
103 case "sku":
104 if v != nil {
105 var sku Sku
106 err = json.Unmarshal(*v, &sku)
107 if err != nil {
108 return err
109 }
110 a.Sku = &sku
111 }
112 case "location":
113 if v != nil {
114 var location string
115 err = json.Unmarshal(*v, &location)
116 if err != nil {
117 return err
118 }
119 a.Location = &location
120 }
121 case "identity":
122 if v != nil {
123 var identity Identity
124 err = json.Unmarshal(*v, &identity)
125 if err != nil {
126 return err
127 }
128 a.Identity = &identity
129 }
130 }
131 }
132
133 return nil
134 }
135
136
137 type AssignmentListResult struct {
138 autorest.Response `json:"-"`
139
140 Value *[]Assignment `json:"value,omitempty"`
141
142 NextLink *string `json:"nextLink,omitempty"`
143 }
144
145
146 type AssignmentListResultIterator struct {
147 i int
148 page AssignmentListResultPage
149 }
150
151
152
153 func (iter *AssignmentListResultIterator) NextWithContext(ctx context.Context) (err error) {
154 if tracing.IsEnabled() {
155 ctx = tracing.StartSpan(ctx, fqdn+"/AssignmentListResultIterator.NextWithContext")
156 defer func() {
157 sc := -1
158 if iter.Response().Response.Response != nil {
159 sc = iter.Response().Response.Response.StatusCode
160 }
161 tracing.EndSpan(ctx, sc, err)
162 }()
163 }
164 iter.i++
165 if iter.i < len(iter.page.Values()) {
166 return nil
167 }
168 err = iter.page.NextWithContext(ctx)
169 if err != nil {
170 iter.i--
171 return err
172 }
173 iter.i = 0
174 return nil
175 }
176
177
178
179
180 func (iter *AssignmentListResultIterator) Next() error {
181 return iter.NextWithContext(context.Background())
182 }
183
184
185 func (iter AssignmentListResultIterator) NotDone() bool {
186 return iter.page.NotDone() && iter.i < len(iter.page.Values())
187 }
188
189
190 func (iter AssignmentListResultIterator) Response() AssignmentListResult {
191 return iter.page.Response()
192 }
193
194
195
196 func (iter AssignmentListResultIterator) Value() Assignment {
197 if !iter.page.NotDone() {
198 return Assignment{}
199 }
200 return iter.page.Values()[iter.i]
201 }
202
203
204 func NewAssignmentListResultIterator(page AssignmentListResultPage) AssignmentListResultIterator {
205 return AssignmentListResultIterator{page: page}
206 }
207
208
209 func (alr AssignmentListResult) IsEmpty() bool {
210 return alr.Value == nil || len(*alr.Value) == 0
211 }
212
213
214 func (alr AssignmentListResult) hasNextLink() bool {
215 return alr.NextLink != nil && len(*alr.NextLink) != 0
216 }
217
218
219
220 func (alr AssignmentListResult) assignmentListResultPreparer(ctx context.Context) (*http.Request, error) {
221 if !alr.hasNextLink() {
222 return nil, nil
223 }
224 return autorest.Prepare((&http.Request{}).WithContext(ctx),
225 autorest.AsJSON(),
226 autorest.AsGet(),
227 autorest.WithBaseURL(to.String(alr.NextLink)))
228 }
229
230
231 type AssignmentListResultPage struct {
232 fn func(context.Context, AssignmentListResult) (AssignmentListResult, error)
233 alr AssignmentListResult
234 }
235
236
237
238 func (page *AssignmentListResultPage) NextWithContext(ctx context.Context) (err error) {
239 if tracing.IsEnabled() {
240 ctx = tracing.StartSpan(ctx, fqdn+"/AssignmentListResultPage.NextWithContext")
241 defer func() {
242 sc := -1
243 if page.Response().Response.Response != nil {
244 sc = page.Response().Response.Response.StatusCode
245 }
246 tracing.EndSpan(ctx, sc, err)
247 }()
248 }
249 for {
250 next, err := page.fn(ctx, page.alr)
251 if err != nil {
252 return err
253 }
254 page.alr = next
255 if !next.hasNextLink() || !next.IsEmpty() {
256 break
257 }
258 }
259 return nil
260 }
261
262
263
264
265 func (page *AssignmentListResultPage) Next() error {
266 return page.NextWithContext(context.Background())
267 }
268
269
270 func (page AssignmentListResultPage) NotDone() bool {
271 return !page.alr.IsEmpty()
272 }
273
274
275 func (page AssignmentListResultPage) Response() AssignmentListResult {
276 return page.alr
277 }
278
279
280 func (page AssignmentListResultPage) Values() []Assignment {
281 if page.alr.IsEmpty() {
282 return nil
283 }
284 return *page.alr.Value
285 }
286
287
288 func NewAssignmentListResultPage(cur AssignmentListResult, getNextPage func(context.Context, AssignmentListResult) (AssignmentListResult, error)) AssignmentListResultPage {
289 return AssignmentListResultPage{
290 fn: getNextPage,
291 alr: cur,
292 }
293 }
294
295
296 type AssignmentProperties struct {
297
298 DisplayName *string `json:"displayName,omitempty"`
299
300 PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"`
301
302 Scope *string `json:"scope,omitempty"`
303
304 NotScopes *[]string `json:"notScopes,omitempty"`
305
306 Parameters map[string]*ParameterValuesValue `json:"parameters"`
307
308 Description *string `json:"description,omitempty"`
309
310 Metadata interface{} `json:"metadata,omitempty"`
311
312 EnforcementMode EnforcementMode `json:"enforcementMode,omitempty"`
313 }
314
315
316 func (ap AssignmentProperties) MarshalJSON() ([]byte, error) {
317 objectMap := make(map[string]interface{})
318 if ap.DisplayName != nil {
319 objectMap["displayName"] = ap.DisplayName
320 }
321 if ap.PolicyDefinitionID != nil {
322 objectMap["policyDefinitionId"] = ap.PolicyDefinitionID
323 }
324 if ap.Scope != nil {
325 objectMap["scope"] = ap.Scope
326 }
327 if ap.NotScopes != nil {
328 objectMap["notScopes"] = ap.NotScopes
329 }
330 if ap.Parameters != nil {
331 objectMap["parameters"] = ap.Parameters
332 }
333 if ap.Description != nil {
334 objectMap["description"] = ap.Description
335 }
336 if ap.Metadata != nil {
337 objectMap["metadata"] = ap.Metadata
338 }
339 if ap.EnforcementMode != "" {
340 objectMap["enforcementMode"] = ap.EnforcementMode
341 }
342 return json.Marshal(objectMap)
343 }
344
345
346 type CloudError struct {
347 Error *ErrorResponse `json:"error,omitempty"`
348 }
349
350
351 type Definition struct {
352 autorest.Response `json:"-"`
353
354 *DefinitionProperties `json:"properties,omitempty"`
355
356 ID *string `json:"id,omitempty"`
357
358 Name *string `json:"name,omitempty"`
359
360 Type *string `json:"type,omitempty"`
361 }
362
363
364 func (d Definition) MarshalJSON() ([]byte, error) {
365 objectMap := make(map[string]interface{})
366 if d.DefinitionProperties != nil {
367 objectMap["properties"] = d.DefinitionProperties
368 }
369 return json.Marshal(objectMap)
370 }
371
372
373 func (d *Definition) UnmarshalJSON(body []byte) error {
374 var m map[string]*json.RawMessage
375 err := json.Unmarshal(body, &m)
376 if err != nil {
377 return err
378 }
379 for k, v := range m {
380 switch k {
381 case "properties":
382 if v != nil {
383 var definitionProperties DefinitionProperties
384 err = json.Unmarshal(*v, &definitionProperties)
385 if err != nil {
386 return err
387 }
388 d.DefinitionProperties = &definitionProperties
389 }
390 case "id":
391 if v != nil {
392 var ID string
393 err = json.Unmarshal(*v, &ID)
394 if err != nil {
395 return err
396 }
397 d.ID = &ID
398 }
399 case "name":
400 if v != nil {
401 var name string
402 err = json.Unmarshal(*v, &name)
403 if err != nil {
404 return err
405 }
406 d.Name = &name
407 }
408 case "type":
409 if v != nil {
410 var typeVar string
411 err = json.Unmarshal(*v, &typeVar)
412 if err != nil {
413 return err
414 }
415 d.Type = &typeVar
416 }
417 }
418 }
419
420 return nil
421 }
422
423
424 type DefinitionGroup struct {
425
426 Name *string `json:"name,omitempty"`
427
428 DisplayName *string `json:"displayName,omitempty"`
429
430 Category *string `json:"category,omitempty"`
431
432 Description *string `json:"description,omitempty"`
433
434 AdditionalMetadataID *string `json:"additionalMetadataId,omitempty"`
435 }
436
437
438 type DefinitionListResult struct {
439 autorest.Response `json:"-"`
440
441 Value *[]Definition `json:"value,omitempty"`
442
443 NextLink *string `json:"nextLink,omitempty"`
444 }
445
446
447 type DefinitionListResultIterator struct {
448 i int
449 page DefinitionListResultPage
450 }
451
452
453
454 func (iter *DefinitionListResultIterator) NextWithContext(ctx context.Context) (err error) {
455 if tracing.IsEnabled() {
456 ctx = tracing.StartSpan(ctx, fqdn+"/DefinitionListResultIterator.NextWithContext")
457 defer func() {
458 sc := -1
459 if iter.Response().Response.Response != nil {
460 sc = iter.Response().Response.Response.StatusCode
461 }
462 tracing.EndSpan(ctx, sc, err)
463 }()
464 }
465 iter.i++
466 if iter.i < len(iter.page.Values()) {
467 return nil
468 }
469 err = iter.page.NextWithContext(ctx)
470 if err != nil {
471 iter.i--
472 return err
473 }
474 iter.i = 0
475 return nil
476 }
477
478
479
480
481 func (iter *DefinitionListResultIterator) Next() error {
482 return iter.NextWithContext(context.Background())
483 }
484
485
486 func (iter DefinitionListResultIterator) NotDone() bool {
487 return iter.page.NotDone() && iter.i < len(iter.page.Values())
488 }
489
490
491 func (iter DefinitionListResultIterator) Response() DefinitionListResult {
492 return iter.page.Response()
493 }
494
495
496
497 func (iter DefinitionListResultIterator) Value() Definition {
498 if !iter.page.NotDone() {
499 return Definition{}
500 }
501 return iter.page.Values()[iter.i]
502 }
503
504
505 func NewDefinitionListResultIterator(page DefinitionListResultPage) DefinitionListResultIterator {
506 return DefinitionListResultIterator{page: page}
507 }
508
509
510 func (dlr DefinitionListResult) IsEmpty() bool {
511 return dlr.Value == nil || len(*dlr.Value) == 0
512 }
513
514
515 func (dlr DefinitionListResult) hasNextLink() bool {
516 return dlr.NextLink != nil && len(*dlr.NextLink) != 0
517 }
518
519
520
521 func (dlr DefinitionListResult) definitionListResultPreparer(ctx context.Context) (*http.Request, error) {
522 if !dlr.hasNextLink() {
523 return nil, nil
524 }
525 return autorest.Prepare((&http.Request{}).WithContext(ctx),
526 autorest.AsJSON(),
527 autorest.AsGet(),
528 autorest.WithBaseURL(to.String(dlr.NextLink)))
529 }
530
531
532 type DefinitionListResultPage struct {
533 fn func(context.Context, DefinitionListResult) (DefinitionListResult, error)
534 dlr DefinitionListResult
535 }
536
537
538
539 func (page *DefinitionListResultPage) NextWithContext(ctx context.Context) (err error) {
540 if tracing.IsEnabled() {
541 ctx = tracing.StartSpan(ctx, fqdn+"/DefinitionListResultPage.NextWithContext")
542 defer func() {
543 sc := -1
544 if page.Response().Response.Response != nil {
545 sc = page.Response().Response.Response.StatusCode
546 }
547 tracing.EndSpan(ctx, sc, err)
548 }()
549 }
550 for {
551 next, err := page.fn(ctx, page.dlr)
552 if err != nil {
553 return err
554 }
555 page.dlr = next
556 if !next.hasNextLink() || !next.IsEmpty() {
557 break
558 }
559 }
560 return nil
561 }
562
563
564
565
566 func (page *DefinitionListResultPage) Next() error {
567 return page.NextWithContext(context.Background())
568 }
569
570
571 func (page DefinitionListResultPage) NotDone() bool {
572 return !page.dlr.IsEmpty()
573 }
574
575
576 func (page DefinitionListResultPage) Response() DefinitionListResult {
577 return page.dlr
578 }
579
580
581 func (page DefinitionListResultPage) Values() []Definition {
582 if page.dlr.IsEmpty() {
583 return nil
584 }
585 return *page.dlr.Value
586 }
587
588
589 func NewDefinitionListResultPage(cur DefinitionListResult, getNextPage func(context.Context, DefinitionListResult) (DefinitionListResult, error)) DefinitionListResultPage {
590 return DefinitionListResultPage{
591 fn: getNextPage,
592 dlr: cur,
593 }
594 }
595
596
597 type DefinitionProperties struct {
598
599 PolicyType Type `json:"policyType,omitempty"`
600
601 Mode *string `json:"mode,omitempty"`
602
603 DisplayName *string `json:"displayName,omitempty"`
604
605 Description *string `json:"description,omitempty"`
606
607 PolicyRule interface{} `json:"policyRule,omitempty"`
608
609 Metadata interface{} `json:"metadata,omitempty"`
610
611 Parameters map[string]*ParameterDefinitionsValue `json:"parameters"`
612 }
613
614
615 func (dp DefinitionProperties) MarshalJSON() ([]byte, error) {
616 objectMap := make(map[string]interface{})
617 if dp.PolicyType != "" {
618 objectMap["policyType"] = dp.PolicyType
619 }
620 if dp.Mode != nil {
621 objectMap["mode"] = dp.Mode
622 }
623 if dp.DisplayName != nil {
624 objectMap["displayName"] = dp.DisplayName
625 }
626 if dp.Description != nil {
627 objectMap["description"] = dp.Description
628 }
629 if dp.PolicyRule != nil {
630 objectMap["policyRule"] = dp.PolicyRule
631 }
632 if dp.Metadata != nil {
633 objectMap["metadata"] = dp.Metadata
634 }
635 if dp.Parameters != nil {
636 objectMap["parameters"] = dp.Parameters
637 }
638 return json.Marshal(objectMap)
639 }
640
641
642 type DefinitionReference struct {
643
644 PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"`
645
646 Parameters map[string]*ParameterValuesValue `json:"parameters"`
647
648 PolicyDefinitionReferenceID *string `json:"policyDefinitionReferenceId,omitempty"`
649
650 GroupNames *[]string `json:"groupNames,omitempty"`
651 }
652
653
654 func (dr DefinitionReference) MarshalJSON() ([]byte, error) {
655 objectMap := make(map[string]interface{})
656 if dr.PolicyDefinitionID != nil {
657 objectMap["policyDefinitionId"] = dr.PolicyDefinitionID
658 }
659 if dr.Parameters != nil {
660 objectMap["parameters"] = dr.Parameters
661 }
662 if dr.PolicyDefinitionReferenceID != nil {
663 objectMap["policyDefinitionReferenceId"] = dr.PolicyDefinitionReferenceID
664 }
665 if dr.GroupNames != nil {
666 objectMap["groupNames"] = dr.GroupNames
667 }
668 return json.Marshal(objectMap)
669 }
670
671
672 type ErrorAdditionalInfo struct {
673
674 Type *string `json:"type,omitempty"`
675
676 Info interface{} `json:"info,omitempty"`
677 }
678
679
680 func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) {
681 objectMap := make(map[string]interface{})
682 return json.Marshal(objectMap)
683 }
684
685
686
687 type ErrorResponse struct {
688
689 Code *string `json:"code,omitempty"`
690
691 Message *string `json:"message,omitempty"`
692
693 Target *string `json:"target,omitempty"`
694
695 Details *[]ErrorResponse `json:"details,omitempty"`
696
697 AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"`
698 }
699
700
701 func (er ErrorResponse) MarshalJSON() ([]byte, error) {
702 objectMap := make(map[string]interface{})
703 return json.Marshal(objectMap)
704 }
705
706
707 type Identity struct {
708
709 PrincipalID *string `json:"principalId,omitempty"`
710
711 TenantID *string `json:"tenantId,omitempty"`
712
713 Type ResourceIdentityType `json:"type,omitempty"`
714 }
715
716
717 func (i Identity) MarshalJSON() ([]byte, error) {
718 objectMap := make(map[string]interface{})
719 if i.Type != "" {
720 objectMap["type"] = i.Type
721 }
722 return json.Marshal(objectMap)
723 }
724
725
726 type ParameterDefinitionsValue struct {
727
728 Type ParameterType `json:"type,omitempty"`
729
730 AllowedValues *[]interface{} `json:"allowedValues,omitempty"`
731
732 DefaultValue interface{} `json:"defaultValue,omitempty"`
733
734 Metadata *ParameterDefinitionsValueMetadata `json:"metadata,omitempty"`
735 }
736
737
738 type ParameterDefinitionsValueMetadata struct {
739
740 AdditionalProperties map[string]interface{} `json:""`
741
742 DisplayName *string `json:"displayName,omitempty"`
743
744 Description *string `json:"description,omitempty"`
745 }
746
747
748 func (pdv ParameterDefinitionsValueMetadata) MarshalJSON() ([]byte, error) {
749 objectMap := make(map[string]interface{})
750 if pdv.DisplayName != nil {
751 objectMap["displayName"] = pdv.DisplayName
752 }
753 if pdv.Description != nil {
754 objectMap["description"] = pdv.Description
755 }
756 for k, v := range pdv.AdditionalProperties {
757 objectMap[k] = v
758 }
759 return json.Marshal(objectMap)
760 }
761
762
763 func (pdv *ParameterDefinitionsValueMetadata) UnmarshalJSON(body []byte) error {
764 var m map[string]*json.RawMessage
765 err := json.Unmarshal(body, &m)
766 if err != nil {
767 return err
768 }
769 for k, v := range m {
770 switch k {
771 default:
772 if v != nil {
773 var additionalProperties interface{}
774 err = json.Unmarshal(*v, &additionalProperties)
775 if err != nil {
776 return err
777 }
778 if pdv.AdditionalProperties == nil {
779 pdv.AdditionalProperties = make(map[string]interface{})
780 }
781 pdv.AdditionalProperties[k] = additionalProperties
782 }
783 case "displayName":
784 if v != nil {
785 var displayName string
786 err = json.Unmarshal(*v, &displayName)
787 if err != nil {
788 return err
789 }
790 pdv.DisplayName = &displayName
791 }
792 case "description":
793 if v != nil {
794 var description string
795 err = json.Unmarshal(*v, &description)
796 if err != nil {
797 return err
798 }
799 pdv.Description = &description
800 }
801 }
802 }
803
804 return nil
805 }
806
807
808 type ParameterValuesValue struct {
809
810 Value interface{} `json:"value,omitempty"`
811 }
812
813
814 type SetDefinition struct {
815 autorest.Response `json:"-"`
816
817 *SetDefinitionProperties `json:"properties,omitempty"`
818
819 ID *string `json:"id,omitempty"`
820
821 Name *string `json:"name,omitempty"`
822
823 Type *string `json:"type,omitempty"`
824 }
825
826
827 func (sd SetDefinition) MarshalJSON() ([]byte, error) {
828 objectMap := make(map[string]interface{})
829 if sd.SetDefinitionProperties != nil {
830 objectMap["properties"] = sd.SetDefinitionProperties
831 }
832 return json.Marshal(objectMap)
833 }
834
835
836 func (sd *SetDefinition) UnmarshalJSON(body []byte) error {
837 var m map[string]*json.RawMessage
838 err := json.Unmarshal(body, &m)
839 if err != nil {
840 return err
841 }
842 for k, v := range m {
843 switch k {
844 case "properties":
845 if v != nil {
846 var setDefinitionProperties SetDefinitionProperties
847 err = json.Unmarshal(*v, &setDefinitionProperties)
848 if err != nil {
849 return err
850 }
851 sd.SetDefinitionProperties = &setDefinitionProperties
852 }
853 case "id":
854 if v != nil {
855 var ID string
856 err = json.Unmarshal(*v, &ID)
857 if err != nil {
858 return err
859 }
860 sd.ID = &ID
861 }
862 case "name":
863 if v != nil {
864 var name string
865 err = json.Unmarshal(*v, &name)
866 if err != nil {
867 return err
868 }
869 sd.Name = &name
870 }
871 case "type":
872 if v != nil {
873 var typeVar string
874 err = json.Unmarshal(*v, &typeVar)
875 if err != nil {
876 return err
877 }
878 sd.Type = &typeVar
879 }
880 }
881 }
882
883 return nil
884 }
885
886
887 type SetDefinitionListResult struct {
888 autorest.Response `json:"-"`
889
890 Value *[]SetDefinition `json:"value,omitempty"`
891
892 NextLink *string `json:"nextLink,omitempty"`
893 }
894
895
896 type SetDefinitionListResultIterator struct {
897 i int
898 page SetDefinitionListResultPage
899 }
900
901
902
903 func (iter *SetDefinitionListResultIterator) NextWithContext(ctx context.Context) (err error) {
904 if tracing.IsEnabled() {
905 ctx = tracing.StartSpan(ctx, fqdn+"/SetDefinitionListResultIterator.NextWithContext")
906 defer func() {
907 sc := -1
908 if iter.Response().Response.Response != nil {
909 sc = iter.Response().Response.Response.StatusCode
910 }
911 tracing.EndSpan(ctx, sc, err)
912 }()
913 }
914 iter.i++
915 if iter.i < len(iter.page.Values()) {
916 return nil
917 }
918 err = iter.page.NextWithContext(ctx)
919 if err != nil {
920 iter.i--
921 return err
922 }
923 iter.i = 0
924 return nil
925 }
926
927
928
929
930 func (iter *SetDefinitionListResultIterator) Next() error {
931 return iter.NextWithContext(context.Background())
932 }
933
934
935 func (iter SetDefinitionListResultIterator) NotDone() bool {
936 return iter.page.NotDone() && iter.i < len(iter.page.Values())
937 }
938
939
940 func (iter SetDefinitionListResultIterator) Response() SetDefinitionListResult {
941 return iter.page.Response()
942 }
943
944
945
946 func (iter SetDefinitionListResultIterator) Value() SetDefinition {
947 if !iter.page.NotDone() {
948 return SetDefinition{}
949 }
950 return iter.page.Values()[iter.i]
951 }
952
953
954 func NewSetDefinitionListResultIterator(page SetDefinitionListResultPage) SetDefinitionListResultIterator {
955 return SetDefinitionListResultIterator{page: page}
956 }
957
958
959 func (sdlr SetDefinitionListResult) IsEmpty() bool {
960 return sdlr.Value == nil || len(*sdlr.Value) == 0
961 }
962
963
964 func (sdlr SetDefinitionListResult) hasNextLink() bool {
965 return sdlr.NextLink != nil && len(*sdlr.NextLink) != 0
966 }
967
968
969
970 func (sdlr SetDefinitionListResult) setDefinitionListResultPreparer(ctx context.Context) (*http.Request, error) {
971 if !sdlr.hasNextLink() {
972 return nil, nil
973 }
974 return autorest.Prepare((&http.Request{}).WithContext(ctx),
975 autorest.AsJSON(),
976 autorest.AsGet(),
977 autorest.WithBaseURL(to.String(sdlr.NextLink)))
978 }
979
980
981 type SetDefinitionListResultPage struct {
982 fn func(context.Context, SetDefinitionListResult) (SetDefinitionListResult, error)
983 sdlr SetDefinitionListResult
984 }
985
986
987
988 func (page *SetDefinitionListResultPage) NextWithContext(ctx context.Context) (err error) {
989 if tracing.IsEnabled() {
990 ctx = tracing.StartSpan(ctx, fqdn+"/SetDefinitionListResultPage.NextWithContext")
991 defer func() {
992 sc := -1
993 if page.Response().Response.Response != nil {
994 sc = page.Response().Response.Response.StatusCode
995 }
996 tracing.EndSpan(ctx, sc, err)
997 }()
998 }
999 for {
1000 next, err := page.fn(ctx, page.sdlr)
1001 if err != nil {
1002 return err
1003 }
1004 page.sdlr = next
1005 if !next.hasNextLink() || !next.IsEmpty() {
1006 break
1007 }
1008 }
1009 return nil
1010 }
1011
1012
1013
1014
1015 func (page *SetDefinitionListResultPage) Next() error {
1016 return page.NextWithContext(context.Background())
1017 }
1018
1019
1020 func (page SetDefinitionListResultPage) NotDone() bool {
1021 return !page.sdlr.IsEmpty()
1022 }
1023
1024
1025 func (page SetDefinitionListResultPage) Response() SetDefinitionListResult {
1026 return page.sdlr
1027 }
1028
1029
1030 func (page SetDefinitionListResultPage) Values() []SetDefinition {
1031 if page.sdlr.IsEmpty() {
1032 return nil
1033 }
1034 return *page.sdlr.Value
1035 }
1036
1037
1038 func NewSetDefinitionListResultPage(cur SetDefinitionListResult, getNextPage func(context.Context, SetDefinitionListResult) (SetDefinitionListResult, error)) SetDefinitionListResultPage {
1039 return SetDefinitionListResultPage{
1040 fn: getNextPage,
1041 sdlr: cur,
1042 }
1043 }
1044
1045
1046 type SetDefinitionProperties struct {
1047
1048 PolicyType Type `json:"policyType,omitempty"`
1049
1050 DisplayName *string `json:"displayName,omitempty"`
1051
1052 Description *string `json:"description,omitempty"`
1053
1054 Metadata interface{} `json:"metadata,omitempty"`
1055
1056 Parameters map[string]*ParameterDefinitionsValue `json:"parameters"`
1057
1058 PolicyDefinitions *[]DefinitionReference `json:"policyDefinitions,omitempty"`
1059
1060 PolicyDefinitionGroups *[]DefinitionGroup `json:"policyDefinitionGroups,omitempty"`
1061 }
1062
1063
1064 func (sdp SetDefinitionProperties) MarshalJSON() ([]byte, error) {
1065 objectMap := make(map[string]interface{})
1066 if sdp.PolicyType != "" {
1067 objectMap["policyType"] = sdp.PolicyType
1068 }
1069 if sdp.DisplayName != nil {
1070 objectMap["displayName"] = sdp.DisplayName
1071 }
1072 if sdp.Description != nil {
1073 objectMap["description"] = sdp.Description
1074 }
1075 if sdp.Metadata != nil {
1076 objectMap["metadata"] = sdp.Metadata
1077 }
1078 if sdp.Parameters != nil {
1079 objectMap["parameters"] = sdp.Parameters
1080 }
1081 if sdp.PolicyDefinitions != nil {
1082 objectMap["policyDefinitions"] = sdp.PolicyDefinitions
1083 }
1084 if sdp.PolicyDefinitionGroups != nil {
1085 objectMap["policyDefinitionGroups"] = sdp.PolicyDefinitionGroups
1086 }
1087 return json.Marshal(objectMap)
1088 }
1089
1090
1091 type Sku struct {
1092
1093 Name *string `json:"name,omitempty"`
1094
1095 Tier *string `json:"tier,omitempty"`
1096 }
1097
View as plain text