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

import (
	"fmt"
	arm "github.com/Azure/azure-service-operator/v2/api/cache/v1api20241101/arm"
	storage "github.com/Azure/azure-service-operator/v2/api/cache/v1api20241101/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: /redis/resource-manager/Microsoft.Cache/Redis/stable/2024-11-01/redis.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicies/{accessPolicyName}
type RedisAccessPolicy struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              RedisAccessPolicy_Spec   `json:"spec,omitempty"`
	Status            RedisAccessPolicy_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &RedisAccessPolicy{}

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

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

var _ conversion.Convertible = &RedisAccessPolicy{}

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

	return policy.AssignProperties_From_RedisAccessPolicy(source)
}

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

	return policy.AssignProperties_To_RedisAccessPolicy(destination)
}

var _ configmaps.Exporter = &RedisAccessPolicy{}

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

var _ secrets.Exporter = &RedisAccessPolicy{}

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

var _ genruntime.ImportableResource = &RedisAccessPolicy{}

// InitializeSpec initializes the spec for this resource from the given status
func (policy *RedisAccessPolicy) InitializeSpec(status genruntime.ConvertibleStatus) error {
	if s, ok := status.(*RedisAccessPolicy_STATUS); ok {
		return policy.Spec.Initialize_From_RedisAccessPolicy_STATUS(s)
	}

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

var _ genruntime.KubernetesResource = &RedisAccessPolicy{}

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

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

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

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

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

// GetSupportedOperations returns the operations supported by the resource
func (policy *RedisAccessPolicy) 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/redis/accessPolicies"
func (policy *RedisAccessPolicy) GetType() string {
	return "Microsoft.Cache/redis/accessPolicies"
}

// NewEmptyStatus returns a new empty (blank) status
func (policy *RedisAccessPolicy) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &RedisAccessPolicy_STATUS{}
}

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

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

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

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

	policy.Status = st
	return nil
}

// AssignProperties_From_RedisAccessPolicy populates our RedisAccessPolicy from the provided source RedisAccessPolicy
func (policy *RedisAccessPolicy) AssignProperties_From_RedisAccessPolicy(source *storage.RedisAccessPolicy) error {

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

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

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

	// No error
	return nil
}

// AssignProperties_To_RedisAccessPolicy populates the provided destination RedisAccessPolicy from our RedisAccessPolicy
func (policy *RedisAccessPolicy) AssignProperties_To_RedisAccessPolicy(destination *storage.RedisAccessPolicy) error {

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

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

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

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /redis/resource-manager/Microsoft.Cache/Redis/stable/2024-11-01/redis.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicies/{accessPolicyName}
type RedisAccessPolicyList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []RedisAccessPolicy `json:"items"`
}

type RedisAccessPolicy_Spec struct {
	// +kubebuilder:validation:MaxLength=63
	// +kubebuilder:validation:MinLength=3
	// +kubebuilder:validation:Pattern="^([a-zA-Z0-9][a-zA-Z0-9- ]*[a-zA-Z0-9]|[a-zA-Z0-9])$"
	// AzureName: The name of the resource in Azure. This is often the same as the name of the resource in Kubernetes but it
	// doesn't have to be.
	AzureName string `json:"azureName,omitempty"`

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

	// +kubebuilder:validation:Required
	// Permissions: Permissions for the access policy. Learn how to configure permissions at
	// https://aka.ms/redis/AADPreRequisites
	Permissions *string `json:"permissions,omitempty"`
}

var _ genruntime.ARMTransformer = &RedisAccessPolicy_Spec{}

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

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

	// Set property "Properties":
	if policy.Permissions != nil {
		result.Properties = &arm.RedisCacheAccessPolicyProperties{}
	}
	if policy.Permissions != nil {
		permissions := *policy.Permissions
		result.Properties.Permissions = &permissions
	}
	return result, nil
}

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

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

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

	// no assignment for property "OperatorSpec"

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

	// Set property "Permissions":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Permissions != nil {
			permissions := *typedInput.Properties.Permissions
			policy.Permissions = &permissions
		}
	}

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &RedisAccessPolicy_Spec{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.RedisAccessPolicy_Spec{}
	err := policy.AssignProperties_To_RedisAccessPolicy_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_RedisAccessPolicy_Spec populates our RedisAccessPolicy_Spec from the provided source RedisAccessPolicy_Spec
func (policy *RedisAccessPolicy_Spec) AssignProperties_From_RedisAccessPolicy_Spec(source *storage.RedisAccessPolicy_Spec) error {

	// AzureName
	policy.AzureName = source.AzureName

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

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

	// Permissions
	policy.Permissions = genruntime.ClonePointerToString(source.Permissions)

	// No error
	return nil
}

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

	// AzureName
	destination.AzureName = policy.AzureName

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

	// OriginalVersion
	destination.OriginalVersion = policy.OriginalVersion()

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

	// Permissions
	destination.Permissions = genruntime.ClonePointerToString(policy.Permissions)

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

	// No error
	return nil
}

// Initialize_From_RedisAccessPolicy_STATUS populates our RedisAccessPolicy_Spec from the provided source RedisAccessPolicy_STATUS
func (policy *RedisAccessPolicy_Spec) Initialize_From_RedisAccessPolicy_STATUS(source *RedisAccessPolicy_STATUS) error {

	// Permissions
	policy.Permissions = genruntime.ClonePointerToString(source.Permissions)

	// No error
	return nil
}

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

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

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

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

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

	// Permissions: Permissions for the access policy. Learn how to configure permissions at
	// https://aka.ms/redis/AADPreRequisites
	Permissions *string `json:"permissions,omitempty"`

	// PropertiesType: Built-In or Custom access policy
	PropertiesType *AccessPolicyType_STATUS `json:"properties_type,omitempty"`

	// ProvisioningState: Provisioning state of access policy
	ProvisioningState *AccessPolicyProvisioningState_STATUS `json:"provisioningState,omitempty"`

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

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

var _ genruntime.ConvertibleStatus = &RedisAccessPolicy_STATUS{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.RedisAccessPolicy_STATUS{}
	err := policy.AssignProperties_To_RedisAccessPolicy_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 = &RedisAccessPolicy_STATUS{}

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

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

	// no assignment for property "Conditions"

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

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

	// Set property "Permissions":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Permissions != nil {
			permissions := *typedInput.Properties.Permissions
			policy.Permissions = &permissions
		}
	}

	// Set property "PropertiesType":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Type != nil {
			var temp string
			temp = string(*typedInput.Properties.Type)
			propertiesType := AccessPolicyType_STATUS(temp)
			policy.PropertiesType = &propertiesType
		}
	}

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

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

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

	// No error
	return nil
}

// AssignProperties_From_RedisAccessPolicy_STATUS populates our RedisAccessPolicy_STATUS from the provided source RedisAccessPolicy_STATUS
func (policy *RedisAccessPolicy_STATUS) AssignProperties_From_RedisAccessPolicy_STATUS(source *storage.RedisAccessPolicy_STATUS) error {

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

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

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

	// Permissions
	policy.Permissions = genruntime.ClonePointerToString(source.Permissions)

	// PropertiesType
	if source.PropertiesType != nil {
		propertiesType := *source.PropertiesType
		propertiesTypeTemp := genruntime.ToEnum(propertiesType, accessPolicyType_STATUS_Values)
		policy.PropertiesType = &propertiesTypeTemp
	} else {
		policy.PropertiesType = nil
	}

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

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

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

	// No error
	return nil
}

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

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

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

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

	// Permissions
	destination.Permissions = genruntime.ClonePointerToString(policy.Permissions)

	// PropertiesType
	if policy.PropertiesType != nil {
		propertiesType := string(*policy.PropertiesType)
		destination.PropertiesType = &propertiesType
	} else {
		destination.PropertiesType = nil
	}

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

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

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

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

	// No error
	return nil
}

// Provisioning state of access policy
type AccessPolicyProvisioningState_STATUS string

const (
	AccessPolicyProvisioningState_STATUS_Canceled  = AccessPolicyProvisioningState_STATUS("Canceled")
	AccessPolicyProvisioningState_STATUS_Deleted   = AccessPolicyProvisioningState_STATUS("Deleted")
	AccessPolicyProvisioningState_STATUS_Deleting  = AccessPolicyProvisioningState_STATUS("Deleting")
	AccessPolicyProvisioningState_STATUS_Failed    = AccessPolicyProvisioningState_STATUS("Failed")
	AccessPolicyProvisioningState_STATUS_Succeeded = AccessPolicyProvisioningState_STATUS("Succeeded")
	AccessPolicyProvisioningState_STATUS_Updating  = AccessPolicyProvisioningState_STATUS("Updating")
)

// Mapping from string to AccessPolicyProvisioningState_STATUS
var accessPolicyProvisioningState_STATUS_Values = map[string]AccessPolicyProvisioningState_STATUS{
	"canceled":  AccessPolicyProvisioningState_STATUS_Canceled,
	"deleted":   AccessPolicyProvisioningState_STATUS_Deleted,
	"deleting":  AccessPolicyProvisioningState_STATUS_Deleting,
	"failed":    AccessPolicyProvisioningState_STATUS_Failed,
	"succeeded": AccessPolicyProvisioningState_STATUS_Succeeded,
	"updating":  AccessPolicyProvisioningState_STATUS_Updating,
}

// Built-In or Custom access policy
type AccessPolicyType_STATUS string

const (
	AccessPolicyType_STATUS_BuiltIn = AccessPolicyType_STATUS("BuiltIn")
	AccessPolicyType_STATUS_Custom  = AccessPolicyType_STATUS("Custom")
)

// Mapping from string to AccessPolicyType_STATUS
var accessPolicyType_STATUS_Values = map[string]AccessPolicyType_STATUS{
	"builtin": AccessPolicyType_STATUS_BuiltIn,
	"custom":  AccessPolicyType_STATUS_Custom,
}

// Details for configuring operator behavior. Fields in this struct are interpreted by the operator directly rather than being passed to Azure
type RedisAccessPolicyOperatorSpec 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_RedisAccessPolicyOperatorSpec populates our RedisAccessPolicyOperatorSpec from the provided source RedisAccessPolicyOperatorSpec
func (operator *RedisAccessPolicyOperatorSpec) AssignProperties_From_RedisAccessPolicyOperatorSpec(source *storage.RedisAccessPolicyOperatorSpec) 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_RedisAccessPolicyOperatorSpec populates the provided destination RedisAccessPolicyOperatorSpec from our RedisAccessPolicyOperatorSpec
func (operator *RedisAccessPolicyOperatorSpec) AssignProperties_To_RedisAccessPolicyOperatorSpec(destination *storage.RedisAccessPolicyOperatorSpec) 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(&RedisAccessPolicy{}, &RedisAccessPolicyList{})
}
