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

import (
	"fmt"
	arm "github.com/Azure/azure-service-operator/v2/api/cache/v1api20210301/arm"
	storage "github.com/Azure/azure-service-operator/v2/api/cache/v1api20210301/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,cache}
// +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: /redisenterprise/resource-manager/Microsoft.Cache/RedisEnterprise/stable/2021-03-01/redisenterprise.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}
type RedisEnterpriseDatabase struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              RedisEnterpriseDatabase_Spec   `json:"spec,omitempty"`
	Status            RedisEnterpriseDatabase_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &RedisEnterpriseDatabase{}

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

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

var _ conversion.Convertible = &RedisEnterpriseDatabase{}

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

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

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

	return nil
}

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

	return nil
}

var _ configmaps.Exporter = &RedisEnterpriseDatabase{}

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

var _ secrets.Exporter = &RedisEnterpriseDatabase{}

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

var _ genruntime.KubernetesResource = &RedisEnterpriseDatabase{}

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

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

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.Cache/redisEnterprise/databases"
func (database *RedisEnterpriseDatabase) GetType() string {
	return "Microsoft.Cache/redisEnterprise/databases"
}

// NewEmptyStatus returns a new empty (blank) status
func (database *RedisEnterpriseDatabase) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &RedisEnterpriseDatabase_STATUS{}
}

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

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

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

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

	database.Status = st
	return nil
}

// AssignProperties_From_RedisEnterpriseDatabase populates our RedisEnterpriseDatabase from the provided source RedisEnterpriseDatabase
func (database *RedisEnterpriseDatabase) AssignProperties_From_RedisEnterpriseDatabase(source *storage.RedisEnterpriseDatabase) error {

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

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

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

	// No error
	return nil
}

// AssignProperties_To_RedisEnterpriseDatabase populates the provided destination RedisEnterpriseDatabase from our RedisEnterpriseDatabase
func (database *RedisEnterpriseDatabase) AssignProperties_To_RedisEnterpriseDatabase(destination *storage.RedisEnterpriseDatabase) error {

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

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

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

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /redisenterprise/resource-manager/Microsoft.Cache/RedisEnterprise/stable/2021-03-01/redisenterprise.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}
type RedisEnterpriseDatabaseList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []RedisEnterpriseDatabase `json:"items"`
}

type RedisEnterpriseDatabase_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"`

	// ClientProtocol: Specifies whether redis clients can connect using TLS-encrypted or plaintext redis protocols. Default is
	// TLS-encrypted.
	ClientProtocol *DatabaseProperties_ClientProtocol `json:"clientProtocol,omitempty"`

	// ClusteringPolicy: Clustering policy - default is OSSCluster. Specified at create time.
	ClusteringPolicy *DatabaseProperties_ClusteringPolicy `json:"clusteringPolicy,omitempty"`

	// EvictionPolicy: Redis eviction policy - default is VolatileLRU
	EvictionPolicy *DatabaseProperties_EvictionPolicy `json:"evictionPolicy,omitempty"`

	// Modules: Optional set of redis modules to enable in this database - modules can only be added at creation time.
	Modules []Module `json:"modules,omitempty"`

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

	// Persistence: Persistence settings
	Persistence *Persistence `json:"persistence,omitempty"`

	// Port: TCP port of the database endpoint. Specified at create time. Defaults to an available port.
	Port *int `json:"port,omitempty"`
}

var _ genruntime.ARMTransformer = &RedisEnterpriseDatabase_Spec{}

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

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

	// Set property "Properties":
	if database.ClientProtocol != nil ||
		database.ClusteringPolicy != nil ||
		database.EvictionPolicy != nil ||
		database.Modules != nil ||
		database.Persistence != nil ||
		database.Port != nil {
		result.Properties = &arm.DatabaseProperties{}
	}
	if database.ClientProtocol != nil {
		var temp string
		temp = string(*database.ClientProtocol)
		clientProtocol := arm.DatabaseProperties_ClientProtocol(temp)
		result.Properties.ClientProtocol = &clientProtocol
	}
	if database.ClusteringPolicy != nil {
		var temp string
		temp = string(*database.ClusteringPolicy)
		clusteringPolicy := arm.DatabaseProperties_ClusteringPolicy(temp)
		result.Properties.ClusteringPolicy = &clusteringPolicy
	}
	if database.EvictionPolicy != nil {
		var temp string
		temp = string(*database.EvictionPolicy)
		evictionPolicy := arm.DatabaseProperties_EvictionPolicy(temp)
		result.Properties.EvictionPolicy = &evictionPolicy
	}
	for _, item := range database.Modules {
		item_ARM, err := item.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		result.Properties.Modules = append(result.Properties.Modules, *item_ARM.(*arm.Module))
	}
	if database.Persistence != nil {
		persistence_ARM, err := database.Persistence.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		persistence := *persistence_ARM.(*arm.Persistence)
		result.Properties.Persistence = &persistence
	}
	if database.Port != nil {
		port := *database.Port
		result.Properties.Port = &port
	}
	return result, nil
}

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

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

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

	// Set property "ClientProtocol":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ClientProtocol != nil {
			var temp string
			temp = string(*typedInput.Properties.ClientProtocol)
			clientProtocol := DatabaseProperties_ClientProtocol(temp)
			database.ClientProtocol = &clientProtocol
		}
	}

	// Set property "ClusteringPolicy":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ClusteringPolicy != nil {
			var temp string
			temp = string(*typedInput.Properties.ClusteringPolicy)
			clusteringPolicy := DatabaseProperties_ClusteringPolicy(temp)
			database.ClusteringPolicy = &clusteringPolicy
		}
	}

	// Set property "EvictionPolicy":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.EvictionPolicy != nil {
			var temp string
			temp = string(*typedInput.Properties.EvictionPolicy)
			evictionPolicy := DatabaseProperties_EvictionPolicy(temp)
			database.EvictionPolicy = &evictionPolicy
		}
	}

	// Set property "Modules":
	// copying flattened property:
	if typedInput.Properties != nil {
		for _, item := range typedInput.Properties.Modules {
			var item1 Module
			err := item1.PopulateFromARM(owner, item)
			if err != nil {
				return err
			}
			database.Modules = append(database.Modules, item1)
		}
	}

	// no assignment for property "OperatorSpec"

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

	// Set property "Persistence":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Persistence != nil {
			var persistence1 Persistence
			err := persistence1.PopulateFromARM(owner, *typedInput.Properties.Persistence)
			if err != nil {
				return err
			}
			persistence := persistence1
			database.Persistence = &persistence
		}
	}

	// Set property "Port":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Port != nil {
			port := *typedInput.Properties.Port
			database.Port = &port
		}
	}

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &RedisEnterpriseDatabase_Spec{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.RedisEnterpriseDatabase_Spec{}
	err := database.AssignProperties_To_RedisEnterpriseDatabase_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_RedisEnterpriseDatabase_Spec populates our RedisEnterpriseDatabase_Spec from the provided source RedisEnterpriseDatabase_Spec
func (database *RedisEnterpriseDatabase_Spec) AssignProperties_From_RedisEnterpriseDatabase_Spec(source *storage.RedisEnterpriseDatabase_Spec) error {

	// AzureName
	database.AzureName = source.AzureName

	// ClientProtocol
	if source.ClientProtocol != nil {
		clientProtocol := *source.ClientProtocol
		clientProtocolTemp := genruntime.ToEnum(clientProtocol, databaseProperties_ClientProtocol_Values)
		database.ClientProtocol = &clientProtocolTemp
	} else {
		database.ClientProtocol = nil
	}

	// ClusteringPolicy
	if source.ClusteringPolicy != nil {
		clusteringPolicy := *source.ClusteringPolicy
		clusteringPolicyTemp := genruntime.ToEnum(clusteringPolicy, databaseProperties_ClusteringPolicy_Values)
		database.ClusteringPolicy = &clusteringPolicyTemp
	} else {
		database.ClusteringPolicy = nil
	}

	// EvictionPolicy
	if source.EvictionPolicy != nil {
		evictionPolicy := *source.EvictionPolicy
		evictionPolicyTemp := genruntime.ToEnum(evictionPolicy, databaseProperties_EvictionPolicy_Values)
		database.EvictionPolicy = &evictionPolicyTemp
	} else {
		database.EvictionPolicy = nil
	}

	// Modules
	if source.Modules != nil {
		moduleList := make([]Module, len(source.Modules))
		for moduleIndex, moduleItem := range source.Modules {
			var module Module
			err := module.AssignProperties_From_Module(&moduleItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_Module() to populate field Modules")
			}
			moduleList[moduleIndex] = module
		}
		database.Modules = moduleList
	} else {
		database.Modules = nil
	}

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

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

	// Persistence
	if source.Persistence != nil {
		var persistence Persistence
		err := persistence.AssignProperties_From_Persistence(source.Persistence)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_Persistence() to populate field Persistence")
		}
		database.Persistence = &persistence
	} else {
		database.Persistence = nil
	}

	// Port
	database.Port = genruntime.ClonePointerToInt(source.Port)

	// No error
	return nil
}

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

	// AzureName
	destination.AzureName = database.AzureName

	// ClientProtocol
	if database.ClientProtocol != nil {
		clientProtocol := string(*database.ClientProtocol)
		destination.ClientProtocol = &clientProtocol
	} else {
		destination.ClientProtocol = nil
	}

	// ClusteringPolicy
	if database.ClusteringPolicy != nil {
		clusteringPolicy := string(*database.ClusteringPolicy)
		destination.ClusteringPolicy = &clusteringPolicy
	} else {
		destination.ClusteringPolicy = nil
	}

	// EvictionPolicy
	if database.EvictionPolicy != nil {
		evictionPolicy := string(*database.EvictionPolicy)
		destination.EvictionPolicy = &evictionPolicy
	} else {
		destination.EvictionPolicy = nil
	}

	// Modules
	if database.Modules != nil {
		moduleList := make([]storage.Module, len(database.Modules))
		for moduleIndex, moduleItem := range database.Modules {
			var module storage.Module
			err := moduleItem.AssignProperties_To_Module(&module)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_Module() to populate field Modules")
			}
			moduleList[moduleIndex] = module
		}
		destination.Modules = moduleList
	} else {
		destination.Modules = nil
	}

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

	// OriginalVersion
	destination.OriginalVersion = database.OriginalVersion()

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

	// Persistence
	if database.Persistence != nil {
		var persistence storage.Persistence
		err := database.Persistence.AssignProperties_To_Persistence(&persistence)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_Persistence() to populate field Persistence")
		}
		destination.Persistence = &persistence
	} else {
		destination.Persistence = nil
	}

	// Port
	destination.Port = genruntime.ClonePointerToInt(database.Port)

	// 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 (database *RedisEnterpriseDatabase_Spec) OriginalVersion() string {
	return GroupVersion.Version
}

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

type RedisEnterpriseDatabase_STATUS struct {
	// ClientProtocol: Specifies whether redis clients can connect using TLS-encrypted or plaintext redis protocols. Default is
	// TLS-encrypted.
	ClientProtocol *DatabaseProperties_ClientProtocol_STATUS `json:"clientProtocol,omitempty"`

	// ClusteringPolicy: Clustering policy - default is OSSCluster. Specified at create time.
	ClusteringPolicy *DatabaseProperties_ClusteringPolicy_STATUS `json:"clusteringPolicy,omitempty"`

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

	// EvictionPolicy: Redis eviction policy - default is VolatileLRU
	EvictionPolicy *DatabaseProperties_EvictionPolicy_STATUS `json:"evictionPolicy,omitempty"`

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

	// Modules: Optional set of redis modules to enable in this database - modules can only be added at creation time.
	Modules []Module_STATUS `json:"modules,omitempty"`

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

	// Persistence: Persistence settings
	Persistence *Persistence_STATUS `json:"persistence,omitempty"`

	// Port: TCP port of the database endpoint. Specified at create time. Defaults to an available port.
	Port *int `json:"port,omitempty"`

	// ProvisioningState: Current provisioning status of the database
	ProvisioningState *ProvisioningState_STATUS `json:"provisioningState,omitempty"`

	// ResourceState: Current resource status of the database
	ResourceState *ResourceState_STATUS `json:"resourceState,omitempty"`

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

var _ genruntime.ConvertibleStatus = &RedisEnterpriseDatabase_STATUS{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.RedisEnterpriseDatabase_STATUS{}
	err := database.AssignProperties_To_RedisEnterpriseDatabase_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 = &RedisEnterpriseDatabase_STATUS{}

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

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

	// Set property "ClientProtocol":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ClientProtocol != nil {
			var temp string
			temp = string(*typedInput.Properties.ClientProtocol)
			clientProtocol := DatabaseProperties_ClientProtocol_STATUS(temp)
			database.ClientProtocol = &clientProtocol
		}
	}

	// Set property "ClusteringPolicy":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ClusteringPolicy != nil {
			var temp string
			temp = string(*typedInput.Properties.ClusteringPolicy)
			clusteringPolicy := DatabaseProperties_ClusteringPolicy_STATUS(temp)
			database.ClusteringPolicy = &clusteringPolicy
		}
	}

	// no assignment for property "Conditions"

	// Set property "EvictionPolicy":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.EvictionPolicy != nil {
			var temp string
			temp = string(*typedInput.Properties.EvictionPolicy)
			evictionPolicy := DatabaseProperties_EvictionPolicy_STATUS(temp)
			database.EvictionPolicy = &evictionPolicy
		}
	}

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

	// Set property "Modules":
	// copying flattened property:
	if typedInput.Properties != nil {
		for _, item := range typedInput.Properties.Modules {
			var item1 Module_STATUS
			err := item1.PopulateFromARM(owner, item)
			if err != nil {
				return err
			}
			database.Modules = append(database.Modules, item1)
		}
	}

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

	// Set property "Persistence":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Persistence != nil {
			var persistence1 Persistence_STATUS
			err := persistence1.PopulateFromARM(owner, *typedInput.Properties.Persistence)
			if err != nil {
				return err
			}
			persistence := persistence1
			database.Persistence = &persistence
		}
	}

	// Set property "Port":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Port != nil {
			port := *typedInput.Properties.Port
			database.Port = &port
		}
	}

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

	// Set property "ResourceState":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ResourceState != nil {
			var temp string
			temp = string(*typedInput.Properties.ResourceState)
			resourceState := ResourceState_STATUS(temp)
			database.ResourceState = &resourceState
		}
	}

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

	// No error
	return nil
}

// AssignProperties_From_RedisEnterpriseDatabase_STATUS populates our RedisEnterpriseDatabase_STATUS from the provided source RedisEnterpriseDatabase_STATUS
func (database *RedisEnterpriseDatabase_STATUS) AssignProperties_From_RedisEnterpriseDatabase_STATUS(source *storage.RedisEnterpriseDatabase_STATUS) error {

	// ClientProtocol
	if source.ClientProtocol != nil {
		clientProtocol := *source.ClientProtocol
		clientProtocolTemp := genruntime.ToEnum(clientProtocol, databaseProperties_ClientProtocol_STATUS_Values)
		database.ClientProtocol = &clientProtocolTemp
	} else {
		database.ClientProtocol = nil
	}

	// ClusteringPolicy
	if source.ClusteringPolicy != nil {
		clusteringPolicy := *source.ClusteringPolicy
		clusteringPolicyTemp := genruntime.ToEnum(clusteringPolicy, databaseProperties_ClusteringPolicy_STATUS_Values)
		database.ClusteringPolicy = &clusteringPolicyTemp
	} else {
		database.ClusteringPolicy = nil
	}

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

	// EvictionPolicy
	if source.EvictionPolicy != nil {
		evictionPolicy := *source.EvictionPolicy
		evictionPolicyTemp := genruntime.ToEnum(evictionPolicy, databaseProperties_EvictionPolicy_STATUS_Values)
		database.EvictionPolicy = &evictionPolicyTemp
	} else {
		database.EvictionPolicy = nil
	}

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

	// Modules
	if source.Modules != nil {
		moduleList := make([]Module_STATUS, len(source.Modules))
		for moduleIndex, moduleItem := range source.Modules {
			var module Module_STATUS
			err := module.AssignProperties_From_Module_STATUS(&moduleItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_Module_STATUS() to populate field Modules")
			}
			moduleList[moduleIndex] = module
		}
		database.Modules = moduleList
	} else {
		database.Modules = nil
	}

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

	// Persistence
	if source.Persistence != nil {
		var persistence Persistence_STATUS
		err := persistence.AssignProperties_From_Persistence_STATUS(source.Persistence)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_Persistence_STATUS() to populate field Persistence")
		}
		database.Persistence = &persistence
	} else {
		database.Persistence = nil
	}

	// Port
	database.Port = genruntime.ClonePointerToInt(source.Port)

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

	// ResourceState
	if source.ResourceState != nil {
		resourceState := *source.ResourceState
		resourceStateTemp := genruntime.ToEnum(resourceState, resourceState_STATUS_Values)
		database.ResourceState = &resourceStateTemp
	} else {
		database.ResourceState = nil
	}

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

	// No error
	return nil
}

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

	// ClientProtocol
	if database.ClientProtocol != nil {
		clientProtocol := string(*database.ClientProtocol)
		destination.ClientProtocol = &clientProtocol
	} else {
		destination.ClientProtocol = nil
	}

	// ClusteringPolicy
	if database.ClusteringPolicy != nil {
		clusteringPolicy := string(*database.ClusteringPolicy)
		destination.ClusteringPolicy = &clusteringPolicy
	} else {
		destination.ClusteringPolicy = nil
	}

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

	// EvictionPolicy
	if database.EvictionPolicy != nil {
		evictionPolicy := string(*database.EvictionPolicy)
		destination.EvictionPolicy = &evictionPolicy
	} else {
		destination.EvictionPolicy = nil
	}

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

	// Modules
	if database.Modules != nil {
		moduleList := make([]storage.Module_STATUS, len(database.Modules))
		for moduleIndex, moduleItem := range database.Modules {
			var module storage.Module_STATUS
			err := moduleItem.AssignProperties_To_Module_STATUS(&module)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_Module_STATUS() to populate field Modules")
			}
			moduleList[moduleIndex] = module
		}
		destination.Modules = moduleList
	} else {
		destination.Modules = nil
	}

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

	// Persistence
	if database.Persistence != nil {
		var persistence storage.Persistence_STATUS
		err := database.Persistence.AssignProperties_To_Persistence_STATUS(&persistence)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_Persistence_STATUS() to populate field Persistence")
		}
		destination.Persistence = &persistence
	} else {
		destination.Persistence = nil
	}

	// Port
	destination.Port = genruntime.ClonePointerToInt(database.Port)

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

	// ResourceState
	if database.ResourceState != nil {
		resourceState := string(*database.ResourceState)
		destination.ResourceState = &resourceState
	} else {
		destination.ResourceState = nil
	}

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

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

	// No error
	return nil
}

// +kubebuilder:validation:Enum={"Encrypted","Plaintext"}
type DatabaseProperties_ClientProtocol string

const (
	DatabaseProperties_ClientProtocol_Encrypted = DatabaseProperties_ClientProtocol("Encrypted")
	DatabaseProperties_ClientProtocol_Plaintext = DatabaseProperties_ClientProtocol("Plaintext")
)

// Mapping from string to DatabaseProperties_ClientProtocol
var databaseProperties_ClientProtocol_Values = map[string]DatabaseProperties_ClientProtocol{
	"encrypted": DatabaseProperties_ClientProtocol_Encrypted,
	"plaintext": DatabaseProperties_ClientProtocol_Plaintext,
}

type DatabaseProperties_ClientProtocol_STATUS string

const (
	DatabaseProperties_ClientProtocol_STATUS_Encrypted = DatabaseProperties_ClientProtocol_STATUS("Encrypted")
	DatabaseProperties_ClientProtocol_STATUS_Plaintext = DatabaseProperties_ClientProtocol_STATUS("Plaintext")
)

// Mapping from string to DatabaseProperties_ClientProtocol_STATUS
var databaseProperties_ClientProtocol_STATUS_Values = map[string]DatabaseProperties_ClientProtocol_STATUS{
	"encrypted": DatabaseProperties_ClientProtocol_STATUS_Encrypted,
	"plaintext": DatabaseProperties_ClientProtocol_STATUS_Plaintext,
}

// +kubebuilder:validation:Enum={"EnterpriseCluster","OSSCluster"}
type DatabaseProperties_ClusteringPolicy string

const (
	DatabaseProperties_ClusteringPolicy_EnterpriseCluster = DatabaseProperties_ClusteringPolicy("EnterpriseCluster")
	DatabaseProperties_ClusteringPolicy_OSSCluster        = DatabaseProperties_ClusteringPolicy("OSSCluster")
)

// Mapping from string to DatabaseProperties_ClusteringPolicy
var databaseProperties_ClusteringPolicy_Values = map[string]DatabaseProperties_ClusteringPolicy{
	"enterprisecluster": DatabaseProperties_ClusteringPolicy_EnterpriseCluster,
	"osscluster":        DatabaseProperties_ClusteringPolicy_OSSCluster,
}

type DatabaseProperties_ClusteringPolicy_STATUS string

const (
	DatabaseProperties_ClusteringPolicy_STATUS_EnterpriseCluster = DatabaseProperties_ClusteringPolicy_STATUS("EnterpriseCluster")
	DatabaseProperties_ClusteringPolicy_STATUS_OSSCluster        = DatabaseProperties_ClusteringPolicy_STATUS("OSSCluster")
)

// Mapping from string to DatabaseProperties_ClusteringPolicy_STATUS
var databaseProperties_ClusteringPolicy_STATUS_Values = map[string]DatabaseProperties_ClusteringPolicy_STATUS{
	"enterprisecluster": DatabaseProperties_ClusteringPolicy_STATUS_EnterpriseCluster,
	"osscluster":        DatabaseProperties_ClusteringPolicy_STATUS_OSSCluster,
}

// +kubebuilder:validation:Enum={"AllKeysLFU","AllKeysLRU","AllKeysRandom","NoEviction","VolatileLFU","VolatileLRU","VolatileRandom","VolatileTTL"}
type DatabaseProperties_EvictionPolicy string

const (
	DatabaseProperties_EvictionPolicy_AllKeysLFU     = DatabaseProperties_EvictionPolicy("AllKeysLFU")
	DatabaseProperties_EvictionPolicy_AllKeysLRU     = DatabaseProperties_EvictionPolicy("AllKeysLRU")
	DatabaseProperties_EvictionPolicy_AllKeysRandom  = DatabaseProperties_EvictionPolicy("AllKeysRandom")
	DatabaseProperties_EvictionPolicy_NoEviction     = DatabaseProperties_EvictionPolicy("NoEviction")
	DatabaseProperties_EvictionPolicy_VolatileLFU    = DatabaseProperties_EvictionPolicy("VolatileLFU")
	DatabaseProperties_EvictionPolicy_VolatileLRU    = DatabaseProperties_EvictionPolicy("VolatileLRU")
	DatabaseProperties_EvictionPolicy_VolatileRandom = DatabaseProperties_EvictionPolicy("VolatileRandom")
	DatabaseProperties_EvictionPolicy_VolatileTTL    = DatabaseProperties_EvictionPolicy("VolatileTTL")
)

// Mapping from string to DatabaseProperties_EvictionPolicy
var databaseProperties_EvictionPolicy_Values = map[string]DatabaseProperties_EvictionPolicy{
	"allkeyslfu":     DatabaseProperties_EvictionPolicy_AllKeysLFU,
	"allkeyslru":     DatabaseProperties_EvictionPolicy_AllKeysLRU,
	"allkeysrandom":  DatabaseProperties_EvictionPolicy_AllKeysRandom,
	"noeviction":     DatabaseProperties_EvictionPolicy_NoEviction,
	"volatilelfu":    DatabaseProperties_EvictionPolicy_VolatileLFU,
	"volatilelru":    DatabaseProperties_EvictionPolicy_VolatileLRU,
	"volatilerandom": DatabaseProperties_EvictionPolicy_VolatileRandom,
	"volatilettl":    DatabaseProperties_EvictionPolicy_VolatileTTL,
}

type DatabaseProperties_EvictionPolicy_STATUS string

const (
	DatabaseProperties_EvictionPolicy_STATUS_AllKeysLFU     = DatabaseProperties_EvictionPolicy_STATUS("AllKeysLFU")
	DatabaseProperties_EvictionPolicy_STATUS_AllKeysLRU     = DatabaseProperties_EvictionPolicy_STATUS("AllKeysLRU")
	DatabaseProperties_EvictionPolicy_STATUS_AllKeysRandom  = DatabaseProperties_EvictionPolicy_STATUS("AllKeysRandom")
	DatabaseProperties_EvictionPolicy_STATUS_NoEviction     = DatabaseProperties_EvictionPolicy_STATUS("NoEviction")
	DatabaseProperties_EvictionPolicy_STATUS_VolatileLFU    = DatabaseProperties_EvictionPolicy_STATUS("VolatileLFU")
	DatabaseProperties_EvictionPolicy_STATUS_VolatileLRU    = DatabaseProperties_EvictionPolicy_STATUS("VolatileLRU")
	DatabaseProperties_EvictionPolicy_STATUS_VolatileRandom = DatabaseProperties_EvictionPolicy_STATUS("VolatileRandom")
	DatabaseProperties_EvictionPolicy_STATUS_VolatileTTL    = DatabaseProperties_EvictionPolicy_STATUS("VolatileTTL")
)

// Mapping from string to DatabaseProperties_EvictionPolicy_STATUS
var databaseProperties_EvictionPolicy_STATUS_Values = map[string]DatabaseProperties_EvictionPolicy_STATUS{
	"allkeyslfu":     DatabaseProperties_EvictionPolicy_STATUS_AllKeysLFU,
	"allkeyslru":     DatabaseProperties_EvictionPolicy_STATUS_AllKeysLRU,
	"allkeysrandom":  DatabaseProperties_EvictionPolicy_STATUS_AllKeysRandom,
	"noeviction":     DatabaseProperties_EvictionPolicy_STATUS_NoEviction,
	"volatilelfu":    DatabaseProperties_EvictionPolicy_STATUS_VolatileLFU,
	"volatilelru":    DatabaseProperties_EvictionPolicy_STATUS_VolatileLRU,
	"volatilerandom": DatabaseProperties_EvictionPolicy_STATUS_VolatileRandom,
	"volatilettl":    DatabaseProperties_EvictionPolicy_STATUS_VolatileTTL,
}

// Specifies configuration of a redis module
type Module struct {
	// Args: Configuration options for the module, e.g. 'ERROR_RATE 0.00 INITIAL_SIZE 400'.
	Args *string `json:"args,omitempty"`

	// +kubebuilder:validation:Required
	// Name: The name of the module, e.g. 'RedisBloom', 'RediSearch', 'RedisTimeSeries'
	Name *string `json:"name,omitempty"`
}

var _ genruntime.ARMTransformer = &Module{}

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

	// Set property "Args":
	if module.Args != nil {
		args := *module.Args
		result.Args = &args
	}

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

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

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

	// Set property "Args":
	if typedInput.Args != nil {
		args := *typedInput.Args
		module.Args = &args
	}

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

	// No error
	return nil
}

// AssignProperties_From_Module populates our Module from the provided source Module
func (module *Module) AssignProperties_From_Module(source *storage.Module) error {

	// Args
	module.Args = genruntime.ClonePointerToString(source.Args)

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

	// No error
	return nil
}

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

	// Args
	destination.Args = genruntime.ClonePointerToString(module.Args)

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

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

	// No error
	return nil
}

// Specifies configuration of a redis module
type Module_STATUS struct {
	// Args: Configuration options for the module, e.g. 'ERROR_RATE 0.00 INITIAL_SIZE 400'.
	Args *string `json:"args,omitempty"`

	// Name: The name of the module, e.g. 'RedisBloom', 'RediSearch', 'RedisTimeSeries'
	Name *string `json:"name,omitempty"`

	// Version: The version of the module, e.g. '1.0'.
	Version *string `json:"version,omitempty"`
}

var _ genruntime.FromARMConverter = &Module_STATUS{}

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

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

	// Set property "Args":
	if typedInput.Args != nil {
		args := *typedInput.Args
		module.Args = &args
	}

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

	// Set property "Version":
	if typedInput.Version != nil {
		version := *typedInput.Version
		module.Version = &version
	}

	// No error
	return nil
}

// AssignProperties_From_Module_STATUS populates our Module_STATUS from the provided source Module_STATUS
func (module *Module_STATUS) AssignProperties_From_Module_STATUS(source *storage.Module_STATUS) error {

	// Args
	module.Args = genruntime.ClonePointerToString(source.Args)

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

	// Version
	module.Version = genruntime.ClonePointerToString(source.Version)

	// No error
	return nil
}

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

	// Args
	destination.Args = genruntime.ClonePointerToString(module.Args)

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

	// Version
	destination.Version = genruntime.ClonePointerToString(module.Version)

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

	// No error
	return nil
}

// Persistence-related configuration for the RedisEnterprise database
type Persistence struct {
	// AofEnabled: Sets whether AOF is enabled.
	AofEnabled *bool `json:"aofEnabled,omitempty"`

	// AofFrequency: Sets the frequency at which data is written to disk.
	AofFrequency *Persistence_AofFrequency `json:"aofFrequency,omitempty"`

	// RdbEnabled: Sets whether RDB is enabled.
	RdbEnabled *bool `json:"rdbEnabled,omitempty"`

	// RdbFrequency: Sets the frequency at which a snapshot of the database is created.
	RdbFrequency *Persistence_RdbFrequency `json:"rdbFrequency,omitempty"`
}

var _ genruntime.ARMTransformer = &Persistence{}

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

	// Set property "AofEnabled":
	if persistence.AofEnabled != nil {
		aofEnabled := *persistence.AofEnabled
		result.AofEnabled = &aofEnabled
	}

	// Set property "AofFrequency":
	if persistence.AofFrequency != nil {
		var temp string
		temp = string(*persistence.AofFrequency)
		aofFrequency := arm.Persistence_AofFrequency(temp)
		result.AofFrequency = &aofFrequency
	}

	// Set property "RdbEnabled":
	if persistence.RdbEnabled != nil {
		rdbEnabled := *persistence.RdbEnabled
		result.RdbEnabled = &rdbEnabled
	}

	// Set property "RdbFrequency":
	if persistence.RdbFrequency != nil {
		var temp string
		temp = string(*persistence.RdbFrequency)
		rdbFrequency := arm.Persistence_RdbFrequency(temp)
		result.RdbFrequency = &rdbFrequency
	}
	return result, nil
}

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

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

	// Set property "AofEnabled":
	if typedInput.AofEnabled != nil {
		aofEnabled := *typedInput.AofEnabled
		persistence.AofEnabled = &aofEnabled
	}

	// Set property "AofFrequency":
	if typedInput.AofFrequency != nil {
		var temp string
		temp = string(*typedInput.AofFrequency)
		aofFrequency := Persistence_AofFrequency(temp)
		persistence.AofFrequency = &aofFrequency
	}

	// Set property "RdbEnabled":
	if typedInput.RdbEnabled != nil {
		rdbEnabled := *typedInput.RdbEnabled
		persistence.RdbEnabled = &rdbEnabled
	}

	// Set property "RdbFrequency":
	if typedInput.RdbFrequency != nil {
		var temp string
		temp = string(*typedInput.RdbFrequency)
		rdbFrequency := Persistence_RdbFrequency(temp)
		persistence.RdbFrequency = &rdbFrequency
	}

	// No error
	return nil
}

// AssignProperties_From_Persistence populates our Persistence from the provided source Persistence
func (persistence *Persistence) AssignProperties_From_Persistence(source *storage.Persistence) error {

	// AofEnabled
	if source.AofEnabled != nil {
		aofEnabled := *source.AofEnabled
		persistence.AofEnabled = &aofEnabled
	} else {
		persistence.AofEnabled = nil
	}

	// AofFrequency
	if source.AofFrequency != nil {
		aofFrequency := *source.AofFrequency
		aofFrequencyTemp := genruntime.ToEnum(aofFrequency, persistence_AofFrequency_Values)
		persistence.AofFrequency = &aofFrequencyTemp
	} else {
		persistence.AofFrequency = nil
	}

	// RdbEnabled
	if source.RdbEnabled != nil {
		rdbEnabled := *source.RdbEnabled
		persistence.RdbEnabled = &rdbEnabled
	} else {
		persistence.RdbEnabled = nil
	}

	// RdbFrequency
	if source.RdbFrequency != nil {
		rdbFrequency := *source.RdbFrequency
		rdbFrequencyTemp := genruntime.ToEnum(rdbFrequency, persistence_RdbFrequency_Values)
		persistence.RdbFrequency = &rdbFrequencyTemp
	} else {
		persistence.RdbFrequency = nil
	}

	// No error
	return nil
}

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

	// AofEnabled
	if persistence.AofEnabled != nil {
		aofEnabled := *persistence.AofEnabled
		destination.AofEnabled = &aofEnabled
	} else {
		destination.AofEnabled = nil
	}

	// AofFrequency
	if persistence.AofFrequency != nil {
		aofFrequency := string(*persistence.AofFrequency)
		destination.AofFrequency = &aofFrequency
	} else {
		destination.AofFrequency = nil
	}

	// RdbEnabled
	if persistence.RdbEnabled != nil {
		rdbEnabled := *persistence.RdbEnabled
		destination.RdbEnabled = &rdbEnabled
	} else {
		destination.RdbEnabled = nil
	}

	// RdbFrequency
	if persistence.RdbFrequency != nil {
		rdbFrequency := string(*persistence.RdbFrequency)
		destination.RdbFrequency = &rdbFrequency
	} else {
		destination.RdbFrequency = nil
	}

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

	// No error
	return nil
}

// Persistence-related configuration for the RedisEnterprise database
type Persistence_STATUS struct {
	// AofEnabled: Sets whether AOF is enabled.
	AofEnabled *bool `json:"aofEnabled,omitempty"`

	// AofFrequency: Sets the frequency at which data is written to disk.
	AofFrequency *Persistence_AofFrequency_STATUS `json:"aofFrequency,omitempty"`

	// RdbEnabled: Sets whether RDB is enabled.
	RdbEnabled *bool `json:"rdbEnabled,omitempty"`

	// RdbFrequency: Sets the frequency at which a snapshot of the database is created.
	RdbFrequency *Persistence_RdbFrequency_STATUS `json:"rdbFrequency,omitempty"`
}

var _ genruntime.FromARMConverter = &Persistence_STATUS{}

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

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

	// Set property "AofEnabled":
	if typedInput.AofEnabled != nil {
		aofEnabled := *typedInput.AofEnabled
		persistence.AofEnabled = &aofEnabled
	}

	// Set property "AofFrequency":
	if typedInput.AofFrequency != nil {
		var temp string
		temp = string(*typedInput.AofFrequency)
		aofFrequency := Persistence_AofFrequency_STATUS(temp)
		persistence.AofFrequency = &aofFrequency
	}

	// Set property "RdbEnabled":
	if typedInput.RdbEnabled != nil {
		rdbEnabled := *typedInput.RdbEnabled
		persistence.RdbEnabled = &rdbEnabled
	}

	// Set property "RdbFrequency":
	if typedInput.RdbFrequency != nil {
		var temp string
		temp = string(*typedInput.RdbFrequency)
		rdbFrequency := Persistence_RdbFrequency_STATUS(temp)
		persistence.RdbFrequency = &rdbFrequency
	}

	// No error
	return nil
}

// AssignProperties_From_Persistence_STATUS populates our Persistence_STATUS from the provided source Persistence_STATUS
func (persistence *Persistence_STATUS) AssignProperties_From_Persistence_STATUS(source *storage.Persistence_STATUS) error {

	// AofEnabled
	if source.AofEnabled != nil {
		aofEnabled := *source.AofEnabled
		persistence.AofEnabled = &aofEnabled
	} else {
		persistence.AofEnabled = nil
	}

	// AofFrequency
	if source.AofFrequency != nil {
		aofFrequency := *source.AofFrequency
		aofFrequencyTemp := genruntime.ToEnum(aofFrequency, persistence_AofFrequency_STATUS_Values)
		persistence.AofFrequency = &aofFrequencyTemp
	} else {
		persistence.AofFrequency = nil
	}

	// RdbEnabled
	if source.RdbEnabled != nil {
		rdbEnabled := *source.RdbEnabled
		persistence.RdbEnabled = &rdbEnabled
	} else {
		persistence.RdbEnabled = nil
	}

	// RdbFrequency
	if source.RdbFrequency != nil {
		rdbFrequency := *source.RdbFrequency
		rdbFrequencyTemp := genruntime.ToEnum(rdbFrequency, persistence_RdbFrequency_STATUS_Values)
		persistence.RdbFrequency = &rdbFrequencyTemp
	} else {
		persistence.RdbFrequency = nil
	}

	// No error
	return nil
}

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

	// AofEnabled
	if persistence.AofEnabled != nil {
		aofEnabled := *persistence.AofEnabled
		destination.AofEnabled = &aofEnabled
	} else {
		destination.AofEnabled = nil
	}

	// AofFrequency
	if persistence.AofFrequency != nil {
		aofFrequency := string(*persistence.AofFrequency)
		destination.AofFrequency = &aofFrequency
	} else {
		destination.AofFrequency = nil
	}

	// RdbEnabled
	if persistence.RdbEnabled != nil {
		rdbEnabled := *persistence.RdbEnabled
		destination.RdbEnabled = &rdbEnabled
	} else {
		destination.RdbEnabled = nil
	}

	// RdbFrequency
	if persistence.RdbFrequency != nil {
		rdbFrequency := string(*persistence.RdbFrequency)
		destination.RdbFrequency = &rdbFrequency
	} else {
		destination.RdbFrequency = nil
	}

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

	// No error
	return nil
}

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

// +kubebuilder:validation:Enum={"1s","always"}
type Persistence_AofFrequency string

const (
	Persistence_AofFrequency_1S     = Persistence_AofFrequency("1s")
	Persistence_AofFrequency_Always = Persistence_AofFrequency("always")
)

// Mapping from string to Persistence_AofFrequency
var persistence_AofFrequency_Values = map[string]Persistence_AofFrequency{
	"1s":     Persistence_AofFrequency_1S,
	"always": Persistence_AofFrequency_Always,
}

type Persistence_AofFrequency_STATUS string

const (
	Persistence_AofFrequency_STATUS_1S     = Persistence_AofFrequency_STATUS("1s")
	Persistence_AofFrequency_STATUS_Always = Persistence_AofFrequency_STATUS("always")
)

// Mapping from string to Persistence_AofFrequency_STATUS
var persistence_AofFrequency_STATUS_Values = map[string]Persistence_AofFrequency_STATUS{
	"1s":     Persistence_AofFrequency_STATUS_1S,
	"always": Persistence_AofFrequency_STATUS_Always,
}

// +kubebuilder:validation:Enum={"12h","1h","6h"}
type Persistence_RdbFrequency string

const (
	Persistence_RdbFrequency_12H = Persistence_RdbFrequency("12h")
	Persistence_RdbFrequency_1H  = Persistence_RdbFrequency("1h")
	Persistence_RdbFrequency_6H  = Persistence_RdbFrequency("6h")
)

// Mapping from string to Persistence_RdbFrequency
var persistence_RdbFrequency_Values = map[string]Persistence_RdbFrequency{
	"12h": Persistence_RdbFrequency_12H,
	"1h":  Persistence_RdbFrequency_1H,
	"6h":  Persistence_RdbFrequency_6H,
}

type Persistence_RdbFrequency_STATUS string

const (
	Persistence_RdbFrequency_STATUS_12H = Persistence_RdbFrequency_STATUS("12h")
	Persistence_RdbFrequency_STATUS_1H  = Persistence_RdbFrequency_STATUS("1h")
	Persistence_RdbFrequency_STATUS_6H  = Persistence_RdbFrequency_STATUS("6h")
)

// Mapping from string to Persistence_RdbFrequency_STATUS
var persistence_RdbFrequency_STATUS_Values = map[string]Persistence_RdbFrequency_STATUS{
	"12h": Persistence_RdbFrequency_STATUS_12H,
	"1h":  Persistence_RdbFrequency_STATUS_1H,
	"6h":  Persistence_RdbFrequency_STATUS_6H,
}

func init() {
	SchemeBuilder.Register(&RedisEnterpriseDatabase{}, &RedisEnterpriseDatabaseList{})
}
