1package virtualmachineimagebuilder
2
3// Copyright (c) Microsoft Corporation. All rights reserved.
4// Licensed under the MIT License. See License.txt in the project root for license information.
5//
6// Code generated by Microsoft (R) AutoRest Code Generator.
7// Changes may cause incorrect behavior and will be lost if the code is regenerated.
8
9import (
10	"context"
11	"encoding/json"
12	"github.com/Azure/go-autorest/autorest"
13	"github.com/Azure/go-autorest/autorest/azure"
14	"github.com/Azure/go-autorest/autorest/date"
15	"github.com/Azure/go-autorest/autorest/to"
16	"github.com/Azure/go-autorest/tracing"
17	"net/http"
18)
19
20// The package's fully qualified name.
21const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/virtualmachineimagebuilder/mgmt/2018-02-01-preview/virtualmachineimagebuilder"
22
23// APIError api error.
24type APIError struct {
25	// Details - The Api error details
26	Details *[]APIErrorBase `json:"details,omitempty"`
27	// Innererror - The Api inner error
28	Innererror *InnerError `json:"innererror,omitempty"`
29	// Code - The error code.
30	Code *string `json:"code,omitempty"`
31	// Target - The target of the particular error.
32	Target *string `json:"target,omitempty"`
33	// Message - The error message.
34	Message *string `json:"message,omitempty"`
35}
36
37// APIErrorBase api error base.
38type APIErrorBase struct {
39	// Code - The error code.
40	Code *string `json:"code,omitempty"`
41	// Target - The target of the particular error.
42	Target *string `json:"target,omitempty"`
43	// Message - The error message.
44	Message *string `json:"message,omitempty"`
45}
46
47// ImageTemplate ...
48type ImageTemplate struct {
49	autorest.Response        `json:"-"`
50	*ImageTemplateProperties `json:"properties,omitempty"`
51	// ID - READ-ONLY; Resource Id
52	ID *string `json:"id,omitempty"`
53	// Name - READ-ONLY; Resource name
54	Name *string `json:"name,omitempty"`
55	// Type - READ-ONLY; Resource type
56	Type *string `json:"type,omitempty"`
57	// Location - Resource location
58	Location *string `json:"location,omitempty"`
59	// Tags - Resource tags
60	Tags map[string]*string `json:"tags"`
61}
62
63// MarshalJSON is the custom marshaler for ImageTemplate.
64func (it ImageTemplate) MarshalJSON() ([]byte, error) {
65	objectMap := make(map[string]interface{})
66	if it.ImageTemplateProperties != nil {
67		objectMap["properties"] = it.ImageTemplateProperties
68	}
69	if it.Location != nil {
70		objectMap["location"] = it.Location
71	}
72	if it.Tags != nil {
73		objectMap["tags"] = it.Tags
74	}
75	return json.Marshal(objectMap)
76}
77
78// UnmarshalJSON is the custom unmarshaler for ImageTemplate struct.
79func (it *ImageTemplate) UnmarshalJSON(body []byte) error {
80	var m map[string]*json.RawMessage
81	err := json.Unmarshal(body, &m)
82	if err != nil {
83		return err
84	}
85	for k, v := range m {
86		switch k {
87		case "properties":
88			if v != nil {
89				var imageTemplateProperties ImageTemplateProperties
90				err = json.Unmarshal(*v, &imageTemplateProperties)
91				if err != nil {
92					return err
93				}
94				it.ImageTemplateProperties = &imageTemplateProperties
95			}
96		case "id":
97			if v != nil {
98				var ID string
99				err = json.Unmarshal(*v, &ID)
100				if err != nil {
101					return err
102				}
103				it.ID = &ID
104			}
105		case "name":
106			if v != nil {
107				var name string
108				err = json.Unmarshal(*v, &name)
109				if err != nil {
110					return err
111				}
112				it.Name = &name
113			}
114		case "type":
115			if v != nil {
116				var typeVar string
117				err = json.Unmarshal(*v, &typeVar)
118				if err != nil {
119					return err
120				}
121				it.Type = &typeVar
122			}
123		case "location":
124			if v != nil {
125				var location string
126				err = json.Unmarshal(*v, &location)
127				if err != nil {
128					return err
129				}
130				it.Location = &location
131			}
132		case "tags":
133			if v != nil {
134				var tags map[string]*string
135				err = json.Unmarshal(*v, &tags)
136				if err != nil {
137					return err
138				}
139				it.Tags = tags
140			}
141		}
142	}
143
144	return nil
145}
146
147// BasicImageTemplateCustomizer ...
148type BasicImageTemplateCustomizer interface {
149	AsImageTemplateShellCustomizer() (*ImageTemplateShellCustomizer, bool)
150	AsImageTemplateCustomizer() (*ImageTemplateCustomizer, bool)
151}
152
153// ImageTemplateCustomizer ...
154type ImageTemplateCustomizer struct {
155	// Name - Friendly Name to provide context on what this customization step does
156	Name *string `json:"name,omitempty"`
157	// Type - Possible values include: 'TypeImageTemplateCustomizer', 'TypeShell'
158	Type TypeBasicImageTemplateCustomizer `json:"type,omitempty"`
159}
160
161func unmarshalBasicImageTemplateCustomizer(body []byte) (BasicImageTemplateCustomizer, error) {
162	var m map[string]interface{}
163	err := json.Unmarshal(body, &m)
164	if err != nil {
165		return nil, err
166	}
167
168	switch m["type"] {
169	case string(TypeShell):
170		var itsc ImageTemplateShellCustomizer
171		err := json.Unmarshal(body, &itsc)
172		return itsc, err
173	default:
174		var itc ImageTemplateCustomizer
175		err := json.Unmarshal(body, &itc)
176		return itc, err
177	}
178}
179func unmarshalBasicImageTemplateCustomizerArray(body []byte) ([]BasicImageTemplateCustomizer, error) {
180	var rawMessages []*json.RawMessage
181	err := json.Unmarshal(body, &rawMessages)
182	if err != nil {
183		return nil, err
184	}
185
186	itcArray := make([]BasicImageTemplateCustomizer, len(rawMessages))
187
188	for index, rawMessage := range rawMessages {
189		itc, err := unmarshalBasicImageTemplateCustomizer(*rawMessage)
190		if err != nil {
191			return nil, err
192		}
193		itcArray[index] = itc
194	}
195	return itcArray, nil
196}
197
198// MarshalJSON is the custom marshaler for ImageTemplateCustomizer.
199func (itc ImageTemplateCustomizer) MarshalJSON() ([]byte, error) {
200	itc.Type = TypeImageTemplateCustomizer
201	objectMap := make(map[string]interface{})
202	if itc.Name != nil {
203		objectMap["name"] = itc.Name
204	}
205	if itc.Type != "" {
206		objectMap["type"] = itc.Type
207	}
208	return json.Marshal(objectMap)
209}
210
211// AsImageTemplateShellCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateCustomizer.
212func (itc ImageTemplateCustomizer) AsImageTemplateShellCustomizer() (*ImageTemplateShellCustomizer, bool) {
213	return nil, false
214}
215
216// AsImageTemplateCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateCustomizer.
217func (itc ImageTemplateCustomizer) AsImageTemplateCustomizer() (*ImageTemplateCustomizer, bool) {
218	return &itc, true
219}
220
221// AsBasicImageTemplateCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateCustomizer.
222func (itc ImageTemplateCustomizer) AsBasicImageTemplateCustomizer() (BasicImageTemplateCustomizer, bool) {
223	return &itc, true
224}
225
226// BasicImageTemplateDistributor generic distribution object
227type BasicImageTemplateDistributor interface {
228	AsImageTemplateManagedImageDistributor() (*ImageTemplateManagedImageDistributor, bool)
229	AsImageTemplateSharedImageDistributor() (*ImageTemplateSharedImageDistributor, bool)
230	AsImageTemplateDistributor() (*ImageTemplateDistributor, bool)
231}
232
233// ImageTemplateDistributor generic distribution object
234type ImageTemplateDistributor struct {
235	// RunOutputName - The name to be used for the associated RunOutput.
236	RunOutputName *string `json:"runOutputName,omitempty"`
237	// ArtifactTags - Tags that will be applied to the artifact once it has been created/updated by the distributor.
238	ArtifactTags map[string]*string `json:"artifactTags"`
239	// Type - Possible values include: 'TypeImageTemplateDistributor', 'TypeManagedImage', 'TypeSharedImage'
240	Type TypeBasicImageTemplateDistributor `json:"type,omitempty"`
241}
242
243func unmarshalBasicImageTemplateDistributor(body []byte) (BasicImageTemplateDistributor, error) {
244	var m map[string]interface{}
245	err := json.Unmarshal(body, &m)
246	if err != nil {
247		return nil, err
248	}
249
250	switch m["type"] {
251	case string(TypeManagedImage):
252		var itmid ImageTemplateManagedImageDistributor
253		err := json.Unmarshal(body, &itmid)
254		return itmid, err
255	case string(TypeSharedImage):
256		var itsid ImageTemplateSharedImageDistributor
257		err := json.Unmarshal(body, &itsid)
258		return itsid, err
259	default:
260		var itd ImageTemplateDistributor
261		err := json.Unmarshal(body, &itd)
262		return itd, err
263	}
264}
265func unmarshalBasicImageTemplateDistributorArray(body []byte) ([]BasicImageTemplateDistributor, error) {
266	var rawMessages []*json.RawMessage
267	err := json.Unmarshal(body, &rawMessages)
268	if err != nil {
269		return nil, err
270	}
271
272	itdArray := make([]BasicImageTemplateDistributor, len(rawMessages))
273
274	for index, rawMessage := range rawMessages {
275		itd, err := unmarshalBasicImageTemplateDistributor(*rawMessage)
276		if err != nil {
277			return nil, err
278		}
279		itdArray[index] = itd
280	}
281	return itdArray, nil
282}
283
284// MarshalJSON is the custom marshaler for ImageTemplateDistributor.
285func (itd ImageTemplateDistributor) MarshalJSON() ([]byte, error) {
286	itd.Type = TypeImageTemplateDistributor
287	objectMap := make(map[string]interface{})
288	if itd.RunOutputName != nil {
289		objectMap["runOutputName"] = itd.RunOutputName
290	}
291	if itd.ArtifactTags != nil {
292		objectMap["artifactTags"] = itd.ArtifactTags
293	}
294	if itd.Type != "" {
295		objectMap["type"] = itd.Type
296	}
297	return json.Marshal(objectMap)
298}
299
300// AsImageTemplateManagedImageDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateDistributor.
301func (itd ImageTemplateDistributor) AsImageTemplateManagedImageDistributor() (*ImageTemplateManagedImageDistributor, bool) {
302	return nil, false
303}
304
305// AsImageTemplateSharedImageDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateDistributor.
306func (itd ImageTemplateDistributor) AsImageTemplateSharedImageDistributor() (*ImageTemplateSharedImageDistributor, bool) {
307	return nil, false
308}
309
310// AsImageTemplateDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateDistributor.
311func (itd ImageTemplateDistributor) AsImageTemplateDistributor() (*ImageTemplateDistributor, bool) {
312	return &itd, true
313}
314
315// AsBasicImageTemplateDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateDistributor.
316func (itd ImageTemplateDistributor) AsBasicImageTemplateDistributor() (BasicImageTemplateDistributor, bool) {
317	return &itd, true
318}
319
320// ImageTemplateIsoSource describes an image source that is an installation ISO. Currently only supports
321// Red Hat Enterprise Linux 7.2-7.5 ISO's.
322type ImageTemplateIsoSource struct {
323	// SourceURI - URL to get the ISO image. This URL has to be accessible to the resource provider at the time of the imageTemplate creation.
324	SourceURI *string `json:"sourceURI,omitempty"`
325	// Sha256Checksum - SHA256 Checksum of the ISO image.
326	Sha256Checksum *string `json:"sha256Checksum,omitempty"`
327	// Type - Possible values include: 'TypeImageTemplateSource', 'TypeISO', 'TypePlatformImage'
328	Type Type `json:"type,omitempty"`
329}
330
331// MarshalJSON is the custom marshaler for ImageTemplateIsoSource.
332func (itis ImageTemplateIsoSource) MarshalJSON() ([]byte, error) {
333	itis.Type = TypeISO
334	objectMap := make(map[string]interface{})
335	if itis.SourceURI != nil {
336		objectMap["sourceURI"] = itis.SourceURI
337	}
338	if itis.Sha256Checksum != nil {
339		objectMap["sha256Checksum"] = itis.Sha256Checksum
340	}
341	if itis.Type != "" {
342		objectMap["type"] = itis.Type
343	}
344	return json.Marshal(objectMap)
345}
346
347// AsImageTemplateIsoSource is the BasicImageTemplateSource implementation for ImageTemplateIsoSource.
348func (itis ImageTemplateIsoSource) AsImageTemplateIsoSource() (*ImageTemplateIsoSource, bool) {
349	return &itis, true
350}
351
352// AsImageTemplatePlatformImageSource is the BasicImageTemplateSource implementation for ImageTemplateIsoSource.
353func (itis ImageTemplateIsoSource) AsImageTemplatePlatformImageSource() (*ImageTemplatePlatformImageSource, bool) {
354	return nil, false
355}
356
357// AsImageTemplateSource is the BasicImageTemplateSource implementation for ImageTemplateIsoSource.
358func (itis ImageTemplateIsoSource) AsImageTemplateSource() (*ImageTemplateSource, bool) {
359	return nil, false
360}
361
362// AsBasicImageTemplateSource is the BasicImageTemplateSource implementation for ImageTemplateIsoSource.
363func (itis ImageTemplateIsoSource) AsBasicImageTemplateSource() (BasicImageTemplateSource, bool) {
364	return &itis, true
365}
366
367// ImageTemplateLastRunStatus ...
368type ImageTemplateLastRunStatus struct {
369	// StartTime - Start time of the last run (UTC)
370	StartTime *date.Time `json:"startTime,omitempty"`
371	// EndTime - End time of the last run (UTC)
372	EndTime *date.Time `json:"endTime,omitempty"`
373	// RunState - State of the last run. Possible values include: 'RunStateReady', 'RunStateRunning', 'RunStateSucceeded', 'RunStatePartiallySucceeded', 'RunStateFailed'
374	RunState RunState `json:"runState,omitempty"`
375	// RunSubState - Sub state of the last run. Possible values include: 'Queued', 'Building', 'Customizing', 'Distributing'
376	RunSubState RunSubState `json:"runSubState,omitempty"`
377	// Message - Verbose information about the last run state
378	Message *string `json:"message,omitempty"`
379}
380
381// ImageTemplateListResult ...
382type ImageTemplateListResult struct {
383	autorest.Response `json:"-"`
384	Value             *[]ImageTemplate `json:"value,omitempty"`
385	// NextLink - The continuation token.
386	NextLink *string `json:"nextLink,omitempty"`
387}
388
389// ImageTemplateListResultIterator provides access to a complete listing of ImageTemplate values.
390type ImageTemplateListResultIterator struct {
391	i    int
392	page ImageTemplateListResultPage
393}
394
395// NextWithContext advances to the next value.  If there was an error making
396// the request the iterator does not advance and the error is returned.
397func (iter *ImageTemplateListResultIterator) NextWithContext(ctx context.Context) (err error) {
398	if tracing.IsEnabled() {
399		ctx = tracing.StartSpan(ctx, fqdn+"/ImageTemplateListResultIterator.NextWithContext")
400		defer func() {
401			sc := -1
402			if iter.Response().Response.Response != nil {
403				sc = iter.Response().Response.Response.StatusCode
404			}
405			tracing.EndSpan(ctx, sc, err)
406		}()
407	}
408	iter.i++
409	if iter.i < len(iter.page.Values()) {
410		return nil
411	}
412	err = iter.page.NextWithContext(ctx)
413	if err != nil {
414		iter.i--
415		return err
416	}
417	iter.i = 0
418	return nil
419}
420
421// Next advances to the next value.  If there was an error making
422// the request the iterator does not advance and the error is returned.
423// Deprecated: Use NextWithContext() instead.
424func (iter *ImageTemplateListResultIterator) Next() error {
425	return iter.NextWithContext(context.Background())
426}
427
428// NotDone returns true if the enumeration should be started or is not yet complete.
429func (iter ImageTemplateListResultIterator) NotDone() bool {
430	return iter.page.NotDone() && iter.i < len(iter.page.Values())
431}
432
433// Response returns the raw server response from the last page request.
434func (iter ImageTemplateListResultIterator) Response() ImageTemplateListResult {
435	return iter.page.Response()
436}
437
438// Value returns the current value or a zero-initialized value if the
439// iterator has advanced beyond the end of the collection.
440func (iter ImageTemplateListResultIterator) Value() ImageTemplate {
441	if !iter.page.NotDone() {
442		return ImageTemplate{}
443	}
444	return iter.page.Values()[iter.i]
445}
446
447// Creates a new instance of the ImageTemplateListResultIterator type.
448func NewImageTemplateListResultIterator(page ImageTemplateListResultPage) ImageTemplateListResultIterator {
449	return ImageTemplateListResultIterator{page: page}
450}
451
452// IsEmpty returns true if the ListResult contains no values.
453func (itlr ImageTemplateListResult) IsEmpty() bool {
454	return itlr.Value == nil || len(*itlr.Value) == 0
455}
456
457// hasNextLink returns true if the NextLink is not empty.
458func (itlr ImageTemplateListResult) hasNextLink() bool {
459	return itlr.NextLink != nil && len(*itlr.NextLink) != 0
460}
461
462// imageTemplateListResultPreparer prepares a request to retrieve the next set of results.
463// It returns nil if no more results exist.
464func (itlr ImageTemplateListResult) imageTemplateListResultPreparer(ctx context.Context) (*http.Request, error) {
465	if !itlr.hasNextLink() {
466		return nil, nil
467	}
468	return autorest.Prepare((&http.Request{}).WithContext(ctx),
469		autorest.AsJSON(),
470		autorest.AsGet(),
471		autorest.WithBaseURL(to.String(itlr.NextLink)))
472}
473
474// ImageTemplateListResultPage contains a page of ImageTemplate values.
475type ImageTemplateListResultPage struct {
476	fn   func(context.Context, ImageTemplateListResult) (ImageTemplateListResult, error)
477	itlr ImageTemplateListResult
478}
479
480// NextWithContext advances to the next page of values.  If there was an error making
481// the request the page does not advance and the error is returned.
482func (page *ImageTemplateListResultPage) NextWithContext(ctx context.Context) (err error) {
483	if tracing.IsEnabled() {
484		ctx = tracing.StartSpan(ctx, fqdn+"/ImageTemplateListResultPage.NextWithContext")
485		defer func() {
486			sc := -1
487			if page.Response().Response.Response != nil {
488				sc = page.Response().Response.Response.StatusCode
489			}
490			tracing.EndSpan(ctx, sc, err)
491		}()
492	}
493	for {
494		next, err := page.fn(ctx, page.itlr)
495		if err != nil {
496			return err
497		}
498		page.itlr = next
499		if !next.hasNextLink() || !next.IsEmpty() {
500			break
501		}
502	}
503	return nil
504}
505
506// Next advances to the next page of values.  If there was an error making
507// the request the page does not advance and the error is returned.
508// Deprecated: Use NextWithContext() instead.
509func (page *ImageTemplateListResultPage) Next() error {
510	return page.NextWithContext(context.Background())
511}
512
513// NotDone returns true if the page enumeration should be started or is not yet complete.
514func (page ImageTemplateListResultPage) NotDone() bool {
515	return !page.itlr.IsEmpty()
516}
517
518// Response returns the raw server response from the last page request.
519func (page ImageTemplateListResultPage) Response() ImageTemplateListResult {
520	return page.itlr
521}
522
523// Values returns the slice of values for the current page or nil if there are no values.
524func (page ImageTemplateListResultPage) Values() []ImageTemplate {
525	if page.itlr.IsEmpty() {
526		return nil
527	}
528	return *page.itlr.Value
529}
530
531// Creates a new instance of the ImageTemplateListResultPage type.
532func NewImageTemplateListResultPage(cur ImageTemplateListResult, getNextPage func(context.Context, ImageTemplateListResult) (ImageTemplateListResult, error)) ImageTemplateListResultPage {
533	return ImageTemplateListResultPage{
534		fn:   getNextPage,
535		itlr: cur,
536	}
537}
538
539// ImageTemplateManagedImageDistributor distribute as a Managed Disk Image.
540type ImageTemplateManagedImageDistributor struct {
541	// ImageID - Resource Id of the Managed Disk Image
542	ImageID *string `json:"imageId,omitempty"`
543	// Location - Azure location for the image, should match if image already exists
544	Location *string `json:"location,omitempty"`
545	// RunOutputName - The name to be used for the associated RunOutput.
546	RunOutputName *string `json:"runOutputName,omitempty"`
547	// ArtifactTags - Tags that will be applied to the artifact once it has been created/updated by the distributor.
548	ArtifactTags map[string]*string `json:"artifactTags"`
549	// Type - Possible values include: 'TypeImageTemplateDistributor', 'TypeManagedImage', 'TypeSharedImage'
550	Type TypeBasicImageTemplateDistributor `json:"type,omitempty"`
551}
552
553// MarshalJSON is the custom marshaler for ImageTemplateManagedImageDistributor.
554func (itmid ImageTemplateManagedImageDistributor) MarshalJSON() ([]byte, error) {
555	itmid.Type = TypeManagedImage
556	objectMap := make(map[string]interface{})
557	if itmid.ImageID != nil {
558		objectMap["imageId"] = itmid.ImageID
559	}
560	if itmid.Location != nil {
561		objectMap["location"] = itmid.Location
562	}
563	if itmid.RunOutputName != nil {
564		objectMap["runOutputName"] = itmid.RunOutputName
565	}
566	if itmid.ArtifactTags != nil {
567		objectMap["artifactTags"] = itmid.ArtifactTags
568	}
569	if itmid.Type != "" {
570		objectMap["type"] = itmid.Type
571	}
572	return json.Marshal(objectMap)
573}
574
575// AsImageTemplateManagedImageDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateManagedImageDistributor.
576func (itmid ImageTemplateManagedImageDistributor) AsImageTemplateManagedImageDistributor() (*ImageTemplateManagedImageDistributor, bool) {
577	return &itmid, true
578}
579
580// AsImageTemplateSharedImageDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateManagedImageDistributor.
581func (itmid ImageTemplateManagedImageDistributor) AsImageTemplateSharedImageDistributor() (*ImageTemplateSharedImageDistributor, bool) {
582	return nil, false
583}
584
585// AsImageTemplateDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateManagedImageDistributor.
586func (itmid ImageTemplateManagedImageDistributor) AsImageTemplateDistributor() (*ImageTemplateDistributor, bool) {
587	return nil, false
588}
589
590// AsBasicImageTemplateDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateManagedImageDistributor.
591func (itmid ImageTemplateManagedImageDistributor) AsBasicImageTemplateDistributor() (BasicImageTemplateDistributor, bool) {
592	return &itmid, true
593}
594
595// ImageTemplatePlatformImageSource describes an image source from [Azure Gallery
596// Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages).
597type ImageTemplatePlatformImageSource struct {
598	// Publisher - Image Publisher in [Azure Gallery Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages).
599	Publisher *string `json:"publisher,omitempty"`
600	// Offer - Image offer from the [Azure Gallery Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages).
601	Offer *string `json:"offer,omitempty"`
602	// Sku - Image sku from the [Azure Gallery Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages).
603	Sku *string `json:"sku,omitempty"`
604	// Version - Image version from the [Azure Gallery Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages).
605	Version *string `json:"version,omitempty"`
606	// Type - Possible values include: 'TypeImageTemplateSource', 'TypeISO', 'TypePlatformImage'
607	Type Type `json:"type,omitempty"`
608}
609
610// MarshalJSON is the custom marshaler for ImageTemplatePlatformImageSource.
611func (itpis ImageTemplatePlatformImageSource) MarshalJSON() ([]byte, error) {
612	itpis.Type = TypePlatformImage
613	objectMap := make(map[string]interface{})
614	if itpis.Publisher != nil {
615		objectMap["publisher"] = itpis.Publisher
616	}
617	if itpis.Offer != nil {
618		objectMap["offer"] = itpis.Offer
619	}
620	if itpis.Sku != nil {
621		objectMap["sku"] = itpis.Sku
622	}
623	if itpis.Version != nil {
624		objectMap["version"] = itpis.Version
625	}
626	if itpis.Type != "" {
627		objectMap["type"] = itpis.Type
628	}
629	return json.Marshal(objectMap)
630}
631
632// AsImageTemplateIsoSource is the BasicImageTemplateSource implementation for ImageTemplatePlatformImageSource.
633func (itpis ImageTemplatePlatformImageSource) AsImageTemplateIsoSource() (*ImageTemplateIsoSource, bool) {
634	return nil, false
635}
636
637// AsImageTemplatePlatformImageSource is the BasicImageTemplateSource implementation for ImageTemplatePlatformImageSource.
638func (itpis ImageTemplatePlatformImageSource) AsImageTemplatePlatformImageSource() (*ImageTemplatePlatformImageSource, bool) {
639	return &itpis, true
640}
641
642// AsImageTemplateSource is the BasicImageTemplateSource implementation for ImageTemplatePlatformImageSource.
643func (itpis ImageTemplatePlatformImageSource) AsImageTemplateSource() (*ImageTemplateSource, bool) {
644	return nil, false
645}
646
647// AsBasicImageTemplateSource is the BasicImageTemplateSource implementation for ImageTemplatePlatformImageSource.
648func (itpis ImageTemplatePlatformImageSource) AsBasicImageTemplateSource() (BasicImageTemplateSource, bool) {
649	return &itpis, true
650}
651
652// ImageTemplateProperties ...
653type ImageTemplateProperties struct {
654	// Source - Specifies the properties used to describe the source image.
655	Source BasicImageTemplateSource `json:"source,omitempty"`
656	// Customize - Specifies the properties used to describe the customization steps of the image, like Image source etc
657	Customize *[]BasicImageTemplateCustomizer `json:"customize,omitempty"`
658	// Distribute - The distribution targets where the image output needs to go to.
659	Distribute *[]BasicImageTemplateDistributor `json:"distribute,omitempty"`
660	// ProvisioningState - READ-ONLY; Provisioning state of the resource. Possible values include: 'Creating', 'Succeeded', 'Failed', 'Deleting'
661	ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
662	// ProvisioningError - READ-ONLY; Provisioning error, if any
663	ProvisioningError *ProvisioningError `json:"provisioningError,omitempty"`
664	// LastRunStatus - READ-ONLY; State of 'run' that is currently executing or was last executed.
665	LastRunStatus *ImageTemplateLastRunStatus `json:"lastRunStatus,omitempty"`
666}
667
668// MarshalJSON is the custom marshaler for ImageTemplateProperties.
669func (itp ImageTemplateProperties) MarshalJSON() ([]byte, error) {
670	objectMap := make(map[string]interface{})
671	objectMap["source"] = itp.Source
672	if itp.Customize != nil {
673		objectMap["customize"] = itp.Customize
674	}
675	if itp.Distribute != nil {
676		objectMap["distribute"] = itp.Distribute
677	}
678	return json.Marshal(objectMap)
679}
680
681// UnmarshalJSON is the custom unmarshaler for ImageTemplateProperties struct.
682func (itp *ImageTemplateProperties) UnmarshalJSON(body []byte) error {
683	var m map[string]*json.RawMessage
684	err := json.Unmarshal(body, &m)
685	if err != nil {
686		return err
687	}
688	for k, v := range m {
689		switch k {
690		case "source":
691			if v != nil {
692				source, err := unmarshalBasicImageTemplateSource(*v)
693				if err != nil {
694					return err
695				}
696				itp.Source = source
697			}
698		case "customize":
699			if v != nil {
700				customize, err := unmarshalBasicImageTemplateCustomizerArray(*v)
701				if err != nil {
702					return err
703				}
704				itp.Customize = &customize
705			}
706		case "distribute":
707			if v != nil {
708				distribute, err := unmarshalBasicImageTemplateDistributorArray(*v)
709				if err != nil {
710					return err
711				}
712				itp.Distribute = &distribute
713			}
714		case "provisioningState":
715			if v != nil {
716				var provisioningState ProvisioningState
717				err = json.Unmarshal(*v, &provisioningState)
718				if err != nil {
719					return err
720				}
721				itp.ProvisioningState = provisioningState
722			}
723		case "provisioningError":
724			if v != nil {
725				var provisioningError ProvisioningError
726				err = json.Unmarshal(*v, &provisioningError)
727				if err != nil {
728					return err
729				}
730				itp.ProvisioningError = &provisioningError
731			}
732		case "lastRunStatus":
733			if v != nil {
734				var lastRunStatus ImageTemplateLastRunStatus
735				err = json.Unmarshal(*v, &lastRunStatus)
736				if err != nil {
737					return err
738				}
739				itp.LastRunStatus = &lastRunStatus
740			}
741		}
742	}
743
744	return nil
745}
746
747// ImageTemplateSharedImageDistributor distribute via Shared Image Gallery.
748type ImageTemplateSharedImageDistributor struct {
749	// GalleryImageID - Resource Id of the Shared Image Gallery image
750	GalleryImageID     *string   `json:"galleryImageId,omitempty"`
751	ReplicationRegions *[]string `json:"replicationRegions,omitempty"`
752	// RunOutputName - The name to be used for the associated RunOutput.
753	RunOutputName *string `json:"runOutputName,omitempty"`
754	// ArtifactTags - Tags that will be applied to the artifact once it has been created/updated by the distributor.
755	ArtifactTags map[string]*string `json:"artifactTags"`
756	// Type - Possible values include: 'TypeImageTemplateDistributor', 'TypeManagedImage', 'TypeSharedImage'
757	Type TypeBasicImageTemplateDistributor `json:"type,omitempty"`
758}
759
760// MarshalJSON is the custom marshaler for ImageTemplateSharedImageDistributor.
761func (itsid ImageTemplateSharedImageDistributor) MarshalJSON() ([]byte, error) {
762	itsid.Type = TypeSharedImage
763	objectMap := make(map[string]interface{})
764	if itsid.GalleryImageID != nil {
765		objectMap["galleryImageId"] = itsid.GalleryImageID
766	}
767	if itsid.ReplicationRegions != nil {
768		objectMap["replicationRegions"] = itsid.ReplicationRegions
769	}
770	if itsid.RunOutputName != nil {
771		objectMap["runOutputName"] = itsid.RunOutputName
772	}
773	if itsid.ArtifactTags != nil {
774		objectMap["artifactTags"] = itsid.ArtifactTags
775	}
776	if itsid.Type != "" {
777		objectMap["type"] = itsid.Type
778	}
779	return json.Marshal(objectMap)
780}
781
782// AsImageTemplateManagedImageDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateSharedImageDistributor.
783func (itsid ImageTemplateSharedImageDistributor) AsImageTemplateManagedImageDistributor() (*ImageTemplateManagedImageDistributor, bool) {
784	return nil, false
785}
786
787// AsImageTemplateSharedImageDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateSharedImageDistributor.
788func (itsid ImageTemplateSharedImageDistributor) AsImageTemplateSharedImageDistributor() (*ImageTemplateSharedImageDistributor, bool) {
789	return &itsid, true
790}
791
792// AsImageTemplateDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateSharedImageDistributor.
793func (itsid ImageTemplateSharedImageDistributor) AsImageTemplateDistributor() (*ImageTemplateDistributor, bool) {
794	return nil, false
795}
796
797// AsBasicImageTemplateDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateSharedImageDistributor.
798func (itsid ImageTemplateSharedImageDistributor) AsBasicImageTemplateDistributor() (BasicImageTemplateDistributor, bool) {
799	return &itsid, true
800}
801
802// ImageTemplateShellCustomizer runs a shell script during the customization phase
803type ImageTemplateShellCustomizer struct {
804	// Script - The shell script to be run for customizing. It can be a github link, SAS URI for Azure Storage, etc
805	Script *string `json:"script,omitempty"`
806	// Name - Friendly Name to provide context on what this customization step does
807	Name *string `json:"name,omitempty"`
808	// Type - Possible values include: 'TypeImageTemplateCustomizer', 'TypeShell'
809	Type TypeBasicImageTemplateCustomizer `json:"type,omitempty"`
810}
811
812// MarshalJSON is the custom marshaler for ImageTemplateShellCustomizer.
813func (itsc ImageTemplateShellCustomizer) MarshalJSON() ([]byte, error) {
814	itsc.Type = TypeShell
815	objectMap := make(map[string]interface{})
816	if itsc.Script != nil {
817		objectMap["script"] = itsc.Script
818	}
819	if itsc.Name != nil {
820		objectMap["name"] = itsc.Name
821	}
822	if itsc.Type != "" {
823		objectMap["type"] = itsc.Type
824	}
825	return json.Marshal(objectMap)
826}
827
828// AsImageTemplateShellCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateShellCustomizer.
829func (itsc ImageTemplateShellCustomizer) AsImageTemplateShellCustomizer() (*ImageTemplateShellCustomizer, bool) {
830	return &itsc, true
831}
832
833// AsImageTemplateCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateShellCustomizer.
834func (itsc ImageTemplateShellCustomizer) AsImageTemplateCustomizer() (*ImageTemplateCustomizer, bool) {
835	return nil, false
836}
837
838// AsBasicImageTemplateCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateShellCustomizer.
839func (itsc ImageTemplateShellCustomizer) AsBasicImageTemplateCustomizer() (BasicImageTemplateCustomizer, bool) {
840	return &itsc, true
841}
842
843// BasicImageTemplateSource ...
844type BasicImageTemplateSource interface {
845	AsImageTemplateIsoSource() (*ImageTemplateIsoSource, bool)
846	AsImageTemplatePlatformImageSource() (*ImageTemplatePlatformImageSource, bool)
847	AsImageTemplateSource() (*ImageTemplateSource, bool)
848}
849
850// ImageTemplateSource ...
851type ImageTemplateSource struct {
852	// Type - Possible values include: 'TypeImageTemplateSource', 'TypeISO', 'TypePlatformImage'
853	Type Type `json:"type,omitempty"`
854}
855
856func unmarshalBasicImageTemplateSource(body []byte) (BasicImageTemplateSource, error) {
857	var m map[string]interface{}
858	err := json.Unmarshal(body, &m)
859	if err != nil {
860		return nil, err
861	}
862
863	switch m["type"] {
864	case string(TypeISO):
865		var itis ImageTemplateIsoSource
866		err := json.Unmarshal(body, &itis)
867		return itis, err
868	case string(TypePlatformImage):
869		var itpis ImageTemplatePlatformImageSource
870		err := json.Unmarshal(body, &itpis)
871		return itpis, err
872	default:
873		var its ImageTemplateSource
874		err := json.Unmarshal(body, &its)
875		return its, err
876	}
877}
878func unmarshalBasicImageTemplateSourceArray(body []byte) ([]BasicImageTemplateSource, error) {
879	var rawMessages []*json.RawMessage
880	err := json.Unmarshal(body, &rawMessages)
881	if err != nil {
882		return nil, err
883	}
884
885	itsArray := make([]BasicImageTemplateSource, len(rawMessages))
886
887	for index, rawMessage := range rawMessages {
888		its, err := unmarshalBasicImageTemplateSource(*rawMessage)
889		if err != nil {
890			return nil, err
891		}
892		itsArray[index] = its
893	}
894	return itsArray, nil
895}
896
897// MarshalJSON is the custom marshaler for ImageTemplateSource.
898func (its ImageTemplateSource) MarshalJSON() ([]byte, error) {
899	its.Type = TypeImageTemplateSource
900	objectMap := make(map[string]interface{})
901	if its.Type != "" {
902		objectMap["type"] = its.Type
903	}
904	return json.Marshal(objectMap)
905}
906
907// AsImageTemplateIsoSource is the BasicImageTemplateSource implementation for ImageTemplateSource.
908func (its ImageTemplateSource) AsImageTemplateIsoSource() (*ImageTemplateIsoSource, bool) {
909	return nil, false
910}
911
912// AsImageTemplatePlatformImageSource is the BasicImageTemplateSource implementation for ImageTemplateSource.
913func (its ImageTemplateSource) AsImageTemplatePlatformImageSource() (*ImageTemplatePlatformImageSource, bool) {
914	return nil, false
915}
916
917// AsImageTemplateSource is the BasicImageTemplateSource implementation for ImageTemplateSource.
918func (its ImageTemplateSource) AsImageTemplateSource() (*ImageTemplateSource, bool) {
919	return &its, true
920}
921
922// AsBasicImageTemplateSource is the BasicImageTemplateSource implementation for ImageTemplateSource.
923func (its ImageTemplateSource) AsBasicImageTemplateSource() (BasicImageTemplateSource, bool) {
924	return &its, true
925}
926
927// ImageTemplateUpdateParameters parameters for updating an image template.
928type ImageTemplateUpdateParameters struct {
929	// Tags - The user-specified tags associated with the image template.
930	Tags map[string]*string `json:"tags"`
931}
932
933// MarshalJSON is the custom marshaler for ImageTemplateUpdateParameters.
934func (itup ImageTemplateUpdateParameters) MarshalJSON() ([]byte, error) {
935	objectMap := make(map[string]interface{})
936	if itup.Tags != nil {
937		objectMap["tags"] = itup.Tags
938	}
939	return json.Marshal(objectMap)
940}
941
942// InnerError inner error details.
943type InnerError struct {
944	// Exceptiontype - The exception type.
945	Exceptiontype *string `json:"exceptiontype,omitempty"`
946	// Errordetail - The internal error message or exception dump.
947	Errordetail *string `json:"errordetail,omitempty"`
948}
949
950// Operation ...
951type Operation struct {
952	// Name - This is of the format {provider}/{resource}/{operation}
953	Name       *string           `json:"name,omitempty"`
954	Display    *OperationDisplay `json:"display,omitempty"`
955	Origin     *string           `json:"origin,omitempty"`
956	Properties interface{}       `json:"properties,omitempty"`
957}
958
959// OperationDisplay ...
960type OperationDisplay struct {
961	Provider *string `json:"provider,omitempty"`
962	// Operation - For example: read, write, delete, or listKeys/action
963	Operation   *string `json:"operation,omitempty"`
964	Resource    *string `json:"resource,omitempty"`
965	Description *string `json:"description,omitempty"`
966}
967
968// OperationListResult ...
969type OperationListResult struct {
970	autorest.Response `json:"-"`
971	Value             *[]Operation `json:"value,omitempty"`
972	NextLink          *string      `json:"nextLink,omitempty"`
973}
974
975// OperationListResultIterator provides access to a complete listing of Operation values.
976type OperationListResultIterator struct {
977	i    int
978	page OperationListResultPage
979}
980
981// NextWithContext advances to the next value.  If there was an error making
982// the request the iterator does not advance and the error is returned.
983func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) {
984	if tracing.IsEnabled() {
985		ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext")
986		defer func() {
987			sc := -1
988			if iter.Response().Response.Response != nil {
989				sc = iter.Response().Response.Response.StatusCode
990			}
991			tracing.EndSpan(ctx, sc, err)
992		}()
993	}
994	iter.i++
995	if iter.i < len(iter.page.Values()) {
996		return nil
997	}
998	err = iter.page.NextWithContext(ctx)
999	if err != nil {
1000		iter.i--
1001		return err
1002	}
1003	iter.i = 0
1004	return nil
1005}
1006
1007// Next advances to the next value.  If there was an error making
1008// the request the iterator does not advance and the error is returned.
1009// Deprecated: Use NextWithContext() instead.
1010func (iter *OperationListResultIterator) Next() error {
1011	return iter.NextWithContext(context.Background())
1012}
1013
1014// NotDone returns true if the enumeration should be started or is not yet complete.
1015func (iter OperationListResultIterator) NotDone() bool {
1016	return iter.page.NotDone() && iter.i < len(iter.page.Values())
1017}
1018
1019// Response returns the raw server response from the last page request.
1020func (iter OperationListResultIterator) Response() OperationListResult {
1021	return iter.page.Response()
1022}
1023
1024// Value returns the current value or a zero-initialized value if the
1025// iterator has advanced beyond the end of the collection.
1026func (iter OperationListResultIterator) Value() Operation {
1027	if !iter.page.NotDone() {
1028		return Operation{}
1029	}
1030	return iter.page.Values()[iter.i]
1031}
1032
1033// Creates a new instance of the OperationListResultIterator type.
1034func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator {
1035	return OperationListResultIterator{page: page}
1036}
1037
1038// IsEmpty returns true if the ListResult contains no values.
1039func (olr OperationListResult) IsEmpty() bool {
1040	return olr.Value == nil || len(*olr.Value) == 0
1041}
1042
1043// hasNextLink returns true if the NextLink is not empty.
1044func (olr OperationListResult) hasNextLink() bool {
1045	return olr.NextLink != nil && len(*olr.NextLink) != 0
1046}
1047
1048// operationListResultPreparer prepares a request to retrieve the next set of results.
1049// It returns nil if no more results exist.
1050func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) {
1051	if !olr.hasNextLink() {
1052		return nil, nil
1053	}
1054	return autorest.Prepare((&http.Request{}).WithContext(ctx),
1055		autorest.AsJSON(),
1056		autorest.AsGet(),
1057		autorest.WithBaseURL(to.String(olr.NextLink)))
1058}
1059
1060// OperationListResultPage contains a page of Operation values.
1061type OperationListResultPage struct {
1062	fn  func(context.Context, OperationListResult) (OperationListResult, error)
1063	olr OperationListResult
1064}
1065
1066// NextWithContext advances to the next page of values.  If there was an error making
1067// the request the page does not advance and the error is returned.
1068func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) {
1069	if tracing.IsEnabled() {
1070		ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext")
1071		defer func() {
1072			sc := -1
1073			if page.Response().Response.Response != nil {
1074				sc = page.Response().Response.Response.StatusCode
1075			}
1076			tracing.EndSpan(ctx, sc, err)
1077		}()
1078	}
1079	for {
1080		next, err := page.fn(ctx, page.olr)
1081		if err != nil {
1082			return err
1083		}
1084		page.olr = next
1085		if !next.hasNextLink() || !next.IsEmpty() {
1086			break
1087		}
1088	}
1089	return nil
1090}
1091
1092// Next advances to the next page of values.  If there was an error making
1093// the request the page does not advance and the error is returned.
1094// Deprecated: Use NextWithContext() instead.
1095func (page *OperationListResultPage) Next() error {
1096	return page.NextWithContext(context.Background())
1097}
1098
1099// NotDone returns true if the page enumeration should be started or is not yet complete.
1100func (page OperationListResultPage) NotDone() bool {
1101	return !page.olr.IsEmpty()
1102}
1103
1104// Response returns the raw server response from the last page request.
1105func (page OperationListResultPage) Response() OperationListResult {
1106	return page.olr
1107}
1108
1109// Values returns the slice of values for the current page or nil if there are no values.
1110func (page OperationListResultPage) Values() []Operation {
1111	if page.olr.IsEmpty() {
1112		return nil
1113	}
1114	return *page.olr.Value
1115}
1116
1117// Creates a new instance of the OperationListResultPage type.
1118func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage {
1119	return OperationListResultPage{
1120		fn:  getNextPage,
1121		olr: cur,
1122	}
1123}
1124
1125// ProvisioningError ...
1126type ProvisioningError struct {
1127	// ProvisioningErrorCode - Error code of the provisioning failure. Possible values include: 'BadSourceType', 'BadPIRSource', 'BadISOSource', 'BadCustomizerType', 'NoCustomizerShellScript', 'ServerError', 'Other'
1128	ProvisioningErrorCode ProvisioningErrorCode `json:"provisioningErrorCode,omitempty"`
1129	// Message - Verbose error message about the provisioning failure
1130	Message *string `json:"message,omitempty"`
1131}
1132
1133// Resource the Resource model definition.
1134type Resource struct {
1135	// ID - READ-ONLY; Resource Id
1136	ID *string `json:"id,omitempty"`
1137	// Name - READ-ONLY; Resource name
1138	Name *string `json:"name,omitempty"`
1139	// Type - READ-ONLY; Resource type
1140	Type *string `json:"type,omitempty"`
1141	// Location - Resource location
1142	Location *string `json:"location,omitempty"`
1143	// Tags - Resource tags
1144	Tags map[string]*string `json:"tags"`
1145}
1146
1147// MarshalJSON is the custom marshaler for Resource.
1148func (r Resource) MarshalJSON() ([]byte, error) {
1149	objectMap := make(map[string]interface{})
1150	if r.Location != nil {
1151		objectMap["location"] = r.Location
1152	}
1153	if r.Tags != nil {
1154		objectMap["tags"] = r.Tags
1155	}
1156	return json.Marshal(objectMap)
1157}
1158
1159// RunOutput represents an output that was created by running an image template.
1160type RunOutput struct {
1161	autorest.Response    `json:"-"`
1162	*RunOutputProperties `json:"properties,omitempty"`
1163	// ID - READ-ONLY; Resource Id
1164	ID *string `json:"id,omitempty"`
1165	// Name - Resource name
1166	Name *string `json:"name,omitempty"`
1167	// Type - READ-ONLY; Resource type
1168	Type *string `json:"type,omitempty"`
1169}
1170
1171// MarshalJSON is the custom marshaler for RunOutput.
1172func (ro RunOutput) MarshalJSON() ([]byte, error) {
1173	objectMap := make(map[string]interface{})
1174	if ro.RunOutputProperties != nil {
1175		objectMap["properties"] = ro.RunOutputProperties
1176	}
1177	if ro.Name != nil {
1178		objectMap["name"] = ro.Name
1179	}
1180	return json.Marshal(objectMap)
1181}
1182
1183// UnmarshalJSON is the custom unmarshaler for RunOutput struct.
1184func (ro *RunOutput) UnmarshalJSON(body []byte) error {
1185	var m map[string]*json.RawMessage
1186	err := json.Unmarshal(body, &m)
1187	if err != nil {
1188		return err
1189	}
1190	for k, v := range m {
1191		switch k {
1192		case "properties":
1193			if v != nil {
1194				var runOutputProperties RunOutputProperties
1195				err = json.Unmarshal(*v, &runOutputProperties)
1196				if err != nil {
1197					return err
1198				}
1199				ro.RunOutputProperties = &runOutputProperties
1200			}
1201		case "id":
1202			if v != nil {
1203				var ID string
1204				err = json.Unmarshal(*v, &ID)
1205				if err != nil {
1206					return err
1207				}
1208				ro.ID = &ID
1209			}
1210		case "name":
1211			if v != nil {
1212				var name string
1213				err = json.Unmarshal(*v, &name)
1214				if err != nil {
1215					return err
1216				}
1217				ro.Name = &name
1218			}
1219		case "type":
1220			if v != nil {
1221				var typeVar string
1222				err = json.Unmarshal(*v, &typeVar)
1223				if err != nil {
1224					return err
1225				}
1226				ro.Type = &typeVar
1227			}
1228		}
1229	}
1230
1231	return nil
1232}
1233
1234// RunOutputCollection ...
1235type RunOutputCollection struct {
1236	autorest.Response `json:"-"`
1237	Value             *[]RunOutput `json:"value,omitempty"`
1238	// NextLink - The continuation token.
1239	NextLink *string `json:"nextLink,omitempty"`
1240}
1241
1242// RunOutputCollectionIterator provides access to a complete listing of RunOutput values.
1243type RunOutputCollectionIterator struct {
1244	i    int
1245	page RunOutputCollectionPage
1246}
1247
1248// NextWithContext advances to the next value.  If there was an error making
1249// the request the iterator does not advance and the error is returned.
1250func (iter *RunOutputCollectionIterator) NextWithContext(ctx context.Context) (err error) {
1251	if tracing.IsEnabled() {
1252		ctx = tracing.StartSpan(ctx, fqdn+"/RunOutputCollectionIterator.NextWithContext")
1253		defer func() {
1254			sc := -1
1255			if iter.Response().Response.Response != nil {
1256				sc = iter.Response().Response.Response.StatusCode
1257			}
1258			tracing.EndSpan(ctx, sc, err)
1259		}()
1260	}
1261	iter.i++
1262	if iter.i < len(iter.page.Values()) {
1263		return nil
1264	}
1265	err = iter.page.NextWithContext(ctx)
1266	if err != nil {
1267		iter.i--
1268		return err
1269	}
1270	iter.i = 0
1271	return nil
1272}
1273
1274// Next advances to the next value.  If there was an error making
1275// the request the iterator does not advance and the error is returned.
1276// Deprecated: Use NextWithContext() instead.
1277func (iter *RunOutputCollectionIterator) Next() error {
1278	return iter.NextWithContext(context.Background())
1279}
1280
1281// NotDone returns true if the enumeration should be started or is not yet complete.
1282func (iter RunOutputCollectionIterator) NotDone() bool {
1283	return iter.page.NotDone() && iter.i < len(iter.page.Values())
1284}
1285
1286// Response returns the raw server response from the last page request.
1287func (iter RunOutputCollectionIterator) Response() RunOutputCollection {
1288	return iter.page.Response()
1289}
1290
1291// Value returns the current value or a zero-initialized value if the
1292// iterator has advanced beyond the end of the collection.
1293func (iter RunOutputCollectionIterator) Value() RunOutput {
1294	if !iter.page.NotDone() {
1295		return RunOutput{}
1296	}
1297	return iter.page.Values()[iter.i]
1298}
1299
1300// Creates a new instance of the RunOutputCollectionIterator type.
1301func NewRunOutputCollectionIterator(page RunOutputCollectionPage) RunOutputCollectionIterator {
1302	return RunOutputCollectionIterator{page: page}
1303}
1304
1305// IsEmpty returns true if the ListResult contains no values.
1306func (roc RunOutputCollection) IsEmpty() bool {
1307	return roc.Value == nil || len(*roc.Value) == 0
1308}
1309
1310// hasNextLink returns true if the NextLink is not empty.
1311func (roc RunOutputCollection) hasNextLink() bool {
1312	return roc.NextLink != nil && len(*roc.NextLink) != 0
1313}
1314
1315// runOutputCollectionPreparer prepares a request to retrieve the next set of results.
1316// It returns nil if no more results exist.
1317func (roc RunOutputCollection) runOutputCollectionPreparer(ctx context.Context) (*http.Request, error) {
1318	if !roc.hasNextLink() {
1319		return nil, nil
1320	}
1321	return autorest.Prepare((&http.Request{}).WithContext(ctx),
1322		autorest.AsJSON(),
1323		autorest.AsGet(),
1324		autorest.WithBaseURL(to.String(roc.NextLink)))
1325}
1326
1327// RunOutputCollectionPage contains a page of RunOutput values.
1328type RunOutputCollectionPage struct {
1329	fn  func(context.Context, RunOutputCollection) (RunOutputCollection, error)
1330	roc RunOutputCollection
1331}
1332
1333// NextWithContext advances to the next page of values.  If there was an error making
1334// the request the page does not advance and the error is returned.
1335func (page *RunOutputCollectionPage) NextWithContext(ctx context.Context) (err error) {
1336	if tracing.IsEnabled() {
1337		ctx = tracing.StartSpan(ctx, fqdn+"/RunOutputCollectionPage.NextWithContext")
1338		defer func() {
1339			sc := -1
1340			if page.Response().Response.Response != nil {
1341				sc = page.Response().Response.Response.StatusCode
1342			}
1343			tracing.EndSpan(ctx, sc, err)
1344		}()
1345	}
1346	for {
1347		next, err := page.fn(ctx, page.roc)
1348		if err != nil {
1349			return err
1350		}
1351		page.roc = next
1352		if !next.hasNextLink() || !next.IsEmpty() {
1353			break
1354		}
1355	}
1356	return nil
1357}
1358
1359// Next advances to the next page of values.  If there was an error making
1360// the request the page does not advance and the error is returned.
1361// Deprecated: Use NextWithContext() instead.
1362func (page *RunOutputCollectionPage) Next() error {
1363	return page.NextWithContext(context.Background())
1364}
1365
1366// NotDone returns true if the page enumeration should be started or is not yet complete.
1367func (page RunOutputCollectionPage) NotDone() bool {
1368	return !page.roc.IsEmpty()
1369}
1370
1371// Response returns the raw server response from the last page request.
1372func (page RunOutputCollectionPage) Response() RunOutputCollection {
1373	return page.roc
1374}
1375
1376// Values returns the slice of values for the current page or nil if there are no values.
1377func (page RunOutputCollectionPage) Values() []RunOutput {
1378	if page.roc.IsEmpty() {
1379		return nil
1380	}
1381	return *page.roc.Value
1382}
1383
1384// Creates a new instance of the RunOutputCollectionPage type.
1385func NewRunOutputCollectionPage(cur RunOutputCollection, getNextPage func(context.Context, RunOutputCollection) (RunOutputCollection, error)) RunOutputCollectionPage {
1386	return RunOutputCollectionPage{
1387		fn:  getNextPage,
1388		roc: cur,
1389	}
1390}
1391
1392// RunOutputProperties ...
1393type RunOutputProperties struct {
1394	// ArtifactID - The resource id of the artifact.
1395	ArtifactID *string `json:"artifactId,omitempty"`
1396	// ProvisioningState - READ-ONLY; Provisioning state of the resource. Possible values include: 'ProvisioningState1Creating', 'ProvisioningState1Succeeded', 'ProvisioningState1Failed', 'ProvisioningState1Deleting'
1397	ProvisioningState ProvisioningState1 `json:"provisioningState,omitempty"`
1398}
1399
1400// MarshalJSON is the custom marshaler for RunOutputProperties.
1401func (rop RunOutputProperties) MarshalJSON() ([]byte, error) {
1402	objectMap := make(map[string]interface{})
1403	if rop.ArtifactID != nil {
1404		objectMap["artifactId"] = rop.ArtifactID
1405	}
1406	return json.Marshal(objectMap)
1407}
1408
1409// SubResource the Sub Resource model definition.
1410type SubResource struct {
1411	// ID - READ-ONLY; Resource Id
1412	ID *string `json:"id,omitempty"`
1413	// Name - Resource name
1414	Name *string `json:"name,omitempty"`
1415	// Type - READ-ONLY; Resource type
1416	Type *string `json:"type,omitempty"`
1417}
1418
1419// MarshalJSON is the custom marshaler for SubResource.
1420func (sr SubResource) MarshalJSON() ([]byte, error) {
1421	objectMap := make(map[string]interface{})
1422	if sr.Name != nil {
1423		objectMap["name"] = sr.Name
1424	}
1425	return json.Marshal(objectMap)
1426}
1427
1428// VirtualMachineImageTemplateCreateOrUpdateFuture an abstraction for monitoring and retrieving the results
1429// of a long-running operation.
1430type VirtualMachineImageTemplateCreateOrUpdateFuture struct {
1431	azure.FutureAPI
1432	// Result returns the result of the asynchronous operation.
1433	// If the operation has not completed it will return an error.
1434	Result func(VirtualMachineImageTemplateClient) (ImageTemplate, error)
1435}
1436
1437// UnmarshalJSON is the custom unmarshaller for CreateFuture.
1438func (future *VirtualMachineImageTemplateCreateOrUpdateFuture) UnmarshalJSON(body []byte) error {
1439	var azFuture azure.Future
1440	if err := json.Unmarshal(body, &azFuture); err != nil {
1441		return err
1442	}
1443	future.FutureAPI = &azFuture
1444	future.Result = future.result
1445	return nil
1446}
1447
1448// result is the default implementation for VirtualMachineImageTemplateCreateOrUpdateFuture.Result.
1449func (future *VirtualMachineImageTemplateCreateOrUpdateFuture) result(client VirtualMachineImageTemplateClient) (it ImageTemplate, err error) {
1450	var done bool
1451	done, err = future.DoneWithContext(context.Background(), client)
1452	if err != nil {
1453		err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplateCreateOrUpdateFuture", "Result", future.Response(), "Polling failure")
1454		return
1455	}
1456	if !done {
1457		it.Response.Response = future.Response()
1458		err = azure.NewAsyncOpIncompleteError("virtualmachineimagebuilder.VirtualMachineImageTemplateCreateOrUpdateFuture")
1459		return
1460	}
1461	sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1462	if it.Response.Response, err = future.GetResult(sender); err == nil && it.Response.Response.StatusCode != http.StatusNoContent {
1463		it, err = client.CreateOrUpdateResponder(it.Response.Response)
1464		if err != nil {
1465			err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplateCreateOrUpdateFuture", "Result", it.Response.Response, "Failure responding to request")
1466		}
1467	}
1468	return
1469}
1470
1471// VirtualMachineImageTemplateDeleteFuture an abstraction for monitoring and retrieving the results of a
1472// long-running operation.
1473type VirtualMachineImageTemplateDeleteFuture struct {
1474	azure.FutureAPI
1475	// Result returns the result of the asynchronous operation.
1476	// If the operation has not completed it will return an error.
1477	Result func(VirtualMachineImageTemplateClient) (autorest.Response, error)
1478}
1479
1480// UnmarshalJSON is the custom unmarshaller for CreateFuture.
1481func (future *VirtualMachineImageTemplateDeleteFuture) UnmarshalJSON(body []byte) error {
1482	var azFuture azure.Future
1483	if err := json.Unmarshal(body, &azFuture); err != nil {
1484		return err
1485	}
1486	future.FutureAPI = &azFuture
1487	future.Result = future.result
1488	return nil
1489}
1490
1491// result is the default implementation for VirtualMachineImageTemplateDeleteFuture.Result.
1492func (future *VirtualMachineImageTemplateDeleteFuture) result(client VirtualMachineImageTemplateClient) (ar autorest.Response, err error) {
1493	var done bool
1494	done, err = future.DoneWithContext(context.Background(), client)
1495	if err != nil {
1496		err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplateDeleteFuture", "Result", future.Response(), "Polling failure")
1497		return
1498	}
1499	if !done {
1500		ar.Response = future.Response()
1501		err = azure.NewAsyncOpIncompleteError("virtualmachineimagebuilder.VirtualMachineImageTemplateDeleteFuture")
1502		return
1503	}
1504	ar.Response = future.Response()
1505	return
1506}
1507
1508// VirtualMachineImageTemplateRunFuture an abstraction for monitoring and retrieving the results of a
1509// long-running operation.
1510type VirtualMachineImageTemplateRunFuture struct {
1511	azure.FutureAPI
1512	// Result returns the result of the asynchronous operation.
1513	// If the operation has not completed it will return an error.
1514	Result func(VirtualMachineImageTemplateClient) (autorest.Response, error)
1515}
1516
1517// UnmarshalJSON is the custom unmarshaller for CreateFuture.
1518func (future *VirtualMachineImageTemplateRunFuture) UnmarshalJSON(body []byte) error {
1519	var azFuture azure.Future
1520	if err := json.Unmarshal(body, &azFuture); err != nil {
1521		return err
1522	}
1523	future.FutureAPI = &azFuture
1524	future.Result = future.result
1525	return nil
1526}
1527
1528// result is the default implementation for VirtualMachineImageTemplateRunFuture.Result.
1529func (future *VirtualMachineImageTemplateRunFuture) result(client VirtualMachineImageTemplateClient) (ar autorest.Response, err error) {
1530	var done bool
1531	done, err = future.DoneWithContext(context.Background(), client)
1532	if err != nil {
1533		err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplateRunFuture", "Result", future.Response(), "Polling failure")
1534		return
1535	}
1536	if !done {
1537		ar.Response = future.Response()
1538		err = azure.NewAsyncOpIncompleteError("virtualmachineimagebuilder.VirtualMachineImageTemplateRunFuture")
1539		return
1540	}
1541	ar.Response = future.Response()
1542	return
1543}
1544