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

import (
	"fmt"
	arm "github.com/Azure/azure-service-operator/v2/api/dbformysql/v1api20220101/arm"
	storage "github.com/Azure/azure-service-operator/v2/api/dbformysql/v1api20220101/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,dbformysql}
// +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: /mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2022-01-01/Configurations.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/configurations/{configurationName}
type FlexibleServersConfiguration struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              FlexibleServersConfiguration_Spec   `json:"spec,omitempty"`
	Status            FlexibleServersConfiguration_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &FlexibleServersConfiguration{}

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

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

var _ conversion.Convertible = &FlexibleServersConfiguration{}

// ConvertFrom populates our FlexibleServersConfiguration from the provided hub FlexibleServersConfiguration
func (configuration *FlexibleServersConfiguration) ConvertFrom(hub conversion.Hub) error {
	// intermediate variable for conversion
	var source storage.FlexibleServersConfiguration

	err := source.ConvertFrom(hub)
	if err != nil {
		return eris.Wrap(err, "converting from hub to source")
	}

	err = configuration.AssignProperties_From_FlexibleServersConfiguration(&source)
	if err != nil {
		return eris.Wrap(err, "converting from source to configuration")
	}

	return nil
}

// ConvertTo populates the provided hub FlexibleServersConfiguration from our FlexibleServersConfiguration
func (configuration *FlexibleServersConfiguration) ConvertTo(hub conversion.Hub) error {
	// intermediate variable for conversion
	var destination storage.FlexibleServersConfiguration
	err := configuration.AssignProperties_To_FlexibleServersConfiguration(&destination)
	if err != nil {
		return eris.Wrap(err, "converting to destination from configuration")
	}
	err = destination.ConvertTo(hub)
	if err != nil {
		return eris.Wrap(err, "converting from destination to hub")
	}

	return nil
}

var _ configmaps.Exporter = &FlexibleServersConfiguration{}

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

var _ secrets.Exporter = &FlexibleServersConfiguration{}

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

var _ genruntime.KubernetesResource = &FlexibleServersConfiguration{}

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

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

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.DBforMySQL/flexibleServers/configurations"
func (configuration *FlexibleServersConfiguration) GetType() string {
	return "Microsoft.DBforMySQL/flexibleServers/configurations"
}

// NewEmptyStatus returns a new empty (blank) status
func (configuration *FlexibleServersConfiguration) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &FlexibleServersConfiguration_STATUS{}
}

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

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

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

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

	configuration.Status = st
	return nil
}

// AssignProperties_From_FlexibleServersConfiguration populates our FlexibleServersConfiguration from the provided source FlexibleServersConfiguration
func (configuration *FlexibleServersConfiguration) AssignProperties_From_FlexibleServersConfiguration(source *storage.FlexibleServersConfiguration) error {

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

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

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

	// No error
	return nil
}

// AssignProperties_To_FlexibleServersConfiguration populates the provided destination FlexibleServersConfiguration from our FlexibleServersConfiguration
func (configuration *FlexibleServersConfiguration) AssignProperties_To_FlexibleServersConfiguration(destination *storage.FlexibleServersConfiguration) error {

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

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

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

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2022-01-01/Configurations.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/configurations/{configurationName}
type FlexibleServersConfigurationList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []FlexibleServersConfiguration `json:"items"`
}

type FlexibleServersConfiguration_Spec struct {
	// +kubebuilder:validation:Pattern="^[a-zA-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"`

	// CurrentValue: Current value of the configuration.
	CurrentValue *string `json:"currentValue,omitempty"`

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

	// Source: Source of the configuration.
	Source *ConfigurationProperties_Source `json:"source,omitempty"`

	// Value: Value of the configuration.
	Value *string `json:"value,omitempty"`
}

var _ genruntime.ARMTransformer = &FlexibleServersConfiguration_Spec{}

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

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

	// Set property "Properties":
	if configuration.CurrentValue != nil ||
		configuration.Source != nil ||
		configuration.Value != nil {
		result.Properties = &arm.ConfigurationProperties{}
	}
	if configuration.CurrentValue != nil {
		currentValue := *configuration.CurrentValue
		result.Properties.CurrentValue = &currentValue
	}
	if configuration.Source != nil {
		var temp string
		temp = string(*configuration.Source)
		source := arm.ConfigurationProperties_Source(temp)
		result.Properties.Source = &source
	}
	if configuration.Value != nil {
		value := *configuration.Value
		result.Properties.Value = &value
	}
	return result, nil
}

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

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

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

	// Set property "CurrentValue":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.CurrentValue != nil {
			currentValue := *typedInput.Properties.CurrentValue
			configuration.CurrentValue = &currentValue
		}
	}

	// no assignment for property "OperatorSpec"

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

	// Set property "Source":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Source != nil {
			var temp string
			temp = string(*typedInput.Properties.Source)
			source := ConfigurationProperties_Source(temp)
			configuration.Source = &source
		}
	}

	// Set property "Value":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Value != nil {
			value := *typedInput.Properties.Value
			configuration.Value = &value
		}
	}

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &FlexibleServersConfiguration_Spec{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.FlexibleServersConfiguration_Spec{}
	err := configuration.AssignProperties_To_FlexibleServersConfiguration_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_FlexibleServersConfiguration_Spec populates our FlexibleServersConfiguration_Spec from the provided source FlexibleServersConfiguration_Spec
func (configuration *FlexibleServersConfiguration_Spec) AssignProperties_From_FlexibleServersConfiguration_Spec(source *storage.FlexibleServersConfiguration_Spec) error {

	// AzureName
	configuration.AzureName = source.AzureName

	// CurrentValue
	configuration.CurrentValue = genruntime.ClonePointerToString(source.CurrentValue)

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

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

	// Source
	if source.Source != nil {
		sourceValue := *source.Source
		sourceTemp := genruntime.ToEnum(sourceValue, configurationProperties_Source_Values)
		configuration.Source = &sourceTemp
	} else {
		configuration.Source = nil
	}

	// Value
	configuration.Value = genruntime.ClonePointerToString(source.Value)

	// No error
	return nil
}

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

	// AzureName
	destination.AzureName = configuration.AzureName

	// CurrentValue
	destination.CurrentValue = genruntime.ClonePointerToString(configuration.CurrentValue)

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

	// OriginalVersion
	destination.OriginalVersion = configuration.OriginalVersion()

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

	// Source
	if configuration.Source != nil {
		source := string(*configuration.Source)
		destination.Source = &source
	} else {
		destination.Source = nil
	}

	// Value
	destination.Value = genruntime.ClonePointerToString(configuration.Value)

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

	// No error
	return nil
}

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

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

type FlexibleServersConfiguration_STATUS struct {
	// AllowedValues: Allowed values of the configuration.
	AllowedValues *string `json:"allowedValues,omitempty"`

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

	// CurrentValue: Current value of the configuration.
	CurrentValue *string `json:"currentValue,omitempty"`

	// DataType: Data type of the configuration.
	DataType *string `json:"dataType,omitempty"`

	// DefaultValue: Default value of the configuration.
	DefaultValue *string `json:"defaultValue,omitempty"`

	// Description: Description of the configuration.
	Description *string `json:"description,omitempty"`

	// DocumentationLink: The link used to get the document from community or Azure site.
	DocumentationLink *string `json:"documentationLink,omitempty"`

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

	// IsConfigPendingRestart: If is the configuration pending restart or not.
	IsConfigPendingRestart *ConfigurationProperties_IsConfigPendingRestart_STATUS `json:"isConfigPendingRestart,omitempty"`

	// IsDynamicConfig: If is the configuration dynamic.
	IsDynamicConfig *ConfigurationProperties_IsDynamicConfig_STATUS `json:"isDynamicConfig,omitempty"`

	// IsReadOnly: If is the configuration read only.
	IsReadOnly *ConfigurationProperties_IsReadOnly_STATUS `json:"isReadOnly,omitempty"`

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

	// Source: Source of the configuration.
	Source *ConfigurationProperties_Source_STATUS `json:"source,omitempty"`

	// SystemData: The system metadata relating to this resource.
	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"`

	// Value: Value of the configuration.
	Value *string `json:"value,omitempty"`
}

var _ genruntime.ConvertibleStatus = &FlexibleServersConfiguration_STATUS{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.FlexibleServersConfiguration_STATUS{}
	err := configuration.AssignProperties_To_FlexibleServersConfiguration_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 = &FlexibleServersConfiguration_STATUS{}

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

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

	// Set property "AllowedValues":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.AllowedValues != nil {
			allowedValues := *typedInput.Properties.AllowedValues
			configuration.AllowedValues = &allowedValues
		}
	}

	// no assignment for property "Conditions"

	// Set property "CurrentValue":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.CurrentValue != nil {
			currentValue := *typedInput.Properties.CurrentValue
			configuration.CurrentValue = &currentValue
		}
	}

	// Set property "DataType":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.DataType != nil {
			dataType := *typedInput.Properties.DataType
			configuration.DataType = &dataType
		}
	}

	// Set property "DefaultValue":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.DefaultValue != nil {
			defaultValue := *typedInput.Properties.DefaultValue
			configuration.DefaultValue = &defaultValue
		}
	}

	// Set property "Description":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Description != nil {
			description := *typedInput.Properties.Description
			configuration.Description = &description
		}
	}

	// Set property "DocumentationLink":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.DocumentationLink != nil {
			documentationLink := *typedInput.Properties.DocumentationLink
			configuration.DocumentationLink = &documentationLink
		}
	}

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

	// Set property "IsConfigPendingRestart":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.IsConfigPendingRestart != nil {
			var temp string
			temp = string(*typedInput.Properties.IsConfigPendingRestart)
			isConfigPendingRestart := ConfigurationProperties_IsConfigPendingRestart_STATUS(temp)
			configuration.IsConfigPendingRestart = &isConfigPendingRestart
		}
	}

	// Set property "IsDynamicConfig":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.IsDynamicConfig != nil {
			var temp string
			temp = string(*typedInput.Properties.IsDynamicConfig)
			isDynamicConfig := ConfigurationProperties_IsDynamicConfig_STATUS(temp)
			configuration.IsDynamicConfig = &isDynamicConfig
		}
	}

	// Set property "IsReadOnly":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.IsReadOnly != nil {
			var temp string
			temp = string(*typedInput.Properties.IsReadOnly)
			isReadOnly := ConfigurationProperties_IsReadOnly_STATUS(temp)
			configuration.IsReadOnly = &isReadOnly
		}
	}

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

	// Set property "Source":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Source != nil {
			var temp string
			temp = string(*typedInput.Properties.Source)
			source := ConfigurationProperties_Source_STATUS(temp)
			configuration.Source = &source
		}
	}

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

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

	// Set property "Value":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Value != nil {
			value := *typedInput.Properties.Value
			configuration.Value = &value
		}
	}

	// No error
	return nil
}

// AssignProperties_From_FlexibleServersConfiguration_STATUS populates our FlexibleServersConfiguration_STATUS from the provided source FlexibleServersConfiguration_STATUS
func (configuration *FlexibleServersConfiguration_STATUS) AssignProperties_From_FlexibleServersConfiguration_STATUS(source *storage.FlexibleServersConfiguration_STATUS) error {

	// AllowedValues
	configuration.AllowedValues = genruntime.ClonePointerToString(source.AllowedValues)

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

	// CurrentValue
	configuration.CurrentValue = genruntime.ClonePointerToString(source.CurrentValue)

	// DataType
	configuration.DataType = genruntime.ClonePointerToString(source.DataType)

	// DefaultValue
	configuration.DefaultValue = genruntime.ClonePointerToString(source.DefaultValue)

	// Description
	configuration.Description = genruntime.ClonePointerToString(source.Description)

	// DocumentationLink
	configuration.DocumentationLink = genruntime.ClonePointerToString(source.DocumentationLink)

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

	// IsConfigPendingRestart
	if source.IsConfigPendingRestart != nil {
		isConfigPendingRestart := *source.IsConfigPendingRestart
		isConfigPendingRestartTemp := genruntime.ToEnum(isConfigPendingRestart, configurationProperties_IsConfigPendingRestart_STATUS_Values)
		configuration.IsConfigPendingRestart = &isConfigPendingRestartTemp
	} else {
		configuration.IsConfigPendingRestart = nil
	}

	// IsDynamicConfig
	if source.IsDynamicConfig != nil {
		isDynamicConfig := *source.IsDynamicConfig
		isDynamicConfigTemp := genruntime.ToEnum(isDynamicConfig, configurationProperties_IsDynamicConfig_STATUS_Values)
		configuration.IsDynamicConfig = &isDynamicConfigTemp
	} else {
		configuration.IsDynamicConfig = nil
	}

	// IsReadOnly
	if source.IsReadOnly != nil {
		isReadOnly := *source.IsReadOnly
		isReadOnlyTemp := genruntime.ToEnum(isReadOnly, configurationProperties_IsReadOnly_STATUS_Values)
		configuration.IsReadOnly = &isReadOnlyTemp
	} else {
		configuration.IsReadOnly = nil
	}

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

	// Source
	if source.Source != nil {
		sourceValue := *source.Source
		sourceTemp := genruntime.ToEnum(sourceValue, configurationProperties_Source_STATUS_Values)
		configuration.Source = &sourceTemp
	} else {
		configuration.Source = 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")
		}
		configuration.SystemData = &systemDatum
	} else {
		configuration.SystemData = nil
	}

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

	// Value
	configuration.Value = genruntime.ClonePointerToString(source.Value)

	// No error
	return nil
}

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

	// AllowedValues
	destination.AllowedValues = genruntime.ClonePointerToString(configuration.AllowedValues)

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

	// CurrentValue
	destination.CurrentValue = genruntime.ClonePointerToString(configuration.CurrentValue)

	// DataType
	destination.DataType = genruntime.ClonePointerToString(configuration.DataType)

	// DefaultValue
	destination.DefaultValue = genruntime.ClonePointerToString(configuration.DefaultValue)

	// Description
	destination.Description = genruntime.ClonePointerToString(configuration.Description)

	// DocumentationLink
	destination.DocumentationLink = genruntime.ClonePointerToString(configuration.DocumentationLink)

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

	// IsConfigPendingRestart
	if configuration.IsConfigPendingRestart != nil {
		isConfigPendingRestart := string(*configuration.IsConfigPendingRestart)
		destination.IsConfigPendingRestart = &isConfigPendingRestart
	} else {
		destination.IsConfigPendingRestart = nil
	}

	// IsDynamicConfig
	if configuration.IsDynamicConfig != nil {
		isDynamicConfig := string(*configuration.IsDynamicConfig)
		destination.IsDynamicConfig = &isDynamicConfig
	} else {
		destination.IsDynamicConfig = nil
	}

	// IsReadOnly
	if configuration.IsReadOnly != nil {
		isReadOnly := string(*configuration.IsReadOnly)
		destination.IsReadOnly = &isReadOnly
	} else {
		destination.IsReadOnly = nil
	}

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

	// Source
	if configuration.Source != nil {
		source := string(*configuration.Source)
		destination.Source = &source
	} else {
		destination.Source = nil
	}

	// SystemData
	if configuration.SystemData != nil {
		var systemDatum storage.SystemData_STATUS
		err := configuration.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(configuration.Type)

	// Value
	destination.Value = genruntime.ClonePointerToString(configuration.Value)

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

	// No error
	return nil
}

type ConfigurationProperties_IsConfigPendingRestart_STATUS string

const (
	ConfigurationProperties_IsConfigPendingRestart_STATUS_False = ConfigurationProperties_IsConfigPendingRestart_STATUS("False")
	ConfigurationProperties_IsConfigPendingRestart_STATUS_True  = ConfigurationProperties_IsConfigPendingRestart_STATUS("True")
)

// Mapping from string to ConfigurationProperties_IsConfigPendingRestart_STATUS
var configurationProperties_IsConfigPendingRestart_STATUS_Values = map[string]ConfigurationProperties_IsConfigPendingRestart_STATUS{
	"false": ConfigurationProperties_IsConfigPendingRestart_STATUS_False,
	"true":  ConfigurationProperties_IsConfigPendingRestart_STATUS_True,
}

type ConfigurationProperties_IsDynamicConfig_STATUS string

const (
	ConfigurationProperties_IsDynamicConfig_STATUS_False = ConfigurationProperties_IsDynamicConfig_STATUS("False")
	ConfigurationProperties_IsDynamicConfig_STATUS_True  = ConfigurationProperties_IsDynamicConfig_STATUS("True")
)

// Mapping from string to ConfigurationProperties_IsDynamicConfig_STATUS
var configurationProperties_IsDynamicConfig_STATUS_Values = map[string]ConfigurationProperties_IsDynamicConfig_STATUS{
	"false": ConfigurationProperties_IsDynamicConfig_STATUS_False,
	"true":  ConfigurationProperties_IsDynamicConfig_STATUS_True,
}

type ConfigurationProperties_IsReadOnly_STATUS string

const (
	ConfigurationProperties_IsReadOnly_STATUS_False = ConfigurationProperties_IsReadOnly_STATUS("False")
	ConfigurationProperties_IsReadOnly_STATUS_True  = ConfigurationProperties_IsReadOnly_STATUS("True")
)

// Mapping from string to ConfigurationProperties_IsReadOnly_STATUS
var configurationProperties_IsReadOnly_STATUS_Values = map[string]ConfigurationProperties_IsReadOnly_STATUS{
	"false": ConfigurationProperties_IsReadOnly_STATUS_False,
	"true":  ConfigurationProperties_IsReadOnly_STATUS_True,
}

// +kubebuilder:validation:Enum={"system-default","user-override"}
type ConfigurationProperties_Source string

const (
	ConfigurationProperties_Source_SystemDefault = ConfigurationProperties_Source("system-default")
	ConfigurationProperties_Source_UserOverride  = ConfigurationProperties_Source("user-override")
)

// Mapping from string to ConfigurationProperties_Source
var configurationProperties_Source_Values = map[string]ConfigurationProperties_Source{
	"system-default": ConfigurationProperties_Source_SystemDefault,
	"user-override":  ConfigurationProperties_Source_UserOverride,
}

type ConfigurationProperties_Source_STATUS string

const (
	ConfigurationProperties_Source_STATUS_SystemDefault = ConfigurationProperties_Source_STATUS("system-default")
	ConfigurationProperties_Source_STATUS_UserOverride  = ConfigurationProperties_Source_STATUS("user-override")
)

// Mapping from string to ConfigurationProperties_Source_STATUS
var configurationProperties_Source_STATUS_Values = map[string]ConfigurationProperties_Source_STATUS{
	"system-default": ConfigurationProperties_Source_STATUS_SystemDefault,
	"user-override":  ConfigurationProperties_Source_STATUS_UserOverride,
}

// Details for configuring operator behavior. Fields in this struct are interpreted by the operator directly rather than being passed to Azure
type FlexibleServersConfigurationOperatorSpec 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_FlexibleServersConfigurationOperatorSpec populates our FlexibleServersConfigurationOperatorSpec from the provided source FlexibleServersConfigurationOperatorSpec
func (operator *FlexibleServersConfigurationOperatorSpec) AssignProperties_From_FlexibleServersConfigurationOperatorSpec(source *storage.FlexibleServersConfigurationOperatorSpec) 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_FlexibleServersConfigurationOperatorSpec populates the provided destination FlexibleServersConfigurationOperatorSpec from our FlexibleServersConfigurationOperatorSpec
func (operator *FlexibleServersConfigurationOperatorSpec) AssignProperties_To_FlexibleServersConfigurationOperatorSpec(destination *storage.FlexibleServersConfigurationOperatorSpec) 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
}

func init() {
	SchemeBuilder.Register(&FlexibleServersConfiguration{}, &FlexibleServersConfigurationList{})
}
