diff --git a/profiles/preview/preview/virtualmachineimagebuilder/mgmt/virtualmachineimagebuilder/models.go b/profiles/preview/preview/virtualmachineimagebuilder/mgmt/virtualmachineimagebuilder/models.go index 4cbf8db9cd82..694d94ff6a86 100644 --- a/profiles/preview/preview/virtualmachineimagebuilder/mgmt/virtualmachineimagebuilder/models.go +++ b/profiles/preview/preview/virtualmachineimagebuilder/mgmt/virtualmachineimagebuilder/models.go @@ -22,7 +22,7 @@ package virtualmachineimagebuilder import ( "context" - original "github.com/Azure/azure-sdk-for-go/services/preview/virtualmachineimagebuilder/mgmt/2018-02-01-preview/virtualmachineimagebuilder" + original "github.com/Azure/azure-sdk-for-go/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder" ) const ( @@ -32,13 +32,17 @@ const ( type ProvisioningErrorCode = original.ProvisioningErrorCode const ( - BadCustomizerType ProvisioningErrorCode = original.BadCustomizerType - BadISOSource ProvisioningErrorCode = original.BadISOSource - BadPIRSource ProvisioningErrorCode = original.BadPIRSource - BadSourceType ProvisioningErrorCode = original.BadSourceType - NoCustomizerShellScript ProvisioningErrorCode = original.NoCustomizerShellScript - Other ProvisioningErrorCode = original.Other - ServerError ProvisioningErrorCode = original.ServerError + BadCustomizerType ProvisioningErrorCode = original.BadCustomizerType + BadDistributeType ProvisioningErrorCode = original.BadDistributeType + BadISOSource ProvisioningErrorCode = original.BadISOSource + BadManagedImageSource ProvisioningErrorCode = original.BadManagedImageSource + BadPIRSource ProvisioningErrorCode = original.BadPIRSource + BadSharedImageDistribute ProvisioningErrorCode = original.BadSharedImageDistribute + BadSourceType ProvisioningErrorCode = original.BadSourceType + NoCustomizerScript ProvisioningErrorCode = original.NoCustomizerScript + Other ProvisioningErrorCode = original.Other + ServerError ProvisioningErrorCode = original.ServerError + UnsupportedCustomizerType ProvisioningErrorCode = original.UnsupportedCustomizerType ) type ProvisioningState = original.ProvisioningState @@ -64,7 +68,6 @@ type RunState = original.RunState const ( RunStateFailed RunState = original.RunStateFailed RunStatePartiallySucceeded RunState = original.RunStatePartiallySucceeded - RunStateReady RunState = original.RunStateReady RunStateRunning RunState = original.RunStateRunning RunStateSucceeded RunState = original.RunStateSucceeded ) @@ -83,6 +86,7 @@ type Type = original.Type const ( TypeImageTemplateSource Type = original.TypeImageTemplateSource TypeISO Type = original.TypeISO + TypeManagedImage Type = original.TypeManagedImage TypePlatformImage Type = original.TypePlatformImage ) @@ -90,15 +94,18 @@ type TypeBasicImageTemplateCustomizer = original.TypeBasicImageTemplateCustomize const ( TypeImageTemplateCustomizer TypeBasicImageTemplateCustomizer = original.TypeImageTemplateCustomizer + TypePowerShell TypeBasicImageTemplateCustomizer = original.TypePowerShell TypeShell TypeBasicImageTemplateCustomizer = original.TypeShell + TypeWindowsRestart TypeBasicImageTemplateCustomizer = original.TypeWindowsRestart ) type TypeBasicImageTemplateDistributor = original.TypeBasicImageTemplateDistributor const ( - TypeImageTemplateDistributor TypeBasicImageTemplateDistributor = original.TypeImageTemplateDistributor - TypeManagedImage TypeBasicImageTemplateDistributor = original.TypeManagedImage - TypeSharedImage TypeBasicImageTemplateDistributor = original.TypeSharedImage + TypeBasicImageTemplateDistributorTypeImageTemplateDistributor TypeBasicImageTemplateDistributor = original.TypeBasicImageTemplateDistributorTypeImageTemplateDistributor + TypeBasicImageTemplateDistributorTypeManagedImage TypeBasicImageTemplateDistributor = original.TypeBasicImageTemplateDistributorTypeManagedImage + TypeBasicImageTemplateDistributorTypeSharedImage TypeBasicImageTemplateDistributor = original.TypeBasicImageTemplateDistributorTypeSharedImage + TypeBasicImageTemplateDistributorTypeVHD TypeBasicImageTemplateDistributor = original.TypeBasicImageTemplateDistributorTypeVHD ) type APIError = original.APIError @@ -116,12 +123,16 @@ type ImageTemplateListResult = original.ImageTemplateListResult type ImageTemplateListResultIterator = original.ImageTemplateListResultIterator type ImageTemplateListResultPage = original.ImageTemplateListResultPage type ImageTemplateManagedImageDistributor = original.ImageTemplateManagedImageDistributor +type ImageTemplateManagedImageSource = original.ImageTemplateManagedImageSource type ImageTemplatePlatformImageSource = original.ImageTemplatePlatformImageSource +type ImageTemplatePowerShellCustomizer = original.ImageTemplatePowerShellCustomizer type ImageTemplateProperties = original.ImageTemplateProperties +type ImageTemplateRestartCustomizer = original.ImageTemplateRestartCustomizer type ImageTemplateSharedImageDistributor = original.ImageTemplateSharedImageDistributor type ImageTemplateShellCustomizer = original.ImageTemplateShellCustomizer type ImageTemplateSource = original.ImageTemplateSource type ImageTemplateUpdateParameters = original.ImageTemplateUpdateParameters +type ImageTemplateVhdDistributor = original.ImageTemplateVhdDistributor type InnerError = original.InnerError type Operation = original.Operation type OperationDisplay = original.OperationDisplay @@ -137,10 +148,10 @@ type RunOutputCollectionIterator = original.RunOutputCollectionIterator type RunOutputCollectionPage = original.RunOutputCollectionPage type RunOutputProperties = original.RunOutputProperties type SubResource = original.SubResource -type VirtualMachineImageTemplateClient = original.VirtualMachineImageTemplateClient -type VirtualMachineImageTemplateCreateOrUpdateFuture = original.VirtualMachineImageTemplateCreateOrUpdateFuture -type VirtualMachineImageTemplateDeleteFuture = original.VirtualMachineImageTemplateDeleteFuture -type VirtualMachineImageTemplateRunFuture = original.VirtualMachineImageTemplateRunFuture +type VirtualMachineImageTemplatesClient = original.VirtualMachineImageTemplatesClient +type VirtualMachineImageTemplatesCreateOrUpdateFuture = original.VirtualMachineImageTemplatesCreateOrUpdateFuture +type VirtualMachineImageTemplatesDeleteFuture = original.VirtualMachineImageTemplatesDeleteFuture +type VirtualMachineImageTemplatesRunFuture = original.VirtualMachineImageTemplatesRunFuture func New(subscriptionID string) BaseClient { return original.New(subscriptionID) @@ -169,11 +180,11 @@ func NewRunOutputCollectionIterator(page RunOutputCollectionPage) RunOutputColle func NewRunOutputCollectionPage(getNextPage func(context.Context, RunOutputCollection) (RunOutputCollection, error)) RunOutputCollectionPage { return original.NewRunOutputCollectionPage(getNextPage) } -func NewVirtualMachineImageTemplateClient(subscriptionID string) VirtualMachineImageTemplateClient { - return original.NewVirtualMachineImageTemplateClient(subscriptionID) +func NewVirtualMachineImageTemplatesClient(subscriptionID string) VirtualMachineImageTemplatesClient { + return original.NewVirtualMachineImageTemplatesClient(subscriptionID) } -func NewVirtualMachineImageTemplateClientWithBaseURI(baseURI string, subscriptionID string) VirtualMachineImageTemplateClient { - return original.NewVirtualMachineImageTemplateClientWithBaseURI(baseURI, subscriptionID) +func NewVirtualMachineImageTemplatesClientWithBaseURI(baseURI string, subscriptionID string) VirtualMachineImageTemplatesClient { + return original.NewVirtualMachineImageTemplatesClientWithBaseURI(baseURI, subscriptionID) } func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { return original.NewWithBaseURI(baseURI, subscriptionID) diff --git a/profiles/preview/preview/virtualmachineimagebuilder/mgmt/virtualmachineimagebuilder/virtualmachineimagebuilderapi/models.go b/profiles/preview/preview/virtualmachineimagebuilder/mgmt/virtualmachineimagebuilder/virtualmachineimagebuilderapi/models.go index 873dba0c98ab..643326c3dee2 100644 --- a/profiles/preview/preview/virtualmachineimagebuilder/mgmt/virtualmachineimagebuilder/virtualmachineimagebuilderapi/models.go +++ b/profiles/preview/preview/virtualmachineimagebuilder/mgmt/virtualmachineimagebuilder/virtualmachineimagebuilderapi/models.go @@ -19,7 +19,7 @@ package virtualmachineimagebuilderapi -import original "github.com/Azure/azure-sdk-for-go/services/preview/virtualmachineimagebuilder/mgmt/2018-02-01-preview/virtualmachineimagebuilder/virtualmachineimagebuilderapi" +import original "github.com/Azure/azure-sdk-for-go/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/virtualmachineimagebuilderapi" type OperationsClientAPI = original.OperationsClientAPI -type VirtualMachineImageTemplateClientAPI = original.VirtualMachineImageTemplateClientAPI +type VirtualMachineImageTemplatesClientAPI = original.VirtualMachineImageTemplatesClientAPI diff --git a/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/client.go b/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/client.go new file mode 100644 index 000000000000..bee46ec97dd2 --- /dev/null +++ b/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/client.go @@ -0,0 +1,52 @@ +// Package virtualmachineimagebuilder implements the Azure ARM Virtualmachineimagebuilder service API version +// 2019-02-01-preview. +// +// Azure Virtual Machine Image Builder Client +package virtualmachineimagebuilder + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Virtualmachineimagebuilder + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Virtualmachineimagebuilder. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client. +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/models.go b/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/models.go new file mode 100644 index 000000000000..69b1f1691a09 --- /dev/null +++ b/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/models.go @@ -0,0 +1,1920 @@ +package virtualmachineimagebuilder + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// 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" + +// ProvisioningErrorCode enumerates the values for provisioning error code. +type ProvisioningErrorCode string + +const ( + // BadCustomizerType ... + BadCustomizerType ProvisioningErrorCode = "BadCustomizerType" + // BadDistributeType ... + BadDistributeType ProvisioningErrorCode = "BadDistributeType" + // BadISOSource ... + BadISOSource ProvisioningErrorCode = "BadISOSource" + // BadManagedImageSource ... + BadManagedImageSource ProvisioningErrorCode = "BadManagedImageSource" + // BadPIRSource ... + BadPIRSource ProvisioningErrorCode = "BadPIRSource" + // BadSharedImageDistribute ... + BadSharedImageDistribute ProvisioningErrorCode = "BadSharedImageDistribute" + // BadSourceType ... + BadSourceType ProvisioningErrorCode = "BadSourceType" + // NoCustomizerScript ... + NoCustomizerScript ProvisioningErrorCode = "NoCustomizerScript" + // Other ... + Other ProvisioningErrorCode = "Other" + // ServerError ... + ServerError ProvisioningErrorCode = "ServerError" + // UnsupportedCustomizerType ... + UnsupportedCustomizerType ProvisioningErrorCode = "UnsupportedCustomizerType" +) + +// PossibleProvisioningErrorCodeValues returns an array of possible values for the ProvisioningErrorCode const type. +func PossibleProvisioningErrorCodeValues() []ProvisioningErrorCode { + return []ProvisioningErrorCode{BadCustomizerType, BadDistributeType, BadISOSource, BadManagedImageSource, BadPIRSource, BadSharedImageDistribute, BadSourceType, NoCustomizerScript, Other, ServerError, UnsupportedCustomizerType} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // Creating ... + Creating ProvisioningState = "Creating" + // Deleting ... + Deleting ProvisioningState = "Deleting" + // Failed ... + Failed ProvisioningState = "Failed" + // Succeeded ... + Succeeded ProvisioningState = "Succeeded" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{Creating, Deleting, Failed, Succeeded} +} + +// ProvisioningState1 enumerates the values for provisioning state 1. +type ProvisioningState1 string + +const ( + // ProvisioningState1Creating ... + ProvisioningState1Creating ProvisioningState1 = "Creating" + // ProvisioningState1Deleting ... + ProvisioningState1Deleting ProvisioningState1 = "Deleting" + // ProvisioningState1Failed ... + ProvisioningState1Failed ProvisioningState1 = "Failed" + // ProvisioningState1Succeeded ... + ProvisioningState1Succeeded ProvisioningState1 = "Succeeded" +) + +// PossibleProvisioningState1Values returns an array of possible values for the ProvisioningState1 const type. +func PossibleProvisioningState1Values() []ProvisioningState1 { + return []ProvisioningState1{ProvisioningState1Creating, ProvisioningState1Deleting, ProvisioningState1Failed, ProvisioningState1Succeeded} +} + +// RunState enumerates the values for run state. +type RunState string + +const ( + // RunStateFailed ... + RunStateFailed RunState = "Failed" + // RunStatePartiallySucceeded ... + RunStatePartiallySucceeded RunState = "PartiallySucceeded" + // RunStateRunning ... + RunStateRunning RunState = "Running" + // RunStateSucceeded ... + RunStateSucceeded RunState = "Succeeded" +) + +// PossibleRunStateValues returns an array of possible values for the RunState const type. +func PossibleRunStateValues() []RunState { + return []RunState{RunStateFailed, RunStatePartiallySucceeded, RunStateRunning, RunStateSucceeded} +} + +// RunSubState enumerates the values for run sub state. +type RunSubState string + +const ( + // Building ... + Building RunSubState = "Building" + // Customizing ... + Customizing RunSubState = "Customizing" + // Distributing ... + Distributing RunSubState = "Distributing" + // Queued ... + Queued RunSubState = "Queued" +) + +// PossibleRunSubStateValues returns an array of possible values for the RunSubState const type. +func PossibleRunSubStateValues() []RunSubState { + return []RunSubState{Building, Customizing, Distributing, Queued} +} + +// Type enumerates the values for type. +type Type string + +const ( + // TypeImageTemplateSource ... + TypeImageTemplateSource Type = "ImageTemplateSource" + // TypeISO ... + TypeISO Type = "ISO" + // TypeManagedImage ... + TypeManagedImage Type = "ManagedImage" + // TypePlatformImage ... + TypePlatformImage Type = "PlatformImage" +) + +// PossibleTypeValues returns an array of possible values for the Type const type. +func PossibleTypeValues() []Type { + return []Type{TypeImageTemplateSource, TypeISO, TypeManagedImage, TypePlatformImage} +} + +// TypeBasicImageTemplateCustomizer enumerates the values for type basic image template customizer. +type TypeBasicImageTemplateCustomizer string + +const ( + // TypeImageTemplateCustomizer ... + TypeImageTemplateCustomizer TypeBasicImageTemplateCustomizer = "ImageTemplateCustomizer" + // TypePowerShell ... + TypePowerShell TypeBasicImageTemplateCustomizer = "PowerShell" + // TypeShell ... + TypeShell TypeBasicImageTemplateCustomizer = "Shell" + // TypeWindowsRestart ... + TypeWindowsRestart TypeBasicImageTemplateCustomizer = "WindowsRestart" +) + +// PossibleTypeBasicImageTemplateCustomizerValues returns an array of possible values for the TypeBasicImageTemplateCustomizer const type. +func PossibleTypeBasicImageTemplateCustomizerValues() []TypeBasicImageTemplateCustomizer { + return []TypeBasicImageTemplateCustomizer{TypeImageTemplateCustomizer, TypePowerShell, TypeShell, TypeWindowsRestart} +} + +// TypeBasicImageTemplateDistributor enumerates the values for type basic image template distributor. +type TypeBasicImageTemplateDistributor string + +const ( + // TypeBasicImageTemplateDistributorTypeImageTemplateDistributor ... + TypeBasicImageTemplateDistributorTypeImageTemplateDistributor TypeBasicImageTemplateDistributor = "ImageTemplateDistributor" + // TypeBasicImageTemplateDistributorTypeManagedImage ... + TypeBasicImageTemplateDistributorTypeManagedImage TypeBasicImageTemplateDistributor = "ManagedImage" + // TypeBasicImageTemplateDistributorTypeSharedImage ... + TypeBasicImageTemplateDistributorTypeSharedImage TypeBasicImageTemplateDistributor = "SharedImage" + // TypeBasicImageTemplateDistributorTypeVHD ... + TypeBasicImageTemplateDistributorTypeVHD TypeBasicImageTemplateDistributor = "VHD" +) + +// PossibleTypeBasicImageTemplateDistributorValues returns an array of possible values for the TypeBasicImageTemplateDistributor const type. +func PossibleTypeBasicImageTemplateDistributorValues() []TypeBasicImageTemplateDistributor { + return []TypeBasicImageTemplateDistributor{TypeBasicImageTemplateDistributorTypeImageTemplateDistributor, TypeBasicImageTemplateDistributorTypeManagedImage, TypeBasicImageTemplateDistributorTypeSharedImage, TypeBasicImageTemplateDistributorTypeVHD} +} + +// 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 - Resource Id + ID *string `json:"id,omitempty"` + // Name - Resource name + Name *string `json:"name,omitempty"` + // Type - 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.ID != nil { + objectMap["id"] = it.ID + } + if it.Name != nil { + objectMap["name"] = it.Name + } + if it.Type != nil { + objectMap["type"] = it.Type + } + 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 +} + +// 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.NextLink == nil || len(to.String(itlr.NextLink)) < 1 { + 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) + }() + } + next, err := page.fn(ctx, page.itlr) + if err != nil { + return err + } + page.itlr = next + 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(getNextPage func(context.Context, ImageTemplateListResult) (ImageTemplateListResult, error)) ImageTemplateListResultPage { + return ImageTemplateListResultPage{fn: getNextPage} +} + +// 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 +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"` + 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.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 - Provisioning state of the resource. Possible values include: 'Creating', 'Succeeded', 'Failed', 'Deleting' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // ProvisioningError - Provisioning error, if any + ProvisioningError *ProvisioningError `json:"provisioningError,omitempty"` + // LastRunStatus - State of 'run' that is currently executing or was last executed. + LastRunStatus *ImageTemplateLastRunStatus `json:"lastRunStatus,omitempty"` +} + +// 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 +} + +// AsImageTemplateSharedImageDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateSharedImageDistributor. +func (itsid ImageTemplateSharedImageDistributor) AsImageTemplateSharedImageDistributor() (*ImageTemplateSharedImageDistributor, bool) { + return &itsid, true +} + +// AsImageTemplateVhdDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateSharedImageDistributor. +func (itsid ImageTemplateSharedImageDistributor) AsImageTemplateVhdDistributor() (*ImageTemplateVhdDistributor, bool) { + return nil, false +} + +// AsImageTemplateDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateSharedImageDistributor. +func (itsid ImageTemplateSharedImageDistributor) AsImageTemplateDistributor() (*ImageTemplateDistributor, bool) { + return nil, false +} + +// AsBasicImageTemplateDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateSharedImageDistributor. +func (itsid ImageTemplateSharedImageDistributor) AsBasicImageTemplateDistributor() (BasicImageTemplateDistributor, bool) { + return &itsid, true +} + +// ImageTemplateShellCustomizer runs a shell script during the customization phase (Linux) +type ImageTemplateShellCustomizer struct { + // Script - The shell script to be run for customizing. It can be a github link, SAS URI for Azure Storage, etc + Script *string `json:"script,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 ImageTemplateShellCustomizer. +func (itsc ImageTemplateShellCustomizer) MarshalJSON() ([]byte, error) { + itsc.Type = TypeShell + objectMap := make(map[string]interface{}) + if itsc.Script != nil { + objectMap["script"] = itsc.Script + } + if itsc.Name != nil { + objectMap["name"] = itsc.Name + } + if itsc.Type != "" { + objectMap["type"] = itsc.Type + } + return json.Marshal(objectMap) +} + +// AsImageTemplateShellCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateShellCustomizer. +func (itsc ImageTemplateShellCustomizer) AsImageTemplateShellCustomizer() (*ImageTemplateShellCustomizer, bool) { + return &itsc, true +} + +// AsImageTemplateRestartCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateShellCustomizer. +func (itsc ImageTemplateShellCustomizer) AsImageTemplateRestartCustomizer() (*ImageTemplateRestartCustomizer, bool) { + return nil, false +} + +// AsImageTemplatePowerShellCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateShellCustomizer. +func (itsc ImageTemplateShellCustomizer) AsImageTemplatePowerShellCustomizer() (*ImageTemplatePowerShellCustomizer, bool) { + return nil, false +} + +// AsImageTemplateCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateShellCustomizer. +func (itsc ImageTemplateShellCustomizer) AsImageTemplateCustomizer() (*ImageTemplateCustomizer, bool) { + return nil, false +} + +// AsBasicImageTemplateCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateShellCustomizer. +func (itsc ImageTemplateShellCustomizer) AsBasicImageTemplateCustomizer() (BasicImageTemplateCustomizer, bool) { + return &itsc, true +} + +// BasicImageTemplateSource ... +type BasicImageTemplateSource interface { + AsImageTemplateIsoSource() (*ImageTemplateIsoSource, bool) + AsImageTemplatePlatformImageSource() (*ImageTemplatePlatformImageSource, bool) + AsImageTemplateManagedImageSource() (*ImageTemplateManagedImageSource, bool) + AsImageTemplateSource() (*ImageTemplateSource, bool) +} + +// ImageTemplateSource ... +type ImageTemplateSource struct { + // Type - Possible values include: 'TypeImageTemplateSource', 'TypeISO', 'TypePlatformImage', 'TypeManagedImage' + Type Type `json:"type,omitempty"` +} + +func unmarshalBasicImageTemplateSource(body []byte) (BasicImageTemplateSource, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["type"] { + case string(TypeISO): + var itis ImageTemplateIsoSource + err := json.Unmarshal(body, &itis) + return itis, err + case string(TypePlatformImage): + var itpis ImageTemplatePlatformImageSource + err := json.Unmarshal(body, &itpis) + return itpis, err + case string(TypeManagedImage): + var itmis ImageTemplateManagedImageSource + err := json.Unmarshal(body, &itmis) + return itmis, err + default: + var its ImageTemplateSource + err := json.Unmarshal(body, &its) + return its, err + } +} +func unmarshalBasicImageTemplateSourceArray(body []byte) ([]BasicImageTemplateSource, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + itsArray := make([]BasicImageTemplateSource, len(rawMessages)) + + for index, rawMessage := range rawMessages { + its, err := unmarshalBasicImageTemplateSource(*rawMessage) + if err != nil { + return nil, err + } + itsArray[index] = its + } + return itsArray, nil +} + +// MarshalJSON is the custom marshaler for ImageTemplateSource. +func (its ImageTemplateSource) MarshalJSON() ([]byte, error) { + its.Type = TypeImageTemplateSource + objectMap := make(map[string]interface{}) + if its.Type != "" { + objectMap["type"] = its.Type + } + return json.Marshal(objectMap) +} + +// AsImageTemplateIsoSource is the BasicImageTemplateSource implementation for ImageTemplateSource. +func (its ImageTemplateSource) AsImageTemplateIsoSource() (*ImageTemplateIsoSource, bool) { + return nil, false +} + +// AsImageTemplatePlatformImageSource is the BasicImageTemplateSource implementation for ImageTemplateSource. +func (its ImageTemplateSource) AsImageTemplatePlatformImageSource() (*ImageTemplatePlatformImageSource, bool) { + return nil, false +} + +// AsImageTemplateManagedImageSource is the BasicImageTemplateSource implementation for ImageTemplateSource. +func (its ImageTemplateSource) AsImageTemplateManagedImageSource() (*ImageTemplateManagedImageSource, bool) { + return nil, false +} + +// AsImageTemplateSource is the BasicImageTemplateSource implementation for ImageTemplateSource. +func (its ImageTemplateSource) AsImageTemplateSource() (*ImageTemplateSource, bool) { + return &its, true +} + +// AsBasicImageTemplateSource is the BasicImageTemplateSource implementation for ImageTemplateSource. +func (its ImageTemplateSource) AsBasicImageTemplateSource() (BasicImageTemplateSource, bool) { + return &its, true +} + +// ImageTemplateUpdateParameters parameters for updating an image template. +type ImageTemplateUpdateParameters struct { + // Tags - The user-specified tags associated with the image template. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ImageTemplateUpdateParameters. +func (itup ImageTemplateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if itup.Tags != nil { + objectMap["tags"] = itup.Tags + } + return json.Marshal(objectMap) +} + +// ImageTemplateVhdDistributor distribute via VHD in a storage account. +type ImageTemplateVhdDistributor 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"` +} + +// MarshalJSON is the custom marshaler for ImageTemplateVhdDistributor. +func (itvd ImageTemplateVhdDistributor) MarshalJSON() ([]byte, error) { + itvd.Type = TypeBasicImageTemplateDistributorTypeVHD + objectMap := make(map[string]interface{}) + if itvd.RunOutputName != nil { + objectMap["runOutputName"] = itvd.RunOutputName + } + if itvd.ArtifactTags != nil { + objectMap["artifactTags"] = itvd.ArtifactTags + } + if itvd.Type != "" { + objectMap["type"] = itvd.Type + } + return json.Marshal(objectMap) +} + +// AsImageTemplateManagedImageDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateVhdDistributor. +func (itvd ImageTemplateVhdDistributor) AsImageTemplateManagedImageDistributor() (*ImageTemplateManagedImageDistributor, bool) { + return nil, false +} + +// AsImageTemplateSharedImageDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateVhdDistributor. +func (itvd ImageTemplateVhdDistributor) AsImageTemplateSharedImageDistributor() (*ImageTemplateSharedImageDistributor, bool) { + return nil, false +} + +// AsImageTemplateVhdDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateVhdDistributor. +func (itvd ImageTemplateVhdDistributor) AsImageTemplateVhdDistributor() (*ImageTemplateVhdDistributor, bool) { + return &itvd, true +} + +// AsImageTemplateDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateVhdDistributor. +func (itvd ImageTemplateVhdDistributor) AsImageTemplateDistributor() (*ImageTemplateDistributor, bool) { + return nil, false +} + +// AsBasicImageTemplateDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateVhdDistributor. +func (itvd ImageTemplateVhdDistributor) AsBasicImageTemplateDistributor() (BasicImageTemplateDistributor, bool) { + return &itvd, true +} + +// InnerError inner error details. +type InnerError struct { + // ExceptionType - The exception type. + ExceptionType *string `json:"exceptionType,omitempty"` + // ErrorDetail - The internal error message or exception dump. + ErrorDetail *string `json:"errorDetail,omitempty"` +} + +// Operation ... +type Operation struct { + // Name - This is of the format {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + Display *OperationDisplay `json:"display,omitempty"` + Origin *string `json:"origin,omitempty"` + Properties interface{} `json:"properties,omitempty"` +} + +// OperationDisplay ... +type OperationDisplay struct { + Provider *string `json:"provider,omitempty"` + // Operation - For example: read, write, delete, or listKeys/action + Operation *string `json:"operation,omitempty"` + Resource *string `json:"resource,omitempty"` + Description *string `json:"description,omitempty"` +} + +// OperationListResult ... +type OperationListResult struct { + autorest.Response `json:"-"` + Value *[]Operation `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// 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 *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.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 *OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) 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 OperationListResultIterator) Response() OperationListResult { + 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 OperationListResultIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListResultIterator type. +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// 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 *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + 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 *OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []Operation { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationListResultPage type. +func NewOperationListResultPage(getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{fn: getNextPage} +} + +// ProvisioningError ... +type ProvisioningError struct { + // ProvisioningErrorCode - Error code of the provisioning failure. Possible values include: 'BadSourceType', 'BadPIRSource', 'BadISOSource', 'BadManagedImageSource', 'BadCustomizerType', 'UnsupportedCustomizerType', 'NoCustomizerScript', 'BadDistributeType', 'BadSharedImageDistribute', 'ServerError', 'Other' + ProvisioningErrorCode ProvisioningErrorCode `json:"provisioningErrorCode,omitempty"` + // Message - Verbose error message about the provisioning failure + Message *string `json:"message,omitempty"` +} + +// Resource the Resource model definition. +type Resource struct { + // ID - Resource Id + ID *string `json:"id,omitempty"` + // Name - Resource name + Name *string `json:"name,omitempty"` + // Type - 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 Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if r.ID != nil { + objectMap["id"] = r.ID + } + if r.Name != nil { + objectMap["name"] = r.Name + } + if r.Type != nil { + objectMap["type"] = r.Type + } + if r.Location != nil { + objectMap["location"] = r.Location + } + if r.Tags != nil { + objectMap["tags"] = r.Tags + } + return json.Marshal(objectMap) +} + +// RunOutput represents an output that was created by running an image template. +type RunOutput struct { + autorest.Response `json:"-"` + *RunOutputProperties `json:"properties,omitempty"` + // ID - Resource Id + ID *string `json:"id,omitempty"` + // Name - Resource name + Name *string `json:"name,omitempty"` + // Type - Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RunOutput. +func (ro RunOutput) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ro.RunOutputProperties != nil { + objectMap["properties"] = ro.RunOutputProperties + } + if ro.ID != nil { + objectMap["id"] = ro.ID + } + if ro.Name != nil { + objectMap["name"] = ro.Name + } + if ro.Type != nil { + objectMap["type"] = ro.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RunOutput struct. +func (ro *RunOutput) 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 runOutputProperties RunOutputProperties + err = json.Unmarshal(*v, &runOutputProperties) + if err != nil { + return err + } + ro.RunOutputProperties = &runOutputProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ro.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ro.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ro.Type = &typeVar + } + } + } + + return nil +} + +// RunOutputCollection ... +type RunOutputCollection struct { + autorest.Response `json:"-"` + Value *[]RunOutput `json:"value,omitempty"` + // NextLink - The continuation token. + NextLink *string `json:"nextLink,omitempty"` +} + +// RunOutputCollectionIterator provides access to a complete listing of RunOutput values. +type RunOutputCollectionIterator struct { + i int + page RunOutputCollectionPage +} + +// 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 *RunOutputCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RunOutputCollectionIterator.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 *RunOutputCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RunOutputCollectionIterator) 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 RunOutputCollectionIterator) Response() RunOutputCollection { + 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 RunOutputCollectionIterator) Value() RunOutput { + if !iter.page.NotDone() { + return RunOutput{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RunOutputCollectionIterator type. +func NewRunOutputCollectionIterator(page RunOutputCollectionPage) RunOutputCollectionIterator { + return RunOutputCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (roc RunOutputCollection) IsEmpty() bool { + return roc.Value == nil || len(*roc.Value) == 0 +} + +// runOutputCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (roc RunOutputCollection) runOutputCollectionPreparer(ctx context.Context) (*http.Request, error) { + if roc.NextLink == nil || len(to.String(roc.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(roc.NextLink))) +} + +// RunOutputCollectionPage contains a page of RunOutput values. +type RunOutputCollectionPage struct { + fn func(context.Context, RunOutputCollection) (RunOutputCollection, error) + roc RunOutputCollection +} + +// 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 *RunOutputCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RunOutputCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.roc) + if err != nil { + return err + } + page.roc = next + 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 *RunOutputCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RunOutputCollectionPage) NotDone() bool { + return !page.roc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RunOutputCollectionPage) Response() RunOutputCollection { + return page.roc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RunOutputCollectionPage) Values() []RunOutput { + if page.roc.IsEmpty() { + return nil + } + return *page.roc.Value +} + +// Creates a new instance of the RunOutputCollectionPage type. +func NewRunOutputCollectionPage(getNextPage func(context.Context, RunOutputCollection) (RunOutputCollection, error)) RunOutputCollectionPage { + return RunOutputCollectionPage{fn: getNextPage} +} + +// RunOutputProperties ... +type RunOutputProperties struct { + // ArtifactID - The resource id of the artifact. + ArtifactID *string `json:"artifactId,omitempty"` + // ArtifactLocation - The URL location of the artifact. + ArtifactLocation *string `json:"artifactLocation,omitempty"` + // ProvisioningState - Provisioning state of the resource. Possible values include: 'ProvisioningState1Creating', 'ProvisioningState1Succeeded', 'ProvisioningState1Failed', 'ProvisioningState1Deleting' + ProvisioningState ProvisioningState1 `json:"provisioningState,omitempty"` +} + +// SubResource the Sub Resource model definition. +type SubResource struct { + // ID - Resource Id + ID *string `json:"id,omitempty"` + // Name - Resource name + Name *string `json:"name,omitempty"` + // Type - Resource type + Type *string `json:"type,omitempty"` +} + +// VirtualMachineImageTemplatesCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type VirtualMachineImageTemplatesCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *VirtualMachineImageTemplatesCreateOrUpdateFuture) Result(client VirtualMachineImageTemplatesClient) (it ImageTemplate, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("virtualmachineimagebuilder.VirtualMachineImageTemplatesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if it.Response.Response, err = future.GetResult(sender); err == nil && it.Response.Response.StatusCode != http.StatusNoContent { + it, err = client.CreateOrUpdateResponder(it.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesCreateOrUpdateFuture", "Result", it.Response.Response, "Failure responding to request") + } + } + return +} + +// VirtualMachineImageTemplatesDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type VirtualMachineImageTemplatesDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *VirtualMachineImageTemplatesDeleteFuture) Result(client VirtualMachineImageTemplatesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("virtualmachineimagebuilder.VirtualMachineImageTemplatesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// VirtualMachineImageTemplatesRunFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type VirtualMachineImageTemplatesRunFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *VirtualMachineImageTemplatesRunFuture) Result(client VirtualMachineImageTemplatesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesRunFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("virtualmachineimagebuilder.VirtualMachineImageTemplatesRunFuture") + return + } + ar.Response = future.Response() + return +} diff --git a/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/operations.go b/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/operations.go new file mode 100644 index 000000000000..08d9fb32983c --- /dev/null +++ b/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/operations.go @@ -0,0 +1,147 @@ +package virtualmachineimagebuilder + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the azure Virtual Machine Image Builder Client +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists available operations for the Microsoft.VirtualMachineImages provider +func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2019-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.VirtualMachineImages/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "virtualmachineimagebuilder.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "virtualmachineimagebuilder.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/version.go b/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/version.go new file mode 100644 index 000000000000..ae7f0d11ccd6 --- /dev/null +++ b/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/version.go @@ -0,0 +1,30 @@ +package virtualmachineimagebuilder + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " virtualmachineimagebuilder/2019-02-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/virtualmachineimagebuilderapi/interfaces.go b/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/virtualmachineimagebuilderapi/interfaces.go new file mode 100644 index 000000000000..2082ac1d0277 --- /dev/null +++ b/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/virtualmachineimagebuilderapi/interfaces.go @@ -0,0 +1,45 @@ +package virtualmachineimagebuilderapi + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder" +) + +// VirtualMachineImageTemplatesClientAPI contains the set of methods on the VirtualMachineImageTemplatesClient type. +type VirtualMachineImageTemplatesClientAPI interface { + CreateOrUpdate(ctx context.Context, parameters virtualmachineimagebuilder.ImageTemplate, resourceGroupName string, imageTemplateName string) (result virtualmachineimagebuilder.VirtualMachineImageTemplatesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, imageTemplateName string) (result virtualmachineimagebuilder.VirtualMachineImageTemplatesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, imageTemplateName string) (result virtualmachineimagebuilder.ImageTemplate, err error) + GetRunOutput(ctx context.Context, resourceGroupName string, imageTemplateName string, runOutputName string) (result virtualmachineimagebuilder.RunOutput, err error) + List(ctx context.Context) (result virtualmachineimagebuilder.ImageTemplateListResultPage, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result virtualmachineimagebuilder.ImageTemplateListResultPage, err error) + ListRunOutputs(ctx context.Context, resourceGroupName string, imageTemplateName string) (result virtualmachineimagebuilder.RunOutputCollectionPage, err error) + Run(ctx context.Context, resourceGroupName string, imageTemplateName string) (result virtualmachineimagebuilder.VirtualMachineImageTemplatesRunFuture, err error) + Update(ctx context.Context, parameters virtualmachineimagebuilder.ImageTemplateUpdateParameters, resourceGroupName string, imageTemplateName string) (result virtualmachineimagebuilder.ImageTemplate, err error) +} + +var _ VirtualMachineImageTemplatesClientAPI = (*virtualmachineimagebuilder.VirtualMachineImageTemplatesClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result virtualmachineimagebuilder.OperationListResultPage, err error) +} + +var _ OperationsClientAPI = (*virtualmachineimagebuilder.OperationsClient)(nil) diff --git a/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/virtualmachineimagetemplates.go b/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/virtualmachineimagetemplates.go new file mode 100644 index 000000000000..22bac9d6b93c --- /dev/null +++ b/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/virtualmachineimagetemplates.go @@ -0,0 +1,898 @@ +package virtualmachineimagebuilder + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// VirtualMachineImageTemplatesClient is the azure Virtual Machine Image Builder Client +type VirtualMachineImageTemplatesClient struct { + BaseClient +} + +// NewVirtualMachineImageTemplatesClient creates an instance of the VirtualMachineImageTemplatesClient client. +func NewVirtualMachineImageTemplatesClient(subscriptionID string) VirtualMachineImageTemplatesClient { + return NewVirtualMachineImageTemplatesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewVirtualMachineImageTemplatesClientWithBaseURI creates an instance of the VirtualMachineImageTemplatesClient +// client. +func NewVirtualMachineImageTemplatesClientWithBaseURI(baseURI string, subscriptionID string) VirtualMachineImageTemplatesClient { + return VirtualMachineImageTemplatesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update a virtual machine image template +// Parameters: +// parameters - parameters supplied to the CreateImageTemplate operation +// resourceGroupName - the name of the resource group. +// imageTemplateName - the name of the image Template +func (client VirtualMachineImageTemplatesClient) CreateOrUpdate(ctx context.Context, parameters ImageTemplate, resourceGroupName string, imageTemplateName string) (result VirtualMachineImageTemplatesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineImageTemplatesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ImageTemplateProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ImageTemplateProperties.Source", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ImageTemplateProperties.Distribute", Name: validation.Null, Rule: true, Chain: nil}, + }}}}, + {TargetValue: imageTemplateName, + Constraints: []validation.Constraint{{Target: "imageTemplateName", Name: validation.Pattern, Rule: `^[A-Za-z0-9-_]{1,64}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, parameters, resourceGroupName, imageTemplateName) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client VirtualMachineImageTemplatesClient) CreateOrUpdatePreparer(ctx context.Context, parameters ImageTemplate, resourceGroupName string, imageTemplateName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "imageTemplateName": autorest.Encode("path", imageTemplateName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachineImageTemplatesClient) CreateOrUpdateSender(req *http.Request) (future VirtualMachineImageTemplatesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client VirtualMachineImageTemplatesClient) CreateOrUpdateResponder(resp *http.Response) (result ImageTemplate, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a virtual machine image template +// Parameters: +// resourceGroupName - the name of the resource group. +// imageTemplateName - the name of the image Template +func (client VirtualMachineImageTemplatesClient) Delete(ctx context.Context, resourceGroupName string, imageTemplateName string) (result VirtualMachineImageTemplatesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineImageTemplatesClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: imageTemplateName, + Constraints: []validation.Constraint{{Target: "imageTemplateName", Name: validation.Pattern, Rule: `^[A-Za-z0-9-_]{1,64}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, imageTemplateName) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client VirtualMachineImageTemplatesClient) DeletePreparer(ctx context.Context, resourceGroupName string, imageTemplateName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "imageTemplateName": autorest.Encode("path", imageTemplateName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachineImageTemplatesClient) DeleteSender(req *http.Request) (future VirtualMachineImageTemplatesDeleteFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client VirtualMachineImageTemplatesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get information about a virtual machine image template +// Parameters: +// resourceGroupName - the name of the resource group. +// imageTemplateName - the name of the image Template +func (client VirtualMachineImageTemplatesClient) Get(ctx context.Context, resourceGroupName string, imageTemplateName string) (result ImageTemplate, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineImageTemplatesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: imageTemplateName, + Constraints: []validation.Constraint{{Target: "imageTemplateName", Name: validation.Pattern, Rule: `^[A-Za-z0-9-_]{1,64}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, imageTemplateName) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client VirtualMachineImageTemplatesClient) GetPreparer(ctx context.Context, resourceGroupName string, imageTemplateName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "imageTemplateName": autorest.Encode("path", imageTemplateName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachineImageTemplatesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client VirtualMachineImageTemplatesClient) GetResponder(resp *http.Response) (result ImageTemplate, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetRunOutput get the specified run output for the specified image template resource +// Parameters: +// resourceGroupName - the name of the resource group. +// imageTemplateName - the name of the image Template +// runOutputName - the name of the run output +func (client VirtualMachineImageTemplatesClient) GetRunOutput(ctx context.Context, resourceGroupName string, imageTemplateName string, runOutputName string) (result RunOutput, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineImageTemplatesClient.GetRunOutput") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: imageTemplateName, + Constraints: []validation.Constraint{{Target: "imageTemplateName", Name: validation.Pattern, Rule: `^[A-Za-z0-9-_]{1,64}$`, Chain: nil}}}, + {TargetValue: runOutputName, + Constraints: []validation.Constraint{{Target: "runOutputName", Name: validation.Pattern, Rule: `^[A-Za-z0-9-_]{1,64}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "GetRunOutput", err.Error()) + } + + req, err := client.GetRunOutputPreparer(ctx, resourceGroupName, imageTemplateName, runOutputName) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "GetRunOutput", nil, "Failure preparing request") + return + } + + resp, err := client.GetRunOutputSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "GetRunOutput", resp, "Failure sending request") + return + } + + result, err = client.GetRunOutputResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "GetRunOutput", resp, "Failure responding to request") + } + + return +} + +// GetRunOutputPreparer prepares the GetRunOutput request. +func (client VirtualMachineImageTemplatesClient) GetRunOutputPreparer(ctx context.Context, resourceGroupName string, imageTemplateName string, runOutputName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "imageTemplateName": autorest.Encode("path", imageTemplateName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runOutputName": autorest.Encode("path", runOutputName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/runOutputs/{runOutputName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetRunOutputSender sends the GetRunOutput request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachineImageTemplatesClient) GetRunOutputSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetRunOutputResponder handles the response to the GetRunOutput request. The method always +// closes the http.Response Body. +func (client VirtualMachineImageTemplatesClient) GetRunOutputResponder(resp *http.Response) (result RunOutput, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets information about the VM image templates associated with the subscription. +func (client VirtualMachineImageTemplatesClient) List(ctx context.Context) (result ImageTemplateListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineImageTemplatesClient.List") + defer func() { + sc := -1 + if result.itlr.Response.Response != nil { + sc = result.itlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.itlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "List", resp, "Failure sending request") + return + } + + result.itlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client VirtualMachineImageTemplatesClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.VirtualMachineImages/imageTemplates", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachineImageTemplatesClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client VirtualMachineImageTemplatesClient) ListResponder(resp *http.Response) (result ImageTemplateListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client VirtualMachineImageTemplatesClient) listNextResults(ctx context.Context, lastResults ImageTemplateListResult) (result ImageTemplateListResult, err error) { + req, err := lastResults.imageTemplateListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client VirtualMachineImageTemplatesClient) ListComplete(ctx context.Context) (result ImageTemplateListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineImageTemplatesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup gets information about the VM image templates associated with the specified resource group. +// Parameters: +// resourceGroupName - the name of the resource group. +func (client VirtualMachineImageTemplatesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ImageTemplateListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineImageTemplatesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.itlr.Response.Response != nil { + sc = result.itlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.itlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.itlr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client VirtualMachineImageTemplatesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachineImageTemplatesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client VirtualMachineImageTemplatesClient) ListByResourceGroupResponder(resp *http.Response) (result ImageTemplateListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client VirtualMachineImageTemplatesClient) listByResourceGroupNextResults(ctx context.Context, lastResults ImageTemplateListResult) (result ImageTemplateListResult, err error) { + req, err := lastResults.imageTemplateListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client VirtualMachineImageTemplatesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ImageTemplateListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineImageTemplatesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListRunOutputs list all run outputs for the specified Image Template resource +// Parameters: +// resourceGroupName - the name of the resource group. +// imageTemplateName - the name of the image Template +func (client VirtualMachineImageTemplatesClient) ListRunOutputs(ctx context.Context, resourceGroupName string, imageTemplateName string) (result RunOutputCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineImageTemplatesClient.ListRunOutputs") + defer func() { + sc := -1 + if result.roc.Response.Response != nil { + sc = result.roc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: imageTemplateName, + Constraints: []validation.Constraint{{Target: "imageTemplateName", Name: validation.Pattern, Rule: `^[A-Za-z0-9-_]{1,64}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "ListRunOutputs", err.Error()) + } + + result.fn = client.listRunOutputsNextResults + req, err := client.ListRunOutputsPreparer(ctx, resourceGroupName, imageTemplateName) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "ListRunOutputs", nil, "Failure preparing request") + return + } + + resp, err := client.ListRunOutputsSender(req) + if err != nil { + result.roc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "ListRunOutputs", resp, "Failure sending request") + return + } + + result.roc, err = client.ListRunOutputsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "ListRunOutputs", resp, "Failure responding to request") + } + + return +} + +// ListRunOutputsPreparer prepares the ListRunOutputs request. +func (client VirtualMachineImageTemplatesClient) ListRunOutputsPreparer(ctx context.Context, resourceGroupName string, imageTemplateName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "imageTemplateName": autorest.Encode("path", imageTemplateName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/runOutputs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListRunOutputsSender sends the ListRunOutputs request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachineImageTemplatesClient) ListRunOutputsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListRunOutputsResponder handles the response to the ListRunOutputs request. The method always +// closes the http.Response Body. +func (client VirtualMachineImageTemplatesClient) ListRunOutputsResponder(resp *http.Response) (result RunOutputCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listRunOutputsNextResults retrieves the next set of results, if any. +func (client VirtualMachineImageTemplatesClient) listRunOutputsNextResults(ctx context.Context, lastResults RunOutputCollection) (result RunOutputCollection, err error) { + req, err := lastResults.runOutputCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "listRunOutputsNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListRunOutputsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "listRunOutputsNextResults", resp, "Failure sending next results request") + } + result, err = client.ListRunOutputsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "listRunOutputsNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListRunOutputsComplete enumerates all values, automatically crossing page boundaries as required. +func (client VirtualMachineImageTemplatesClient) ListRunOutputsComplete(ctx context.Context, resourceGroupName string, imageTemplateName string) (result RunOutputCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineImageTemplatesClient.ListRunOutputs") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListRunOutputs(ctx, resourceGroupName, imageTemplateName) + return +} + +// Run create artifacts from a existing image template +// Parameters: +// resourceGroupName - the name of the resource group. +// imageTemplateName - the name of the image Template +func (client VirtualMachineImageTemplatesClient) Run(ctx context.Context, resourceGroupName string, imageTemplateName string) (result VirtualMachineImageTemplatesRunFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineImageTemplatesClient.Run") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: imageTemplateName, + Constraints: []validation.Constraint{{Target: "imageTemplateName", Name: validation.Pattern, Rule: `^[A-Za-z0-9-_]{1,64}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "Run", err.Error()) + } + + req, err := client.RunPreparer(ctx, resourceGroupName, imageTemplateName) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "Run", nil, "Failure preparing request") + return + } + + result, err = client.RunSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "Run", result.Response(), "Failure sending request") + return + } + + return +} + +// RunPreparer prepares the Run request. +func (client VirtualMachineImageTemplatesClient) RunPreparer(ctx context.Context, resourceGroupName string, imageTemplateName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "imageTemplateName": autorest.Encode("path", imageTemplateName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/run", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RunSender sends the Run request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachineImageTemplatesClient) RunSender(req *http.Request) (future VirtualMachineImageTemplatesRunFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// RunResponder handles the response to the Run request. The method always +// closes the http.Response Body. +func (client VirtualMachineImageTemplatesClient) RunResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update update the tags for this Virtual Machine Image Template +// Parameters: +// parameters - additional parameters for Image Template update. +// resourceGroupName - the name of the resource group. +// imageTemplateName - the name of the image Template +func (client VirtualMachineImageTemplatesClient) Update(ctx context.Context, parameters ImageTemplateUpdateParameters, resourceGroupName string, imageTemplateName string) (result ImageTemplate, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineImageTemplatesClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: imageTemplateName, + Constraints: []validation.Constraint{{Target: "imageTemplateName", Name: validation.Pattern, Rule: `^[A-Za-z0-9-_]{1,64}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, parameters, resourceGroupName, imageTemplateName) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client VirtualMachineImageTemplatesClient) UpdatePreparer(ctx context.Context, parameters ImageTemplateUpdateParameters, resourceGroupName string, imageTemplateName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "imageTemplateName": autorest.Encode("path", imageTemplateName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachineImageTemplatesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client VirtualMachineImageTemplatesClient) UpdateResponder(resp *http.Response) (result ImageTemplate, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +}