From 2e9930d248ae2cd48fed5021e7107386343a44b7 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 9 Dec 2021 06:12:08 +0000 Subject: [PATCH] CodeGen from PR 17018 in Azure/azure-rest-api-specs Add batch tag imagebuilder package-2021-10 (#17018) --- .../virtualmachineimagebuilder/CHANGELOG.md | 2 +- .../virtualmachineimagebuilder/_meta.json | 2 +- .../virtualmachineimagebuilder/CHANGELOG.md | 2 +- .../virtualmachineimagebuilder/_meta.json | 2 +- .../virtualmachineimagebuilder/CHANGELOG.md | 2 +- .../virtualmachineimagebuilder/_meta.json | 2 +- .../virtualmachineimagebuilder/CHANGELOG.md | 2 +- .../virtualmachineimagebuilder/_meta.json | 2 +- .../virtualmachineimagebuilder/CHANGELOG.md | 2 + .../virtualmachineimagebuilder/_meta.json | 11 + .../virtualmachineimagebuilder/client.go | 42 + .../virtualmachineimagebuilder/enums.go | 213 ++ .../virtualmachineimagebuilder/models.go | 2337 +++++++++++++++++ .../virtualmachineimagebuilder/operations.go | 140 + .../virtualmachineimagebuilder/version.go | 19 + .../interfaces.go | 39 + .../virtualmachineimagetemplates.go | 995 +++++++ 17 files changed, 3806 insertions(+), 8 deletions(-) create mode 100644 services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/CHANGELOG.md create mode 100644 services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/_meta.json create mode 100644 services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/client.go create mode 100644 services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/enums.go create mode 100644 services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/models.go create mode 100644 services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/operations.go create mode 100644 services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/version.go create mode 100644 services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/virtualmachineimagebuilderapi/interfaces.go create mode 100644 services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/virtualmachineimagetemplates.go diff --git a/services/preview/virtualmachineimagebuilder/mgmt/2018-02-01-preview/virtualmachineimagebuilder/CHANGELOG.md b/services/preview/virtualmachineimagebuilder/mgmt/2018-02-01-preview/virtualmachineimagebuilder/CHANGELOG.md index 52911e4cc5e4..a1ecf841edb0 100644 --- a/services/preview/virtualmachineimagebuilder/mgmt/2018-02-01-preview/virtualmachineimagebuilder/CHANGELOG.md +++ b/services/preview/virtualmachineimagebuilder/mgmt/2018-02-01-preview/virtualmachineimagebuilder/CHANGELOG.md @@ -1,2 +1,2 @@ -# Change History +# Unreleased diff --git a/services/preview/virtualmachineimagebuilder/mgmt/2018-02-01-preview/virtualmachineimagebuilder/_meta.json b/services/preview/virtualmachineimagebuilder/mgmt/2018-02-01-preview/virtualmachineimagebuilder/_meta.json index 6d721daf5fc6..0b41fb0ab146 100644 --- a/services/preview/virtualmachineimagebuilder/mgmt/2018-02-01-preview/virtualmachineimagebuilder/_meta.json +++ b/services/preview/virtualmachineimagebuilder/mgmt/2018-02-01-preview/virtualmachineimagebuilder/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "f64549f5f1d620d9fb70576a6c6a51d5eb305115", "readme": "/_/azure-rest-api-specs/specification/imagebuilder/resource-manager/readme.md", "tag": "package-2018-02", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/CHANGELOG.md b/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/CHANGELOG.md index 52911e4cc5e4..a1ecf841edb0 100644 --- a/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/CHANGELOG.md +++ b/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/CHANGELOG.md @@ -1,2 +1,2 @@ -# Change History +# Unreleased diff --git a/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/_meta.json b/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/_meta.json index 62d1e7ae97c4..c491d9188780 100644 --- a/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/_meta.json +++ b/services/preview/virtualmachineimagebuilder/mgmt/2019-02-01-preview/virtualmachineimagebuilder/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "f64549f5f1d620d9fb70576a6c6a51d5eb305115", "readme": "/_/azure-rest-api-specs/specification/imagebuilder/resource-manager/readme.md", "tag": "package-2019-02", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/preview/virtualmachineimagebuilder/mgmt/2019-05-01-preview/virtualmachineimagebuilder/CHANGELOG.md b/services/preview/virtualmachineimagebuilder/mgmt/2019-05-01-preview/virtualmachineimagebuilder/CHANGELOG.md index 52911e4cc5e4..a1ecf841edb0 100644 --- a/services/preview/virtualmachineimagebuilder/mgmt/2019-05-01-preview/virtualmachineimagebuilder/CHANGELOG.md +++ b/services/preview/virtualmachineimagebuilder/mgmt/2019-05-01-preview/virtualmachineimagebuilder/CHANGELOG.md @@ -1,2 +1,2 @@ -# Change History +# Unreleased diff --git a/services/preview/virtualmachineimagebuilder/mgmt/2019-05-01-preview/virtualmachineimagebuilder/_meta.json b/services/preview/virtualmachineimagebuilder/mgmt/2019-05-01-preview/virtualmachineimagebuilder/_meta.json index 03b428e65959..14488c6c93f1 100644 --- a/services/preview/virtualmachineimagebuilder/mgmt/2019-05-01-preview/virtualmachineimagebuilder/_meta.json +++ b/services/preview/virtualmachineimagebuilder/mgmt/2019-05-01-preview/virtualmachineimagebuilder/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "f64549f5f1d620d9fb70576a6c6a51d5eb305115", "readme": "/_/azure-rest-api-specs/specification/imagebuilder/resource-manager/readme.md", "tag": "package-preview-2019-05", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/virtualmachineimagebuilder/mgmt/2020-02-14/virtualmachineimagebuilder/CHANGELOG.md b/services/virtualmachineimagebuilder/mgmt/2020-02-14/virtualmachineimagebuilder/CHANGELOG.md index 52911e4cc5e4..a1ecf841edb0 100644 --- a/services/virtualmachineimagebuilder/mgmt/2020-02-14/virtualmachineimagebuilder/CHANGELOG.md +++ b/services/virtualmachineimagebuilder/mgmt/2020-02-14/virtualmachineimagebuilder/CHANGELOG.md @@ -1,2 +1,2 @@ -# Change History +# Unreleased diff --git a/services/virtualmachineimagebuilder/mgmt/2020-02-14/virtualmachineimagebuilder/_meta.json b/services/virtualmachineimagebuilder/mgmt/2020-02-14/virtualmachineimagebuilder/_meta.json index 38d5abcde5c5..44c4b531e4cb 100644 --- a/services/virtualmachineimagebuilder/mgmt/2020-02-14/virtualmachineimagebuilder/_meta.json +++ b/services/virtualmachineimagebuilder/mgmt/2020-02-14/virtualmachineimagebuilder/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c5135f8325eaf79be7b137cae363bdcba028c17", + "commit": "f64549f5f1d620d9fb70576a6c6a51d5eb305115", "readme": "/_/azure-rest-api-specs/specification/imagebuilder/resource-manager/readme.md", "tag": "package-2020-02", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/CHANGELOG.md b/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/CHANGELOG.md new file mode 100644 index 000000000000..a1ecf841edb0 --- /dev/null +++ b/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/CHANGELOG.md @@ -0,0 +1,2 @@ +# Unreleased + diff --git a/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/_meta.json b/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/_meta.json new file mode 100644 index 000000000000..d2e024c022e5 --- /dev/null +++ b/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "f64549f5f1d620d9fb70576a6c6a51d5eb305115", + "readme": "/_/azure-rest-api-specs/specification/imagebuilder/resource-manager/readme.md", + "tag": "package-2021-10", + "use": "@microsoft.azure/autorest.go@2.1.187", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-2021-10 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/imagebuilder/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION" + } +} \ No newline at end of file diff --git a/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/client.go b/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/client.go new file mode 100644 index 000000000000..6b8d72b201e4 --- /dev/null +++ b/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/client.go @@ -0,0 +1,42 @@ +// Package virtualmachineimagebuilder implements the Azure ARM Virtualmachineimagebuilder service API version +// 2021-10-01. +// +// Azure Virtual Machine Image Builder Client +package virtualmachineimagebuilder + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "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 using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/enums.go b/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/enums.go new file mode 100644 index 000000000000..bae2b7e2f0a2 --- /dev/null +++ b/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/enums.go @@ -0,0 +1,213 @@ +package virtualmachineimagebuilder + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// CreatedByType enumerates the values for created by type. +type CreatedByType string + +const ( + // Application ... + Application CreatedByType = "Application" + // Key ... + Key CreatedByType = "Key" + // ManagedIdentity ... + ManagedIdentity CreatedByType = "ManagedIdentity" + // User ... + User CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns an array of possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{Application, Key, ManagedIdentity, User} +} + +// ProvisioningErrorCode enumerates the values for provisioning error code. +type ProvisioningErrorCode string + +const ( + // BadCustomizerType ... + BadCustomizerType ProvisioningErrorCode = "BadCustomizerType" + // BadDistributeType ... + BadDistributeType ProvisioningErrorCode = "BadDistributeType" + // BadManagedImageSource ... + BadManagedImageSource ProvisioningErrorCode = "BadManagedImageSource" + // BadPIRSource ... + BadPIRSource ProvisioningErrorCode = "BadPIRSource" + // BadSharedImageDistribute ... + BadSharedImageDistribute ProvisioningErrorCode = "BadSharedImageDistribute" + // BadSharedImageVersionSource ... + BadSharedImageVersionSource ProvisioningErrorCode = "BadSharedImageVersionSource" + // 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, BadManagedImageSource, BadPIRSource, BadSharedImageDistribute, BadSharedImageVersionSource, 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" + // Updating ... + Updating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{Creating, Deleting, Failed, Succeeded, Updating} +} + +// ResourceIdentityType enumerates the values for resource identity type. +type ResourceIdentityType string + +const ( + // None ... + None ResourceIdentityType = "None" + // UserAssigned ... + UserAssigned ResourceIdentityType = "UserAssigned" +) + +// PossibleResourceIdentityTypeValues returns an array of possible values for the ResourceIdentityType const type. +func PossibleResourceIdentityTypeValues() []ResourceIdentityType { + return []ResourceIdentityType{None, UserAssigned} +} + +// RunState enumerates the values for run state. +type RunState string + +const ( + // RunStateCanceled ... + RunStateCanceled RunState = "Canceled" + // RunStateCanceling ... + RunStateCanceling RunState = "Canceling" + // 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{RunStateCanceled, RunStateCanceling, 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} +} + +// SharedImageStorageAccountType enumerates the values for shared image storage account type. +type SharedImageStorageAccountType string + +const ( + // StandardLRS ... + StandardLRS SharedImageStorageAccountType = "Standard_LRS" + // StandardZRS ... + StandardZRS SharedImageStorageAccountType = "Standard_ZRS" +) + +// PossibleSharedImageStorageAccountTypeValues returns an array of possible values for the SharedImageStorageAccountType const type. +func PossibleSharedImageStorageAccountTypeValues() []SharedImageStorageAccountType { + return []SharedImageStorageAccountType{StandardLRS, StandardZRS} +} + +// Type enumerates the values for type. +type Type string + +const ( + // TypeImageTemplateSource ... + TypeImageTemplateSource Type = "ImageTemplateSource" + // TypeManagedImage ... + TypeManagedImage Type = "ManagedImage" + // TypePlatformImage ... + TypePlatformImage Type = "PlatformImage" + // TypeSharedImageVersion ... + TypeSharedImageVersion Type = "SharedImageVersion" +) + +// PossibleTypeValues returns an array of possible values for the Type const type. +func PossibleTypeValues() []Type { + return []Type{TypeImageTemplateSource, TypeManagedImage, TypePlatformImage, TypeSharedImageVersion} +} + +// TypeBasicImageTemplateCustomizer enumerates the values for type basic image template customizer. +type TypeBasicImageTemplateCustomizer string + +const ( + // TypeFile ... + TypeFile TypeBasicImageTemplateCustomizer = "File" + // TypeImageTemplateCustomizer ... + TypeImageTemplateCustomizer TypeBasicImageTemplateCustomizer = "ImageTemplateCustomizer" + // TypePowerShell ... + TypePowerShell TypeBasicImageTemplateCustomizer = "PowerShell" + // TypeShell ... + TypeShell TypeBasicImageTemplateCustomizer = "Shell" + // TypeWindowsRestart ... + TypeWindowsRestart TypeBasicImageTemplateCustomizer = "WindowsRestart" + // TypeWindowsUpdate ... + TypeWindowsUpdate TypeBasicImageTemplateCustomizer = "WindowsUpdate" +) + +// PossibleTypeBasicImageTemplateCustomizerValues returns an array of possible values for the TypeBasicImageTemplateCustomizer const type. +func PossibleTypeBasicImageTemplateCustomizerValues() []TypeBasicImageTemplateCustomizer { + return []TypeBasicImageTemplateCustomizer{TypeFile, TypeImageTemplateCustomizer, TypePowerShell, TypeShell, TypeWindowsRestart, TypeWindowsUpdate} +} + +// 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} +} diff --git a/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/models.go b/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/models.go new file mode 100644 index 000000000000..ef66b81efeda --- /dev/null +++ b/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/models.go @@ -0,0 +1,2337 @@ +package virtualmachineimagebuilder + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder" + +// AzureEntityResource the resource model definition for an Azure Resource Manager resource with an etag. +type AzureEntityResource struct { + // Etag - READ-ONLY; Resource Etag. + Etag *string `json:"etag,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AzureEntityResource. +func (aer AzureEntityResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// CloudError an error response from the Azure VM Image Builder service. +type CloudError struct { + // Error - Details about the error. + Error *CloudErrorBody `json:"error,omitempty"` +} + +// CloudErrorBody an error response from the Azure VM Image Builder service. +type CloudErrorBody struct { + // Code - An identifier for the error. Codes are invariant and are intended to be consumed programmatically. + Code *string `json:"code,omitempty"` + // Message - A message describing the error, intended to be suitable for display in a user interface. + Message *string `json:"message,omitempty"` + // Target - The target of the particular error. For example, the name of the property in error. + Target *string `json:"target,omitempty"` + // Details - A list of additional details about the error. + Details *[]CloudErrorBody `json:"details,omitempty"` +} + +// ImageTemplate image template is an ARM resource managed by Microsoft.VirtualMachineImages provider +type ImageTemplate struct { + autorest.Response `json:"-"` + // ImageTemplateProperties - The properties of the image template + *ImageTemplateProperties `json:"properties,omitempty"` + // Identity - The identity of the image template, if configured. + Identity *ImageTemplateIdentity `json:"identity,omitempty"` + // SystemData - Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// 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.Identity != nil { + objectMap["identity"] = it.Identity + } + if it.SystemData != nil { + objectMap["systemData"] = it.SystemData + } + if it.Tags != nil { + objectMap["tags"] = it.Tags + } + if it.Location != nil { + objectMap["location"] = it.Location + } + 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 "identity": + if v != nil { + var identity ImageTemplateIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + it.Identity = &identity + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + it.SystemData = &systemData + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + it.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + it.Location = &location + } + 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 + } + } + } + + return nil +} + +// BasicImageTemplateCustomizer describes a unit of image customization +type BasicImageTemplateCustomizer interface { + AsImageTemplateShellCustomizer() (*ImageTemplateShellCustomizer, bool) + AsImageTemplateRestartCustomizer() (*ImageTemplateRestartCustomizer, bool) + AsImageTemplateWindowsUpdateCustomizer() (*ImageTemplateWindowsUpdateCustomizer, bool) + AsImageTemplatePowerShellCustomizer() (*ImageTemplatePowerShellCustomizer, bool) + AsImageTemplateFileCustomizer() (*ImageTemplateFileCustomizer, bool) + AsImageTemplateCustomizer() (*ImageTemplateCustomizer, bool) +} + +// ImageTemplateCustomizer describes a unit of image customization +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', 'TypeWindowsUpdate', 'TypePowerShell', 'TypeFile' + 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(TypeWindowsUpdate): + var itwuc ImageTemplateWindowsUpdateCustomizer + err := json.Unmarshal(body, &itwuc) + return itwuc, err + case string(TypePowerShell): + var itpsc ImageTemplatePowerShellCustomizer + err := json.Unmarshal(body, &itpsc) + return itpsc, err + case string(TypeFile): + var itfc ImageTemplateFileCustomizer + err := json.Unmarshal(body, &itfc) + return itfc, 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 +} + +// AsImageTemplateWindowsUpdateCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateCustomizer. +func (itc ImageTemplateCustomizer) AsImageTemplateWindowsUpdateCustomizer() (*ImageTemplateWindowsUpdateCustomizer, bool) { + return nil, false +} + +// AsImageTemplatePowerShellCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateCustomizer. +func (itc ImageTemplateCustomizer) AsImageTemplatePowerShellCustomizer() (*ImageTemplatePowerShellCustomizer, bool) { + return nil, false +} + +// AsImageTemplateFileCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateCustomizer. +func (itc ImageTemplateCustomizer) AsImageTemplateFileCustomizer() (*ImageTemplateFileCustomizer, 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 +} + +// ImageTemplateFileCustomizer uploads files to VMs (Linux, Windows). Corresponds to Packer file +// provisioner +type ImageTemplateFileCustomizer struct { + // SourceURI - The URI of the file to be uploaded for customizing the VM. It can be a github link, SAS URI for Azure Storage, etc + SourceURI *string `json:"sourceUri,omitempty"` + // Sha256Checksum - SHA256 checksum of the file provided in the sourceUri field above + Sha256Checksum *string `json:"sha256Checksum,omitempty"` + // Destination - The absolute path to a file (with nested directory structures already created) where the file (from sourceUri) will be uploaded to in the VM + Destination *string `json:"destination,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', 'TypeWindowsUpdate', 'TypePowerShell', 'TypeFile' + Type TypeBasicImageTemplateCustomizer `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ImageTemplateFileCustomizer. +func (itfc ImageTemplateFileCustomizer) MarshalJSON() ([]byte, error) { + itfc.Type = TypeFile + objectMap := make(map[string]interface{}) + if itfc.SourceURI != nil { + objectMap["sourceUri"] = itfc.SourceURI + } + if itfc.Sha256Checksum != nil { + objectMap["sha256Checksum"] = itfc.Sha256Checksum + } + if itfc.Destination != nil { + objectMap["destination"] = itfc.Destination + } + if itfc.Name != nil { + objectMap["name"] = itfc.Name + } + if itfc.Type != "" { + objectMap["type"] = itfc.Type + } + return json.Marshal(objectMap) +} + +// AsImageTemplateShellCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateFileCustomizer. +func (itfc ImageTemplateFileCustomizer) AsImageTemplateShellCustomizer() (*ImageTemplateShellCustomizer, bool) { + return nil, false +} + +// AsImageTemplateRestartCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateFileCustomizer. +func (itfc ImageTemplateFileCustomizer) AsImageTemplateRestartCustomizer() (*ImageTemplateRestartCustomizer, bool) { + return nil, false +} + +// AsImageTemplateWindowsUpdateCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateFileCustomizer. +func (itfc ImageTemplateFileCustomizer) AsImageTemplateWindowsUpdateCustomizer() (*ImageTemplateWindowsUpdateCustomizer, bool) { + return nil, false +} + +// AsImageTemplatePowerShellCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateFileCustomizer. +func (itfc ImageTemplateFileCustomizer) AsImageTemplatePowerShellCustomizer() (*ImageTemplatePowerShellCustomizer, bool) { + return nil, false +} + +// AsImageTemplateFileCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateFileCustomizer. +func (itfc ImageTemplateFileCustomizer) AsImageTemplateFileCustomizer() (*ImageTemplateFileCustomizer, bool) { + return &itfc, true +} + +// AsImageTemplateCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateFileCustomizer. +func (itfc ImageTemplateFileCustomizer) AsImageTemplateCustomizer() (*ImageTemplateCustomizer, bool) { + return nil, false +} + +// AsBasicImageTemplateCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateFileCustomizer. +func (itfc ImageTemplateFileCustomizer) AsBasicImageTemplateCustomizer() (BasicImageTemplateCustomizer, bool) { + return &itfc, true +} + +// ImageTemplateIdentity identity for the image template. +type ImageTemplateIdentity struct { + // Type - The type of identity used for the image template. The type 'None' will remove any identities from the image template. Possible values include: 'UserAssigned', 'None' + Type ResourceIdentityType `json:"type,omitempty"` + // UserAssignedIdentities - The list of user identities associated with the image template. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + UserAssignedIdentities map[string]*ImageTemplateIdentityUserAssignedIdentitiesValue `json:"userAssignedIdentities"` +} + +// MarshalJSON is the custom marshaler for ImageTemplateIdentity. +func (iti ImageTemplateIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if iti.Type != "" { + objectMap["type"] = iti.Type + } + if iti.UserAssignedIdentities != nil { + objectMap["userAssignedIdentities"] = iti.UserAssignedIdentities + } + return json.Marshal(objectMap) +} + +// ImageTemplateIdentityUserAssignedIdentitiesValue ... +type ImageTemplateIdentityUserAssignedIdentitiesValue struct { + // PrincipalID - READ-ONLY; The principal id of user assigned identity. + PrincipalID *string `json:"principalId,omitempty"` + // ClientID - READ-ONLY; The client id of user assigned identity. + ClientID *string `json:"clientId,omitempty"` +} + +// MarshalJSON is the custom marshaler for ImageTemplateIdentityUserAssignedIdentitiesValue. +func (itiAiv ImageTemplateIdentityUserAssignedIdentitiesValue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ImageTemplateLastRunStatus describes the latest status of running an image template +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', 'RunStateCanceling', 'RunStateSucceeded', 'RunStatePartiallySucceeded', 'RunStateFailed', 'RunStateCanceled' + 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 the result of List image templates operation +type ImageTemplateListResult struct { + autorest.Response `json:"-"` + // Value - An array of image templates + Value *[]ImageTemplate `json:"value,omitempty"` + // NextLink - The continuation token. + NextLink *string `json:"nextLink,omitempty"` +} + +// ImageTemplateListResultIterator provides access to a complete listing of ImageTemplate values. +type ImageTemplateListResultIterator struct { + i int + page ImageTemplateListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ImageTemplateListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ImageTemplateListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ImageTemplateListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ImageTemplateListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ImageTemplateListResultIterator) Response() ImageTemplateListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ImageTemplateListResultIterator) Value() ImageTemplate { + if !iter.page.NotDone() { + return ImageTemplate{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ImageTemplateListResultIterator type. +func NewImageTemplateListResultIterator(page ImageTemplateListResultPage) ImageTemplateListResultIterator { + return ImageTemplateListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (itlr ImageTemplateListResult) IsEmpty() bool { + return itlr.Value == nil || len(*itlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (itlr ImageTemplateListResult) hasNextLink() bool { + return itlr.NextLink != nil && len(*itlr.NextLink) != 0 +} + +// imageTemplateListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (itlr ImageTemplateListResult) imageTemplateListResultPreparer(ctx context.Context) (*http.Request, error) { + if !itlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(itlr.NextLink))) +} + +// ImageTemplateListResultPage contains a page of ImageTemplate values. +type ImageTemplateListResultPage struct { + fn func(context.Context, ImageTemplateListResult) (ImageTemplateListResult, error) + itlr ImageTemplateListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ImageTemplateListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ImageTemplateListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.itlr) + if err != nil { + return err + } + page.itlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ImageTemplateListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ImageTemplateListResultPage) NotDone() bool { + return !page.itlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ImageTemplateListResultPage) Response() ImageTemplateListResult { + return page.itlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ImageTemplateListResultPage) Values() []ImageTemplate { + if page.itlr.IsEmpty() { + return nil + } + return *page.itlr.Value +} + +// Creates a new instance of the ImageTemplateListResultPage type. +func NewImageTemplateListResultPage(cur ImageTemplateListResult, getNextPage func(context.Context, ImageTemplateListResult) (ImageTemplateListResult, error)) ImageTemplateListResultPage { + return ImageTemplateListResultPage{ + fn: getNextPage, + itlr: cur, + } +} + +// ImageTemplateManagedImageDistributor distribute as a Managed Disk Image. +type ImageTemplateManagedImageDistributor struct { + // ImageID - Resource Id of the Managed Disk Image + ImageID *string `json:"imageId,omitempty"` + // Location - Azure location for the image, should match if image already exists + Location *string `json:"location,omitempty"` + // RunOutputName - The name to be used for the associated RunOutput. + RunOutputName *string `json:"runOutputName,omitempty"` + // ArtifactTags - Tags that will be applied to the artifact once it has been created/updated by the distributor. + ArtifactTags map[string]*string `json:"artifactTags"` + // Type - Possible values include: 'TypeBasicImageTemplateDistributorTypeImageTemplateDistributor', 'TypeBasicImageTemplateDistributorTypeManagedImage', 'TypeBasicImageTemplateDistributorTypeSharedImage', 'TypeBasicImageTemplateDistributorTypeVHD' + Type TypeBasicImageTemplateDistributor `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ImageTemplateManagedImageDistributor. +func (itmid ImageTemplateManagedImageDistributor) MarshalJSON() ([]byte, error) { + itmid.Type = TypeBasicImageTemplateDistributorTypeManagedImage + objectMap := make(map[string]interface{}) + if itmid.ImageID != nil { + objectMap["imageId"] = itmid.ImageID + } + if itmid.Location != nil { + objectMap["location"] = itmid.Location + } + if itmid.RunOutputName != nil { + objectMap["runOutputName"] = itmid.RunOutputName + } + if itmid.ArtifactTags != nil { + objectMap["artifactTags"] = itmid.ArtifactTags + } + if itmid.Type != "" { + objectMap["type"] = itmid.Type + } + return json.Marshal(objectMap) +} + +// AsImageTemplateManagedImageDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateManagedImageDistributor. +func (itmid ImageTemplateManagedImageDistributor) AsImageTemplateManagedImageDistributor() (*ImageTemplateManagedImageDistributor, bool) { + return &itmid, true +} + +// AsImageTemplateSharedImageDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateManagedImageDistributor. +func (itmid ImageTemplateManagedImageDistributor) AsImageTemplateSharedImageDistributor() (*ImageTemplateSharedImageDistributor, bool) { + return nil, false +} + +// AsImageTemplateVhdDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateManagedImageDistributor. +func (itmid ImageTemplateManagedImageDistributor) AsImageTemplateVhdDistributor() (*ImageTemplateVhdDistributor, bool) { + return nil, false +} + +// AsImageTemplateDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateManagedImageDistributor. +func (itmid ImageTemplateManagedImageDistributor) AsImageTemplateDistributor() (*ImageTemplateDistributor, bool) { + return nil, false +} + +// AsBasicImageTemplateDistributor is the BasicImageTemplateDistributor implementation for ImageTemplateManagedImageDistributor. +func (itmid ImageTemplateManagedImageDistributor) AsBasicImageTemplateDistributor() (BasicImageTemplateDistributor, bool) { + return &itmid, true +} + +// ImageTemplateManagedImageSource describes an image source that is a managed image in customer +// subscription. +type ImageTemplateManagedImageSource struct { + // ImageID - ARM resource id of the managed image in customer subscription + ImageID *string `json:"imageId,omitempty"` + // Type - Possible values include: 'TypeImageTemplateSource', 'TypePlatformImage', 'TypeManagedImage', 'TypeSharedImageVersion' + 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) +} + +// 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 +} + +// AsImageTemplateSharedImageVersionSource is the BasicImageTemplateSource implementation for ImageTemplateManagedImageSource. +func (itmis ImageTemplateManagedImageSource) AsImageTemplateSharedImageVersionSource() (*ImageTemplateSharedImageVersionSource, bool) { + return nil, false +} + +// 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). If 'latest' is specified here, the version is evaluated when the image build takes place, not when the template is submitted. + Version *string `json:"version,omitempty"` + // ExactVersion - READ-ONLY; Image version from the [Azure Gallery Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). This readonly field differs from 'version', only if the value specified in 'version' field is 'latest'. + ExactVersion *string `json:"exactVersion,omitempty"` + // PlanInfo - Optional configuration of purchase plan for platform image. + PlanInfo *PlatformImagePurchasePlan `json:"planInfo,omitempty"` + // Type - Possible values include: 'TypeImageTemplateSource', 'TypePlatformImage', 'TypeManagedImage', 'TypeSharedImageVersion' + 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.PlanInfo != nil { + objectMap["planInfo"] = itpis.PlanInfo + } + if itpis.Type != "" { + objectMap["type"] = itpis.Type + } + return json.Marshal(objectMap) +} + +// 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 +} + +// AsImageTemplateSharedImageVersionSource is the BasicImageTemplateSource implementation for ImageTemplatePlatformImageSource. +func (itpis ImageTemplatePlatformImageSource) AsImageTemplateSharedImageVersionSource() (*ImageTemplateSharedImageVersionSource, bool) { + return nil, false +} + +// AsImageTemplateSource is the BasicImageTemplateSource implementation for ImageTemplatePlatformImageSource. +func (itpis ImageTemplatePlatformImageSource) AsImageTemplateSource() (*ImageTemplateSource, bool) { + return nil, false +} + +// AsBasicImageTemplateSource is the BasicImageTemplateSource implementation for ImageTemplatePlatformImageSource. +func (itpis ImageTemplatePlatformImageSource) AsBasicImageTemplateSource() (BasicImageTemplateSource, bool) { + return &itpis, true +} + +// ImageTemplatePowerShellCustomizer runs the specified PowerShell on the VM (Windows). Corresponds to +// Packer powershell provisioner. Exactly one of 'scriptUri' or 'inline' can be specified. +type ImageTemplatePowerShellCustomizer struct { + // ScriptURI - URI of the PowerShell script to be run for customizing. It can be a github link, SAS URI for Azure Storage, etc + ScriptURI *string `json:"scriptUri,omitempty"` + // Sha256Checksum - SHA256 checksum of the power shell script provided in the scriptUri field above + Sha256Checksum *string `json:"sha256Checksum,omitempty"` + // Inline - Array of PowerShell commands to execute + Inline *[]string `json:"inline,omitempty"` + // RunElevated - If specified, the PowerShell script will be run with elevated privileges + RunElevated *bool `json:"runElevated,omitempty"` + // RunAsSystem - If specified, the PowerShell script will be run with elevated privileges using the Local System user. Can only be true when the runElevated field above is set to true. + RunAsSystem *bool `json:"runAsSystem,omitempty"` + // ValidExitCodes - Valid exit codes for the PowerShell script. [Default: 0] + ValidExitCodes *[]int32 `json:"validExitCodes,omitempty"` + // Name - Friendly Name to provide context on what this customization step does + Name *string `json:"name,omitempty"` + // Type - Possible values include: 'TypeImageTemplateCustomizer', 'TypeShell', 'TypeWindowsRestart', 'TypeWindowsUpdate', 'TypePowerShell', 'TypeFile' + 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.ScriptURI != nil { + objectMap["scriptUri"] = itpsc.ScriptURI + } + if itpsc.Sha256Checksum != nil { + objectMap["sha256Checksum"] = itpsc.Sha256Checksum + } + if itpsc.Inline != nil { + objectMap["inline"] = itpsc.Inline + } + if itpsc.RunElevated != nil { + objectMap["runElevated"] = itpsc.RunElevated + } + if itpsc.RunAsSystem != nil { + objectMap["runAsSystem"] = itpsc.RunAsSystem + } + 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 +} + +// AsImageTemplateWindowsUpdateCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplatePowerShellCustomizer. +func (itpsc ImageTemplatePowerShellCustomizer) AsImageTemplateWindowsUpdateCustomizer() (*ImageTemplateWindowsUpdateCustomizer, bool) { + return nil, false +} + +// AsImageTemplatePowerShellCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplatePowerShellCustomizer. +func (itpsc ImageTemplatePowerShellCustomizer) AsImageTemplatePowerShellCustomizer() (*ImageTemplatePowerShellCustomizer, bool) { + return &itpsc, true +} + +// AsImageTemplateFileCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplatePowerShellCustomizer. +func (itpsc ImageTemplatePowerShellCustomizer) AsImageTemplateFileCustomizer() (*ImageTemplateFileCustomizer, bool) { + return nil, false +} + +// 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 describes the properties of an image template +type ImageTemplateProperties struct { + // Source - Specifies the properties used to describe the source image. + Source BasicImageTemplateSource `json:"source,omitempty"` + // Customize - Specifies the properties used to describe the customization steps of the image, like Image source etc + Customize *[]BasicImageTemplateCustomizer `json:"customize,omitempty"` + // Distribute - The distribution targets where the image output needs to go to. + Distribute *[]BasicImageTemplateDistributor `json:"distribute,omitempty"` + // ProvisioningState - READ-ONLY; Provisioning state of the resource. Possible values include: 'Creating', 'Updating', 'Succeeded', 'Failed', 'Deleting' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // ProvisioningError - READ-ONLY; Provisioning error, if any + ProvisioningError *ProvisioningError `json:"provisioningError,omitempty"` + // LastRunStatus - READ-ONLY; State of 'run' that is currently executing or was last executed. + LastRunStatus *ImageTemplateLastRunStatus `json:"lastRunStatus,omitempty"` + // BuildTimeoutInMinutes - Maximum duration to wait while building the image template. Omit or specify 0 to use the default (4 hours). + BuildTimeoutInMinutes *int32 `json:"buildTimeoutInMinutes,omitempty"` + // VMProfile - Describes how virtual machine is set up to build images + VMProfile *ImageTemplateVMProfile `json:"vmProfile,omitempty"` +} + +// MarshalJSON is the custom marshaler for ImageTemplateProperties. +func (itp ImageTemplateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + objectMap["source"] = itp.Source + if itp.Customize != nil { + objectMap["customize"] = itp.Customize + } + if itp.Distribute != nil { + objectMap["distribute"] = itp.Distribute + } + if itp.BuildTimeoutInMinutes != nil { + objectMap["buildTimeoutInMinutes"] = itp.BuildTimeoutInMinutes + } + if itp.VMProfile != nil { + objectMap["vmProfile"] = itp.VMProfile + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ImageTemplateProperties struct. +func (itp *ImageTemplateProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "source": + if v != nil { + source, err := unmarshalBasicImageTemplateSource(*v) + if err != nil { + return err + } + itp.Source = source + } + case "customize": + if v != nil { + customize, err := unmarshalBasicImageTemplateCustomizerArray(*v) + if err != nil { + return err + } + itp.Customize = &customize + } + case "distribute": + if v != nil { + distribute, err := unmarshalBasicImageTemplateDistributorArray(*v) + if err != nil { + return err + } + itp.Distribute = &distribute + } + case "provisioningState": + if v != nil { + var provisioningState ProvisioningState + err = json.Unmarshal(*v, &provisioningState) + if err != nil { + return err + } + itp.ProvisioningState = provisioningState + } + case "provisioningError": + if v != nil { + var provisioningError ProvisioningError + err = json.Unmarshal(*v, &provisioningError) + if err != nil { + return err + } + itp.ProvisioningError = &provisioningError + } + case "lastRunStatus": + if v != nil { + var lastRunStatus ImageTemplateLastRunStatus + err = json.Unmarshal(*v, &lastRunStatus) + if err != nil { + return err + } + itp.LastRunStatus = &lastRunStatus + } + case "buildTimeoutInMinutes": + if v != nil { + var buildTimeoutInMinutes int32 + err = json.Unmarshal(*v, &buildTimeoutInMinutes) + if err != nil { + return err + } + itp.BuildTimeoutInMinutes = &buildTimeoutInMinutes + } + case "vmProfile": + if v != nil { + var VMProfile ImageTemplateVMProfile + err = json.Unmarshal(*v, &VMProfile) + if err != nil { + return err + } + itp.VMProfile = &VMProfile + } + } + } + + 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', 'TypeWindowsUpdate', 'TypePowerShell', 'TypeFile' + 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 +} + +// AsImageTemplateWindowsUpdateCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateRestartCustomizer. +func (itrc ImageTemplateRestartCustomizer) AsImageTemplateWindowsUpdateCustomizer() (*ImageTemplateWindowsUpdateCustomizer, bool) { + return nil, false +} + +// AsImageTemplatePowerShellCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateRestartCustomizer. +func (itrc ImageTemplateRestartCustomizer) AsImageTemplatePowerShellCustomizer() (*ImageTemplatePowerShellCustomizer, bool) { + return nil, false +} + +// AsImageTemplateFileCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateRestartCustomizer. +func (itrc ImageTemplateRestartCustomizer) AsImageTemplateFileCustomizer() (*ImageTemplateFileCustomizer, 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 - A list of regions that the image will be replicated to + ReplicationRegions *[]string `json:"replicationRegions,omitempty"` + // ExcludeFromLatest - Flag that indicates whether created image version should be excluded from latest. Omit to use the default (false). + ExcludeFromLatest *bool `json:"excludeFromLatest,omitempty"` + // StorageAccountType - Storage account type to be used to store the shared image. Omit to use the default (Standard_LRS). Possible values include: 'StandardLRS', 'StandardZRS' + StorageAccountType SharedImageStorageAccountType `json:"storageAccountType,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.ExcludeFromLatest != nil { + objectMap["excludeFromLatest"] = itsid.ExcludeFromLatest + } + if itsid.StorageAccountType != "" { + objectMap["storageAccountType"] = itsid.StorageAccountType + } + 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 +} + +// ImageTemplateSharedImageVersionSource describes an image source that is an image version in a shared +// image gallery. +type ImageTemplateSharedImageVersionSource struct { + // ImageVersionID - ARM resource id of the image version in the shared image gallery + ImageVersionID *string `json:"imageVersionId,omitempty"` + // Type - Possible values include: 'TypeImageTemplateSource', 'TypePlatformImage', 'TypeManagedImage', 'TypeSharedImageVersion' + Type Type `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ImageTemplateSharedImageVersionSource. +func (itsivs ImageTemplateSharedImageVersionSource) MarshalJSON() ([]byte, error) { + itsivs.Type = TypeSharedImageVersion + objectMap := make(map[string]interface{}) + if itsivs.ImageVersionID != nil { + objectMap["imageVersionId"] = itsivs.ImageVersionID + } + if itsivs.Type != "" { + objectMap["type"] = itsivs.Type + } + return json.Marshal(objectMap) +} + +// AsImageTemplatePlatformImageSource is the BasicImageTemplateSource implementation for ImageTemplateSharedImageVersionSource. +func (itsivs ImageTemplateSharedImageVersionSource) AsImageTemplatePlatformImageSource() (*ImageTemplatePlatformImageSource, bool) { + return nil, false +} + +// AsImageTemplateManagedImageSource is the BasicImageTemplateSource implementation for ImageTemplateSharedImageVersionSource. +func (itsivs ImageTemplateSharedImageVersionSource) AsImageTemplateManagedImageSource() (*ImageTemplateManagedImageSource, bool) { + return nil, false +} + +// AsImageTemplateSharedImageVersionSource is the BasicImageTemplateSource implementation for ImageTemplateSharedImageVersionSource. +func (itsivs ImageTemplateSharedImageVersionSource) AsImageTemplateSharedImageVersionSource() (*ImageTemplateSharedImageVersionSource, bool) { + return &itsivs, true +} + +// AsImageTemplateSource is the BasicImageTemplateSource implementation for ImageTemplateSharedImageVersionSource. +func (itsivs ImageTemplateSharedImageVersionSource) AsImageTemplateSource() (*ImageTemplateSource, bool) { + return nil, false +} + +// AsBasicImageTemplateSource is the BasicImageTemplateSource implementation for ImageTemplateSharedImageVersionSource. +func (itsivs ImageTemplateSharedImageVersionSource) AsBasicImageTemplateSource() (BasicImageTemplateSource, bool) { + return &itsivs, true +} + +// ImageTemplateShellCustomizer runs a shell script during the customization phase (Linux). Corresponds to +// Packer shell provisioner. Exactly one of 'scriptUri' or 'inline' can be specified. +type ImageTemplateShellCustomizer struct { + // ScriptURI - URI of the shell script to be run for customizing. It can be a github link, SAS URI for Azure Storage, etc + ScriptURI *string `json:"scriptUri,omitempty"` + // Sha256Checksum - SHA256 checksum of the shell script provided in the scriptUri field + Sha256Checksum *string `json:"sha256Checksum,omitempty"` + // Inline - Array of shell commands to execute + Inline *[]string `json:"inline,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', 'TypeWindowsUpdate', 'TypePowerShell', 'TypeFile' + 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.ScriptURI != nil { + objectMap["scriptUri"] = itsc.ScriptURI + } + if itsc.Sha256Checksum != nil { + objectMap["sha256Checksum"] = itsc.Sha256Checksum + } + if itsc.Inline != nil { + objectMap["inline"] = itsc.Inline + } + 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 +} + +// AsImageTemplateWindowsUpdateCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateShellCustomizer. +func (itsc ImageTemplateShellCustomizer) AsImageTemplateWindowsUpdateCustomizer() (*ImageTemplateWindowsUpdateCustomizer, bool) { + return nil, false +} + +// AsImageTemplatePowerShellCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateShellCustomizer. +func (itsc ImageTemplateShellCustomizer) AsImageTemplatePowerShellCustomizer() (*ImageTemplatePowerShellCustomizer, bool) { + return nil, false +} + +// AsImageTemplateFileCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateShellCustomizer. +func (itsc ImageTemplateShellCustomizer) AsImageTemplateFileCustomizer() (*ImageTemplateFileCustomizer, 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 describes a virtual machine image source for building, customizing and distributing +type BasicImageTemplateSource interface { + AsImageTemplatePlatformImageSource() (*ImageTemplatePlatformImageSource, bool) + AsImageTemplateManagedImageSource() (*ImageTemplateManagedImageSource, bool) + AsImageTemplateSharedImageVersionSource() (*ImageTemplateSharedImageVersionSource, bool) + AsImageTemplateSource() (*ImageTemplateSource, bool) +} + +// ImageTemplateSource describes a virtual machine image source for building, customizing and distributing +type ImageTemplateSource struct { + // Type - Possible values include: 'TypeImageTemplateSource', 'TypePlatformImage', 'TypeManagedImage', 'TypeSharedImageVersion' + 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(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 + case string(TypeSharedImageVersion): + var itsivs ImageTemplateSharedImageVersionSource + err := json.Unmarshal(body, &itsivs) + return itsivs, 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) +} + +// 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 +} + +// AsImageTemplateSharedImageVersionSource is the BasicImageTemplateSource implementation for ImageTemplateSource. +func (its ImageTemplateSource) AsImageTemplateSharedImageVersionSource() (*ImageTemplateSharedImageVersionSource, 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 { + // Identity - The identity of the image template, if configured. + Identity *ImageTemplateIdentity `json:"identity,omitempty"` + // 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.Identity != nil { + objectMap["identity"] = itup.Identity + } + 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 +} + +// ImageTemplateVMProfile describes the virtual machine used to build, customize and capture images +type ImageTemplateVMProfile struct { + // VMSize - Size of the virtual machine used to build, customize and capture images. Omit or specify empty string to use the default (Standard_D2ds_v4). + VMSize *string `json:"vmSize,omitempty"` + // OsDiskSizeGB - Size of the OS disk in GB. Omit or specify 0 to use Azure's default OS disk size. + OsDiskSizeGB *int32 `json:"osDiskSizeGB,omitempty"` + // UserAssignedIdentities - Optional array of resource IDs of user assigned managed identities to be configured on the build VM. This may include the identity of the image template. + UserAssignedIdentities *[]string `json:"userAssignedIdentities,omitempty"` + // VnetConfig - Optional configuration of the virtual network to use to deploy the build virtual machine in. Omit if no specific virtual network needs to be used. + VnetConfig *VirtualNetworkConfig `json:"vnetConfig,omitempty"` +} + +// ImageTemplateWindowsUpdateCustomizer installs Windows Updates. Corresponds to Packer Windows Update +// Provisioner (https://github.com/rgl/packer-provisioner-windows-update) +type ImageTemplateWindowsUpdateCustomizer struct { + // SearchCriteria - Criteria to search updates. Omit or specify empty string to use the default (search all). Refer to above link for examples and detailed description of this field. + SearchCriteria *string `json:"searchCriteria,omitempty"` + // Filters - Array of filters to select updates to apply. Omit or specify empty array to use the default (no filter). Refer to above link for examples and detailed description of this field. + Filters *[]string `json:"filters,omitempty"` + // UpdateLimit - Maximum number of updates to apply at a time. Omit or specify 0 to use the default (1000) + UpdateLimit *int32 `json:"updateLimit,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', 'TypeWindowsUpdate', 'TypePowerShell', 'TypeFile' + Type TypeBasicImageTemplateCustomizer `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ImageTemplateWindowsUpdateCustomizer. +func (itwuc ImageTemplateWindowsUpdateCustomizer) MarshalJSON() ([]byte, error) { + itwuc.Type = TypeWindowsUpdate + objectMap := make(map[string]interface{}) + if itwuc.SearchCriteria != nil { + objectMap["searchCriteria"] = itwuc.SearchCriteria + } + if itwuc.Filters != nil { + objectMap["filters"] = itwuc.Filters + } + if itwuc.UpdateLimit != nil { + objectMap["updateLimit"] = itwuc.UpdateLimit + } + if itwuc.Name != nil { + objectMap["name"] = itwuc.Name + } + if itwuc.Type != "" { + objectMap["type"] = itwuc.Type + } + return json.Marshal(objectMap) +} + +// AsImageTemplateShellCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateWindowsUpdateCustomizer. +func (itwuc ImageTemplateWindowsUpdateCustomizer) AsImageTemplateShellCustomizer() (*ImageTemplateShellCustomizer, bool) { + return nil, false +} + +// AsImageTemplateRestartCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateWindowsUpdateCustomizer. +func (itwuc ImageTemplateWindowsUpdateCustomizer) AsImageTemplateRestartCustomizer() (*ImageTemplateRestartCustomizer, bool) { + return nil, false +} + +// AsImageTemplateWindowsUpdateCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateWindowsUpdateCustomizer. +func (itwuc ImageTemplateWindowsUpdateCustomizer) AsImageTemplateWindowsUpdateCustomizer() (*ImageTemplateWindowsUpdateCustomizer, bool) { + return &itwuc, true +} + +// AsImageTemplatePowerShellCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateWindowsUpdateCustomizer. +func (itwuc ImageTemplateWindowsUpdateCustomizer) AsImageTemplatePowerShellCustomizer() (*ImageTemplatePowerShellCustomizer, bool) { + return nil, false +} + +// AsImageTemplateFileCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateWindowsUpdateCustomizer. +func (itwuc ImageTemplateWindowsUpdateCustomizer) AsImageTemplateFileCustomizer() (*ImageTemplateFileCustomizer, bool) { + return nil, false +} + +// AsImageTemplateCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateWindowsUpdateCustomizer. +func (itwuc ImageTemplateWindowsUpdateCustomizer) AsImageTemplateCustomizer() (*ImageTemplateCustomizer, bool) { + return nil, false +} + +// AsBasicImageTemplateCustomizer is the BasicImageTemplateCustomizer implementation for ImageTemplateWindowsUpdateCustomizer. +func (itwuc ImageTemplateWindowsUpdateCustomizer) AsBasicImageTemplateCustomizer() (BasicImageTemplateCustomizer, bool) { + return &itwuc, true +} + +// 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"` + IsDataAction *bool `json:"isDataAction,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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (olr OperationListResult) hasNextLink() bool { + return olr.NextLink != nil && len(*olr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{ + fn: getNextPage, + olr: cur, + } +} + +// PlatformImagePurchasePlan purchase plan configuration for platform image. +type PlatformImagePurchasePlan struct { + // PlanName - Name of the purchase plan. + PlanName *string `json:"planName,omitempty"` + // PlanProduct - Product of the purchase plan. + PlanProduct *string `json:"planProduct,omitempty"` + // PlanPublisher - Publisher of the purchase plan. + PlanPublisher *string `json:"planPublisher,omitempty"` +} + +// ProvisioningError describes the error happened when create or update an image template +type ProvisioningError struct { + // ProvisioningErrorCode - Error code of the provisioning failure. Possible values include: 'BadSourceType', 'BadPIRSource', 'BadManagedImageSource', 'BadSharedImageVersionSource', '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"` +} + +// ProxyResource the resource model definition for a Azure Resource Manager proxy resource. It will not +// have tags and a location +type ProxyResource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProxyResource. +func (pr ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Resource common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RunOutput represents an output that was created by running an image template. +type RunOutput struct { + autorest.Response `json:"-"` + // RunOutputProperties - The properties of the run output + *RunOutputProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; 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.Name != nil { + objectMap["name"] = ro.Name + } + 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 the result of List run outputs operation +type RunOutputCollection struct { + autorest.Response `json:"-"` + // Value - An array of run outputs + 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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (roc RunOutputCollection) hasNextLink() bool { + return roc.NextLink != nil && len(*roc.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.roc) + if err != nil { + return err + } + page.roc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur RunOutputCollection, getNextPage func(context.Context, RunOutputCollection) (RunOutputCollection, error)) RunOutputCollectionPage { + return RunOutputCollectionPage{ + fn: getNextPage, + roc: cur, + } +} + +// RunOutputProperties describes the properties of a run output +type RunOutputProperties struct { + // ArtifactID - The resource id of the artifact. + ArtifactID *string `json:"artifactId,omitempty"` + // ArtifactURI - The location URI of the artifact. + ArtifactURI *string `json:"artifactUri,omitempty"` + // ProvisioningState - READ-ONLY; Provisioning state of the resource. Possible values include: 'Creating', 'Updating', 'Succeeded', 'Failed', 'Deleting' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for RunOutputProperties. +func (rop RunOutputProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rop.ArtifactID != nil { + objectMap["artifactId"] = rop.ArtifactID + } + if rop.ArtifactURI != nil { + objectMap["artifactUri"] = rop.ArtifactURI + } + return json.Marshal(objectMap) +} + +// SubResource the Sub Resource model definition. +type SubResource struct { + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SubResource. +func (sr SubResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sr.Name != nil { + objectMap["name"] = sr.Name + } + return json.Marshal(objectMap) +} + +// SystemData metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// TrackedResource the resource model definition for an Azure Resource Manager tracked top level resource +// which has 'tags' and a 'location' +type TrackedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + if tr.Location != nil { + objectMap["location"] = tr.Location + } + return json.Marshal(objectMap) +} + +// VirtualMachineImageTemplatesCancelFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type VirtualMachineImageTemplatesCancelFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VirtualMachineImageTemplatesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *VirtualMachineImageTemplatesCancelFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for VirtualMachineImageTemplatesCancelFuture.Result. +func (future *VirtualMachineImageTemplatesCancelFuture) result(client VirtualMachineImageTemplatesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesCancelFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("virtualmachineimagebuilder.VirtualMachineImageTemplatesCancelFuture") + return + } + ar.Response = future.Response() + return +} + +// VirtualMachineImageTemplatesCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type VirtualMachineImageTemplatesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VirtualMachineImageTemplatesClient) (ImageTemplate, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *VirtualMachineImageTemplatesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for VirtualMachineImageTemplatesCreateOrUpdateFuture.Result. +func (future *VirtualMachineImageTemplatesCreateOrUpdateFuture) result(client VirtualMachineImageTemplatesClient) (it ImageTemplate, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + it.Response.Response = future.Response() + 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.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VirtualMachineImageTemplatesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *VirtualMachineImageTemplatesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for VirtualMachineImageTemplatesDeleteFuture.Result. +func (future *VirtualMachineImageTemplatesDeleteFuture) result(client VirtualMachineImageTemplatesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + 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.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VirtualMachineImageTemplatesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *VirtualMachineImageTemplatesRunFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for VirtualMachineImageTemplatesRunFuture.Result. +func (future *VirtualMachineImageTemplatesRunFuture) result(client VirtualMachineImageTemplatesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesRunFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("virtualmachineimagebuilder.VirtualMachineImageTemplatesRunFuture") + return + } + ar.Response = future.Response() + return +} + +// VirtualMachineImageTemplatesUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type VirtualMachineImageTemplatesUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VirtualMachineImageTemplatesClient) (ImageTemplate, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *VirtualMachineImageTemplatesUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for VirtualMachineImageTemplatesUpdateFuture.Result. +func (future *VirtualMachineImageTemplatesUpdateFuture) result(client VirtualMachineImageTemplatesClient) (it ImageTemplate, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + it.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("virtualmachineimagebuilder.VirtualMachineImageTemplatesUpdateFuture") + 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.UpdateResponder(it.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesUpdateFuture", "Result", it.Response.Response, "Failure responding to request") + } + } + return +} + +// VirtualNetworkConfig virtual Network configuration. +type VirtualNetworkConfig struct { + // SubnetID - Resource id of a pre-existing subnet. + SubnetID *string `json:"subnetId,omitempty"` + // ProxyVMSize - Size of the virtual machine used to build, customize and capture images. Omit or specify empty string to use the default (Standard_D1_v2 for Gen1 images and Standard_D2ds_v4 for Gen2 images). + ProxyVMSize *string `json:"proxyVmSize,omitempty"` +} diff --git a/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/operations.go b/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/operations.go new file mode 100644 index 000000000000..8712add6233a --- /dev/null +++ b/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/operations.go @@ -0,0 +1,140 @@ +package virtualmachineimagebuilder + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "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 using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +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 + } + if result.olr.hasNextLink() && result.olr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2021-10-01" + 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 client.Send(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, + 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/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/version.go b/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/version.go new file mode 100644 index 000000000000..7d00bca71900 --- /dev/null +++ b/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/version.go @@ -0,0 +1,19 @@ +package virtualmachineimagebuilder + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " virtualmachineimagebuilder/2021-10-01" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/virtualmachineimagebuilderapi/interfaces.go b/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/virtualmachineimagebuilderapi/interfaces.go new file mode 100644 index 000000000000..6848214fdbd3 --- /dev/null +++ b/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/virtualmachineimagebuilderapi/interfaces.go @@ -0,0 +1,39 @@ +package virtualmachineimagebuilderapi + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder" +) + +// VirtualMachineImageTemplatesClientAPI contains the set of methods on the VirtualMachineImageTemplatesClient type. +type VirtualMachineImageTemplatesClientAPI interface { + Cancel(ctx context.Context, resourceGroupName string, imageTemplateName string) (result virtualmachineimagebuilder.VirtualMachineImageTemplatesCancelFuture, err error) + 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) + ListComplete(ctx context.Context) (result virtualmachineimagebuilder.ImageTemplateListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result virtualmachineimagebuilder.ImageTemplateListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result virtualmachineimagebuilder.ImageTemplateListResultIterator, err error) + ListRunOutputs(ctx context.Context, resourceGroupName string, imageTemplateName string) (result virtualmachineimagebuilder.RunOutputCollectionPage, err error) + ListRunOutputsComplete(ctx context.Context, resourceGroupName string, imageTemplateName string) (result virtualmachineimagebuilder.RunOutputCollectionIterator, 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.VirtualMachineImageTemplatesUpdateFuture, 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) + ListComplete(ctx context.Context) (result virtualmachineimagebuilder.OperationListResultIterator, err error) +} + +var _ OperationsClientAPI = (*virtualmachineimagebuilder.OperationsClient)(nil) diff --git a/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/virtualmachineimagetemplates.go b/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/virtualmachineimagetemplates.go new file mode 100644 index 000000000000..80b8c078177c --- /dev/null +++ b/services/virtualmachineimagebuilder/mgmt/2021-10-01/virtualmachineimagebuilder/virtualmachineimagetemplates.go @@ -0,0 +1,995 @@ +package virtualmachineimagebuilder + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "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 using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewVirtualMachineImageTemplatesClientWithBaseURI(baseURI string, subscriptionID string) VirtualMachineImageTemplatesClient { + return VirtualMachineImageTemplatesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Cancel cancel the long running image build based on the image template +// Parameters: +// resourceGroupName - the name of the resource group. +// imageTemplateName - the name of the image Template +func (client VirtualMachineImageTemplatesClient) Cancel(ctx context.Context, resourceGroupName string, imageTemplateName string) (result VirtualMachineImageTemplatesCancelFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineImageTemplatesClient.Cancel") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.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", "Cancel", err.Error()) + } + + req, err := client.CancelPreparer(ctx, resourceGroupName, imageTemplateName) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "Cancel", nil, "Failure preparing request") + return + } + + result, err = client.CancelSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "Cancel", result.Response(), "Failure sending request") + return + } + + return +} + +// CancelPreparer prepares the Cancel request. +func (client VirtualMachineImageTemplatesClient) CancelPreparer(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 = "2021-10-01" + 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}/cancel", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CancelSender sends the Cancel request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachineImageTemplatesClient) CancelSender(req *http.Request) (future VirtualMachineImageTemplatesCancelFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CancelResponder handles the response to the Cancel request. The method always +// closes the http.Response Body. +func (client VirtualMachineImageTemplatesClient) CancelResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// 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.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.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.Distribute", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ImageTemplateProperties.BuildTimeoutInMinutes", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ImageTemplateProperties.BuildTimeoutInMinutes", Name: validation.InclusiveMaximum, Rule: int64(960), Chain: nil}, + {Target: "parameters.ImageTemplateProperties.BuildTimeoutInMinutes", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}, + }}, + {Target: "parameters.ImageTemplateProperties.VMProfile", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ImageTemplateProperties.VMProfile.OsDiskSizeGB", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ImageTemplateProperties.VMProfile.OsDiskSizeGB", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}, + }}, + }}, + {Target: "parameters.Identity", 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 = "2021-10-01" + 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 + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + 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, + 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.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.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 = "2021-10-01" + 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 + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + 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, + 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 + } + + 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 = "2021-10-01" + 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 client.Send(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, + 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 + } + + 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 = "2021-10-01" + 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 client.Send(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, + 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 + } + if result.itlr.hasNextLink() && result.itlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 = "2021-10-01" + 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 client.Send(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, + 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 + } + if result.itlr.hasNextLink() && result.itlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 = "2021-10-01" + 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 client.Send(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, + 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 + } + if result.roc.hasNextLink() && result.roc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 = "2021-10-01" + 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 client.Send(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, + 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.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.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 = "2021-10-01" + 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 + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + 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, + 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 VirtualMachineImageTemplatesUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineImageTemplatesClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.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 + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "virtualmachineimagebuilder.VirtualMachineImageTemplatesClient", "Update", result.Response(), "Failure sending request") + return + } + + 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 = "2021-10-01" + 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) (future VirtualMachineImageTemplatesUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// 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, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +}