// Code generated by azure-service-operator-codegen. DO NOT EDIT.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
package v1api20220301

import (
	"fmt"
	arm "github.com/Azure/azure-service-operator/v2/api/compute/v1api20220301/arm"
	storage "github.com/Azure/azure-service-operator/v2/api/compute/v1api20220301/storage"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime/conditions"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime/configmaps"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime/core"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime/secrets"
	"github.com/rotisserie/eris"
	"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/runtime/schema"
	"sigs.k8s.io/controller-runtime/pkg/conversion"
)

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,compute}
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
// +kubebuilder:printcolumn:name="Severity",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].severity"
// +kubebuilder:printcolumn:name="Reason",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].reason"
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].message"
// Generator information:
// - Generated from: /compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2022-03-01/virtualMachine.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}
type VirtualMachinesExtension struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              VirtualMachinesExtension_Spec   `json:"spec,omitempty"`
	Status            VirtualMachinesExtension_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &VirtualMachinesExtension{}

// GetConditions returns the conditions of the resource
func (extension *VirtualMachinesExtension) GetConditions() conditions.Conditions {
	return extension.Status.Conditions
}

// SetConditions sets the conditions on the resource status
func (extension *VirtualMachinesExtension) SetConditions(conditions conditions.Conditions) {
	extension.Status.Conditions = conditions
}

var _ conversion.Convertible = &VirtualMachinesExtension{}

// ConvertFrom populates our VirtualMachinesExtension from the provided hub VirtualMachinesExtension
func (extension *VirtualMachinesExtension) ConvertFrom(hub conversion.Hub) error {
	source, ok := hub.(*storage.VirtualMachinesExtension)
	if !ok {
		return fmt.Errorf("expected compute/v1api20220301/storage/VirtualMachinesExtension but received %T instead", hub)
	}

	return extension.AssignProperties_From_VirtualMachinesExtension(source)
}

// ConvertTo populates the provided hub VirtualMachinesExtension from our VirtualMachinesExtension
func (extension *VirtualMachinesExtension) ConvertTo(hub conversion.Hub) error {
	destination, ok := hub.(*storage.VirtualMachinesExtension)
	if !ok {
		return fmt.Errorf("expected compute/v1api20220301/storage/VirtualMachinesExtension but received %T instead", hub)
	}

	return extension.AssignProperties_To_VirtualMachinesExtension(destination)
}

var _ configmaps.Exporter = &VirtualMachinesExtension{}

// ConfigMapDestinationExpressions returns the Spec.OperatorSpec.ConfigMapExpressions property
func (extension *VirtualMachinesExtension) ConfigMapDestinationExpressions() []*core.DestinationExpression {
	if extension.Spec.OperatorSpec == nil {
		return nil
	}
	return extension.Spec.OperatorSpec.ConfigMapExpressions
}

var _ secrets.Exporter = &VirtualMachinesExtension{}

// SecretDestinationExpressions returns the Spec.OperatorSpec.SecretExpressions property
func (extension *VirtualMachinesExtension) SecretDestinationExpressions() []*core.DestinationExpression {
	if extension.Spec.OperatorSpec == nil {
		return nil
	}
	return extension.Spec.OperatorSpec.SecretExpressions
}

var _ genruntime.ImportableResource = &VirtualMachinesExtension{}

// InitializeSpec initializes the spec for this resource from the given status
func (extension *VirtualMachinesExtension) InitializeSpec(status genruntime.ConvertibleStatus) error {
	if s, ok := status.(*VirtualMachinesExtension_STATUS); ok {
		return extension.Spec.Initialize_From_VirtualMachinesExtension_STATUS(s)
	}

	return fmt.Errorf("expected Status of type VirtualMachinesExtension_STATUS but received %T instead", status)
}

var _ genruntime.KubernetesResource = &VirtualMachinesExtension{}

// AzureName returns the Azure name of the resource
func (extension *VirtualMachinesExtension) AzureName() string {
	return extension.Spec.AzureName
}

// GetAPIVersion returns the ARM API version of the resource. This is always "2022-03-01"
func (extension VirtualMachinesExtension) GetAPIVersion() string {
	return "2022-03-01"
}

// GetResourceScope returns the scope of the resource
func (extension *VirtualMachinesExtension) GetResourceScope() genruntime.ResourceScope {
	return genruntime.ResourceScopeResourceGroup
}

// GetSpec returns the specification of this resource
func (extension *VirtualMachinesExtension) GetSpec() genruntime.ConvertibleSpec {
	return &extension.Spec
}

// GetStatus returns the status of this resource
func (extension *VirtualMachinesExtension) GetStatus() genruntime.ConvertibleStatus {
	return &extension.Status
}

// GetSupportedOperations returns the operations supported by the resource
func (extension *VirtualMachinesExtension) GetSupportedOperations() []genruntime.ResourceOperation {
	return []genruntime.ResourceOperation{
		genruntime.ResourceOperationDelete,
		genruntime.ResourceOperationGet,
		genruntime.ResourceOperationPut,
	}
}

// GetType returns the ARM Type of the resource. This is always "Microsoft.Compute/virtualMachines/extensions"
func (extension *VirtualMachinesExtension) GetType() string {
	return "Microsoft.Compute/virtualMachines/extensions"
}

// NewEmptyStatus returns a new empty (blank) status
func (extension *VirtualMachinesExtension) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &VirtualMachinesExtension_STATUS{}
}

// Owner returns the ResourceReference of the owner
func (extension *VirtualMachinesExtension) Owner() *genruntime.ResourceReference {
	if extension.Spec.Owner == nil {
		return nil
	}

	group, kind := genruntime.LookupOwnerGroupKind(extension.Spec)
	return extension.Spec.Owner.AsResourceReference(group, kind)
}

// SetStatus sets the status of this resource
func (extension *VirtualMachinesExtension) SetStatus(status genruntime.ConvertibleStatus) error {
	// If we have exactly the right type of status, assign it
	if st, ok := status.(*VirtualMachinesExtension_STATUS); ok {
		extension.Status = *st
		return nil
	}

	// Convert status to required version
	var st VirtualMachinesExtension_STATUS
	err := status.ConvertStatusTo(&st)
	if err != nil {
		return eris.Wrap(err, "failed to convert status")
	}

	extension.Status = st
	return nil
}

// AssignProperties_From_VirtualMachinesExtension populates our VirtualMachinesExtension from the provided source VirtualMachinesExtension
func (extension *VirtualMachinesExtension) AssignProperties_From_VirtualMachinesExtension(source *storage.VirtualMachinesExtension) error {

	// ObjectMeta
	extension.ObjectMeta = *source.ObjectMeta.DeepCopy()

	// Spec
	var spec VirtualMachinesExtension_Spec
	err := spec.AssignProperties_From_VirtualMachinesExtension_Spec(&source.Spec)
	if err != nil {
		return eris.Wrap(err, "calling AssignProperties_From_VirtualMachinesExtension_Spec() to populate field Spec")
	}
	extension.Spec = spec

	// Status
	var status VirtualMachinesExtension_STATUS
	err = status.AssignProperties_From_VirtualMachinesExtension_STATUS(&source.Status)
	if err != nil {
		return eris.Wrap(err, "calling AssignProperties_From_VirtualMachinesExtension_STATUS() to populate field Status")
	}
	extension.Status = status

	// No error
	return nil
}

// AssignProperties_To_VirtualMachinesExtension populates the provided destination VirtualMachinesExtension from our VirtualMachinesExtension
func (extension *VirtualMachinesExtension) AssignProperties_To_VirtualMachinesExtension(destination *storage.VirtualMachinesExtension) error {

	// ObjectMeta
	destination.ObjectMeta = *extension.ObjectMeta.DeepCopy()

	// Spec
	var spec storage.VirtualMachinesExtension_Spec
	err := extension.Spec.AssignProperties_To_VirtualMachinesExtension_Spec(&spec)
	if err != nil {
		return eris.Wrap(err, "calling AssignProperties_To_VirtualMachinesExtension_Spec() to populate field Spec")
	}
	destination.Spec = spec

	// Status
	var status storage.VirtualMachinesExtension_STATUS
	err = extension.Status.AssignProperties_To_VirtualMachinesExtension_STATUS(&status)
	if err != nil {
		return eris.Wrap(err, "calling AssignProperties_To_VirtualMachinesExtension_STATUS() to populate field Status")
	}
	destination.Status = status

	// No error
	return nil
}

// OriginalGVK returns a GroupValueKind for the original API version used to create the resource
func (extension *VirtualMachinesExtension) OriginalGVK() *schema.GroupVersionKind {
	return &schema.GroupVersionKind{
		Group:   GroupVersion.Group,
		Version: extension.Spec.OriginalVersion(),
		Kind:    "VirtualMachinesExtension",
	}
}

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2022-03-01/virtualMachine.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}
type VirtualMachinesExtensionList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []VirtualMachinesExtension `json:"items"`
}

type VirtualMachinesExtension_Spec struct {
	// AutoUpgradeMinorVersion: Indicates whether the extension should use a newer minor version if one is available at
	// deployment time. Once deployed, however, the extension will not upgrade minor versions unless redeployed, even with this
	// property set to true.
	AutoUpgradeMinorVersion *bool `json:"autoUpgradeMinorVersion,omitempty"`

	// AzureName: The name of the resource in Azure. This is often the same as the name of the resource in Kubernetes but it
	// doesn't have to be.
	AzureName string `json:"azureName,omitempty"`

	// EnableAutomaticUpgrade: Indicates whether the extension should be automatically upgraded by the platform if there is a
	// newer version of the extension available.
	EnableAutomaticUpgrade *bool `json:"enableAutomaticUpgrade,omitempty"`

	// ForceUpdateTag: How the extension handler should be forced to update even if the extension configuration has not changed.
	ForceUpdateTag *string `json:"forceUpdateTag,omitempty"`

	// InstanceView: The virtual machine extension instance view.
	InstanceView *VirtualMachineExtensionInstanceView `json:"instanceView,omitempty"`

	// Location: Resource location
	Location *string `json:"location,omitempty"`

	// OperatorSpec: The specification for configuring operator behavior. This field is interpreted by the operator and not
	// passed directly to Azure
	OperatorSpec *VirtualMachinesExtensionOperatorSpec `json:"operatorSpec,omitempty"`

	// +kubebuilder:validation:Required
	// Owner: The owner of the resource. The owner controls where the resource goes when it is deployed. The owner also
	// controls the resources lifecycle. When the owner is deleted the resource will also be deleted. Owner is expected to be a
	// reference to a compute.azure.com/VirtualMachine resource
	Owner *genruntime.KnownResourceReference `group:"compute.azure.com" json:"owner,omitempty" kind:"VirtualMachine"`

	// ProtectedSettings: The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected
	// settings at all.
	ProtectedSettings *genruntime.SecretMapReference `json:"protectedSettings,omitempty"`

	// ProtectedSettingsFromKeyVault: The extensions protected settings that are passed by reference, and consumed from key
	// vault
	ProtectedSettingsFromKeyVault *KeyVaultSecretReference `json:"protectedSettingsFromKeyVault,omitempty"`

	// Publisher: The name of the extension handler publisher.
	Publisher *string `json:"publisher,omitempty"`

	// Settings: Json formatted public settings for the extension.
	Settings map[string]v1.JSON `json:"settings,omitempty"`

	// SuppressFailures: Indicates whether failures stemming from the extension will be suppressed (Operational failures such
	// as not connecting to the VM will not be suppressed regardless of this value). The default is false.
	SuppressFailures *bool `json:"suppressFailures,omitempty"`

	// Tags: Resource tags
	Tags map[string]string `json:"tags,omitempty"`

	// Type: Specifies the type of the extension; an example is "CustomScriptExtension".
	Type *string `json:"type,omitempty"`

	// TypeHandlerVersion: Specifies the version of the script handler.
	TypeHandlerVersion *string `json:"typeHandlerVersion,omitempty"`
}

var _ genruntime.ARMTransformer = &VirtualMachinesExtension_Spec{}

// ConvertToARM converts from a Kubernetes CRD object to an ARM object
func (extension *VirtualMachinesExtension_Spec) ConvertToARM(resolved genruntime.ConvertToARMResolvedDetails) (interface{}, error) {
	if extension == nil {
		return nil, nil
	}
	result := &arm.VirtualMachinesExtension_Spec{}

	// Set property "Location":
	if extension.Location != nil {
		location := *extension.Location
		result.Location = &location
	}

	// Set property "Name":
	result.Name = resolved.Name

	// Set property "Properties":
	if extension.AutoUpgradeMinorVersion != nil ||
		extension.EnableAutomaticUpgrade != nil ||
		extension.ForceUpdateTag != nil ||
		extension.InstanceView != nil ||
		extension.ProtectedSettings != nil ||
		extension.ProtectedSettingsFromKeyVault != nil ||
		extension.Publisher != nil ||
		extension.Settings != nil ||
		extension.SuppressFailures != nil ||
		extension.Type != nil ||
		extension.TypeHandlerVersion != nil {
		result.Properties = &arm.VirtualMachineExtensionProperties{}
	}
	if extension.AutoUpgradeMinorVersion != nil {
		autoUpgradeMinorVersion := *extension.AutoUpgradeMinorVersion
		result.Properties.AutoUpgradeMinorVersion = &autoUpgradeMinorVersion
	}
	if extension.EnableAutomaticUpgrade != nil {
		enableAutomaticUpgrade := *extension.EnableAutomaticUpgrade
		result.Properties.EnableAutomaticUpgrade = &enableAutomaticUpgrade
	}
	if extension.ForceUpdateTag != nil {
		forceUpdateTag := *extension.ForceUpdateTag
		result.Properties.ForceUpdateTag = &forceUpdateTag
	}
	if extension.InstanceView != nil {
		instanceView_ARM, err := extension.InstanceView.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		instanceView := *instanceView_ARM.(*arm.VirtualMachineExtensionInstanceView)
		result.Properties.InstanceView = &instanceView
	}
	if extension.ProtectedSettings != nil {
		var temp map[string]string
		tempSecret, err := resolved.ResolvedSecretMaps.Lookup(*extension.ProtectedSettings)
		if err != nil {
			return nil, eris.Wrap(err, "looking up secret for property temp")
		}
		temp = tempSecret
		result.Properties.ProtectedSettings = temp
	}
	if extension.ProtectedSettingsFromKeyVault != nil {
		protectedSettingsFromKeyVault_ARM, err := extension.ProtectedSettingsFromKeyVault.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		protectedSettingsFromKeyVault := *protectedSettingsFromKeyVault_ARM.(*arm.KeyVaultSecretReference)
		result.Properties.ProtectedSettingsFromKeyVault = &protectedSettingsFromKeyVault
	}
	if extension.Publisher != nil {
		publisher := *extension.Publisher
		result.Properties.Publisher = &publisher
	}
	if extension.Settings != nil {
		result.Properties.Settings = make(map[string]v1.JSON, len(extension.Settings))
		for key, value := range extension.Settings {
			result.Properties.Settings[key] = *value.DeepCopy()
		}
	}
	if extension.SuppressFailures != nil {
		suppressFailures := *extension.SuppressFailures
		result.Properties.SuppressFailures = &suppressFailures
	}
	if extension.Type != nil {
		typeVar := *extension.Type
		result.Properties.Type = &typeVar
	}
	if extension.TypeHandlerVersion != nil {
		typeHandlerVersion := *extension.TypeHandlerVersion
		result.Properties.TypeHandlerVersion = &typeHandlerVersion
	}

	// Set property "Tags":
	if extension.Tags != nil {
		result.Tags = make(map[string]string, len(extension.Tags))
		for key, value := range extension.Tags {
			result.Tags[key] = value
		}
	}
	return result, nil
}

// NewEmptyARMValue returns an empty ARM value suitable for deserializing into
func (extension *VirtualMachinesExtension_Spec) NewEmptyARMValue() genruntime.ARMResourceStatus {
	return &arm.VirtualMachinesExtension_Spec{}
}

// PopulateFromARM populates a Kubernetes CRD object from an Azure ARM object
func (extension *VirtualMachinesExtension_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerReference, armInput interface{}) error {
	typedInput, ok := armInput.(arm.VirtualMachinesExtension_Spec)
	if !ok {
		return fmt.Errorf("unexpected type supplied for PopulateFromARM() function. Expected arm.VirtualMachinesExtension_Spec, got %T", armInput)
	}

	// Set property "AutoUpgradeMinorVersion":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.AutoUpgradeMinorVersion != nil {
			autoUpgradeMinorVersion := *typedInput.Properties.AutoUpgradeMinorVersion
			extension.AutoUpgradeMinorVersion = &autoUpgradeMinorVersion
		}
	}

	// Set property "AzureName":
	extension.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name))

	// Set property "EnableAutomaticUpgrade":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.EnableAutomaticUpgrade != nil {
			enableAutomaticUpgrade := *typedInput.Properties.EnableAutomaticUpgrade
			extension.EnableAutomaticUpgrade = &enableAutomaticUpgrade
		}
	}

	// Set property "ForceUpdateTag":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ForceUpdateTag != nil {
			forceUpdateTag := *typedInput.Properties.ForceUpdateTag
			extension.ForceUpdateTag = &forceUpdateTag
		}
	}

	// Set property "InstanceView":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.InstanceView != nil {
			var instanceView1 VirtualMachineExtensionInstanceView
			err := instanceView1.PopulateFromARM(owner, *typedInput.Properties.InstanceView)
			if err != nil {
				return err
			}
			instanceView := instanceView1
			extension.InstanceView = &instanceView
		}
	}

	// Set property "Location":
	if typedInput.Location != nil {
		location := *typedInput.Location
		extension.Location = &location
	}

	// no assignment for property "OperatorSpec"

	// Set property "Owner":
	extension.Owner = &genruntime.KnownResourceReference{
		Name:  owner.Name,
		ARMID: owner.ARMID,
	}

	// no assignment for property "ProtectedSettings"

	// Set property "ProtectedSettingsFromKeyVault":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ProtectedSettingsFromKeyVault != nil {
			var protectedSettingsFromKeyVault1 KeyVaultSecretReference
			err := protectedSettingsFromKeyVault1.PopulateFromARM(owner, *typedInput.Properties.ProtectedSettingsFromKeyVault)
			if err != nil {
				return err
			}
			protectedSettingsFromKeyVault := protectedSettingsFromKeyVault1
			extension.ProtectedSettingsFromKeyVault = &protectedSettingsFromKeyVault
		}
	}

	// Set property "Publisher":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Publisher != nil {
			publisher := *typedInput.Properties.Publisher
			extension.Publisher = &publisher
		}
	}

	// Set property "Settings":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Settings != nil {
			extension.Settings = make(map[string]v1.JSON, len(typedInput.Properties.Settings))
			for key, value := range typedInput.Properties.Settings {
				extension.Settings[key] = *value.DeepCopy()
			}
		}
	}

	// Set property "SuppressFailures":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.SuppressFailures != nil {
			suppressFailures := *typedInput.Properties.SuppressFailures
			extension.SuppressFailures = &suppressFailures
		}
	}

	// Set property "Tags":
	if typedInput.Tags != nil {
		extension.Tags = make(map[string]string, len(typedInput.Tags))
		for key, value := range typedInput.Tags {
			extension.Tags[key] = value
		}
	}

	// Set property "Type":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Type != nil {
			typeVar := *typedInput.Properties.Type
			extension.Type = &typeVar
		}
	}

	// Set property "TypeHandlerVersion":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.TypeHandlerVersion != nil {
			typeHandlerVersion := *typedInput.Properties.TypeHandlerVersion
			extension.TypeHandlerVersion = &typeHandlerVersion
		}
	}

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &VirtualMachinesExtension_Spec{}

// ConvertSpecFrom populates our VirtualMachinesExtension_Spec from the provided source
func (extension *VirtualMachinesExtension_Spec) ConvertSpecFrom(source genruntime.ConvertibleSpec) error {
	src, ok := source.(*storage.VirtualMachinesExtension_Spec)
	if ok {
		// Populate our instance from source
		return extension.AssignProperties_From_VirtualMachinesExtension_Spec(src)
	}

	// Convert to an intermediate form
	src = &storage.VirtualMachinesExtension_Spec{}
	err := src.ConvertSpecFrom(source)
	if err != nil {
		return eris.Wrap(err, "initial step of conversion in ConvertSpecFrom()")
	}

	// Update our instance from src
	err = extension.AssignProperties_From_VirtualMachinesExtension_Spec(src)
	if err != nil {
		return eris.Wrap(err, "final step of conversion in ConvertSpecFrom()")
	}

	return nil
}

// ConvertSpecTo populates the provided destination from our VirtualMachinesExtension_Spec
func (extension *VirtualMachinesExtension_Spec) ConvertSpecTo(destination genruntime.ConvertibleSpec) error {
	dst, ok := destination.(*storage.VirtualMachinesExtension_Spec)
	if ok {
		// Populate destination from our instance
		return extension.AssignProperties_To_VirtualMachinesExtension_Spec(dst)
	}

	// Convert to an intermediate form
	dst = &storage.VirtualMachinesExtension_Spec{}
	err := extension.AssignProperties_To_VirtualMachinesExtension_Spec(dst)
	if err != nil {
		return eris.Wrap(err, "initial step of conversion in ConvertSpecTo()")
	}

	// Update dst from our instance
	err = dst.ConvertSpecTo(destination)
	if err != nil {
		return eris.Wrap(err, "final step of conversion in ConvertSpecTo()")
	}

	return nil
}

// AssignProperties_From_VirtualMachinesExtension_Spec populates our VirtualMachinesExtension_Spec from the provided source VirtualMachinesExtension_Spec
func (extension *VirtualMachinesExtension_Spec) AssignProperties_From_VirtualMachinesExtension_Spec(source *storage.VirtualMachinesExtension_Spec) error {

	// AutoUpgradeMinorVersion
	if source.AutoUpgradeMinorVersion != nil {
		autoUpgradeMinorVersion := *source.AutoUpgradeMinorVersion
		extension.AutoUpgradeMinorVersion = &autoUpgradeMinorVersion
	} else {
		extension.AutoUpgradeMinorVersion = nil
	}

	// AzureName
	extension.AzureName = source.AzureName

	// EnableAutomaticUpgrade
	if source.EnableAutomaticUpgrade != nil {
		enableAutomaticUpgrade := *source.EnableAutomaticUpgrade
		extension.EnableAutomaticUpgrade = &enableAutomaticUpgrade
	} else {
		extension.EnableAutomaticUpgrade = nil
	}

	// ForceUpdateTag
	extension.ForceUpdateTag = genruntime.ClonePointerToString(source.ForceUpdateTag)

	// InstanceView
	if source.InstanceView != nil {
		var instanceView VirtualMachineExtensionInstanceView
		err := instanceView.AssignProperties_From_VirtualMachineExtensionInstanceView(source.InstanceView)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_VirtualMachineExtensionInstanceView() to populate field InstanceView")
		}
		extension.InstanceView = &instanceView
	} else {
		extension.InstanceView = nil
	}

	// Location
	extension.Location = genruntime.ClonePointerToString(source.Location)

	// OperatorSpec
	if source.OperatorSpec != nil {
		var operatorSpec VirtualMachinesExtensionOperatorSpec
		err := operatorSpec.AssignProperties_From_VirtualMachinesExtensionOperatorSpec(source.OperatorSpec)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_VirtualMachinesExtensionOperatorSpec() to populate field OperatorSpec")
		}
		extension.OperatorSpec = &operatorSpec
	} else {
		extension.OperatorSpec = nil
	}

	// Owner
	if source.Owner != nil {
		owner := source.Owner.Copy()
		extension.Owner = &owner
	} else {
		extension.Owner = nil
	}

	// ProtectedSettings
	if source.ProtectedSettings != nil {
		protectedSetting := source.ProtectedSettings.Copy()
		extension.ProtectedSettings = &protectedSetting
	} else {
		extension.ProtectedSettings = nil
	}

	// ProtectedSettingsFromKeyVault
	if source.ProtectedSettingsFromKeyVault != nil {
		var protectedSettingsFromKeyVault KeyVaultSecretReference
		err := protectedSettingsFromKeyVault.AssignProperties_From_KeyVaultSecretReference(source.ProtectedSettingsFromKeyVault)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_KeyVaultSecretReference() to populate field ProtectedSettingsFromKeyVault")
		}
		extension.ProtectedSettingsFromKeyVault = &protectedSettingsFromKeyVault
	} else {
		extension.ProtectedSettingsFromKeyVault = nil
	}

	// Publisher
	extension.Publisher = genruntime.ClonePointerToString(source.Publisher)

	// Settings
	if source.Settings != nil {
		settingMap := make(map[string]v1.JSON, len(source.Settings))
		for settingKey, settingValue := range source.Settings {
			settingMap[settingKey] = *settingValue.DeepCopy()
		}
		extension.Settings = settingMap
	} else {
		extension.Settings = nil
	}

	// SuppressFailures
	if source.SuppressFailures != nil {
		suppressFailure := *source.SuppressFailures
		extension.SuppressFailures = &suppressFailure
	} else {
		extension.SuppressFailures = nil
	}

	// Tags
	extension.Tags = genruntime.CloneMapOfStringToString(source.Tags)

	// Type
	extension.Type = genruntime.ClonePointerToString(source.Type)

	// TypeHandlerVersion
	extension.TypeHandlerVersion = genruntime.ClonePointerToString(source.TypeHandlerVersion)

	// No error
	return nil
}

// AssignProperties_To_VirtualMachinesExtension_Spec populates the provided destination VirtualMachinesExtension_Spec from our VirtualMachinesExtension_Spec
func (extension *VirtualMachinesExtension_Spec) AssignProperties_To_VirtualMachinesExtension_Spec(destination *storage.VirtualMachinesExtension_Spec) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// AutoUpgradeMinorVersion
	if extension.AutoUpgradeMinorVersion != nil {
		autoUpgradeMinorVersion := *extension.AutoUpgradeMinorVersion
		destination.AutoUpgradeMinorVersion = &autoUpgradeMinorVersion
	} else {
		destination.AutoUpgradeMinorVersion = nil
	}

	// AzureName
	destination.AzureName = extension.AzureName

	// EnableAutomaticUpgrade
	if extension.EnableAutomaticUpgrade != nil {
		enableAutomaticUpgrade := *extension.EnableAutomaticUpgrade
		destination.EnableAutomaticUpgrade = &enableAutomaticUpgrade
	} else {
		destination.EnableAutomaticUpgrade = nil
	}

	// ForceUpdateTag
	destination.ForceUpdateTag = genruntime.ClonePointerToString(extension.ForceUpdateTag)

	// InstanceView
	if extension.InstanceView != nil {
		var instanceView storage.VirtualMachineExtensionInstanceView
		err := extension.InstanceView.AssignProperties_To_VirtualMachineExtensionInstanceView(&instanceView)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_VirtualMachineExtensionInstanceView() to populate field InstanceView")
		}
		destination.InstanceView = &instanceView
	} else {
		destination.InstanceView = nil
	}

	// Location
	destination.Location = genruntime.ClonePointerToString(extension.Location)

	// OperatorSpec
	if extension.OperatorSpec != nil {
		var operatorSpec storage.VirtualMachinesExtensionOperatorSpec
		err := extension.OperatorSpec.AssignProperties_To_VirtualMachinesExtensionOperatorSpec(&operatorSpec)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_VirtualMachinesExtensionOperatorSpec() to populate field OperatorSpec")
		}
		destination.OperatorSpec = &operatorSpec
	} else {
		destination.OperatorSpec = nil
	}

	// OriginalVersion
	destination.OriginalVersion = extension.OriginalVersion()

	// Owner
	if extension.Owner != nil {
		owner := extension.Owner.Copy()
		destination.Owner = &owner
	} else {
		destination.Owner = nil
	}

	// ProtectedSettings
	if extension.ProtectedSettings != nil {
		protectedSetting := extension.ProtectedSettings.Copy()
		destination.ProtectedSettings = &protectedSetting
	} else {
		destination.ProtectedSettings = nil
	}

	// ProtectedSettingsFromKeyVault
	if extension.ProtectedSettingsFromKeyVault != nil {
		var protectedSettingsFromKeyVault storage.KeyVaultSecretReference
		err := extension.ProtectedSettingsFromKeyVault.AssignProperties_To_KeyVaultSecretReference(&protectedSettingsFromKeyVault)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_KeyVaultSecretReference() to populate field ProtectedSettingsFromKeyVault")
		}
		destination.ProtectedSettingsFromKeyVault = &protectedSettingsFromKeyVault
	} else {
		destination.ProtectedSettingsFromKeyVault = nil
	}

	// Publisher
	destination.Publisher = genruntime.ClonePointerToString(extension.Publisher)

	// Settings
	if extension.Settings != nil {
		settingMap := make(map[string]v1.JSON, len(extension.Settings))
		for settingKey, settingValue := range extension.Settings {
			settingMap[settingKey] = *settingValue.DeepCopy()
		}
		destination.Settings = settingMap
	} else {
		destination.Settings = nil
	}

	// SuppressFailures
	if extension.SuppressFailures != nil {
		suppressFailure := *extension.SuppressFailures
		destination.SuppressFailures = &suppressFailure
	} else {
		destination.SuppressFailures = nil
	}

	// Tags
	destination.Tags = genruntime.CloneMapOfStringToString(extension.Tags)

	// Type
	destination.Type = genruntime.ClonePointerToString(extension.Type)

	// TypeHandlerVersion
	destination.TypeHandlerVersion = genruntime.ClonePointerToString(extension.TypeHandlerVersion)

	// Update the property bag
	if len(propertyBag) > 0 {
		destination.PropertyBag = propertyBag
	} else {
		destination.PropertyBag = nil
	}

	// No error
	return nil
}

// Initialize_From_VirtualMachinesExtension_STATUS populates our VirtualMachinesExtension_Spec from the provided source VirtualMachinesExtension_STATUS
func (extension *VirtualMachinesExtension_Spec) Initialize_From_VirtualMachinesExtension_STATUS(source *VirtualMachinesExtension_STATUS) error {

	// AutoUpgradeMinorVersion
	if source.AutoUpgradeMinorVersion != nil {
		autoUpgradeMinorVersion := *source.AutoUpgradeMinorVersion
		extension.AutoUpgradeMinorVersion = &autoUpgradeMinorVersion
	} else {
		extension.AutoUpgradeMinorVersion = nil
	}

	// EnableAutomaticUpgrade
	if source.EnableAutomaticUpgrade != nil {
		enableAutomaticUpgrade := *source.EnableAutomaticUpgrade
		extension.EnableAutomaticUpgrade = &enableAutomaticUpgrade
	} else {
		extension.EnableAutomaticUpgrade = nil
	}

	// ForceUpdateTag
	extension.ForceUpdateTag = genruntime.ClonePointerToString(source.ForceUpdateTag)

	// InstanceView
	if source.InstanceView != nil {
		var instanceView VirtualMachineExtensionInstanceView
		err := instanceView.Initialize_From_VirtualMachineExtensionInstanceView_STATUS(source.InstanceView)
		if err != nil {
			return eris.Wrap(err, "calling Initialize_From_VirtualMachineExtensionInstanceView_STATUS() to populate field InstanceView")
		}
		extension.InstanceView = &instanceView
	} else {
		extension.InstanceView = nil
	}

	// Location
	extension.Location = genruntime.ClonePointerToString(source.Location)

	// ProtectedSettingsFromKeyVault
	if source.ProtectedSettingsFromKeyVault != nil {
		var protectedSettingsFromKeyVault KeyVaultSecretReference
		err := protectedSettingsFromKeyVault.Initialize_From_KeyVaultSecretReference_STATUS(source.ProtectedSettingsFromKeyVault)
		if err != nil {
			return eris.Wrap(err, "calling Initialize_From_KeyVaultSecretReference_STATUS() to populate field ProtectedSettingsFromKeyVault")
		}
		extension.ProtectedSettingsFromKeyVault = &protectedSettingsFromKeyVault
	} else {
		extension.ProtectedSettingsFromKeyVault = nil
	}

	// Publisher
	extension.Publisher = genruntime.ClonePointerToString(source.Publisher)

	// Settings
	if source.Settings != nil {
		settingMap := make(map[string]v1.JSON, len(source.Settings))
		for settingKey, settingValue := range source.Settings {
			settingMap[settingKey] = *settingValue.DeepCopy()
		}
		extension.Settings = settingMap
	} else {
		extension.Settings = nil
	}

	// SuppressFailures
	if source.SuppressFailures != nil {
		suppressFailure := *source.SuppressFailures
		extension.SuppressFailures = &suppressFailure
	} else {
		extension.SuppressFailures = nil
	}

	// Tags
	extension.Tags = genruntime.CloneMapOfStringToString(source.Tags)

	// Type
	extension.Type = genruntime.ClonePointerToString(source.PropertiesType)

	// TypeHandlerVersion
	extension.TypeHandlerVersion = genruntime.ClonePointerToString(source.TypeHandlerVersion)

	// No error
	return nil
}

// OriginalVersion returns the original API version used to create the resource.
func (extension *VirtualMachinesExtension_Spec) OriginalVersion() string {
	return GroupVersion.Version
}

// SetAzureName sets the Azure name of the resource
func (extension *VirtualMachinesExtension_Spec) SetAzureName(azureName string) {
	extension.AzureName = azureName
}

type VirtualMachinesExtension_STATUS struct {
	// AutoUpgradeMinorVersion: Indicates whether the extension should use a newer minor version if one is available at
	// deployment time. Once deployed, however, the extension will not upgrade minor versions unless redeployed, even with this
	// property set to true.
	AutoUpgradeMinorVersion *bool `json:"autoUpgradeMinorVersion,omitempty"`

	// Conditions: The observed state of the resource
	Conditions []conditions.Condition `json:"conditions,omitempty"`

	// EnableAutomaticUpgrade: Indicates whether the extension should be automatically upgraded by the platform if there is a
	// newer version of the extension available.
	EnableAutomaticUpgrade *bool `json:"enableAutomaticUpgrade,omitempty"`

	// ForceUpdateTag: How the extension handler should be forced to update even if the extension configuration has not changed.
	ForceUpdateTag *string `json:"forceUpdateTag,omitempty"`

	// Id: Resource Id
	Id *string `json:"id,omitempty"`

	// InstanceView: The virtual machine extension instance view.
	InstanceView *VirtualMachineExtensionInstanceView_STATUS `json:"instanceView,omitempty"`

	// Location: Resource location
	Location *string `json:"location,omitempty"`

	// Name: Resource name
	Name *string `json:"name,omitempty"`

	// PropertiesType: Specifies the type of the extension; an example is "CustomScriptExtension".
	PropertiesType *string `json:"properties_type,omitempty"`

	// ProtectedSettingsFromKeyVault: The extensions protected settings that are passed by reference, and consumed from key
	// vault
	ProtectedSettingsFromKeyVault *KeyVaultSecretReference_STATUS `json:"protectedSettingsFromKeyVault,omitempty"`

	// ProvisioningState: The provisioning state, which only appears in the response.
	ProvisioningState *string `json:"provisioningState,omitempty"`

	// Publisher: The name of the extension handler publisher.
	Publisher *string `json:"publisher,omitempty"`

	// Settings: Json formatted public settings for the extension.
	Settings map[string]v1.JSON `json:"settings,omitempty"`

	// SuppressFailures: Indicates whether failures stemming from the extension will be suppressed (Operational failures such
	// as not connecting to the VM will not be suppressed regardless of this value). The default is false.
	SuppressFailures *bool `json:"suppressFailures,omitempty"`

	// Tags: Resource tags
	Tags map[string]string `json:"tags,omitempty"`

	// Type: Resource type
	Type *string `json:"type,omitempty"`

	// TypeHandlerVersion: Specifies the version of the script handler.
	TypeHandlerVersion *string `json:"typeHandlerVersion,omitempty"`
}

var _ genruntime.ConvertibleStatus = &VirtualMachinesExtension_STATUS{}

// ConvertStatusFrom populates our VirtualMachinesExtension_STATUS from the provided source
func (extension *VirtualMachinesExtension_STATUS) ConvertStatusFrom(source genruntime.ConvertibleStatus) error {
	src, ok := source.(*storage.VirtualMachinesExtension_STATUS)
	if ok {
		// Populate our instance from source
		return extension.AssignProperties_From_VirtualMachinesExtension_STATUS(src)
	}

	// Convert to an intermediate form
	src = &storage.VirtualMachinesExtension_STATUS{}
	err := src.ConvertStatusFrom(source)
	if err != nil {
		return eris.Wrap(err, "initial step of conversion in ConvertStatusFrom()")
	}

	// Update our instance from src
	err = extension.AssignProperties_From_VirtualMachinesExtension_STATUS(src)
	if err != nil {
		return eris.Wrap(err, "final step of conversion in ConvertStatusFrom()")
	}

	return nil
}

// ConvertStatusTo populates the provided destination from our VirtualMachinesExtension_STATUS
func (extension *VirtualMachinesExtension_STATUS) ConvertStatusTo(destination genruntime.ConvertibleStatus) error {
	dst, ok := destination.(*storage.VirtualMachinesExtension_STATUS)
	if ok {
		// Populate destination from our instance
		return extension.AssignProperties_To_VirtualMachinesExtension_STATUS(dst)
	}

	// Convert to an intermediate form
	dst = &storage.VirtualMachinesExtension_STATUS{}
	err := extension.AssignProperties_To_VirtualMachinesExtension_STATUS(dst)
	if err != nil {
		return eris.Wrap(err, "initial step of conversion in ConvertStatusTo()")
	}

	// Update dst from our instance
	err = dst.ConvertStatusTo(destination)
	if err != nil {
		return eris.Wrap(err, "final step of conversion in ConvertStatusTo()")
	}

	return nil
}

var _ genruntime.FromARMConverter = &VirtualMachinesExtension_STATUS{}

// NewEmptyARMValue returns an empty ARM value suitable for deserializing into
func (extension *VirtualMachinesExtension_STATUS) NewEmptyARMValue() genruntime.ARMResourceStatus {
	return &arm.VirtualMachinesExtension_STATUS{}
}

// PopulateFromARM populates a Kubernetes CRD object from an Azure ARM object
func (extension *VirtualMachinesExtension_STATUS) PopulateFromARM(owner genruntime.ArbitraryOwnerReference, armInput interface{}) error {
	typedInput, ok := armInput.(arm.VirtualMachinesExtension_STATUS)
	if !ok {
		return fmt.Errorf("unexpected type supplied for PopulateFromARM() function. Expected arm.VirtualMachinesExtension_STATUS, got %T", armInput)
	}

	// Set property "AutoUpgradeMinorVersion":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.AutoUpgradeMinorVersion != nil {
			autoUpgradeMinorVersion := *typedInput.Properties.AutoUpgradeMinorVersion
			extension.AutoUpgradeMinorVersion = &autoUpgradeMinorVersion
		}
	}

	// no assignment for property "Conditions"

	// Set property "EnableAutomaticUpgrade":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.EnableAutomaticUpgrade != nil {
			enableAutomaticUpgrade := *typedInput.Properties.EnableAutomaticUpgrade
			extension.EnableAutomaticUpgrade = &enableAutomaticUpgrade
		}
	}

	// Set property "ForceUpdateTag":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ForceUpdateTag != nil {
			forceUpdateTag := *typedInput.Properties.ForceUpdateTag
			extension.ForceUpdateTag = &forceUpdateTag
		}
	}

	// Set property "Id":
	if typedInput.Id != nil {
		id := *typedInput.Id
		extension.Id = &id
	}

	// Set property "InstanceView":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.InstanceView != nil {
			var instanceView1 VirtualMachineExtensionInstanceView_STATUS
			err := instanceView1.PopulateFromARM(owner, *typedInput.Properties.InstanceView)
			if err != nil {
				return err
			}
			instanceView := instanceView1
			extension.InstanceView = &instanceView
		}
	}

	// Set property "Location":
	if typedInput.Location != nil {
		location := *typedInput.Location
		extension.Location = &location
	}

	// Set property "Name":
	if typedInput.Name != nil {
		name := *typedInput.Name
		extension.Name = &name
	}

	// Set property "PropertiesType":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Type != nil {
			propertiesType := *typedInput.Properties.Type
			extension.PropertiesType = &propertiesType
		}
	}

	// Set property "ProtectedSettingsFromKeyVault":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ProtectedSettingsFromKeyVault != nil {
			var protectedSettingsFromKeyVault1 KeyVaultSecretReference_STATUS
			err := protectedSettingsFromKeyVault1.PopulateFromARM(owner, *typedInput.Properties.ProtectedSettingsFromKeyVault)
			if err != nil {
				return err
			}
			protectedSettingsFromKeyVault := protectedSettingsFromKeyVault1
			extension.ProtectedSettingsFromKeyVault = &protectedSettingsFromKeyVault
		}
	}

	// Set property "ProvisioningState":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ProvisioningState != nil {
			provisioningState := *typedInput.Properties.ProvisioningState
			extension.ProvisioningState = &provisioningState
		}
	}

	// Set property "Publisher":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Publisher != nil {
			publisher := *typedInput.Properties.Publisher
			extension.Publisher = &publisher
		}
	}

	// Set property "Settings":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Settings != nil {
			extension.Settings = make(map[string]v1.JSON, len(typedInput.Properties.Settings))
			for key, value := range typedInput.Properties.Settings {
				extension.Settings[key] = *value.DeepCopy()
			}
		}
	}

	// Set property "SuppressFailures":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.SuppressFailures != nil {
			suppressFailures := *typedInput.Properties.SuppressFailures
			extension.SuppressFailures = &suppressFailures
		}
	}

	// Set property "Tags":
	if typedInput.Tags != nil {
		extension.Tags = make(map[string]string, len(typedInput.Tags))
		for key, value := range typedInput.Tags {
			extension.Tags[key] = value
		}
	}

	// Set property "Type":
	if typedInput.Type != nil {
		typeVar := *typedInput.Type
		extension.Type = &typeVar
	}

	// Set property "TypeHandlerVersion":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.TypeHandlerVersion != nil {
			typeHandlerVersion := *typedInput.Properties.TypeHandlerVersion
			extension.TypeHandlerVersion = &typeHandlerVersion
		}
	}

	// No error
	return nil
}

// AssignProperties_From_VirtualMachinesExtension_STATUS populates our VirtualMachinesExtension_STATUS from the provided source VirtualMachinesExtension_STATUS
func (extension *VirtualMachinesExtension_STATUS) AssignProperties_From_VirtualMachinesExtension_STATUS(source *storage.VirtualMachinesExtension_STATUS) error {

	// AutoUpgradeMinorVersion
	if source.AutoUpgradeMinorVersion != nil {
		autoUpgradeMinorVersion := *source.AutoUpgradeMinorVersion
		extension.AutoUpgradeMinorVersion = &autoUpgradeMinorVersion
	} else {
		extension.AutoUpgradeMinorVersion = nil
	}

	// Conditions
	extension.Conditions = genruntime.CloneSliceOfCondition(source.Conditions)

	// EnableAutomaticUpgrade
	if source.EnableAutomaticUpgrade != nil {
		enableAutomaticUpgrade := *source.EnableAutomaticUpgrade
		extension.EnableAutomaticUpgrade = &enableAutomaticUpgrade
	} else {
		extension.EnableAutomaticUpgrade = nil
	}

	// ForceUpdateTag
	extension.ForceUpdateTag = genruntime.ClonePointerToString(source.ForceUpdateTag)

	// Id
	extension.Id = genruntime.ClonePointerToString(source.Id)

	// InstanceView
	if source.InstanceView != nil {
		var instanceView VirtualMachineExtensionInstanceView_STATUS
		err := instanceView.AssignProperties_From_VirtualMachineExtensionInstanceView_STATUS(source.InstanceView)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_VirtualMachineExtensionInstanceView_STATUS() to populate field InstanceView")
		}
		extension.InstanceView = &instanceView
	} else {
		extension.InstanceView = nil
	}

	// Location
	extension.Location = genruntime.ClonePointerToString(source.Location)

	// Name
	extension.Name = genruntime.ClonePointerToString(source.Name)

	// PropertiesType
	extension.PropertiesType = genruntime.ClonePointerToString(source.PropertiesType)

	// ProtectedSettingsFromKeyVault
	if source.ProtectedSettingsFromKeyVault != nil {
		var protectedSettingsFromKeyVault KeyVaultSecretReference_STATUS
		err := protectedSettingsFromKeyVault.AssignProperties_From_KeyVaultSecretReference_STATUS(source.ProtectedSettingsFromKeyVault)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_KeyVaultSecretReference_STATUS() to populate field ProtectedSettingsFromKeyVault")
		}
		extension.ProtectedSettingsFromKeyVault = &protectedSettingsFromKeyVault
	} else {
		extension.ProtectedSettingsFromKeyVault = nil
	}

	// ProvisioningState
	extension.ProvisioningState = genruntime.ClonePointerToString(source.ProvisioningState)

	// Publisher
	extension.Publisher = genruntime.ClonePointerToString(source.Publisher)

	// Settings
	if source.Settings != nil {
		settingMap := make(map[string]v1.JSON, len(source.Settings))
		for settingKey, settingValue := range source.Settings {
			settingMap[settingKey] = *settingValue.DeepCopy()
		}
		extension.Settings = settingMap
	} else {
		extension.Settings = nil
	}

	// SuppressFailures
	if source.SuppressFailures != nil {
		suppressFailure := *source.SuppressFailures
		extension.SuppressFailures = &suppressFailure
	} else {
		extension.SuppressFailures = nil
	}

	// Tags
	extension.Tags = genruntime.CloneMapOfStringToString(source.Tags)

	// Type
	extension.Type = genruntime.ClonePointerToString(source.Type)

	// TypeHandlerVersion
	extension.TypeHandlerVersion = genruntime.ClonePointerToString(source.TypeHandlerVersion)

	// No error
	return nil
}

// AssignProperties_To_VirtualMachinesExtension_STATUS populates the provided destination VirtualMachinesExtension_STATUS from our VirtualMachinesExtension_STATUS
func (extension *VirtualMachinesExtension_STATUS) AssignProperties_To_VirtualMachinesExtension_STATUS(destination *storage.VirtualMachinesExtension_STATUS) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// AutoUpgradeMinorVersion
	if extension.AutoUpgradeMinorVersion != nil {
		autoUpgradeMinorVersion := *extension.AutoUpgradeMinorVersion
		destination.AutoUpgradeMinorVersion = &autoUpgradeMinorVersion
	} else {
		destination.AutoUpgradeMinorVersion = nil
	}

	// Conditions
	destination.Conditions = genruntime.CloneSliceOfCondition(extension.Conditions)

	// EnableAutomaticUpgrade
	if extension.EnableAutomaticUpgrade != nil {
		enableAutomaticUpgrade := *extension.EnableAutomaticUpgrade
		destination.EnableAutomaticUpgrade = &enableAutomaticUpgrade
	} else {
		destination.EnableAutomaticUpgrade = nil
	}

	// ForceUpdateTag
	destination.ForceUpdateTag = genruntime.ClonePointerToString(extension.ForceUpdateTag)

	// Id
	destination.Id = genruntime.ClonePointerToString(extension.Id)

	// InstanceView
	if extension.InstanceView != nil {
		var instanceView storage.VirtualMachineExtensionInstanceView_STATUS
		err := extension.InstanceView.AssignProperties_To_VirtualMachineExtensionInstanceView_STATUS(&instanceView)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_VirtualMachineExtensionInstanceView_STATUS() to populate field InstanceView")
		}
		destination.InstanceView = &instanceView
	} else {
		destination.InstanceView = nil
	}

	// Location
	destination.Location = genruntime.ClonePointerToString(extension.Location)

	// Name
	destination.Name = genruntime.ClonePointerToString(extension.Name)

	// PropertiesType
	destination.PropertiesType = genruntime.ClonePointerToString(extension.PropertiesType)

	// ProtectedSettingsFromKeyVault
	if extension.ProtectedSettingsFromKeyVault != nil {
		var protectedSettingsFromKeyVault storage.KeyVaultSecretReference_STATUS
		err := extension.ProtectedSettingsFromKeyVault.AssignProperties_To_KeyVaultSecretReference_STATUS(&protectedSettingsFromKeyVault)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_KeyVaultSecretReference_STATUS() to populate field ProtectedSettingsFromKeyVault")
		}
		destination.ProtectedSettingsFromKeyVault = &protectedSettingsFromKeyVault
	} else {
		destination.ProtectedSettingsFromKeyVault = nil
	}

	// ProvisioningState
	destination.ProvisioningState = genruntime.ClonePointerToString(extension.ProvisioningState)

	// Publisher
	destination.Publisher = genruntime.ClonePointerToString(extension.Publisher)

	// Settings
	if extension.Settings != nil {
		settingMap := make(map[string]v1.JSON, len(extension.Settings))
		for settingKey, settingValue := range extension.Settings {
			settingMap[settingKey] = *settingValue.DeepCopy()
		}
		destination.Settings = settingMap
	} else {
		destination.Settings = nil
	}

	// SuppressFailures
	if extension.SuppressFailures != nil {
		suppressFailure := *extension.SuppressFailures
		destination.SuppressFailures = &suppressFailure
	} else {
		destination.SuppressFailures = nil
	}

	// Tags
	destination.Tags = genruntime.CloneMapOfStringToString(extension.Tags)

	// Type
	destination.Type = genruntime.ClonePointerToString(extension.Type)

	// TypeHandlerVersion
	destination.TypeHandlerVersion = genruntime.ClonePointerToString(extension.TypeHandlerVersion)

	// Update the property bag
	if len(propertyBag) > 0 {
		destination.PropertyBag = propertyBag
	} else {
		destination.PropertyBag = nil
	}

	// No error
	return nil
}

// The instance view of a virtual machine extension.
type VirtualMachineExtensionInstanceView struct {
	// Name: The virtual machine extension name.
	Name *string `json:"name,omitempty"`

	// Statuses: The resource status information.
	Statuses []InstanceViewStatus `json:"statuses,omitempty"`

	// Substatuses: The resource status information.
	Substatuses []InstanceViewStatus `json:"substatuses,omitempty"`

	// Type: Specifies the type of the extension; an example is "CustomScriptExtension".
	Type *string `json:"type,omitempty"`

	// TypeHandlerVersion: Specifies the version of the script handler.
	TypeHandlerVersion *string `json:"typeHandlerVersion,omitempty"`
}

var _ genruntime.ARMTransformer = &VirtualMachineExtensionInstanceView{}

// ConvertToARM converts from a Kubernetes CRD object to an ARM object
func (view *VirtualMachineExtensionInstanceView) ConvertToARM(resolved genruntime.ConvertToARMResolvedDetails) (interface{}, error) {
	if view == nil {
		return nil, nil
	}
	result := &arm.VirtualMachineExtensionInstanceView{}

	// Set property "Name":
	if view.Name != nil {
		name := *view.Name
		result.Name = &name
	}

	// Set property "Statuses":
	for _, item := range view.Statuses {
		item_ARM, err := item.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		result.Statuses = append(result.Statuses, *item_ARM.(*arm.InstanceViewStatus))
	}

	// Set property "Substatuses":
	for _, item := range view.Substatuses {
		item_ARM, err := item.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		result.Substatuses = append(result.Substatuses, *item_ARM.(*arm.InstanceViewStatus))
	}

	// Set property "Type":
	if view.Type != nil {
		typeVar := *view.Type
		result.Type = &typeVar
	}

	// Set property "TypeHandlerVersion":
	if view.TypeHandlerVersion != nil {
		typeHandlerVersion := *view.TypeHandlerVersion
		result.TypeHandlerVersion = &typeHandlerVersion
	}
	return result, nil
}

// NewEmptyARMValue returns an empty ARM value suitable for deserializing into
func (view *VirtualMachineExtensionInstanceView) NewEmptyARMValue() genruntime.ARMResourceStatus {
	return &arm.VirtualMachineExtensionInstanceView{}
}

// PopulateFromARM populates a Kubernetes CRD object from an Azure ARM object
func (view *VirtualMachineExtensionInstanceView) PopulateFromARM(owner genruntime.ArbitraryOwnerReference, armInput interface{}) error {
	typedInput, ok := armInput.(arm.VirtualMachineExtensionInstanceView)
	if !ok {
		return fmt.Errorf("unexpected type supplied for PopulateFromARM() function. Expected arm.VirtualMachineExtensionInstanceView, got %T", armInput)
	}

	// Set property "Name":
	if typedInput.Name != nil {
		name := *typedInput.Name
		view.Name = &name
	}

	// Set property "Statuses":
	for _, item := range typedInput.Statuses {
		var item1 InstanceViewStatus
		err := item1.PopulateFromARM(owner, item)
		if err != nil {
			return err
		}
		view.Statuses = append(view.Statuses, item1)
	}

	// Set property "Substatuses":
	for _, item := range typedInput.Substatuses {
		var item1 InstanceViewStatus
		err := item1.PopulateFromARM(owner, item)
		if err != nil {
			return err
		}
		view.Substatuses = append(view.Substatuses, item1)
	}

	// Set property "Type":
	if typedInput.Type != nil {
		typeVar := *typedInput.Type
		view.Type = &typeVar
	}

	// Set property "TypeHandlerVersion":
	if typedInput.TypeHandlerVersion != nil {
		typeHandlerVersion := *typedInput.TypeHandlerVersion
		view.TypeHandlerVersion = &typeHandlerVersion
	}

	// No error
	return nil
}

// AssignProperties_From_VirtualMachineExtensionInstanceView populates our VirtualMachineExtensionInstanceView from the provided source VirtualMachineExtensionInstanceView
func (view *VirtualMachineExtensionInstanceView) AssignProperties_From_VirtualMachineExtensionInstanceView(source *storage.VirtualMachineExtensionInstanceView) error {

	// Name
	view.Name = genruntime.ClonePointerToString(source.Name)

	// Statuses
	if source.Statuses != nil {
		statusList := make([]InstanceViewStatus, len(source.Statuses))
		for statusIndex, statusItem := range source.Statuses {
			var status InstanceViewStatus
			err := status.AssignProperties_From_InstanceViewStatus(&statusItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_InstanceViewStatus() to populate field Statuses")
			}
			statusList[statusIndex] = status
		}
		view.Statuses = statusList
	} else {
		view.Statuses = nil
	}

	// Substatuses
	if source.Substatuses != nil {
		substatusList := make([]InstanceViewStatus, len(source.Substatuses))
		for substatusIndex, substatusItem := range source.Substatuses {
			var substatus InstanceViewStatus
			err := substatus.AssignProperties_From_InstanceViewStatus(&substatusItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_InstanceViewStatus() to populate field Substatuses")
			}
			substatusList[substatusIndex] = substatus
		}
		view.Substatuses = substatusList
	} else {
		view.Substatuses = nil
	}

	// Type
	view.Type = genruntime.ClonePointerToString(source.Type)

	// TypeHandlerVersion
	view.TypeHandlerVersion = genruntime.ClonePointerToString(source.TypeHandlerVersion)

	// No error
	return nil
}

// AssignProperties_To_VirtualMachineExtensionInstanceView populates the provided destination VirtualMachineExtensionInstanceView from our VirtualMachineExtensionInstanceView
func (view *VirtualMachineExtensionInstanceView) AssignProperties_To_VirtualMachineExtensionInstanceView(destination *storage.VirtualMachineExtensionInstanceView) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// Name
	destination.Name = genruntime.ClonePointerToString(view.Name)

	// Statuses
	if view.Statuses != nil {
		statusList := make([]storage.InstanceViewStatus, len(view.Statuses))
		for statusIndex, statusItem := range view.Statuses {
			var status storage.InstanceViewStatus
			err := statusItem.AssignProperties_To_InstanceViewStatus(&status)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_InstanceViewStatus() to populate field Statuses")
			}
			statusList[statusIndex] = status
		}
		destination.Statuses = statusList
	} else {
		destination.Statuses = nil
	}

	// Substatuses
	if view.Substatuses != nil {
		substatusList := make([]storage.InstanceViewStatus, len(view.Substatuses))
		for substatusIndex, substatusItem := range view.Substatuses {
			var substatus storage.InstanceViewStatus
			err := substatusItem.AssignProperties_To_InstanceViewStatus(&substatus)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_InstanceViewStatus() to populate field Substatuses")
			}
			substatusList[substatusIndex] = substatus
		}
		destination.Substatuses = substatusList
	} else {
		destination.Substatuses = nil
	}

	// Type
	destination.Type = genruntime.ClonePointerToString(view.Type)

	// TypeHandlerVersion
	destination.TypeHandlerVersion = genruntime.ClonePointerToString(view.TypeHandlerVersion)

	// Update the property bag
	if len(propertyBag) > 0 {
		destination.PropertyBag = propertyBag
	} else {
		destination.PropertyBag = nil
	}

	// No error
	return nil
}

// Initialize_From_VirtualMachineExtensionInstanceView_STATUS populates our VirtualMachineExtensionInstanceView from the provided source VirtualMachineExtensionInstanceView_STATUS
func (view *VirtualMachineExtensionInstanceView) Initialize_From_VirtualMachineExtensionInstanceView_STATUS(source *VirtualMachineExtensionInstanceView_STATUS) error {

	// Name
	view.Name = genruntime.ClonePointerToString(source.Name)

	// Statuses
	if source.Statuses != nil {
		statusList := make([]InstanceViewStatus, len(source.Statuses))
		for statusIndex, statusItem := range source.Statuses {
			var status InstanceViewStatus
			err := status.Initialize_From_InstanceViewStatus_STATUS(&statusItem)
			if err != nil {
				return eris.Wrap(err, "calling Initialize_From_InstanceViewStatus_STATUS() to populate field Statuses")
			}
			statusList[statusIndex] = status
		}
		view.Statuses = statusList
	} else {
		view.Statuses = nil
	}

	// Substatuses
	if source.Substatuses != nil {
		substatusList := make([]InstanceViewStatus, len(source.Substatuses))
		for substatusIndex, substatusItem := range source.Substatuses {
			var substatus InstanceViewStatus
			err := substatus.Initialize_From_InstanceViewStatus_STATUS(&substatusItem)
			if err != nil {
				return eris.Wrap(err, "calling Initialize_From_InstanceViewStatus_STATUS() to populate field Substatuses")
			}
			substatusList[substatusIndex] = substatus
		}
		view.Substatuses = substatusList
	} else {
		view.Substatuses = nil
	}

	// Type
	view.Type = genruntime.ClonePointerToString(source.Type)

	// TypeHandlerVersion
	view.TypeHandlerVersion = genruntime.ClonePointerToString(source.TypeHandlerVersion)

	// No error
	return nil
}

// The instance view of a virtual machine extension.
type VirtualMachineExtensionInstanceView_STATUS struct {
	// Name: The virtual machine extension name.
	Name *string `json:"name,omitempty"`

	// Statuses: The resource status information.
	Statuses []InstanceViewStatus_STATUS `json:"statuses,omitempty"`

	// Substatuses: The resource status information.
	Substatuses []InstanceViewStatus_STATUS `json:"substatuses,omitempty"`

	// Type: Specifies the type of the extension; an example is "CustomScriptExtension".
	Type *string `json:"type,omitempty"`

	// TypeHandlerVersion: Specifies the version of the script handler.
	TypeHandlerVersion *string `json:"typeHandlerVersion,omitempty"`
}

var _ genruntime.FromARMConverter = &VirtualMachineExtensionInstanceView_STATUS{}

// NewEmptyARMValue returns an empty ARM value suitable for deserializing into
func (view *VirtualMachineExtensionInstanceView_STATUS) NewEmptyARMValue() genruntime.ARMResourceStatus {
	return &arm.VirtualMachineExtensionInstanceView_STATUS{}
}

// PopulateFromARM populates a Kubernetes CRD object from an Azure ARM object
func (view *VirtualMachineExtensionInstanceView_STATUS) PopulateFromARM(owner genruntime.ArbitraryOwnerReference, armInput interface{}) error {
	typedInput, ok := armInput.(arm.VirtualMachineExtensionInstanceView_STATUS)
	if !ok {
		return fmt.Errorf("unexpected type supplied for PopulateFromARM() function. Expected arm.VirtualMachineExtensionInstanceView_STATUS, got %T", armInput)
	}

	// Set property "Name":
	if typedInput.Name != nil {
		name := *typedInput.Name
		view.Name = &name
	}

	// Set property "Statuses":
	for _, item := range typedInput.Statuses {
		var item1 InstanceViewStatus_STATUS
		err := item1.PopulateFromARM(owner, item)
		if err != nil {
			return err
		}
		view.Statuses = append(view.Statuses, item1)
	}

	// Set property "Substatuses":
	for _, item := range typedInput.Substatuses {
		var item1 InstanceViewStatus_STATUS
		err := item1.PopulateFromARM(owner, item)
		if err != nil {
			return err
		}
		view.Substatuses = append(view.Substatuses, item1)
	}

	// Set property "Type":
	if typedInput.Type != nil {
		typeVar := *typedInput.Type
		view.Type = &typeVar
	}

	// Set property "TypeHandlerVersion":
	if typedInput.TypeHandlerVersion != nil {
		typeHandlerVersion := *typedInput.TypeHandlerVersion
		view.TypeHandlerVersion = &typeHandlerVersion
	}

	// No error
	return nil
}

// AssignProperties_From_VirtualMachineExtensionInstanceView_STATUS populates our VirtualMachineExtensionInstanceView_STATUS from the provided source VirtualMachineExtensionInstanceView_STATUS
func (view *VirtualMachineExtensionInstanceView_STATUS) AssignProperties_From_VirtualMachineExtensionInstanceView_STATUS(source *storage.VirtualMachineExtensionInstanceView_STATUS) error {

	// Name
	view.Name = genruntime.ClonePointerToString(source.Name)

	// Statuses
	if source.Statuses != nil {
		statusList := make([]InstanceViewStatus_STATUS, len(source.Statuses))
		for statusIndex, statusItem := range source.Statuses {
			var status InstanceViewStatus_STATUS
			err := status.AssignProperties_From_InstanceViewStatus_STATUS(&statusItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_InstanceViewStatus_STATUS() to populate field Statuses")
			}
			statusList[statusIndex] = status
		}
		view.Statuses = statusList
	} else {
		view.Statuses = nil
	}

	// Substatuses
	if source.Substatuses != nil {
		substatusList := make([]InstanceViewStatus_STATUS, len(source.Substatuses))
		for substatusIndex, substatusItem := range source.Substatuses {
			var substatus InstanceViewStatus_STATUS
			err := substatus.AssignProperties_From_InstanceViewStatus_STATUS(&substatusItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_InstanceViewStatus_STATUS() to populate field Substatuses")
			}
			substatusList[substatusIndex] = substatus
		}
		view.Substatuses = substatusList
	} else {
		view.Substatuses = nil
	}

	// Type
	view.Type = genruntime.ClonePointerToString(source.Type)

	// TypeHandlerVersion
	view.TypeHandlerVersion = genruntime.ClonePointerToString(source.TypeHandlerVersion)

	// No error
	return nil
}

// AssignProperties_To_VirtualMachineExtensionInstanceView_STATUS populates the provided destination VirtualMachineExtensionInstanceView_STATUS from our VirtualMachineExtensionInstanceView_STATUS
func (view *VirtualMachineExtensionInstanceView_STATUS) AssignProperties_To_VirtualMachineExtensionInstanceView_STATUS(destination *storage.VirtualMachineExtensionInstanceView_STATUS) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// Name
	destination.Name = genruntime.ClonePointerToString(view.Name)

	// Statuses
	if view.Statuses != nil {
		statusList := make([]storage.InstanceViewStatus_STATUS, len(view.Statuses))
		for statusIndex, statusItem := range view.Statuses {
			var status storage.InstanceViewStatus_STATUS
			err := statusItem.AssignProperties_To_InstanceViewStatus_STATUS(&status)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_InstanceViewStatus_STATUS() to populate field Statuses")
			}
			statusList[statusIndex] = status
		}
		destination.Statuses = statusList
	} else {
		destination.Statuses = nil
	}

	// Substatuses
	if view.Substatuses != nil {
		substatusList := make([]storage.InstanceViewStatus_STATUS, len(view.Substatuses))
		for substatusIndex, substatusItem := range view.Substatuses {
			var substatus storage.InstanceViewStatus_STATUS
			err := substatusItem.AssignProperties_To_InstanceViewStatus_STATUS(&substatus)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_InstanceViewStatus_STATUS() to populate field Substatuses")
			}
			substatusList[substatusIndex] = substatus
		}
		destination.Substatuses = substatusList
	} else {
		destination.Substatuses = nil
	}

	// Type
	destination.Type = genruntime.ClonePointerToString(view.Type)

	// TypeHandlerVersion
	destination.TypeHandlerVersion = genruntime.ClonePointerToString(view.TypeHandlerVersion)

	// Update the property bag
	if len(propertyBag) > 0 {
		destination.PropertyBag = propertyBag
	} else {
		destination.PropertyBag = nil
	}

	// No error
	return nil
}

// Details for configuring operator behavior. Fields in this struct are interpreted by the operator directly rather than being passed to Azure
type VirtualMachinesExtensionOperatorSpec struct {
	// ConfigMapExpressions: configures where to place operator written dynamic ConfigMaps (created with CEL expressions).
	ConfigMapExpressions []*core.DestinationExpression `json:"configMapExpressions,omitempty"`

	// SecretExpressions: configures where to place operator written dynamic secrets (created with CEL expressions).
	SecretExpressions []*core.DestinationExpression `json:"secretExpressions,omitempty"`
}

// AssignProperties_From_VirtualMachinesExtensionOperatorSpec populates our VirtualMachinesExtensionOperatorSpec from the provided source VirtualMachinesExtensionOperatorSpec
func (operator *VirtualMachinesExtensionOperatorSpec) AssignProperties_From_VirtualMachinesExtensionOperatorSpec(source *storage.VirtualMachinesExtensionOperatorSpec) error {

	// ConfigMapExpressions
	if source.ConfigMapExpressions != nil {
		configMapExpressionList := make([]*core.DestinationExpression, len(source.ConfigMapExpressions))
		for configMapExpressionIndex, configMapExpressionItem := range source.ConfigMapExpressions {
			if configMapExpressionItem != nil {
				configMapExpression := *configMapExpressionItem.DeepCopy()
				configMapExpressionList[configMapExpressionIndex] = &configMapExpression
			} else {
				configMapExpressionList[configMapExpressionIndex] = nil
			}
		}
		operator.ConfigMapExpressions = configMapExpressionList
	} else {
		operator.ConfigMapExpressions = nil
	}

	// SecretExpressions
	if source.SecretExpressions != nil {
		secretExpressionList := make([]*core.DestinationExpression, len(source.SecretExpressions))
		for secretExpressionIndex, secretExpressionItem := range source.SecretExpressions {
			if secretExpressionItem != nil {
				secretExpression := *secretExpressionItem.DeepCopy()
				secretExpressionList[secretExpressionIndex] = &secretExpression
			} else {
				secretExpressionList[secretExpressionIndex] = nil
			}
		}
		operator.SecretExpressions = secretExpressionList
	} else {
		operator.SecretExpressions = nil
	}

	// No error
	return nil
}

// AssignProperties_To_VirtualMachinesExtensionOperatorSpec populates the provided destination VirtualMachinesExtensionOperatorSpec from our VirtualMachinesExtensionOperatorSpec
func (operator *VirtualMachinesExtensionOperatorSpec) AssignProperties_To_VirtualMachinesExtensionOperatorSpec(destination *storage.VirtualMachinesExtensionOperatorSpec) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// ConfigMapExpressions
	if operator.ConfigMapExpressions != nil {
		configMapExpressionList := make([]*core.DestinationExpression, len(operator.ConfigMapExpressions))
		for configMapExpressionIndex, configMapExpressionItem := range operator.ConfigMapExpressions {
			if configMapExpressionItem != nil {
				configMapExpression := *configMapExpressionItem.DeepCopy()
				configMapExpressionList[configMapExpressionIndex] = &configMapExpression
			} else {
				configMapExpressionList[configMapExpressionIndex] = nil
			}
		}
		destination.ConfigMapExpressions = configMapExpressionList
	} else {
		destination.ConfigMapExpressions = nil
	}

	// SecretExpressions
	if operator.SecretExpressions != nil {
		secretExpressionList := make([]*core.DestinationExpression, len(operator.SecretExpressions))
		for secretExpressionIndex, secretExpressionItem := range operator.SecretExpressions {
			if secretExpressionItem != nil {
				secretExpression := *secretExpressionItem.DeepCopy()
				secretExpressionList[secretExpressionIndex] = &secretExpression
			} else {
				secretExpressionList[secretExpressionIndex] = nil
			}
		}
		destination.SecretExpressions = secretExpressionList
	} else {
		destination.SecretExpressions = nil
	}

	// Update the property bag
	if len(propertyBag) > 0 {
		destination.PropertyBag = propertyBag
	} else {
		destination.PropertyBag = nil
	}

	// No error
	return nil
}

// Instance view status.
type InstanceViewStatus struct {
	// Code: The status code.
	Code *string `json:"code,omitempty"`

	// DisplayStatus: The short localizable label for the status.
	DisplayStatus *string `json:"displayStatus,omitempty"`

	// Level: The level code.
	Level *InstanceViewStatus_Level `json:"level,omitempty"`

	// Message: The detailed status message, including for alerts and error messages.
	Message *string `json:"message,omitempty"`

	// Time: The time of the status.
	Time *string `json:"time,omitempty"`
}

var _ genruntime.ARMTransformer = &InstanceViewStatus{}

// ConvertToARM converts from a Kubernetes CRD object to an ARM object
func (status *InstanceViewStatus) ConvertToARM(resolved genruntime.ConvertToARMResolvedDetails) (interface{}, error) {
	if status == nil {
		return nil, nil
	}
	result := &arm.InstanceViewStatus{}

	// Set property "Code":
	if status.Code != nil {
		code := *status.Code
		result.Code = &code
	}

	// Set property "DisplayStatus":
	if status.DisplayStatus != nil {
		displayStatus := *status.DisplayStatus
		result.DisplayStatus = &displayStatus
	}

	// Set property "Level":
	if status.Level != nil {
		var temp string
		temp = string(*status.Level)
		level := arm.InstanceViewStatus_Level(temp)
		result.Level = &level
	}

	// Set property "Message":
	if status.Message != nil {
		message := *status.Message
		result.Message = &message
	}

	// Set property "Time":
	if status.Time != nil {
		time := *status.Time
		result.Time = &time
	}
	return result, nil
}

// NewEmptyARMValue returns an empty ARM value suitable for deserializing into
func (status *InstanceViewStatus) NewEmptyARMValue() genruntime.ARMResourceStatus {
	return &arm.InstanceViewStatus{}
}

// PopulateFromARM populates a Kubernetes CRD object from an Azure ARM object
func (status *InstanceViewStatus) PopulateFromARM(owner genruntime.ArbitraryOwnerReference, armInput interface{}) error {
	typedInput, ok := armInput.(arm.InstanceViewStatus)
	if !ok {
		return fmt.Errorf("unexpected type supplied for PopulateFromARM() function. Expected arm.InstanceViewStatus, got %T", armInput)
	}

	// Set property "Code":
	if typedInput.Code != nil {
		code := *typedInput.Code
		status.Code = &code
	}

	// Set property "DisplayStatus":
	if typedInput.DisplayStatus != nil {
		displayStatus := *typedInput.DisplayStatus
		status.DisplayStatus = &displayStatus
	}

	// Set property "Level":
	if typedInput.Level != nil {
		var temp string
		temp = string(*typedInput.Level)
		level := InstanceViewStatus_Level(temp)
		status.Level = &level
	}

	// Set property "Message":
	if typedInput.Message != nil {
		message := *typedInput.Message
		status.Message = &message
	}

	// Set property "Time":
	if typedInput.Time != nil {
		time := *typedInput.Time
		status.Time = &time
	}

	// No error
	return nil
}

// AssignProperties_From_InstanceViewStatus populates our InstanceViewStatus from the provided source InstanceViewStatus
func (status *InstanceViewStatus) AssignProperties_From_InstanceViewStatus(source *storage.InstanceViewStatus) error {

	// Code
	status.Code = genruntime.ClonePointerToString(source.Code)

	// DisplayStatus
	status.DisplayStatus = genruntime.ClonePointerToString(source.DisplayStatus)

	// Level
	if source.Level != nil {
		level := *source.Level
		levelTemp := genruntime.ToEnum(level, instanceViewStatus_Level_Values)
		status.Level = &levelTemp
	} else {
		status.Level = nil
	}

	// Message
	status.Message = genruntime.ClonePointerToString(source.Message)

	// Time
	status.Time = genruntime.ClonePointerToString(source.Time)

	// No error
	return nil
}

// AssignProperties_To_InstanceViewStatus populates the provided destination InstanceViewStatus from our InstanceViewStatus
func (status *InstanceViewStatus) AssignProperties_To_InstanceViewStatus(destination *storage.InstanceViewStatus) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// Code
	destination.Code = genruntime.ClonePointerToString(status.Code)

	// DisplayStatus
	destination.DisplayStatus = genruntime.ClonePointerToString(status.DisplayStatus)

	// Level
	if status.Level != nil {
		level := string(*status.Level)
		destination.Level = &level
	} else {
		destination.Level = nil
	}

	// Message
	destination.Message = genruntime.ClonePointerToString(status.Message)

	// Time
	destination.Time = genruntime.ClonePointerToString(status.Time)

	// Update the property bag
	if len(propertyBag) > 0 {
		destination.PropertyBag = propertyBag
	} else {
		destination.PropertyBag = nil
	}

	// No error
	return nil
}

// Initialize_From_InstanceViewStatus_STATUS populates our InstanceViewStatus from the provided source InstanceViewStatus_STATUS
func (status *InstanceViewStatus) Initialize_From_InstanceViewStatus_STATUS(source *InstanceViewStatus_STATUS) error {

	// Code
	status.Code = genruntime.ClonePointerToString(source.Code)

	// DisplayStatus
	status.DisplayStatus = genruntime.ClonePointerToString(source.DisplayStatus)

	// Level
	if source.Level != nil {
		level := genruntime.ToEnum(string(*source.Level), instanceViewStatus_Level_Values)
		status.Level = &level
	} else {
		status.Level = nil
	}

	// Message
	status.Message = genruntime.ClonePointerToString(source.Message)

	// Time
	status.Time = genruntime.ClonePointerToString(source.Time)

	// No error
	return nil
}

// +kubebuilder:validation:Enum={"Error","Info","Warning"}
type InstanceViewStatus_Level string

const (
	InstanceViewStatus_Level_Error   = InstanceViewStatus_Level("Error")
	InstanceViewStatus_Level_Info    = InstanceViewStatus_Level("Info")
	InstanceViewStatus_Level_Warning = InstanceViewStatus_Level("Warning")
)

// Mapping from string to InstanceViewStatus_Level
var instanceViewStatus_Level_Values = map[string]InstanceViewStatus_Level{
	"error":   InstanceViewStatus_Level_Error,
	"info":    InstanceViewStatus_Level_Info,
	"warning": InstanceViewStatus_Level_Warning,
}

func init() {
	SchemeBuilder.Register(&VirtualMachinesExtension{}, &VirtualMachinesExtensionList{})
}
