forked from Azure/azure-sdk-for-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.go
1846 lines (1654 loc) · 67.4 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
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package virtualmachineimagebuilder
// 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/date"
"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/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder"
// APIError api error.
type APIError struct {
// Details - The Api error details
Details *[]APIErrorBase `json:"details,omitempty"`
// InnerError - The Api inner error
InnerError *InnerError `json:"innerError,omitempty"`
// Code - The error code.
Code *string `json:"code,omitempty"`
// Target - The target of the particular error.
Target *string `json:"target,omitempty"`
// Message - The error message.
Message *string `json:"message,omitempty"`
}
// APIErrorBase api error base.
type APIErrorBase struct {
// Code - The error code.
Code *string `json:"code,omitempty"`
// Target - The target of the particular error.
Target *string `json:"target,omitempty"`
// Message - The error message.
Message *string `json:"message,omitempty"`
}
// ImageTemplate ...
type ImageTemplate struct {
autorest.Response `json:"-"`
*ImageTemplateProperties `json:"properties,omitempty"`
// ID - READ-ONLY; Resource Id
ID *string `json:"id,omitempty"`
// Name - READ-ONLY; Resource name
Name *string `json:"name,omitempty"`
// Type - READ-ONLY; Resource type
Type *string `json:"type,omitempty"`
// Location - Resource location
Location *string `json:"location,omitempty"`
// Tags - Resource tags
Tags map[string]*string `json:"tags"`
}
// MarshalJSON is the custom marshaler for ImageTemplate.
func (it ImageTemplate) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if it.ImageTemplateProperties != nil {
objectMap["properties"] = it.ImageTemplateProperties
}
if it.Location != nil {
objectMap["location"] = it.Location
}
if it.Tags != nil {
objectMap["tags"] = it.Tags
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for ImageTemplate struct.
func (it *ImageTemplate) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "properties":
if v != nil {
var imageTemplateProperties ImageTemplateProperties
err = json.Unmarshal(*v, &imageTemplateProperties)
if err != nil {
return err
}
it.ImageTemplateProperties = &imageTemplateProperties
}
case "id":
if v != nil {
var ID string
err = json.Unmarshal(*v, &ID)
if err != nil {
return err
}
it.ID = &ID
}
case "name":
if v != nil {
var name string
err = json.Unmarshal(*v, &name)
if err != nil {
return err
}
it.Name = &name
}
case "type":
if v != nil {
var typeVar string
err = json.Unmarshal(*v, &typeVar)
if err != nil {
return err
}
it.Type = &typeVar
}
case "location":
if v != nil {
var location string
err = json.Unmarshal(*v, &location)
if err != nil {
return err
}
it.Location = &location
}
case "tags":
if v != nil {
var tags map[string]*string
err = json.Unmarshal(*v, &tags)
if err != nil {
return err
}
it.Tags = tags
}
}
}
return nil
}
// BasicImageTemplateCustomizer ...
type BasicImageTemplateCustomizer interface {
AsImageTemplateShellCustomizer() (*ImageTemplateShellCustomizer, bool)
AsImageTemplateRestartCustomizer() (*ImageTemplateRestartCustomizer, bool)
AsImageTemplatePowerShellCustomizer() (*ImageTemplatePowerShellCustomizer, bool)
AsImageTemplateCustomizer() (*ImageTemplateCustomizer, bool)
}
// ImageTemplateCustomizer ...
type ImageTemplateCustomizer struct {
// Name - Friendly Name to provide context on what this customization step does
Name *string `json:"name,omitempty"`
// Type - Possible values include: 'TypeImageTemplateCustomizer', 'TypeShell', 'TypeWindowsRestart', 'TypePowerShell'
Type TypeBasicImageTemplateCustomizer `json:"type,omitempty"`
}
func unmarshalBasicImageTemplateCustomizer(body []byte) (BasicImageTemplateCustomizer, error) {
var m map[string]interface{}
err := json.Unmarshal(body, &m)
if err != nil {
return nil, err
}
switch m["type"] {
case string(TypeShell):
var itsc ImageTemplateShellCustomizer
err := json.Unmarshal(body, &itsc)
return itsc, err
case string(TypeWindowsRestart):
var itrc ImageTemplateRestartCustomizer
err := json.Unmarshal(body, &itrc)
return itrc, err
case string(TypePowerShell):
var itpsc ImageTemplatePowerShellCustomizer
err := json.Unmarshal(body, &itpsc)
return itpsc, err
default:
var itc ImageTemplateCustomizer
err := json.Unmarshal(body, &itc)
return itc, err
}
}
func unmarshalBasicImageTemplateCustomizerArray(body []byte) ([]BasicImageTemplateCustomizer, error) {
var rawMessages []*json.RawMessage
err := json.Unmarshal(body, &rawMessages)
if err != nil {
return nil, err
}
itcArray := make([]BasicImageTemplateCustomizer, len(rawMessages))
for index, rawMessage := range rawMessages {
itc, err := unmarshalBasicImageTemplateCustomizer(*rawMessage)
if err != nil {
return nil, err
}
itcArray[index] = itc
}
return itcArray, nil
}
// MarshalJSON is the custom marshaler for ImageTemplateCustomizer.
func (itc ImageTemplateCustomizer) MarshalJSON() ([]byte, error) {
itc.Type = TypeImageTemplateCustomizer
objectMap := make(map[string]interface{})
if itc.Name != nil {
objectMap["name"] = itc.Name
}
if itc.Type != "" {
objectMap["type"] = itc.Type
}
return json.Marshal(objectMap)
}
// AsImageTemplateShellCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateCustomizer.
func (itc ImageTemplateCustomizer) AsImageTemplateShellCustomizer() (*ImageTemplateShellCustomizer, bool) {
return nil, false
}
// AsImageTemplateRestartCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateCustomizer.
func (itc ImageTemplateCustomizer) AsImageTemplateRestartCustomizer() (*ImageTemplateRestartCustomizer, bool) {
return nil, false
}
// AsImageTemplatePowerShellCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateCustomizer.
func (itc ImageTemplateCustomizer) AsImageTemplatePowerShellCustomizer() (*ImageTemplatePowerShellCustomizer, bool) {
return nil, false
}
// AsImageTemplateCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateCustomizer.
func (itc ImageTemplateCustomizer) AsImageTemplateCustomizer() (*ImageTemplateCustomizer, bool) {
return &itc, true
}
// AsBasicImageTemplateCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateCustomizer.
func (itc ImageTemplateCustomizer) AsBasicImageTemplateCustomizer() (BasicImageTemplateCustomizer, bool) {
return &itc, true
}
// BasicImageTemplateDistributor generic distribution object
type BasicImageTemplateDistributor interface {
AsImageTemplateManagedImageDistributor() (*ImageTemplateManagedImageDistributor, bool)
AsImageTemplateSharedImageDistributor() (*ImageTemplateSharedImageDistributor, bool)
AsImageTemplateVhdDistributor() (*ImageTemplateVhdDistributor, bool)
AsImageTemplateDistributor() (*ImageTemplateDistributor, bool)
}
// ImageTemplateDistributor generic distribution object
type ImageTemplateDistributor struct {
// RunOutputName - The name to be used for the associated RunOutput.
RunOutputName *string `json:"runOutputName,omitempty"`
// ArtifactTags - Tags that will be applied to the artifact once it has been created/updated by the distributor.
ArtifactTags map[string]*string `json:"artifactTags"`
// Type - Possible values include: 'TypeBasicImageTemplateDistributorTypeImageTemplateDistributor', 'TypeBasicImageTemplateDistributorTypeManagedImage', 'TypeBasicImageTemplateDistributorTypeSharedImage', 'TypeBasicImageTemplateDistributorTypeVHD'
Type TypeBasicImageTemplateDistributor `json:"type,omitempty"`
}
func unmarshalBasicImageTemplateDistributor(body []byte) (BasicImageTemplateDistributor, error) {
var m map[string]interface{}
err := json.Unmarshal(body, &m)
if err != nil {
return nil, err
}
switch m["type"] {
case string(TypeBasicImageTemplateDistributorTypeManagedImage):
var itmid ImageTemplateManagedImageDistributor
err := json.Unmarshal(body, &itmid)
return itmid, err
case string(TypeBasicImageTemplateDistributorTypeSharedImage):
var itsid ImageTemplateSharedImageDistributor
err := json.Unmarshal(body, &itsid)
return itsid, err
case string(TypeBasicImageTemplateDistributorTypeVHD):
var itvd ImageTemplateVhdDistributor
err := json.Unmarshal(body, &itvd)
return itvd, err
default:
var itd ImageTemplateDistributor
err := json.Unmarshal(body, &itd)
return itd, err
}
}
func unmarshalBasicImageTemplateDistributorArray(body []byte) ([]BasicImageTemplateDistributor, error) {
var rawMessages []*json.RawMessage
err := json.Unmarshal(body, &rawMessages)
if err != nil {
return nil, err
}
itdArray := make([]BasicImageTemplateDistributor, len(rawMessages))
for index, rawMessage := range rawMessages {
itd, err := unmarshalBasicImageTemplateDistributor(*rawMessage)
if err != nil {
return nil, err
}
itdArray[index] = itd
}
return itdArray, nil
}
// MarshalJSON is the custom marshaler for ImageTemplateDistributor.
func (itd ImageTemplateDistributor) MarshalJSON() ([]byte, error) {
itd.Type = TypeBasicImageTemplateDistributorTypeImageTemplateDistributor
objectMap := make(map[string]interface{})
if itd.RunOutputName != nil {
objectMap["runOutputName"] = itd.RunOutputName
}
if itd.ArtifactTags != nil {
objectMap["artifactTags"] = itd.ArtifactTags
}
if itd.Type != "" {
objectMap["type"] = itd.Type
}
return json.Marshal(objectMap)
}
// AsImageTemplateManagedImageDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateDistributor.
func (itd ImageTemplateDistributor) AsImageTemplateManagedImageDistributor() (*ImageTemplateManagedImageDistributor, bool) {
return nil, false
}
// AsImageTemplateSharedImageDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateDistributor.
func (itd ImageTemplateDistributor) AsImageTemplateSharedImageDistributor() (*ImageTemplateSharedImageDistributor, bool) {
return nil, false
}
// AsImageTemplateVhdDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateDistributor.
func (itd ImageTemplateDistributor) AsImageTemplateVhdDistributor() (*ImageTemplateVhdDistributor, bool) {
return nil, false
}
// AsImageTemplateDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateDistributor.
func (itd ImageTemplateDistributor) AsImageTemplateDistributor() (*ImageTemplateDistributor, bool) {
return &itd, true
}
// AsBasicImageTemplateDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateDistributor.
func (itd ImageTemplateDistributor) AsBasicImageTemplateDistributor() (BasicImageTemplateDistributor, bool) {
return &itd, true
}
// ImageTemplateIsoSource describes an image source that is an installation ISO. Currently only supports
// Red Hat Enterprise Linux 7.2-7.5 ISO's.
type ImageTemplateIsoSource struct {
// SourceURI - URI to get the ISO image. This URI has to be accessible to the resource provider at the time of the image template creation.
SourceURI *string `json:"sourceURI,omitempty"`
// Sha256Checksum - SHA256 Checksum of the ISO image.
Sha256Checksum *string `json:"sha256Checksum,omitempty"`
// Type - Possible values include: 'TypeImageTemplateSource', 'TypeISO', 'TypePlatformImage', 'TypeManagedImage'
Type Type `json:"type,omitempty"`
}
// MarshalJSON is the custom marshaler for ImageTemplateIsoSource.
func (itis ImageTemplateIsoSource) MarshalJSON() ([]byte, error) {
itis.Type = TypeISO
objectMap := make(map[string]interface{})
if itis.SourceURI != nil {
objectMap["sourceURI"] = itis.SourceURI
}
if itis.Sha256Checksum != nil {
objectMap["sha256Checksum"] = itis.Sha256Checksum
}
if itis.Type != "" {
objectMap["type"] = itis.Type
}
return json.Marshal(objectMap)
}
// AsImageTemplateIsoSource is the BasicImageTemplateSource implementation for ImageTemplateIsoSource.
func (itis ImageTemplateIsoSource) AsImageTemplateIsoSource() (*ImageTemplateIsoSource, bool) {
return &itis, true
}
// AsImageTemplatePlatformImageSource is the BasicImageTemplateSource implementation for ImageTemplateIsoSource.
func (itis ImageTemplateIsoSource) AsImageTemplatePlatformImageSource() (*ImageTemplatePlatformImageSource, bool) {
return nil, false
}
// AsImageTemplateManagedImageSource is the BasicImageTemplateSource implementation for ImageTemplateIsoSource.
func (itis ImageTemplateIsoSource) AsImageTemplateManagedImageSource() (*ImageTemplateManagedImageSource, bool) {
return nil, false
}
// AsImageTemplateSource is the BasicImageTemplateSource implementation for ImageTemplateIsoSource.
func (itis ImageTemplateIsoSource) AsImageTemplateSource() (*ImageTemplateSource, bool) {
return nil, false
}
// AsBasicImageTemplateSource is the BasicImageTemplateSource implementation for ImageTemplateIsoSource.
func (itis ImageTemplateIsoSource) AsBasicImageTemplateSource() (BasicImageTemplateSource, bool) {
return &itis, true
}
// ImageTemplateLastRunStatus ...
type ImageTemplateLastRunStatus struct {
// StartTime - Start time of the last run (UTC)
StartTime *date.Time `json:"startTime,omitempty"`
// EndTime - End time of the last run (UTC)
EndTime *date.Time `json:"endTime,omitempty"`
// RunState - State of the last run. Possible values include: 'RunStateRunning', 'RunStateSucceeded', 'RunStatePartiallySucceeded', 'RunStateFailed'
RunState RunState `json:"runState,omitempty"`
// RunSubState - Sub-state of the last run. Possible values include: 'Queued', 'Building', 'Customizing', 'Distributing'
RunSubState RunSubState `json:"runSubState,omitempty"`
// Message - Verbose information about the last run state
Message *string `json:"message,omitempty"`
}
// ImageTemplateListResult ...
type ImageTemplateListResult struct {
autorest.Response `json:"-"`
Value *[]ImageTemplate `json:"value,omitempty"`
// NextLink - The continuation token.
NextLink *string `json:"nextLink,omitempty"`
}
// ImageTemplateListResultIterator provides access to a complete listing of ImageTemplate values.
type ImageTemplateListResultIterator struct {
i int
page ImageTemplateListResultPage
}
// 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 *ImageTemplateListResultIterator) NextWithContext(ctx context.Context) (err error) {
if tracing.IsEnabled() {
ctx = tracing.StartSpan(ctx, fqdn+"/ImageTemplateListResultIterator.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 *ImageTemplateListResultIterator) Next() error {
return iter.NextWithContext(context.Background())
}
// NotDone returns true if the enumeration should be started or is not yet complete.
func (iter ImageTemplateListResultIterator) 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 ImageTemplateListResultIterator) Response() ImageTemplateListResult {
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 ImageTemplateListResultIterator) Value() ImageTemplate {
if !iter.page.NotDone() {
return ImageTemplate{}
}
return iter.page.Values()[iter.i]
}
// Creates a new instance of the ImageTemplateListResultIterator type.
func NewImageTemplateListResultIterator(page ImageTemplateListResultPage) ImageTemplateListResultIterator {
return ImageTemplateListResultIterator{page: page}
}
// IsEmpty returns true if the ListResult contains no values.
func (itlr ImageTemplateListResult) IsEmpty() bool {
return itlr.Value == nil || len(*itlr.Value) == 0
}
// hasNextLink returns true if the NextLink is not empty.
func (itlr ImageTemplateListResult) hasNextLink() bool {
return itlr.NextLink != nil && len(*itlr.NextLink) != 0
}
// imageTemplateListResultPreparer prepares a request to retrieve the next set of results.
// It returns nil if no more results exist.
func (itlr ImageTemplateListResult) imageTemplateListResultPreparer(ctx context.Context) (*http.Request, error) {
if !itlr.hasNextLink() {
return nil, nil
}
return autorest.Prepare((&http.Request{}).WithContext(ctx),
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(itlr.NextLink)))
}
// ImageTemplateListResultPage contains a page of ImageTemplate values.
type ImageTemplateListResultPage struct {
fn func(context.Context, ImageTemplateListResult) (ImageTemplateListResult, error)
itlr ImageTemplateListResult
}
// 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 *ImageTemplateListResultPage) NextWithContext(ctx context.Context) (err error) {
if tracing.IsEnabled() {
ctx = tracing.StartSpan(ctx, fqdn+"/ImageTemplateListResultPage.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.itlr)
if err != nil {
return err
}
page.itlr = 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 *ImageTemplateListResultPage) Next() error {
return page.NextWithContext(context.Background())
}
// NotDone returns true if the page enumeration should be started or is not yet complete.
func (page ImageTemplateListResultPage) NotDone() bool {
return !page.itlr.IsEmpty()
}
// Response returns the raw server response from the last page request.
func (page ImageTemplateListResultPage) Response() ImageTemplateListResult {
return page.itlr
}
// Values returns the slice of values for the current page or nil if there are no values.
func (page ImageTemplateListResultPage) Values() []ImageTemplate {
if page.itlr.IsEmpty() {
return nil
}
return *page.itlr.Value
}
// Creates a new instance of the ImageTemplateListResultPage type.
func NewImageTemplateListResultPage(cur ImageTemplateListResult, getNextPage func(context.Context, ImageTemplateListResult) (ImageTemplateListResult, error)) ImageTemplateListResultPage {
return ImageTemplateListResultPage{
fn: getNextPage,
itlr: cur,
}
}
// ImageTemplateManagedImageDistributor distribute as a Managed Disk Image.
type ImageTemplateManagedImageDistributor struct {
// ImageID - Resource Id of the Managed Disk Image
ImageID *string `json:"imageId,omitempty"`
// Location - Azure location for the image, should match if image already exists
Location *string `json:"location,omitempty"`
// RunOutputName - The name to be used for the associated RunOutput.
RunOutputName *string `json:"runOutputName,omitempty"`
// ArtifactTags - Tags that will be applied to the artifact once it has been created/updated by the distributor.
ArtifactTags map[string]*string `json:"artifactTags"`
// Type - Possible values include: 'TypeBasicImageTemplateDistributorTypeImageTemplateDistributor', 'TypeBasicImageTemplateDistributorTypeManagedImage', 'TypeBasicImageTemplateDistributorTypeSharedImage', 'TypeBasicImageTemplateDistributorTypeVHD'
Type TypeBasicImageTemplateDistributor `json:"type,omitempty"`
}
// MarshalJSON is the custom marshaler for ImageTemplateManagedImageDistributor.
func (itmid ImageTemplateManagedImageDistributor) MarshalJSON() ([]byte, error) {
itmid.Type = TypeBasicImageTemplateDistributorTypeManagedImage
objectMap := make(map[string]interface{})
if itmid.ImageID != nil {
objectMap["imageId"] = itmid.ImageID
}
if itmid.Location != nil {
objectMap["location"] = itmid.Location
}
if itmid.RunOutputName != nil {
objectMap["runOutputName"] = itmid.RunOutputName
}
if itmid.ArtifactTags != nil {
objectMap["artifactTags"] = itmid.ArtifactTags
}
if itmid.Type != "" {
objectMap["type"] = itmid.Type
}
return json.Marshal(objectMap)
}
// AsImageTemplateManagedImageDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateManagedImageDistributor.
func (itmid ImageTemplateManagedImageDistributor) AsImageTemplateManagedImageDistributor() (*ImageTemplateManagedImageDistributor, bool) {
return &itmid, true
}
// AsImageTemplateSharedImageDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateManagedImageDistributor.
func (itmid ImageTemplateManagedImageDistributor) AsImageTemplateSharedImageDistributor() (*ImageTemplateSharedImageDistributor, bool) {
return nil, false
}
// AsImageTemplateVhdDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateManagedImageDistributor.
func (itmid ImageTemplateManagedImageDistributor) AsImageTemplateVhdDistributor() (*ImageTemplateVhdDistributor, bool) {
return nil, false
}
// AsImageTemplateDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateManagedImageDistributor.
func (itmid ImageTemplateManagedImageDistributor) AsImageTemplateDistributor() (*ImageTemplateDistributor, bool) {
return nil, false
}
// AsBasicImageTemplateDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateManagedImageDistributor.
func (itmid ImageTemplateManagedImageDistributor) AsBasicImageTemplateDistributor() (BasicImageTemplateDistributor, bool) {
return &itmid, true
}
// ImageTemplateManagedImageSource describes an image source that is a managed image in customer
// subscription.
type ImageTemplateManagedImageSource struct {
// ImageID - ARM resource id of the managed image in customer subscription
ImageID *string `json:"imageId,omitempty"`
// Type - Possible values include: 'TypeImageTemplateSource', 'TypeISO', 'TypePlatformImage', 'TypeManagedImage'
Type Type `json:"type,omitempty"`
}
// MarshalJSON is the custom marshaler for ImageTemplateManagedImageSource.
func (itmis ImageTemplateManagedImageSource) MarshalJSON() ([]byte, error) {
itmis.Type = TypeManagedImage
objectMap := make(map[string]interface{})
if itmis.ImageID != nil {
objectMap["imageId"] = itmis.ImageID
}
if itmis.Type != "" {
objectMap["type"] = itmis.Type
}
return json.Marshal(objectMap)
}
// AsImageTemplateIsoSource is the BasicImageTemplateSource implementation for ImageTemplateManagedImageSource.
func (itmis ImageTemplateManagedImageSource) AsImageTemplateIsoSource() (*ImageTemplateIsoSource, bool) {
return nil, false
}
// AsImageTemplatePlatformImageSource is the BasicImageTemplateSource implementation for ImageTemplateManagedImageSource.
func (itmis ImageTemplateManagedImageSource) AsImageTemplatePlatformImageSource() (*ImageTemplatePlatformImageSource, bool) {
return nil, false
}
// AsImageTemplateManagedImageSource is the BasicImageTemplateSource implementation for ImageTemplateManagedImageSource.
func (itmis ImageTemplateManagedImageSource) AsImageTemplateManagedImageSource() (*ImageTemplateManagedImageSource, bool) {
return &itmis, true
}
// AsImageTemplateSource is the BasicImageTemplateSource implementation for ImageTemplateManagedImageSource.
func (itmis ImageTemplateManagedImageSource) AsImageTemplateSource() (*ImageTemplateSource, bool) {
return nil, false
}
// AsBasicImageTemplateSource is the BasicImageTemplateSource implementation for ImageTemplateManagedImageSource.
func (itmis ImageTemplateManagedImageSource) AsBasicImageTemplateSource() (BasicImageTemplateSource, bool) {
return &itmis, true
}
// ImageTemplatePlatformImageSource describes an image source from [Azure Gallery
// Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages).
type ImageTemplatePlatformImageSource struct {
// Publisher - Image Publisher in [Azure Gallery Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages).
Publisher *string `json:"publisher,omitempty"`
// Offer - Image offer from the [Azure Gallery Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages).
Offer *string `json:"offer,omitempty"`
// Sku - Image sku from the [Azure Gallery Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages).
Sku *string `json:"sku,omitempty"`
// Version - Image version from the [Azure Gallery Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages).
Version *string `json:"version,omitempty"`
// Type - Possible values include: 'TypeImageTemplateSource', 'TypeISO', 'TypePlatformImage', 'TypeManagedImage'
Type Type `json:"type,omitempty"`
}
// MarshalJSON is the custom marshaler for ImageTemplatePlatformImageSource.
func (itpis ImageTemplatePlatformImageSource) MarshalJSON() ([]byte, error) {
itpis.Type = TypePlatformImage
objectMap := make(map[string]interface{})
if itpis.Publisher != nil {
objectMap["publisher"] = itpis.Publisher
}
if itpis.Offer != nil {
objectMap["offer"] = itpis.Offer
}
if itpis.Sku != nil {
objectMap["sku"] = itpis.Sku
}
if itpis.Version != nil {
objectMap["version"] = itpis.Version
}
if itpis.Type != "" {
objectMap["type"] = itpis.Type
}
return json.Marshal(objectMap)
}
// AsImageTemplateIsoSource is the BasicImageTemplateSource implementation for ImageTemplatePlatformImageSource.
func (itpis ImageTemplatePlatformImageSource) AsImageTemplateIsoSource() (*ImageTemplateIsoSource, bool) {
return nil, false
}
// AsImageTemplatePlatformImageSource is the BasicImageTemplateSource implementation for ImageTemplatePlatformImageSource.
func (itpis ImageTemplatePlatformImageSource) AsImageTemplatePlatformImageSource() (*ImageTemplatePlatformImageSource, bool) {
return &itpis, true
}
// AsImageTemplateManagedImageSource is the BasicImageTemplateSource implementation for ImageTemplatePlatformImageSource.
func (itpis ImageTemplatePlatformImageSource) AsImageTemplateManagedImageSource() (*ImageTemplateManagedImageSource, bool) {
return nil, false
}
// AsImageTemplateSource is the BasicImageTemplateSource implementation for ImageTemplatePlatformImageSource.
func (itpis ImageTemplatePlatformImageSource) AsImageTemplateSource() (*ImageTemplateSource, bool) {
return nil, false
}
// AsBasicImageTemplateSource is the BasicImageTemplateSource implementation for ImageTemplatePlatformImageSource.
func (itpis ImageTemplatePlatformImageSource) AsBasicImageTemplateSource() (BasicImageTemplateSource, bool) {
return &itpis, true
}
// ImageTemplatePowerShellCustomizer runs the specified PowerShell on the VM (Windows). Corresponds to
// Packer powershell provisioner. Exactly one of 'script' or 'inline' can be specified.
type ImageTemplatePowerShellCustomizer struct {
// Script - The PowerShell script to be run for customizing. It can be a github link, SAS URI for Azure Storage, etc
Script *string `json:"script,omitempty"`
// Inline - Array of PowerShell commands to execute
Inline *[]string `json:"inline,omitempty"`
// ValidExitCodes - Valid exit codes for the PowerShell script. [Default: 0]
ValidExitCodes *[]int32 `json:"validExitCodes,omitempty"`
// Name - Friendly Name to provide context on what this customization step does
Name *string `json:"name,omitempty"`
// Type - Possible values include: 'TypeImageTemplateCustomizer', 'TypeShell', 'TypeWindowsRestart', 'TypePowerShell'
Type TypeBasicImageTemplateCustomizer `json:"type,omitempty"`
}
// MarshalJSON is the custom marshaler for ImageTemplatePowerShellCustomizer.
func (itpsc ImageTemplatePowerShellCustomizer) MarshalJSON() ([]byte, error) {
itpsc.Type = TypePowerShell
objectMap := make(map[string]interface{})
if itpsc.Script != nil {
objectMap["script"] = itpsc.Script
}
if itpsc.Inline != nil {
objectMap["inline"] = itpsc.Inline
}
if itpsc.ValidExitCodes != nil {
objectMap["validExitCodes"] = itpsc.ValidExitCodes
}
if itpsc.Name != nil {
objectMap["name"] = itpsc.Name
}
if itpsc.Type != "" {
objectMap["type"] = itpsc.Type
}
return json.Marshal(objectMap)
}
// AsImageTemplateShellCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplatePowerShellCustomizer.
func (itpsc ImageTemplatePowerShellCustomizer) AsImageTemplateShellCustomizer() (*ImageTemplateShellCustomizer, bool) {
return nil, false
}
// AsImageTemplateRestartCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplatePowerShellCustomizer.
func (itpsc ImageTemplatePowerShellCustomizer) AsImageTemplateRestartCustomizer() (*ImageTemplateRestartCustomizer, bool) {
return nil, false
}
// AsImageTemplatePowerShellCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplatePowerShellCustomizer.
func (itpsc ImageTemplatePowerShellCustomizer) AsImageTemplatePowerShellCustomizer() (*ImageTemplatePowerShellCustomizer, bool) {
return &itpsc, true
}
// AsImageTemplateCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplatePowerShellCustomizer.
func (itpsc ImageTemplatePowerShellCustomizer) AsImageTemplateCustomizer() (*ImageTemplateCustomizer, bool) {
return nil, false
}
// AsBasicImageTemplateCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplatePowerShellCustomizer.
func (itpsc ImageTemplatePowerShellCustomizer) AsBasicImageTemplateCustomizer() (BasicImageTemplateCustomizer, bool) {
return &itpsc, true
}
// ImageTemplateProperties ...
type ImageTemplateProperties struct {
// Source - Specifies the properties used to describe the source image.
Source BasicImageTemplateSource `json:"source,omitempty"`
// Customize - Specifies the properties used to describe the customization steps of the image, like Image source etc
Customize *[]BasicImageTemplateCustomizer `json:"customize,omitempty"`
// Distribute - The distribution targets where the image output needs to go to.
Distribute *[]BasicImageTemplateDistributor `json:"distribute,omitempty"`
// ProvisioningState - READ-ONLY; Provisioning state of the resource. Possible values include: 'Creating', 'Succeeded', 'Failed', 'Deleting'
ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
// ProvisioningError - READ-ONLY; Provisioning error, if any
ProvisioningError *ProvisioningError `json:"provisioningError,omitempty"`
// LastRunStatus - READ-ONLY; State of 'run' that is currently executing or was last executed.
LastRunStatus *ImageTemplateLastRunStatus `json:"lastRunStatus,omitempty"`
}
// MarshalJSON is the custom marshaler for ImageTemplateProperties.
func (itp ImageTemplateProperties) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
objectMap["source"] = itp.Source
if itp.Customize != nil {
objectMap["customize"] = itp.Customize
}
if itp.Distribute != nil {
objectMap["distribute"] = itp.Distribute
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for ImageTemplateProperties struct.
func (itp *ImageTemplateProperties) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "source":
if v != nil {
source, err := unmarshalBasicImageTemplateSource(*v)
if err != nil {
return err
}
itp.Source = source
}
case "customize":
if v != nil {
customize, err := unmarshalBasicImageTemplateCustomizerArray(*v)
if err != nil {
return err
}
itp.Customize = &customize
}
case "distribute":
if v != nil {
distribute, err := unmarshalBasicImageTemplateDistributorArray(*v)
if err != nil {
return err
}
itp.Distribute = &distribute
}
case "provisioningState":
if v != nil {
var provisioningState ProvisioningState
err = json.Unmarshal(*v, &provisioningState)
if err != nil {
return err
}
itp.ProvisioningState = provisioningState
}
case "provisioningError":
if v != nil {
var provisioningError ProvisioningError
err = json.Unmarshal(*v, &provisioningError)
if err != nil {
return err
}
itp.ProvisioningError = &provisioningError
}
case "lastRunStatus":
if v != nil {
var lastRunStatus ImageTemplateLastRunStatus
err = json.Unmarshal(*v, &lastRunStatus)
if err != nil {
return err
}
itp.LastRunStatus = &lastRunStatus
}
}
}
return nil
}
// ImageTemplateRestartCustomizer reboots a VM and waits for it to come back online (Windows). Corresponds
// to Packer windows-restart provisioner
type ImageTemplateRestartCustomizer struct {
// RestartCommand - Command to execute the restart [Default: 'shutdown /r /f /t 0 /c "packer restart"']
RestartCommand *string `json:"restartCommand,omitempty"`
// RestartCheckCommand - Command to check if restart succeeded [Default: '']
RestartCheckCommand *string `json:"restartCheckCommand,omitempty"`
// RestartTimeout - Restart timeout specified as a string of magnitude and unit, e.g. '5m' (5 minutes) or '2h' (2 hours) [Default: '5m']
RestartTimeout *string `json:"restartTimeout,omitempty"`
// Name - Friendly Name to provide context on what this customization step does
Name *string `json:"name,omitempty"`
// Type - Possible values include: 'TypeImageTemplateCustomizer', 'TypeShell', 'TypeWindowsRestart', 'TypePowerShell'
Type TypeBasicImageTemplateCustomizer `json:"type,omitempty"`
}
// MarshalJSON is the custom marshaler for ImageTemplateRestartCustomizer.
func (itrc ImageTemplateRestartCustomizer) MarshalJSON() ([]byte, error) {
itrc.Type = TypeWindowsRestart
objectMap := make(map[string]interface{})
if itrc.RestartCommand != nil {
objectMap["restartCommand"] = itrc.RestartCommand
}
if itrc.RestartCheckCommand != nil {
objectMap["restartCheckCommand"] = itrc.RestartCheckCommand
}
if itrc.RestartTimeout != nil {
objectMap["restartTimeout"] = itrc.RestartTimeout
}
if itrc.Name != nil {
objectMap["name"] = itrc.Name
}
if itrc.Type != "" {
objectMap["type"] = itrc.Type
}
return json.Marshal(objectMap)
}
// AsImageTemplateShellCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateRestartCustomizer.
func (itrc ImageTemplateRestartCustomizer) AsImageTemplateShellCustomizer() (*ImageTemplateShellCustomizer, bool) {
return nil, false
}
// AsImageTemplateRestartCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateRestartCustomizer.
func (itrc ImageTemplateRestartCustomizer) AsImageTemplateRestartCustomizer() (*ImageTemplateRestartCustomizer, bool) {
return &itrc, true
}
// AsImageTemplatePowerShellCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateRestartCustomizer.
func (itrc ImageTemplateRestartCustomizer) AsImageTemplatePowerShellCustomizer() (*ImageTemplatePowerShellCustomizer, bool) {
return nil, false
}
// AsImageTemplateCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateRestartCustomizer.
func (itrc ImageTemplateRestartCustomizer) AsImageTemplateCustomizer() (*ImageTemplateCustomizer, bool) {
return nil, false
}
// AsBasicImageTemplateCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateRestartCustomizer.
func (itrc ImageTemplateRestartCustomizer) AsBasicImageTemplateCustomizer() (BasicImageTemplateCustomizer, bool) {
return &itrc, true
}
// ImageTemplateSharedImageDistributor distribute via Shared Image Gallery.
type ImageTemplateSharedImageDistributor struct {
// GalleryImageID - Resource Id of the Shared Image Gallery image
GalleryImageID *string `json:"galleryImageId,omitempty"`
ReplicationRegions *[]string `json:"replicationRegions,omitempty"`
// RunOutputName - The name to be used for the associated RunOutput.
RunOutputName *string `json:"runOutputName,omitempty"`
// ArtifactTags - Tags that will be applied to the artifact once it has been created/updated by the distributor.
ArtifactTags map[string]*string `json:"artifactTags"`
// Type - Possible values include: 'TypeBasicImageTemplateDistributorTypeImageTemplateDistributor', 'TypeBasicImageTemplateDistributorTypeManagedImage', 'TypeBasicImageTemplateDistributorTypeSharedImage', 'TypeBasicImageTemplateDistributorTypeVHD'
Type TypeBasicImageTemplateDistributor `json:"type,omitempty"`
}
// MarshalJSON is the custom marshaler for ImageTemplateSharedImageDistributor.
func (itsid ImageTemplateSharedImageDistributor) MarshalJSON() ([]byte, error) {
itsid.Type = TypeBasicImageTemplateDistributorTypeSharedImage
objectMap := make(map[string]interface{})
if itsid.GalleryImageID != nil {
objectMap["galleryImageId"] = itsid.GalleryImageID
}
if itsid.ReplicationRegions != nil {
objectMap["replicationRegions"] = itsid.ReplicationRegions
}
if itsid.RunOutputName != nil {
objectMap["runOutputName"] = itsid.RunOutputName
}
if itsid.ArtifactTags != nil {
objectMap["artifactTags"] = itsid.ArtifactTags
}
if itsid.Type != "" {
objectMap["type"] = itsid.Type
}
return json.Marshal(objectMap)
}
// AsImageTemplateManagedImageDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateSharedImageDistributor.
func (itsid ImageTemplateSharedImageDistributor) AsImageTemplateManagedImageDistributor() (*ImageTemplateManagedImageDistributor, bool) {
return nil, false