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

import (
	"fmt"
	arm "github.com/Azure/azure-service-operator/v2/api/sql/v1api20211101/arm"
	storage "github.com/Azure/azure-service-operator/v2/api/sql/v1api20211101/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,sql}
// +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: /sql/resource-manager/Microsoft.Sql/stable/2021-11-01/ElasticPools.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}
type ServersElasticPool struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              ServersElasticPool_Spec   `json:"spec,omitempty"`
	Status            ServersElasticPool_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &ServersElasticPool{}

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

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

var _ conversion.Convertible = &ServersElasticPool{}

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

	return pool.AssignProperties_From_ServersElasticPool(source)
}

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

	return pool.AssignProperties_To_ServersElasticPool(destination)
}

var _ configmaps.Exporter = &ServersElasticPool{}

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

var _ secrets.Exporter = &ServersElasticPool{}

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

var _ genruntime.ImportableResource = &ServersElasticPool{}

// InitializeSpec initializes the spec for this resource from the given status
func (pool *ServersElasticPool) InitializeSpec(status genruntime.ConvertibleStatus) error {
	if s, ok := status.(*ServersElasticPool_STATUS); ok {
		return pool.Spec.Initialize_From_ServersElasticPool_STATUS(s)
	}

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

var _ genruntime.KubernetesResource = &ServersElasticPool{}

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

// GetAPIVersion returns the ARM API version of the resource. This is always "2021-11-01"
func (pool ServersElasticPool) GetAPIVersion() string {
	return "2021-11-01"
}

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.Sql/servers/elasticPools"
func (pool *ServersElasticPool) GetType() string {
	return "Microsoft.Sql/servers/elasticPools"
}

// NewEmptyStatus returns a new empty (blank) status
func (pool *ServersElasticPool) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &ServersElasticPool_STATUS{}
}

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

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

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

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

	pool.Status = st
	return nil
}

// AssignProperties_From_ServersElasticPool populates our ServersElasticPool from the provided source ServersElasticPool
func (pool *ServersElasticPool) AssignProperties_From_ServersElasticPool(source *storage.ServersElasticPool) error {

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

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

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

	// No error
	return nil
}

// AssignProperties_To_ServersElasticPool populates the provided destination ServersElasticPool from our ServersElasticPool
func (pool *ServersElasticPool) AssignProperties_To_ServersElasticPool(destination *storage.ServersElasticPool) error {

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

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

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

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /sql/resource-manager/Microsoft.Sql/stable/2021-11-01/ElasticPools.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}
type ServersElasticPoolList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []ServersElasticPool `json:"items"`
}

type ServersElasticPool_Spec struct {
	// 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"`

	// HighAvailabilityReplicaCount: The number of secondary replicas associated with the elastic pool that are used to provide
	// high availability. Applicable only to Hyperscale elastic pools.
	HighAvailabilityReplicaCount *int `json:"highAvailabilityReplicaCount,omitempty"`

	// LicenseType: The license type to apply for this elastic pool.
	LicenseType *ElasticPoolProperties_LicenseType `json:"licenseType,omitempty"`

	// +kubebuilder:validation:Required
	// Location: Resource location.
	Location *string `json:"location,omitempty"`

	// MaintenanceConfigurationId: Maintenance configuration id assigned to the elastic pool. This configuration defines the
	// period when the maintenance updates will will occur.
	MaintenanceConfigurationId *string `json:"maintenanceConfigurationId,omitempty"`

	// MaxSizeBytes: The storage limit for the database elastic pool in bytes.
	MaxSizeBytes *int `json:"maxSizeBytes,omitempty"`

	// MinCapacity: Minimal capacity that serverless pool will not shrink below, if not paused
	MinCapacity *float64 `json:"minCapacity,omitempty"`

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

	// PerDatabaseSettings: The per database settings for the elastic pool.
	PerDatabaseSettings *ElasticPoolPerDatabaseSettings `json:"perDatabaseSettings,omitempty"`

	// Sku: The elastic pool SKU.
	// The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU name, tier/edition,
	// family, and capacity) that are available to your subscription in an Azure region, use the `Capabilities_ListByLocation`
	// REST API or the following command:
	// ```azurecli
	// az sql elastic-pool list-editions -l <location> -o table
	// ````
	Sku *Sku `json:"sku,omitempty"`

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

	// ZoneRedundant: Whether or not this elastic pool is zone redundant, which means the replicas of this elastic pool will be
	// spread across multiple availability zones.
	ZoneRedundant *bool `json:"zoneRedundant,omitempty"`
}

var _ genruntime.ARMTransformer = &ServersElasticPool_Spec{}

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

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

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

	// Set property "Properties":
	if pool.HighAvailabilityReplicaCount != nil ||
		pool.LicenseType != nil ||
		pool.MaintenanceConfigurationId != nil ||
		pool.MaxSizeBytes != nil ||
		pool.MinCapacity != nil ||
		pool.PerDatabaseSettings != nil ||
		pool.ZoneRedundant != nil {
		result.Properties = &arm.ElasticPoolProperties{}
	}
	if pool.HighAvailabilityReplicaCount != nil {
		highAvailabilityReplicaCount := *pool.HighAvailabilityReplicaCount
		result.Properties.HighAvailabilityReplicaCount = &highAvailabilityReplicaCount
	}
	if pool.LicenseType != nil {
		var temp string
		temp = string(*pool.LicenseType)
		licenseType := arm.ElasticPoolProperties_LicenseType(temp)
		result.Properties.LicenseType = &licenseType
	}
	if pool.MaintenanceConfigurationId != nil {
		maintenanceConfigurationId := *pool.MaintenanceConfigurationId
		result.Properties.MaintenanceConfigurationId = &maintenanceConfigurationId
	}
	if pool.MaxSizeBytes != nil {
		maxSizeBytes := *pool.MaxSizeBytes
		result.Properties.MaxSizeBytes = &maxSizeBytes
	}
	if pool.MinCapacity != nil {
		minCapacity := *pool.MinCapacity
		result.Properties.MinCapacity = &minCapacity
	}
	if pool.PerDatabaseSettings != nil {
		perDatabaseSettings_ARM, err := pool.PerDatabaseSettings.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		perDatabaseSettings := *perDatabaseSettings_ARM.(*arm.ElasticPoolPerDatabaseSettings)
		result.Properties.PerDatabaseSettings = &perDatabaseSettings
	}
	if pool.ZoneRedundant != nil {
		zoneRedundant := *pool.ZoneRedundant
		result.Properties.ZoneRedundant = &zoneRedundant
	}

	// Set property "Sku":
	if pool.Sku != nil {
		sku_ARM, err := pool.Sku.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		sku := *sku_ARM.(*arm.Sku)
		result.Sku = &sku
	}

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

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

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

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

	// Set property "HighAvailabilityReplicaCount":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.HighAvailabilityReplicaCount != nil {
			highAvailabilityReplicaCount := *typedInput.Properties.HighAvailabilityReplicaCount
			pool.HighAvailabilityReplicaCount = &highAvailabilityReplicaCount
		}
	}

	// Set property "LicenseType":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.LicenseType != nil {
			var temp string
			temp = string(*typedInput.Properties.LicenseType)
			licenseType := ElasticPoolProperties_LicenseType(temp)
			pool.LicenseType = &licenseType
		}
	}

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

	// Set property "MaintenanceConfigurationId":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.MaintenanceConfigurationId != nil {
			maintenanceConfigurationId := *typedInput.Properties.MaintenanceConfigurationId
			pool.MaintenanceConfigurationId = &maintenanceConfigurationId
		}
	}

	// Set property "MaxSizeBytes":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.MaxSizeBytes != nil {
			maxSizeBytes := *typedInput.Properties.MaxSizeBytes
			pool.MaxSizeBytes = &maxSizeBytes
		}
	}

	// Set property "MinCapacity":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.MinCapacity != nil {
			minCapacity := *typedInput.Properties.MinCapacity
			pool.MinCapacity = &minCapacity
		}
	}

	// no assignment for property "OperatorSpec"

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

	// Set property "PerDatabaseSettings":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.PerDatabaseSettings != nil {
			var perDatabaseSettings1 ElasticPoolPerDatabaseSettings
			err := perDatabaseSettings1.PopulateFromARM(owner, *typedInput.Properties.PerDatabaseSettings)
			if err != nil {
				return err
			}
			perDatabaseSettings := perDatabaseSettings1
			pool.PerDatabaseSettings = &perDatabaseSettings
		}
	}

	// Set property "Sku":
	if typedInput.Sku != nil {
		var sku1 Sku
		err := sku1.PopulateFromARM(owner, *typedInput.Sku)
		if err != nil {
			return err
		}
		sku := sku1
		pool.Sku = &sku
	}

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

	// Set property "ZoneRedundant":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ZoneRedundant != nil {
			zoneRedundant := *typedInput.Properties.ZoneRedundant
			pool.ZoneRedundant = &zoneRedundant
		}
	}

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &ServersElasticPool_Spec{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.ServersElasticPool_Spec{}
	err := pool.AssignProperties_To_ServersElasticPool_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_ServersElasticPool_Spec populates our ServersElasticPool_Spec from the provided source ServersElasticPool_Spec
func (pool *ServersElasticPool_Spec) AssignProperties_From_ServersElasticPool_Spec(source *storage.ServersElasticPool_Spec) error {

	// AzureName
	pool.AzureName = source.AzureName

	// HighAvailabilityReplicaCount
	pool.HighAvailabilityReplicaCount = genruntime.ClonePointerToInt(source.HighAvailabilityReplicaCount)

	// LicenseType
	if source.LicenseType != nil {
		licenseType := *source.LicenseType
		licenseTypeTemp := genruntime.ToEnum(licenseType, elasticPoolProperties_LicenseType_Values)
		pool.LicenseType = &licenseTypeTemp
	} else {
		pool.LicenseType = nil
	}

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

	// MaintenanceConfigurationId
	pool.MaintenanceConfigurationId = genruntime.ClonePointerToString(source.MaintenanceConfigurationId)

	// MaxSizeBytes
	pool.MaxSizeBytes = genruntime.ClonePointerToInt(source.MaxSizeBytes)

	// MinCapacity
	if source.MinCapacity != nil {
		minCapacity := *source.MinCapacity
		pool.MinCapacity = &minCapacity
	} else {
		pool.MinCapacity = nil
	}

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

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

	// PerDatabaseSettings
	if source.PerDatabaseSettings != nil {
		var perDatabaseSetting ElasticPoolPerDatabaseSettings
		err := perDatabaseSetting.AssignProperties_From_ElasticPoolPerDatabaseSettings(source.PerDatabaseSettings)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_ElasticPoolPerDatabaseSettings() to populate field PerDatabaseSettings")
		}
		pool.PerDatabaseSettings = &perDatabaseSetting
	} else {
		pool.PerDatabaseSettings = nil
	}

	// Sku
	if source.Sku != nil {
		var sku Sku
		err := sku.AssignProperties_From_Sku(source.Sku)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_Sku() to populate field Sku")
		}
		pool.Sku = &sku
	} else {
		pool.Sku = nil
	}

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

	// ZoneRedundant
	if source.ZoneRedundant != nil {
		zoneRedundant := *source.ZoneRedundant
		pool.ZoneRedundant = &zoneRedundant
	} else {
		pool.ZoneRedundant = nil
	}

	// No error
	return nil
}

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

	// AzureName
	destination.AzureName = pool.AzureName

	// HighAvailabilityReplicaCount
	destination.HighAvailabilityReplicaCount = genruntime.ClonePointerToInt(pool.HighAvailabilityReplicaCount)

	// LicenseType
	if pool.LicenseType != nil {
		licenseType := string(*pool.LicenseType)
		destination.LicenseType = &licenseType
	} else {
		destination.LicenseType = nil
	}

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

	// MaintenanceConfigurationId
	destination.MaintenanceConfigurationId = genruntime.ClonePointerToString(pool.MaintenanceConfigurationId)

	// MaxSizeBytes
	destination.MaxSizeBytes = genruntime.ClonePointerToInt(pool.MaxSizeBytes)

	// MinCapacity
	if pool.MinCapacity != nil {
		minCapacity := *pool.MinCapacity
		destination.MinCapacity = &minCapacity
	} else {
		destination.MinCapacity = nil
	}

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

	// OriginalVersion
	destination.OriginalVersion = pool.OriginalVersion()

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

	// PerDatabaseSettings
	if pool.PerDatabaseSettings != nil {
		var perDatabaseSetting storage.ElasticPoolPerDatabaseSettings
		err := pool.PerDatabaseSettings.AssignProperties_To_ElasticPoolPerDatabaseSettings(&perDatabaseSetting)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_ElasticPoolPerDatabaseSettings() to populate field PerDatabaseSettings")
		}
		destination.PerDatabaseSettings = &perDatabaseSetting
	} else {
		destination.PerDatabaseSettings = nil
	}

	// Sku
	if pool.Sku != nil {
		var sku storage.Sku
		err := pool.Sku.AssignProperties_To_Sku(&sku)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_Sku() to populate field Sku")
		}
		destination.Sku = &sku
	} else {
		destination.Sku = nil
	}

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

	// ZoneRedundant
	if pool.ZoneRedundant != nil {
		zoneRedundant := *pool.ZoneRedundant
		destination.ZoneRedundant = &zoneRedundant
	} else {
		destination.ZoneRedundant = nil
	}

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

	// No error
	return nil
}

// Initialize_From_ServersElasticPool_STATUS populates our ServersElasticPool_Spec from the provided source ServersElasticPool_STATUS
func (pool *ServersElasticPool_Spec) Initialize_From_ServersElasticPool_STATUS(source *ServersElasticPool_STATUS) error {

	// HighAvailabilityReplicaCount
	pool.HighAvailabilityReplicaCount = genruntime.ClonePointerToInt(source.HighAvailabilityReplicaCount)

	// LicenseType
	if source.LicenseType != nil {
		licenseType := genruntime.ToEnum(string(*source.LicenseType), elasticPoolProperties_LicenseType_Values)
		pool.LicenseType = &licenseType
	} else {
		pool.LicenseType = nil
	}

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

	// MaintenanceConfigurationId
	pool.MaintenanceConfigurationId = genruntime.ClonePointerToString(source.MaintenanceConfigurationId)

	// MaxSizeBytes
	pool.MaxSizeBytes = genruntime.ClonePointerToInt(source.MaxSizeBytes)

	// MinCapacity
	if source.MinCapacity != nil {
		minCapacity := *source.MinCapacity
		pool.MinCapacity = &minCapacity
	} else {
		pool.MinCapacity = nil
	}

	// PerDatabaseSettings
	if source.PerDatabaseSettings != nil {
		var perDatabaseSetting ElasticPoolPerDatabaseSettings
		err := perDatabaseSetting.Initialize_From_ElasticPoolPerDatabaseSettings_STATUS(source.PerDatabaseSettings)
		if err != nil {
			return eris.Wrap(err, "calling Initialize_From_ElasticPoolPerDatabaseSettings_STATUS() to populate field PerDatabaseSettings")
		}
		pool.PerDatabaseSettings = &perDatabaseSetting
	} else {
		pool.PerDatabaseSettings = nil
	}

	// Sku
	if source.Sku != nil {
		var sku Sku
		err := sku.Initialize_From_Sku_STATUS(source.Sku)
		if err != nil {
			return eris.Wrap(err, "calling Initialize_From_Sku_STATUS() to populate field Sku")
		}
		pool.Sku = &sku
	} else {
		pool.Sku = nil
	}

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

	// ZoneRedundant
	if source.ZoneRedundant != nil {
		zoneRedundant := *source.ZoneRedundant
		pool.ZoneRedundant = &zoneRedundant
	} else {
		pool.ZoneRedundant = nil
	}

	// No error
	return nil
}

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

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

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

	// CreationDate: The creation date of the elastic pool (ISO8601 format).
	CreationDate *string `json:"creationDate,omitempty"`

	// HighAvailabilityReplicaCount: The number of secondary replicas associated with the elastic pool that are used to provide
	// high availability. Applicable only to Hyperscale elastic pools.
	HighAvailabilityReplicaCount *int `json:"highAvailabilityReplicaCount,omitempty"`

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

	// Kind: Kind of elastic pool. This is metadata used for the Azure portal experience.
	Kind *string `json:"kind,omitempty"`

	// LicenseType: The license type to apply for this elastic pool.
	LicenseType *ElasticPoolProperties_LicenseType_STATUS `json:"licenseType,omitempty"`

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

	// MaintenanceConfigurationId: Maintenance configuration id assigned to the elastic pool. This configuration defines the
	// period when the maintenance updates will will occur.
	MaintenanceConfigurationId *string `json:"maintenanceConfigurationId,omitempty"`

	// MaxSizeBytes: The storage limit for the database elastic pool in bytes.
	MaxSizeBytes *int `json:"maxSizeBytes,omitempty"`

	// MinCapacity: Minimal capacity that serverless pool will not shrink below, if not paused
	MinCapacity *float64 `json:"minCapacity,omitempty"`

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

	// PerDatabaseSettings: The per database settings for the elastic pool.
	PerDatabaseSettings *ElasticPoolPerDatabaseSettings_STATUS `json:"perDatabaseSettings,omitempty"`

	// Sku: The elastic pool SKU.
	// The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU name, tier/edition,
	// family, and capacity) that are available to your subscription in an Azure region, use the `Capabilities_ListByLocation`
	// REST API or the following command:
	// ```azurecli
	// az sql elastic-pool list-editions -l <location> -o table
	// ````
	Sku *Sku_STATUS `json:"sku,omitempty"`

	// State: The state of the elastic pool.
	State *ElasticPoolProperties_State_STATUS `json:"state,omitempty"`

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

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

	// ZoneRedundant: Whether or not this elastic pool is zone redundant, which means the replicas of this elastic pool will be
	// spread across multiple availability zones.
	ZoneRedundant *bool `json:"zoneRedundant,omitempty"`
}

var _ genruntime.ConvertibleStatus = &ServersElasticPool_STATUS{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.ServersElasticPool_STATUS{}
	err := pool.AssignProperties_To_ServersElasticPool_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 = &ServersElasticPool_STATUS{}

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

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

	// no assignment for property "Conditions"

	// Set property "CreationDate":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.CreationDate != nil {
			creationDate := *typedInput.Properties.CreationDate
			pool.CreationDate = &creationDate
		}
	}

	// Set property "HighAvailabilityReplicaCount":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.HighAvailabilityReplicaCount != nil {
			highAvailabilityReplicaCount := *typedInput.Properties.HighAvailabilityReplicaCount
			pool.HighAvailabilityReplicaCount = &highAvailabilityReplicaCount
		}
	}

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

	// Set property "Kind":
	if typedInput.Kind != nil {
		kind := *typedInput.Kind
		pool.Kind = &kind
	}

	// Set property "LicenseType":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.LicenseType != nil {
			var temp string
			temp = string(*typedInput.Properties.LicenseType)
			licenseType := ElasticPoolProperties_LicenseType_STATUS(temp)
			pool.LicenseType = &licenseType
		}
	}

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

	// Set property "MaintenanceConfigurationId":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.MaintenanceConfigurationId != nil {
			maintenanceConfigurationId := *typedInput.Properties.MaintenanceConfigurationId
			pool.MaintenanceConfigurationId = &maintenanceConfigurationId
		}
	}

	// Set property "MaxSizeBytes":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.MaxSizeBytes != nil {
			maxSizeBytes := *typedInput.Properties.MaxSizeBytes
			pool.MaxSizeBytes = &maxSizeBytes
		}
	}

	// Set property "MinCapacity":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.MinCapacity != nil {
			minCapacity := *typedInput.Properties.MinCapacity
			pool.MinCapacity = &minCapacity
		}
	}

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

	// Set property "PerDatabaseSettings":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.PerDatabaseSettings != nil {
			var perDatabaseSettings1 ElasticPoolPerDatabaseSettings_STATUS
			err := perDatabaseSettings1.PopulateFromARM(owner, *typedInput.Properties.PerDatabaseSettings)
			if err != nil {
				return err
			}
			perDatabaseSettings := perDatabaseSettings1
			pool.PerDatabaseSettings = &perDatabaseSettings
		}
	}

	// Set property "Sku":
	if typedInput.Sku != nil {
		var sku1 Sku_STATUS
		err := sku1.PopulateFromARM(owner, *typedInput.Sku)
		if err != nil {
			return err
		}
		sku := sku1
		pool.Sku = &sku
	}

	// Set property "State":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.State != nil {
			var temp string
			temp = string(*typedInput.Properties.State)
			state := ElasticPoolProperties_State_STATUS(temp)
			pool.State = &state
		}
	}

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

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

	// Set property "ZoneRedundant":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ZoneRedundant != nil {
			zoneRedundant := *typedInput.Properties.ZoneRedundant
			pool.ZoneRedundant = &zoneRedundant
		}
	}

	// No error
	return nil
}

// AssignProperties_From_ServersElasticPool_STATUS populates our ServersElasticPool_STATUS from the provided source ServersElasticPool_STATUS
func (pool *ServersElasticPool_STATUS) AssignProperties_From_ServersElasticPool_STATUS(source *storage.ServersElasticPool_STATUS) error {

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

	// CreationDate
	pool.CreationDate = genruntime.ClonePointerToString(source.CreationDate)

	// HighAvailabilityReplicaCount
	pool.HighAvailabilityReplicaCount = genruntime.ClonePointerToInt(source.HighAvailabilityReplicaCount)

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

	// Kind
	pool.Kind = genruntime.ClonePointerToString(source.Kind)

	// LicenseType
	if source.LicenseType != nil {
		licenseType := *source.LicenseType
		licenseTypeTemp := genruntime.ToEnum(licenseType, elasticPoolProperties_LicenseType_STATUS_Values)
		pool.LicenseType = &licenseTypeTemp
	} else {
		pool.LicenseType = nil
	}

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

	// MaintenanceConfigurationId
	pool.MaintenanceConfigurationId = genruntime.ClonePointerToString(source.MaintenanceConfigurationId)

	// MaxSizeBytes
	pool.MaxSizeBytes = genruntime.ClonePointerToInt(source.MaxSizeBytes)

	// MinCapacity
	if source.MinCapacity != nil {
		minCapacity := *source.MinCapacity
		pool.MinCapacity = &minCapacity
	} else {
		pool.MinCapacity = nil
	}

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

	// PerDatabaseSettings
	if source.PerDatabaseSettings != nil {
		var perDatabaseSetting ElasticPoolPerDatabaseSettings_STATUS
		err := perDatabaseSetting.AssignProperties_From_ElasticPoolPerDatabaseSettings_STATUS(source.PerDatabaseSettings)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_ElasticPoolPerDatabaseSettings_STATUS() to populate field PerDatabaseSettings")
		}
		pool.PerDatabaseSettings = &perDatabaseSetting
	} else {
		pool.PerDatabaseSettings = nil
	}

	// Sku
	if source.Sku != nil {
		var sku Sku_STATUS
		err := sku.AssignProperties_From_Sku_STATUS(source.Sku)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_Sku_STATUS() to populate field Sku")
		}
		pool.Sku = &sku
	} else {
		pool.Sku = nil
	}

	// State
	if source.State != nil {
		state := *source.State
		stateTemp := genruntime.ToEnum(state, elasticPoolProperties_State_STATUS_Values)
		pool.State = &stateTemp
	} else {
		pool.State = nil
	}

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

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

	// ZoneRedundant
	if source.ZoneRedundant != nil {
		zoneRedundant := *source.ZoneRedundant
		pool.ZoneRedundant = &zoneRedundant
	} else {
		pool.ZoneRedundant = nil
	}

	// No error
	return nil
}

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

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

	// CreationDate
	destination.CreationDate = genruntime.ClonePointerToString(pool.CreationDate)

	// HighAvailabilityReplicaCount
	destination.HighAvailabilityReplicaCount = genruntime.ClonePointerToInt(pool.HighAvailabilityReplicaCount)

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

	// Kind
	destination.Kind = genruntime.ClonePointerToString(pool.Kind)

	// LicenseType
	if pool.LicenseType != nil {
		licenseType := string(*pool.LicenseType)
		destination.LicenseType = &licenseType
	} else {
		destination.LicenseType = nil
	}

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

	// MaintenanceConfigurationId
	destination.MaintenanceConfigurationId = genruntime.ClonePointerToString(pool.MaintenanceConfigurationId)

	// MaxSizeBytes
	destination.MaxSizeBytes = genruntime.ClonePointerToInt(pool.MaxSizeBytes)

	// MinCapacity
	if pool.MinCapacity != nil {
		minCapacity := *pool.MinCapacity
		destination.MinCapacity = &minCapacity
	} else {
		destination.MinCapacity = nil
	}

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

	// PerDatabaseSettings
	if pool.PerDatabaseSettings != nil {
		var perDatabaseSetting storage.ElasticPoolPerDatabaseSettings_STATUS
		err := pool.PerDatabaseSettings.AssignProperties_To_ElasticPoolPerDatabaseSettings_STATUS(&perDatabaseSetting)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_ElasticPoolPerDatabaseSettings_STATUS() to populate field PerDatabaseSettings")
		}
		destination.PerDatabaseSettings = &perDatabaseSetting
	} else {
		destination.PerDatabaseSettings = nil
	}

	// Sku
	if pool.Sku != nil {
		var sku storage.Sku_STATUS
		err := pool.Sku.AssignProperties_To_Sku_STATUS(&sku)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_Sku_STATUS() to populate field Sku")
		}
		destination.Sku = &sku
	} else {
		destination.Sku = nil
	}

	// State
	if pool.State != nil {
		state := string(*pool.State)
		destination.State = &state
	} else {
		destination.State = nil
	}

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

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

	// ZoneRedundant
	if pool.ZoneRedundant != nil {
		zoneRedundant := *pool.ZoneRedundant
		destination.ZoneRedundant = &zoneRedundant
	} else {
		destination.ZoneRedundant = nil
	}

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

	// No error
	return nil
}

// Per database settings of an elastic pool.
type ElasticPoolPerDatabaseSettings struct {
	// MaxCapacity: The maximum capacity any one database can consume.
	MaxCapacity *float64 `json:"maxCapacity,omitempty"`

	// MinCapacity: The minimum capacity all databases are guaranteed.
	MinCapacity *float64 `json:"minCapacity,omitempty"`
}

var _ genruntime.ARMTransformer = &ElasticPoolPerDatabaseSettings{}

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

	// Set property "MaxCapacity":
	if settings.MaxCapacity != nil {
		maxCapacity := *settings.MaxCapacity
		result.MaxCapacity = &maxCapacity
	}

	// Set property "MinCapacity":
	if settings.MinCapacity != nil {
		minCapacity := *settings.MinCapacity
		result.MinCapacity = &minCapacity
	}
	return result, nil
}

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

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

	// Set property "MaxCapacity":
	if typedInput.MaxCapacity != nil {
		maxCapacity := *typedInput.MaxCapacity
		settings.MaxCapacity = &maxCapacity
	}

	// Set property "MinCapacity":
	if typedInput.MinCapacity != nil {
		minCapacity := *typedInput.MinCapacity
		settings.MinCapacity = &minCapacity
	}

	// No error
	return nil
}

// AssignProperties_From_ElasticPoolPerDatabaseSettings populates our ElasticPoolPerDatabaseSettings from the provided source ElasticPoolPerDatabaseSettings
func (settings *ElasticPoolPerDatabaseSettings) AssignProperties_From_ElasticPoolPerDatabaseSettings(source *storage.ElasticPoolPerDatabaseSettings) error {

	// MaxCapacity
	if source.MaxCapacity != nil {
		maxCapacity := *source.MaxCapacity
		settings.MaxCapacity = &maxCapacity
	} else {
		settings.MaxCapacity = nil
	}

	// MinCapacity
	if source.MinCapacity != nil {
		minCapacity := *source.MinCapacity
		settings.MinCapacity = &minCapacity
	} else {
		settings.MinCapacity = nil
	}

	// No error
	return nil
}

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

	// MaxCapacity
	if settings.MaxCapacity != nil {
		maxCapacity := *settings.MaxCapacity
		destination.MaxCapacity = &maxCapacity
	} else {
		destination.MaxCapacity = nil
	}

	// MinCapacity
	if settings.MinCapacity != nil {
		minCapacity := *settings.MinCapacity
		destination.MinCapacity = &minCapacity
	} else {
		destination.MinCapacity = nil
	}

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

	// No error
	return nil
}

// Initialize_From_ElasticPoolPerDatabaseSettings_STATUS populates our ElasticPoolPerDatabaseSettings from the provided source ElasticPoolPerDatabaseSettings_STATUS
func (settings *ElasticPoolPerDatabaseSettings) Initialize_From_ElasticPoolPerDatabaseSettings_STATUS(source *ElasticPoolPerDatabaseSettings_STATUS) error {

	// MaxCapacity
	if source.MaxCapacity != nil {
		maxCapacity := *source.MaxCapacity
		settings.MaxCapacity = &maxCapacity
	} else {
		settings.MaxCapacity = nil
	}

	// MinCapacity
	if source.MinCapacity != nil {
		minCapacity := *source.MinCapacity
		settings.MinCapacity = &minCapacity
	} else {
		settings.MinCapacity = nil
	}

	// No error
	return nil
}

// Per database settings of an elastic pool.
type ElasticPoolPerDatabaseSettings_STATUS struct {
	// MaxCapacity: The maximum capacity any one database can consume.
	MaxCapacity *float64 `json:"maxCapacity,omitempty"`

	// MinCapacity: The minimum capacity all databases are guaranteed.
	MinCapacity *float64 `json:"minCapacity,omitempty"`
}

var _ genruntime.FromARMConverter = &ElasticPoolPerDatabaseSettings_STATUS{}

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

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

	// Set property "MaxCapacity":
	if typedInput.MaxCapacity != nil {
		maxCapacity := *typedInput.MaxCapacity
		settings.MaxCapacity = &maxCapacity
	}

	// Set property "MinCapacity":
	if typedInput.MinCapacity != nil {
		minCapacity := *typedInput.MinCapacity
		settings.MinCapacity = &minCapacity
	}

	// No error
	return nil
}

// AssignProperties_From_ElasticPoolPerDatabaseSettings_STATUS populates our ElasticPoolPerDatabaseSettings_STATUS from the provided source ElasticPoolPerDatabaseSettings_STATUS
func (settings *ElasticPoolPerDatabaseSettings_STATUS) AssignProperties_From_ElasticPoolPerDatabaseSettings_STATUS(source *storage.ElasticPoolPerDatabaseSettings_STATUS) error {

	// MaxCapacity
	if source.MaxCapacity != nil {
		maxCapacity := *source.MaxCapacity
		settings.MaxCapacity = &maxCapacity
	} else {
		settings.MaxCapacity = nil
	}

	// MinCapacity
	if source.MinCapacity != nil {
		minCapacity := *source.MinCapacity
		settings.MinCapacity = &minCapacity
	} else {
		settings.MinCapacity = nil
	}

	// No error
	return nil
}

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

	// MaxCapacity
	if settings.MaxCapacity != nil {
		maxCapacity := *settings.MaxCapacity
		destination.MaxCapacity = &maxCapacity
	} else {
		destination.MaxCapacity = nil
	}

	// MinCapacity
	if settings.MinCapacity != nil {
		minCapacity := *settings.MinCapacity
		destination.MinCapacity = &minCapacity
	} else {
		destination.MinCapacity = nil
	}

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

	// No error
	return nil
}

// +kubebuilder:validation:Enum={"BasePrice","LicenseIncluded"}
type ElasticPoolProperties_LicenseType string

const (
	ElasticPoolProperties_LicenseType_BasePrice       = ElasticPoolProperties_LicenseType("BasePrice")
	ElasticPoolProperties_LicenseType_LicenseIncluded = ElasticPoolProperties_LicenseType("LicenseIncluded")
)

// Mapping from string to ElasticPoolProperties_LicenseType
var elasticPoolProperties_LicenseType_Values = map[string]ElasticPoolProperties_LicenseType{
	"baseprice":       ElasticPoolProperties_LicenseType_BasePrice,
	"licenseincluded": ElasticPoolProperties_LicenseType_LicenseIncluded,
}

type ElasticPoolProperties_LicenseType_STATUS string

const (
	ElasticPoolProperties_LicenseType_STATUS_BasePrice       = ElasticPoolProperties_LicenseType_STATUS("BasePrice")
	ElasticPoolProperties_LicenseType_STATUS_LicenseIncluded = ElasticPoolProperties_LicenseType_STATUS("LicenseIncluded")
)

// Mapping from string to ElasticPoolProperties_LicenseType_STATUS
var elasticPoolProperties_LicenseType_STATUS_Values = map[string]ElasticPoolProperties_LicenseType_STATUS{
	"baseprice":       ElasticPoolProperties_LicenseType_STATUS_BasePrice,
	"licenseincluded": ElasticPoolProperties_LicenseType_STATUS_LicenseIncluded,
}

type ElasticPoolProperties_State_STATUS string

const (
	ElasticPoolProperties_State_STATUS_Creating = ElasticPoolProperties_State_STATUS("Creating")
	ElasticPoolProperties_State_STATUS_Disabled = ElasticPoolProperties_State_STATUS("Disabled")
	ElasticPoolProperties_State_STATUS_Ready    = ElasticPoolProperties_State_STATUS("Ready")
)

// Mapping from string to ElasticPoolProperties_State_STATUS
var elasticPoolProperties_State_STATUS_Values = map[string]ElasticPoolProperties_State_STATUS{
	"creating": ElasticPoolProperties_State_STATUS_Creating,
	"disabled": ElasticPoolProperties_State_STATUS_Disabled,
	"ready":    ElasticPoolProperties_State_STATUS_Ready,
}

// Details for configuring operator behavior. Fields in this struct are interpreted by the operator directly rather than being passed to Azure
type ServersElasticPoolOperatorSpec 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_ServersElasticPoolOperatorSpec populates our ServersElasticPoolOperatorSpec from the provided source ServersElasticPoolOperatorSpec
func (operator *ServersElasticPoolOperatorSpec) AssignProperties_From_ServersElasticPoolOperatorSpec(source *storage.ServersElasticPoolOperatorSpec) 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_ServersElasticPoolOperatorSpec populates the provided destination ServersElasticPoolOperatorSpec from our ServersElasticPoolOperatorSpec
func (operator *ServersElasticPoolOperatorSpec) AssignProperties_To_ServersElasticPoolOperatorSpec(destination *storage.ServersElasticPoolOperatorSpec) 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(&ServersElasticPool{}, &ServersElasticPoolList{})
}
