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

import (
	"fmt"
	arm "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20250301/arm"
	storage "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20250301/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"
	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,containerservice}
// +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: /containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2025-03-01/fleets.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/fleets/{fleetName}/autoUpgradeProfiles/{autoUpgradeProfileName}
type FleetsAutoUpgradeProfile struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              FleetsAutoUpgradeProfile_Spec   `json:"spec,omitempty"`
	Status            FleetsAutoUpgradeProfile_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &FleetsAutoUpgradeProfile{}

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

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

var _ conversion.Convertible = &FleetsAutoUpgradeProfile{}

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

	return profile.AssignProperties_From_FleetsAutoUpgradeProfile(source)
}

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

	return profile.AssignProperties_To_FleetsAutoUpgradeProfile(destination)
}

var _ configmaps.Exporter = &FleetsAutoUpgradeProfile{}

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

var _ secrets.Exporter = &FleetsAutoUpgradeProfile{}

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

var _ genruntime.ImportableResource = &FleetsAutoUpgradeProfile{}

// InitializeSpec initializes the spec for this resource from the given status
func (profile *FleetsAutoUpgradeProfile) InitializeSpec(status genruntime.ConvertibleStatus) error {
	if s, ok := status.(*FleetsAutoUpgradeProfile_STATUS); ok {
		return profile.Spec.Initialize_From_FleetsAutoUpgradeProfile_STATUS(s)
	}

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

var _ genruntime.KubernetesResource = &FleetsAutoUpgradeProfile{}

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

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

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.ContainerService/fleets/autoUpgradeProfiles"
func (profile *FleetsAutoUpgradeProfile) GetType() string {
	return "Microsoft.ContainerService/fleets/autoUpgradeProfiles"
}

// NewEmptyStatus returns a new empty (blank) status
func (profile *FleetsAutoUpgradeProfile) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &FleetsAutoUpgradeProfile_STATUS{}
}

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

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

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

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

	profile.Status = st
	return nil
}

// AssignProperties_From_FleetsAutoUpgradeProfile populates our FleetsAutoUpgradeProfile from the provided source FleetsAutoUpgradeProfile
func (profile *FleetsAutoUpgradeProfile) AssignProperties_From_FleetsAutoUpgradeProfile(source *storage.FleetsAutoUpgradeProfile) error {

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

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

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

	// No error
	return nil
}

// AssignProperties_To_FleetsAutoUpgradeProfile populates the provided destination FleetsAutoUpgradeProfile from our FleetsAutoUpgradeProfile
func (profile *FleetsAutoUpgradeProfile) AssignProperties_To_FleetsAutoUpgradeProfile(destination *storage.FleetsAutoUpgradeProfile) error {

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

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

	// Status
	var status storage.FleetsAutoUpgradeProfile_STATUS
	err = profile.Status.AssignProperties_To_FleetsAutoUpgradeProfile_STATUS(&status)
	if err != nil {
		return eris.Wrap(err, "calling AssignProperties_To_FleetsAutoUpgradeProfile_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 (profile *FleetsAutoUpgradeProfile) OriginalGVK() *schema.GroupVersionKind {
	return &schema.GroupVersionKind{
		Group:   GroupVersion.Group,
		Version: profile.Spec.OriginalVersion(),
		Kind:    "FleetsAutoUpgradeProfile",
	}
}

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2025-03-01/fleets.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/fleets/{fleetName}/autoUpgradeProfiles/{autoUpgradeProfileName}
type FleetsAutoUpgradeProfileList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []FleetsAutoUpgradeProfile `json:"items"`
}

type FleetsAutoUpgradeProfile_Spec struct {
	// +kubebuilder:validation:MaxLength=50
	// +kubebuilder:validation:MinLength=1
	// +kubebuilder:validation:Pattern="^[a-z0-9]([-a-z0-9]*[a-z0-9])?$"
	// 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"`

	// +kubebuilder:validation:Required
	// Channel: Configures how auto-upgrade will be run.
	Channel *UpgradeChannel `json:"channel,omitempty"`

	// Disabled: If set to False: the auto upgrade has effect - target managed clusters will be upgraded on schedule.
	// If set to True: the auto upgrade has no effect - no upgrade will be run on the target managed clusters.
	// This is a boolean and not an enum because enabled/disabled are all available states of the auto upgrade profile.
	// By default, this is set to False.
	Disabled *bool `json:"disabled,omitempty"`

	// NodeImageSelection: The node image upgrade to be applied to the target clusters in auto upgrade.
	NodeImageSelection *AutoUpgradeNodeImageSelection `json:"nodeImageSelection,omitempty"`

	// OperatorSpec: The specification for configuring operator behavior. This field is interpreted by the operator and not
	// passed directly to Azure
	OperatorSpec *FleetsAutoUpgradeProfileOperatorSpec `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 containerservice.azure.com/Fleet resource
	Owner *genruntime.KnownResourceReference `group:"containerservice.azure.com" json:"owner,omitempty" kind:"Fleet"`

	// UpdateStrategyReference: The resource id of the UpdateStrategy resource to reference. If not specified, the auto upgrade
	// will run on all clusters which are members of the fleet.
	UpdateStrategyReference *genruntime.ResourceReference `armReference:"UpdateStrategyId" json:"updateStrategyReference,omitempty"`
}

var _ genruntime.ARMTransformer = &FleetsAutoUpgradeProfile_Spec{}

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

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

	// Set property "Properties":
	if profile.Channel != nil ||
		profile.Disabled != nil ||
		profile.NodeImageSelection != nil ||
		profile.UpdateStrategyReference != nil {
		result.Properties = &arm.AutoUpgradeProfileProperties{}
	}
	if profile.Channel != nil {
		var temp string
		temp = string(*profile.Channel)
		channel := arm.UpgradeChannel(temp)
		result.Properties.Channel = &channel
	}
	if profile.Disabled != nil {
		disabled := *profile.Disabled
		result.Properties.Disabled = &disabled
	}
	if profile.NodeImageSelection != nil {
		nodeImageSelection_ARM, err := profile.NodeImageSelection.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		nodeImageSelection := *nodeImageSelection_ARM.(*arm.AutoUpgradeNodeImageSelection)
		result.Properties.NodeImageSelection = &nodeImageSelection
	}
	if profile.UpdateStrategyReference != nil {
		updateStrategyIdARMID, err := resolved.ResolvedReferences.Lookup(*profile.UpdateStrategyReference)
		if err != nil {
			return nil, err
		}
		updateStrategyId := updateStrategyIdARMID
		result.Properties.UpdateStrategyId = &updateStrategyId
	}
	return result, nil
}

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

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

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

	// Set property "Channel":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Channel != nil {
			var temp string
			temp = string(*typedInput.Properties.Channel)
			channel := UpgradeChannel(temp)
			profile.Channel = &channel
		}
	}

	// Set property "Disabled":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Disabled != nil {
			disabled := *typedInput.Properties.Disabled
			profile.Disabled = &disabled
		}
	}

	// Set property "NodeImageSelection":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.NodeImageSelection != nil {
			var nodeImageSelection1 AutoUpgradeNodeImageSelection
			err := nodeImageSelection1.PopulateFromARM(owner, *typedInput.Properties.NodeImageSelection)
			if err != nil {
				return err
			}
			nodeImageSelection := nodeImageSelection1
			profile.NodeImageSelection = &nodeImageSelection
		}
	}

	// no assignment for property "OperatorSpec"

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

	// no assignment for property "UpdateStrategyReference"

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &FleetsAutoUpgradeProfile_Spec{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.FleetsAutoUpgradeProfile_Spec{}
	err := profile.AssignProperties_To_FleetsAutoUpgradeProfile_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_FleetsAutoUpgradeProfile_Spec populates our FleetsAutoUpgradeProfile_Spec from the provided source FleetsAutoUpgradeProfile_Spec
func (profile *FleetsAutoUpgradeProfile_Spec) AssignProperties_From_FleetsAutoUpgradeProfile_Spec(source *storage.FleetsAutoUpgradeProfile_Spec) error {

	// AzureName
	profile.AzureName = source.AzureName

	// Channel
	if source.Channel != nil {
		channel := *source.Channel
		channelTemp := genruntime.ToEnum(channel, upgradeChannel_Values)
		profile.Channel = &channelTemp
	} else {
		profile.Channel = nil
	}

	// Disabled
	if source.Disabled != nil {
		disabled := *source.Disabled
		profile.Disabled = &disabled
	} else {
		profile.Disabled = nil
	}

	// NodeImageSelection
	if source.NodeImageSelection != nil {
		var nodeImageSelection AutoUpgradeNodeImageSelection
		err := nodeImageSelection.AssignProperties_From_AutoUpgradeNodeImageSelection(source.NodeImageSelection)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_AutoUpgradeNodeImageSelection() to populate field NodeImageSelection")
		}
		profile.NodeImageSelection = &nodeImageSelection
	} else {
		profile.NodeImageSelection = nil
	}

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

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

	// UpdateStrategyReference
	if source.UpdateStrategyReference != nil {
		updateStrategyReference := source.UpdateStrategyReference.Copy()
		profile.UpdateStrategyReference = &updateStrategyReference
	} else {
		profile.UpdateStrategyReference = nil
	}

	// No error
	return nil
}

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

	// AzureName
	destination.AzureName = profile.AzureName

	// Channel
	if profile.Channel != nil {
		channel := string(*profile.Channel)
		destination.Channel = &channel
	} else {
		destination.Channel = nil
	}

	// Disabled
	if profile.Disabled != nil {
		disabled := *profile.Disabled
		destination.Disabled = &disabled
	} else {
		destination.Disabled = nil
	}

	// NodeImageSelection
	if profile.NodeImageSelection != nil {
		var nodeImageSelection storage.AutoUpgradeNodeImageSelection
		err := profile.NodeImageSelection.AssignProperties_To_AutoUpgradeNodeImageSelection(&nodeImageSelection)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_AutoUpgradeNodeImageSelection() to populate field NodeImageSelection")
		}
		destination.NodeImageSelection = &nodeImageSelection
	} else {
		destination.NodeImageSelection = nil
	}

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

	// OriginalVersion
	destination.OriginalVersion = profile.OriginalVersion()

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

	// UpdateStrategyReference
	if profile.UpdateStrategyReference != nil {
		updateStrategyReference := profile.UpdateStrategyReference.Copy()
		destination.UpdateStrategyReference = &updateStrategyReference
	} else {
		destination.UpdateStrategyReference = nil
	}

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

	// No error
	return nil
}

// Initialize_From_FleetsAutoUpgradeProfile_STATUS populates our FleetsAutoUpgradeProfile_Spec from the provided source FleetsAutoUpgradeProfile_STATUS
func (profile *FleetsAutoUpgradeProfile_Spec) Initialize_From_FleetsAutoUpgradeProfile_STATUS(source *FleetsAutoUpgradeProfile_STATUS) error {

	// Channel
	if source.Channel != nil {
		channel := genruntime.ToEnum(string(*source.Channel), upgradeChannel_Values)
		profile.Channel = &channel
	} else {
		profile.Channel = nil
	}

	// Disabled
	if source.Disabled != nil {
		disabled := *source.Disabled
		profile.Disabled = &disabled
	} else {
		profile.Disabled = nil
	}

	// NodeImageSelection
	if source.NodeImageSelection != nil {
		var nodeImageSelection AutoUpgradeNodeImageSelection
		err := nodeImageSelection.Initialize_From_AutoUpgradeNodeImageSelection_STATUS(source.NodeImageSelection)
		if err != nil {
			return eris.Wrap(err, "calling Initialize_From_AutoUpgradeNodeImageSelection_STATUS() to populate field NodeImageSelection")
		}
		profile.NodeImageSelection = &nodeImageSelection
	} else {
		profile.NodeImageSelection = nil
	}

	// UpdateStrategyReference
	if source.UpdateStrategyId != nil {
		updateStrategyReference := genruntime.CreateResourceReferenceFromARMID(*source.UpdateStrategyId)
		profile.UpdateStrategyReference = &updateStrategyReference
	} else {
		profile.UpdateStrategyReference = nil
	}

	// No error
	return nil
}

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

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

type FleetsAutoUpgradeProfile_STATUS struct {
	// AutoUpgradeProfileStatus: The status of the auto upgrade profile.
	AutoUpgradeProfileStatus *AutoUpgradeProfileStatus_STATUS `json:"autoUpgradeProfileStatus,omitempty"`

	// Channel: Configures how auto-upgrade will be run.
	Channel *UpgradeChannel_STATUS `json:"channel,omitempty"`

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

	// Disabled: If set to False: the auto upgrade has effect - target managed clusters will be upgraded on schedule.
	// If set to True: the auto upgrade has no effect - no upgrade will be run on the target managed clusters.
	// This is a boolean and not an enum because enabled/disabled are all available states of the auto upgrade profile.
	// By default, this is set to False.
	Disabled *bool `json:"disabled,omitempty"`

	// ETag: If eTag is provided in the response body, it may also be provided as a header per the normal etag convention.
	// Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in
	// the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header
	// fields.
	ETag *string `json:"eTag,omitempty"`

	// Id: Fully qualified resource ID for the resource. E.g.
	// "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"
	Id *string `json:"id,omitempty"`

	// Name: The name of the resource
	Name *string `json:"name,omitempty"`

	// NodeImageSelection: The node image upgrade to be applied to the target clusters in auto upgrade.
	NodeImageSelection *AutoUpgradeNodeImageSelection_STATUS `json:"nodeImageSelection,omitempty"`

	// ProvisioningState: The provisioning state of the AutoUpgradeProfile resource.
	ProvisioningState *AutoUpgradeProfileProvisioningState_STATUS `json:"provisioningState,omitempty"`

	// SystemData: Azure Resource Manager metadata containing createdBy and modifiedBy information.
	SystemData *SystemData_STATUS `json:"systemData,omitempty"`

	// Type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
	Type *string `json:"type,omitempty"`

	// UpdateStrategyId: The resource id of the UpdateStrategy resource to reference. If not specified, the auto upgrade will
	// run on all clusters which are members of the fleet.
	UpdateStrategyId *string `json:"updateStrategyId,omitempty"`
}

var _ genruntime.ConvertibleStatus = &FleetsAutoUpgradeProfile_STATUS{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.FleetsAutoUpgradeProfile_STATUS{}
	err := profile.AssignProperties_To_FleetsAutoUpgradeProfile_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 = &FleetsAutoUpgradeProfile_STATUS{}

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

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

	// Set property "AutoUpgradeProfileStatus":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.AutoUpgradeProfileStatus != nil {
			var autoUpgradeProfileStatus1 AutoUpgradeProfileStatus_STATUS
			err := autoUpgradeProfileStatus1.PopulateFromARM(owner, *typedInput.Properties.AutoUpgradeProfileStatus)
			if err != nil {
				return err
			}
			autoUpgradeProfileStatus := autoUpgradeProfileStatus1
			profile.AutoUpgradeProfileStatus = &autoUpgradeProfileStatus
		}
	}

	// Set property "Channel":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Channel != nil {
			var temp string
			temp = string(*typedInput.Properties.Channel)
			channel := UpgradeChannel_STATUS(temp)
			profile.Channel = &channel
		}
	}

	// no assignment for property "Conditions"

	// Set property "Disabled":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Disabled != nil {
			disabled := *typedInput.Properties.Disabled
			profile.Disabled = &disabled
		}
	}

	// Set property "ETag":
	if typedInput.ETag != nil {
		eTag := *typedInput.ETag
		profile.ETag = &eTag
	}

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

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

	// Set property "NodeImageSelection":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.NodeImageSelection != nil {
			var nodeImageSelection1 AutoUpgradeNodeImageSelection_STATUS
			err := nodeImageSelection1.PopulateFromARM(owner, *typedInput.Properties.NodeImageSelection)
			if err != nil {
				return err
			}
			nodeImageSelection := nodeImageSelection1
			profile.NodeImageSelection = &nodeImageSelection
		}
	}

	// Set property "ProvisioningState":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ProvisioningState != nil {
			var temp string
			temp = string(*typedInput.Properties.ProvisioningState)
			provisioningState := AutoUpgradeProfileProvisioningState_STATUS(temp)
			profile.ProvisioningState = &provisioningState
		}
	}

	// Set property "SystemData":
	if typedInput.SystemData != nil {
		var systemData1 SystemData_STATUS
		err := systemData1.PopulateFromARM(owner, *typedInput.SystemData)
		if err != nil {
			return err
		}
		systemData := systemData1
		profile.SystemData = &systemData
	}

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

	// Set property "UpdateStrategyId":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.UpdateStrategyId != nil {
			updateStrategyId := *typedInput.Properties.UpdateStrategyId
			profile.UpdateStrategyId = &updateStrategyId
		}
	}

	// No error
	return nil
}

// AssignProperties_From_FleetsAutoUpgradeProfile_STATUS populates our FleetsAutoUpgradeProfile_STATUS from the provided source FleetsAutoUpgradeProfile_STATUS
func (profile *FleetsAutoUpgradeProfile_STATUS) AssignProperties_From_FleetsAutoUpgradeProfile_STATUS(source *storage.FleetsAutoUpgradeProfile_STATUS) error {

	// AutoUpgradeProfileStatus
	if source.AutoUpgradeProfileStatus != nil {
		var autoUpgradeProfileStatus AutoUpgradeProfileStatus_STATUS
		err := autoUpgradeProfileStatus.AssignProperties_From_AutoUpgradeProfileStatus_STATUS(source.AutoUpgradeProfileStatus)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_AutoUpgradeProfileStatus_STATUS() to populate field AutoUpgradeProfileStatus")
		}
		profile.AutoUpgradeProfileStatus = &autoUpgradeProfileStatus
	} else {
		profile.AutoUpgradeProfileStatus = nil
	}

	// Channel
	if source.Channel != nil {
		channel := *source.Channel
		channelTemp := genruntime.ToEnum(channel, upgradeChannel_STATUS_Values)
		profile.Channel = &channelTemp
	} else {
		profile.Channel = nil
	}

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

	// Disabled
	if source.Disabled != nil {
		disabled := *source.Disabled
		profile.Disabled = &disabled
	} else {
		profile.Disabled = nil
	}

	// ETag
	profile.ETag = genruntime.ClonePointerToString(source.ETag)

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

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

	// NodeImageSelection
	if source.NodeImageSelection != nil {
		var nodeImageSelection AutoUpgradeNodeImageSelection_STATUS
		err := nodeImageSelection.AssignProperties_From_AutoUpgradeNodeImageSelection_STATUS(source.NodeImageSelection)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_AutoUpgradeNodeImageSelection_STATUS() to populate field NodeImageSelection")
		}
		profile.NodeImageSelection = &nodeImageSelection
	} else {
		profile.NodeImageSelection = nil
	}

	// ProvisioningState
	if source.ProvisioningState != nil {
		provisioningState := *source.ProvisioningState
		provisioningStateTemp := genruntime.ToEnum(provisioningState, autoUpgradeProfileProvisioningState_STATUS_Values)
		profile.ProvisioningState = &provisioningStateTemp
	} else {
		profile.ProvisioningState = nil
	}

	// SystemData
	if source.SystemData != nil {
		var systemDatum SystemData_STATUS
		err := systemDatum.AssignProperties_From_SystemData_STATUS(source.SystemData)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_SystemData_STATUS() to populate field SystemData")
		}
		profile.SystemData = &systemDatum
	} else {
		profile.SystemData = nil
	}

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

	// UpdateStrategyId
	profile.UpdateStrategyId = genruntime.ClonePointerToString(source.UpdateStrategyId)

	// No error
	return nil
}

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

	// AutoUpgradeProfileStatus
	if profile.AutoUpgradeProfileStatus != nil {
		var autoUpgradeProfileStatus storage.AutoUpgradeProfileStatus_STATUS
		err := profile.AutoUpgradeProfileStatus.AssignProperties_To_AutoUpgradeProfileStatus_STATUS(&autoUpgradeProfileStatus)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_AutoUpgradeProfileStatus_STATUS() to populate field AutoUpgradeProfileStatus")
		}
		destination.AutoUpgradeProfileStatus = &autoUpgradeProfileStatus
	} else {
		destination.AutoUpgradeProfileStatus = nil
	}

	// Channel
	if profile.Channel != nil {
		channel := string(*profile.Channel)
		destination.Channel = &channel
	} else {
		destination.Channel = nil
	}

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

	// Disabled
	if profile.Disabled != nil {
		disabled := *profile.Disabled
		destination.Disabled = &disabled
	} else {
		destination.Disabled = nil
	}

	// ETag
	destination.ETag = genruntime.ClonePointerToString(profile.ETag)

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

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

	// NodeImageSelection
	if profile.NodeImageSelection != nil {
		var nodeImageSelection storage.AutoUpgradeNodeImageSelection_STATUS
		err := profile.NodeImageSelection.AssignProperties_To_AutoUpgradeNodeImageSelection_STATUS(&nodeImageSelection)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_AutoUpgradeNodeImageSelection_STATUS() to populate field NodeImageSelection")
		}
		destination.NodeImageSelection = &nodeImageSelection
	} else {
		destination.NodeImageSelection = nil
	}

	// ProvisioningState
	if profile.ProvisioningState != nil {
		provisioningState := string(*profile.ProvisioningState)
		destination.ProvisioningState = &provisioningState
	} else {
		destination.ProvisioningState = nil
	}

	// SystemData
	if profile.SystemData != nil {
		var systemDatum storage.SystemData_STATUS
		err := profile.SystemData.AssignProperties_To_SystemData_STATUS(&systemDatum)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_SystemData_STATUS() to populate field SystemData")
		}
		destination.SystemData = &systemDatum
	} else {
		destination.SystemData = nil
	}

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

	// UpdateStrategyId
	destination.UpdateStrategyId = genruntime.ClonePointerToString(profile.UpdateStrategyId)

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

	// No error
	return nil
}

// The node image upgrade to be applied to the target clusters in auto upgrade.
type AutoUpgradeNodeImageSelection struct {
	// +kubebuilder:validation:Required
	// Type: The node image upgrade type.
	Type *AutoUpgradeNodeImageSelectionType `json:"type,omitempty"`
}

var _ genruntime.ARMTransformer = &AutoUpgradeNodeImageSelection{}

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

	// Set property "Type":
	if selection.Type != nil {
		var temp string
		temp = string(*selection.Type)
		typeVar := arm.AutoUpgradeNodeImageSelectionType(temp)
		result.Type = &typeVar
	}
	return result, nil
}

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

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

	// Set property "Type":
	if typedInput.Type != nil {
		var temp string
		temp = string(*typedInput.Type)
		typeVar := AutoUpgradeNodeImageSelectionType(temp)
		selection.Type = &typeVar
	}

	// No error
	return nil
}

// AssignProperties_From_AutoUpgradeNodeImageSelection populates our AutoUpgradeNodeImageSelection from the provided source AutoUpgradeNodeImageSelection
func (selection *AutoUpgradeNodeImageSelection) AssignProperties_From_AutoUpgradeNodeImageSelection(source *storage.AutoUpgradeNodeImageSelection) error {

	// Type
	if source.Type != nil {
		typeVar := *source.Type
		typeTemp := genruntime.ToEnum(typeVar, autoUpgradeNodeImageSelectionType_Values)
		selection.Type = &typeTemp
	} else {
		selection.Type = nil
	}

	// No error
	return nil
}

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

	// Type
	if selection.Type != nil {
		typeVar := string(*selection.Type)
		destination.Type = &typeVar
	} else {
		destination.Type = nil
	}

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

	// No error
	return nil
}

// Initialize_From_AutoUpgradeNodeImageSelection_STATUS populates our AutoUpgradeNodeImageSelection from the provided source AutoUpgradeNodeImageSelection_STATUS
func (selection *AutoUpgradeNodeImageSelection) Initialize_From_AutoUpgradeNodeImageSelection_STATUS(source *AutoUpgradeNodeImageSelection_STATUS) error {

	// Type
	if source.Type != nil {
		typeVar := genruntime.ToEnum(string(*source.Type), autoUpgradeNodeImageSelectionType_Values)
		selection.Type = &typeVar
	} else {
		selection.Type = nil
	}

	// No error
	return nil
}

// The node image upgrade to be applied to the target clusters in auto upgrade.
type AutoUpgradeNodeImageSelection_STATUS struct {
	// Type: The node image upgrade type.
	Type *AutoUpgradeNodeImageSelectionType_STATUS `json:"type,omitempty"`
}

var _ genruntime.FromARMConverter = &AutoUpgradeNodeImageSelection_STATUS{}

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

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

	// Set property "Type":
	if typedInput.Type != nil {
		var temp string
		temp = string(*typedInput.Type)
		typeVar := AutoUpgradeNodeImageSelectionType_STATUS(temp)
		selection.Type = &typeVar
	}

	// No error
	return nil
}

// AssignProperties_From_AutoUpgradeNodeImageSelection_STATUS populates our AutoUpgradeNodeImageSelection_STATUS from the provided source AutoUpgradeNodeImageSelection_STATUS
func (selection *AutoUpgradeNodeImageSelection_STATUS) AssignProperties_From_AutoUpgradeNodeImageSelection_STATUS(source *storage.AutoUpgradeNodeImageSelection_STATUS) error {

	// Type
	if source.Type != nil {
		typeVar := *source.Type
		typeTemp := genruntime.ToEnum(typeVar, autoUpgradeNodeImageSelectionType_STATUS_Values)
		selection.Type = &typeTemp
	} else {
		selection.Type = nil
	}

	// No error
	return nil
}

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

	// Type
	if selection.Type != nil {
		typeVar := string(*selection.Type)
		destination.Type = &typeVar
	} else {
		destination.Type = nil
	}

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

	// No error
	return nil
}

// The provisioning state of the AutoUpgradeProfile resource.
type AutoUpgradeProfileProvisioningState_STATUS string

const (
	AutoUpgradeProfileProvisioningState_STATUS_Canceled  = AutoUpgradeProfileProvisioningState_STATUS("Canceled")
	AutoUpgradeProfileProvisioningState_STATUS_Failed    = AutoUpgradeProfileProvisioningState_STATUS("Failed")
	AutoUpgradeProfileProvisioningState_STATUS_Succeeded = AutoUpgradeProfileProvisioningState_STATUS("Succeeded")
)

// Mapping from string to AutoUpgradeProfileProvisioningState_STATUS
var autoUpgradeProfileProvisioningState_STATUS_Values = map[string]AutoUpgradeProfileProvisioningState_STATUS{
	"canceled":  AutoUpgradeProfileProvisioningState_STATUS_Canceled,
	"failed":    AutoUpgradeProfileProvisioningState_STATUS_Failed,
	"succeeded": AutoUpgradeProfileProvisioningState_STATUS_Succeeded,
}

// AutoUpgradeProfileStatus is the status of an auto upgrade profile.
type AutoUpgradeProfileStatus_STATUS struct {
	// LastTriggerError: The error details of the last trigger.
	LastTriggerError *ErrorDetail_STATUS `json:"lastTriggerError,omitempty"`

	// LastTriggerStatus: The status of the last AutoUpgrade trigger.
	LastTriggerStatus *AutoUpgradeLastTriggerStatus_STATUS `json:"lastTriggerStatus,omitempty"`

	// LastTriggerUpgradeVersions: The target Kubernetes version or node image versions of the last trigger.
	LastTriggerUpgradeVersions []string `json:"lastTriggerUpgradeVersions,omitempty"`

	// LastTriggeredAt: The UTC time of the last attempt to automatically create and start an UpdateRun as triggered by the
	// release of new versions.
	LastTriggeredAt *string `json:"lastTriggeredAt,omitempty"`
}

var _ genruntime.FromARMConverter = &AutoUpgradeProfileStatus_STATUS{}

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

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

	// Set property "LastTriggerError":
	if typedInput.LastTriggerError != nil {
		var lastTriggerError1 ErrorDetail_STATUS
		err := lastTriggerError1.PopulateFromARM(owner, *typedInput.LastTriggerError)
		if err != nil {
			return err
		}
		lastTriggerError := lastTriggerError1
		status.LastTriggerError = &lastTriggerError
	}

	// Set property "LastTriggerStatus":
	if typedInput.LastTriggerStatus != nil {
		var temp string
		temp = string(*typedInput.LastTriggerStatus)
		lastTriggerStatus := AutoUpgradeLastTriggerStatus_STATUS(temp)
		status.LastTriggerStatus = &lastTriggerStatus
	}

	// Set property "LastTriggerUpgradeVersions":
	for _, item := range typedInput.LastTriggerUpgradeVersions {
		status.LastTriggerUpgradeVersions = append(status.LastTriggerUpgradeVersions, item)
	}

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

	// No error
	return nil
}

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

	// LastTriggerError
	if source.LastTriggerError != nil {
		var lastTriggerError ErrorDetail_STATUS
		err := lastTriggerError.AssignProperties_From_ErrorDetail_STATUS(source.LastTriggerError)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_ErrorDetail_STATUS() to populate field LastTriggerError")
		}
		status.LastTriggerError = &lastTriggerError
	} else {
		status.LastTriggerError = nil
	}

	// LastTriggerStatus
	if source.LastTriggerStatus != nil {
		lastTriggerStatus := *source.LastTriggerStatus
		lastTriggerStatusTemp := genruntime.ToEnum(lastTriggerStatus, autoUpgradeLastTriggerStatus_STATUS_Values)
		status.LastTriggerStatus = &lastTriggerStatusTemp
	} else {
		status.LastTriggerStatus = nil
	}

	// LastTriggerUpgradeVersions
	status.LastTriggerUpgradeVersions = genruntime.CloneSliceOfString(source.LastTriggerUpgradeVersions)

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

	// No error
	return nil
}

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

	// LastTriggerError
	if status.LastTriggerError != nil {
		var lastTriggerError storage.ErrorDetail_STATUS
		err := status.LastTriggerError.AssignProperties_To_ErrorDetail_STATUS(&lastTriggerError)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_ErrorDetail_STATUS() to populate field LastTriggerError")
		}
		destination.LastTriggerError = &lastTriggerError
	} else {
		destination.LastTriggerError = nil
	}

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

	// LastTriggerUpgradeVersions
	destination.LastTriggerUpgradeVersions = genruntime.CloneSliceOfString(status.LastTriggerUpgradeVersions)

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

	// 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 FleetsAutoUpgradeProfileOperatorSpec 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_FleetsAutoUpgradeProfileOperatorSpec populates our FleetsAutoUpgradeProfileOperatorSpec from the provided source FleetsAutoUpgradeProfileOperatorSpec
func (operator *FleetsAutoUpgradeProfileOperatorSpec) AssignProperties_From_FleetsAutoUpgradeProfileOperatorSpec(source *storage.FleetsAutoUpgradeProfileOperatorSpec) 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_FleetsAutoUpgradeProfileOperatorSpec populates the provided destination FleetsAutoUpgradeProfileOperatorSpec from our FleetsAutoUpgradeProfileOperatorSpec
func (operator *FleetsAutoUpgradeProfileOperatorSpec) AssignProperties_To_FleetsAutoUpgradeProfileOperatorSpec(destination *storage.FleetsAutoUpgradeProfileOperatorSpec) 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
}

// Configuration of how auto upgrade will be run.
// +kubebuilder:validation:Enum={"NodeImage","Rapid","Stable"}
type UpgradeChannel string

const (
	UpgradeChannel_NodeImage = UpgradeChannel("NodeImage")
	UpgradeChannel_Rapid     = UpgradeChannel("Rapid")
	UpgradeChannel_Stable    = UpgradeChannel("Stable")
)

// Mapping from string to UpgradeChannel
var upgradeChannel_Values = map[string]UpgradeChannel{
	"nodeimage": UpgradeChannel_NodeImage,
	"rapid":     UpgradeChannel_Rapid,
	"stable":    UpgradeChannel_Stable,
}

// Configuration of how auto upgrade will be run.
type UpgradeChannel_STATUS string

const (
	UpgradeChannel_STATUS_NodeImage = UpgradeChannel_STATUS("NodeImage")
	UpgradeChannel_STATUS_Rapid     = UpgradeChannel_STATUS("Rapid")
	UpgradeChannel_STATUS_Stable    = UpgradeChannel_STATUS("Stable")
)

// Mapping from string to UpgradeChannel_STATUS
var upgradeChannel_STATUS_Values = map[string]UpgradeChannel_STATUS{
	"nodeimage": UpgradeChannel_STATUS_NodeImage,
	"rapid":     UpgradeChannel_STATUS_Rapid,
	"stable":    UpgradeChannel_STATUS_Stable,
}

// AutoUpgradeLastTriggerStatus is the status of the last AutoUpgrade trigger (attempt to automatically create and start
// UpdateRun when there are new released versions) of an auto upgrade profile.
type AutoUpgradeLastTriggerStatus_STATUS string

const (
	AutoUpgradeLastTriggerStatus_STATUS_Failed    = AutoUpgradeLastTriggerStatus_STATUS("Failed")
	AutoUpgradeLastTriggerStatus_STATUS_Succeeded = AutoUpgradeLastTriggerStatus_STATUS("Succeeded")
)

// Mapping from string to AutoUpgradeLastTriggerStatus_STATUS
var autoUpgradeLastTriggerStatus_STATUS_Values = map[string]AutoUpgradeLastTriggerStatus_STATUS{
	"failed":    AutoUpgradeLastTriggerStatus_STATUS_Failed,
	"succeeded": AutoUpgradeLastTriggerStatus_STATUS_Succeeded,
}

// The node image upgrade type.
// +kubebuilder:validation:Enum={"Consistent","Latest"}
type AutoUpgradeNodeImageSelectionType string

const (
	AutoUpgradeNodeImageSelectionType_Consistent = AutoUpgradeNodeImageSelectionType("Consistent")
	AutoUpgradeNodeImageSelectionType_Latest     = AutoUpgradeNodeImageSelectionType("Latest")
)

// Mapping from string to AutoUpgradeNodeImageSelectionType
var autoUpgradeNodeImageSelectionType_Values = map[string]AutoUpgradeNodeImageSelectionType{
	"consistent": AutoUpgradeNodeImageSelectionType_Consistent,
	"latest":     AutoUpgradeNodeImageSelectionType_Latest,
}

// The node image upgrade type.
type AutoUpgradeNodeImageSelectionType_STATUS string

const (
	AutoUpgradeNodeImageSelectionType_STATUS_Consistent = AutoUpgradeNodeImageSelectionType_STATUS("Consistent")
	AutoUpgradeNodeImageSelectionType_STATUS_Latest     = AutoUpgradeNodeImageSelectionType_STATUS("Latest")
)

// Mapping from string to AutoUpgradeNodeImageSelectionType_STATUS
var autoUpgradeNodeImageSelectionType_STATUS_Values = map[string]AutoUpgradeNodeImageSelectionType_STATUS{
	"consistent": AutoUpgradeNodeImageSelectionType_STATUS_Consistent,
	"latest":     AutoUpgradeNodeImageSelectionType_STATUS_Latest,
}

func init() {
	SchemeBuilder.Register(&FleetsAutoUpgradeProfile{}, &FleetsAutoUpgradeProfileList{})
}
