// 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}/accessPolicyAssignments/{accessPolicyAssignmentName}
type RedisAccessPolicyAssignment struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              RedisAccessPolicyAssignment_Spec   `json:"spec,omitempty"`
	Status            RedisAccessPolicyAssignment_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &RedisAccessPolicyAssignment{}

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

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

var _ conversion.Convertible = &RedisAccessPolicyAssignment{}

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

	return assignment.AssignProperties_From_RedisAccessPolicyAssignment(source)
}

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

	return assignment.AssignProperties_To_RedisAccessPolicyAssignment(destination)
}

var _ configmaps.Exporter = &RedisAccessPolicyAssignment{}

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

var _ secrets.Exporter = &RedisAccessPolicyAssignment{}

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

var _ genruntime.ImportableResource = &RedisAccessPolicyAssignment{}

// InitializeSpec initializes the spec for this resource from the given status
func (assignment *RedisAccessPolicyAssignment) InitializeSpec(status genruntime.ConvertibleStatus) error {
	if s, ok := status.(*RedisAccessPolicyAssignment_STATUS); ok {
		return assignment.Spec.Initialize_From_RedisAccessPolicyAssignment_STATUS(s)
	}

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

var _ genruntime.KubernetesResource = &RedisAccessPolicyAssignment{}

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

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

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

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

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

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

// NewEmptyStatus returns a new empty (blank) status
func (assignment *RedisAccessPolicyAssignment) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &RedisAccessPolicyAssignment_STATUS{}
}

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

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

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

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

	assignment.Status = st
	return nil
}

// AssignProperties_From_RedisAccessPolicyAssignment populates our RedisAccessPolicyAssignment from the provided source RedisAccessPolicyAssignment
func (assignment *RedisAccessPolicyAssignment) AssignProperties_From_RedisAccessPolicyAssignment(source *storage.RedisAccessPolicyAssignment) error {

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

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

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

	// No error
	return nil
}

// AssignProperties_To_RedisAccessPolicyAssignment populates the provided destination RedisAccessPolicyAssignment from our RedisAccessPolicyAssignment
func (assignment *RedisAccessPolicyAssignment) AssignProperties_To_RedisAccessPolicyAssignment(destination *storage.RedisAccessPolicyAssignment) error {

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

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

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

// +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}/accessPolicyAssignments/{accessPolicyAssignmentName}
type RedisAccessPolicyAssignmentList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []RedisAccessPolicyAssignment `json:"items"`
}

type RedisAccessPolicyAssignment_Spec struct {
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:Pattern="^([a-zA-Z0-9][a-zA-Z0-9- ]*[a-zA-Z0-9]|[a-zA-Z0-9])$"
	// AccessPolicyName: The name of the access policy that is being assigned
	AccessPolicyName *string `json:"accessPolicyName,omitempty"`

	// +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"`

	// ObjectId: Object Id to assign access policy to
	ObjectId *string `json:"objectId,omitempty" optionalConfigMapPair:"ObjectId"`

	// ObjectIdAlias: User friendly name for object id. Also represents username for token based authentication
	ObjectIdAlias *string `json:"objectIdAlias,omitempty" optionalConfigMapPair:"ObjectIdAlias"`

	// ObjectIdAliasFromConfig: User friendly name for object id. Also represents username for token based authentication
	ObjectIdAliasFromConfig *genruntime.ConfigMapReference `json:"objectIdAliasFromConfig,omitempty" optionalConfigMapPair:"ObjectIdAlias"`

	// ObjectIdFromConfig: Object Id to assign access policy to
	ObjectIdFromConfig *genruntime.ConfigMapReference `json:"objectIdFromConfig,omitempty" optionalConfigMapPair:"ObjectId"`

	// OperatorSpec: The specification for configuring operator behavior. This field is interpreted by the operator and not
	// passed directly to Azure
	OperatorSpec *RedisAccessPolicyAssignmentOperatorSpec `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"`
}

var _ genruntime.ARMTransformer = &RedisAccessPolicyAssignment_Spec{}

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

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

	// Set property "Properties":
	if assignment.AccessPolicyName != nil ||
		assignment.ObjectId != nil ||
		assignment.ObjectIdAlias != nil ||
		assignment.ObjectIdAliasFromConfig != nil ||
		assignment.ObjectIdFromConfig != nil {
		result.Properties = &arm.RedisCacheAccessPolicyAssignmentProperties{}
	}
	if assignment.AccessPolicyName != nil {
		accessPolicyName := *assignment.AccessPolicyName
		result.Properties.AccessPolicyName = &accessPolicyName
	}
	if assignment.ObjectId != nil {
		objectId := *assignment.ObjectId
		result.Properties.ObjectId = &objectId
	}
	if assignment.ObjectIdAlias != nil {
		objectIdAlias := *assignment.ObjectIdAlias
		result.Properties.ObjectIdAlias = &objectIdAlias
	}
	if assignment.ObjectIdAliasFromConfig != nil {
		objectIdAliasValue, err := resolved.ResolvedConfigMaps.Lookup(*assignment.ObjectIdAliasFromConfig)
		if err != nil {
			return nil, eris.Wrap(err, "looking up configmap for property ObjectIdAlias")
		}
		objectIdAlias := objectIdAliasValue
		result.Properties.ObjectIdAlias = &objectIdAlias
	}
	if assignment.ObjectIdFromConfig != nil {
		objectIdValue, err := resolved.ResolvedConfigMaps.Lookup(*assignment.ObjectIdFromConfig)
		if err != nil {
			return nil, eris.Wrap(err, "looking up configmap for property ObjectId")
		}
		objectId := objectIdValue
		result.Properties.ObjectId = &objectId
	}
	return result, nil
}

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

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

	// Set property "AccessPolicyName":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.AccessPolicyName != nil {
			accessPolicyName := *typedInput.Properties.AccessPolicyName
			assignment.AccessPolicyName = &accessPolicyName
		}
	}

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

	// Set property "ObjectId":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ObjectId != nil {
			objectId := *typedInput.Properties.ObjectId
			assignment.ObjectId = &objectId
		}
	}

	// Set property "ObjectIdAlias":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ObjectIdAlias != nil {
			objectIdAlias := *typedInput.Properties.ObjectIdAlias
			assignment.ObjectIdAlias = &objectIdAlias
		}
	}

	// no assignment for property "ObjectIdAliasFromConfig"

	// no assignment for property "ObjectIdFromConfig"

	// no assignment for property "OperatorSpec"

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

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &RedisAccessPolicyAssignment_Spec{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.RedisAccessPolicyAssignment_Spec{}
	err := assignment.AssignProperties_To_RedisAccessPolicyAssignment_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_RedisAccessPolicyAssignment_Spec populates our RedisAccessPolicyAssignment_Spec from the provided source RedisAccessPolicyAssignment_Spec
func (assignment *RedisAccessPolicyAssignment_Spec) AssignProperties_From_RedisAccessPolicyAssignment_Spec(source *storage.RedisAccessPolicyAssignment_Spec) error {

	// AccessPolicyName
	assignment.AccessPolicyName = genruntime.ClonePointerToString(source.AccessPolicyName)

	// AzureName
	assignment.AzureName = source.AzureName

	// ObjectId
	assignment.ObjectId = genruntime.ClonePointerToString(source.ObjectId)

	// ObjectIdAlias
	assignment.ObjectIdAlias = genruntime.ClonePointerToString(source.ObjectIdAlias)

	// ObjectIdAliasFromConfig
	if source.ObjectIdAliasFromConfig != nil {
		objectIdAliasFromConfig := source.ObjectIdAliasFromConfig.Copy()
		assignment.ObjectIdAliasFromConfig = &objectIdAliasFromConfig
	} else {
		assignment.ObjectIdAliasFromConfig = nil
	}

	// ObjectIdFromConfig
	if source.ObjectIdFromConfig != nil {
		objectIdFromConfig := source.ObjectIdFromConfig.Copy()
		assignment.ObjectIdFromConfig = &objectIdFromConfig
	} else {
		assignment.ObjectIdFromConfig = nil
	}

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

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

	// No error
	return nil
}

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

	// AccessPolicyName
	destination.AccessPolicyName = genruntime.ClonePointerToString(assignment.AccessPolicyName)

	// AzureName
	destination.AzureName = assignment.AzureName

	// ObjectId
	destination.ObjectId = genruntime.ClonePointerToString(assignment.ObjectId)

	// ObjectIdAlias
	destination.ObjectIdAlias = genruntime.ClonePointerToString(assignment.ObjectIdAlias)

	// ObjectIdAliasFromConfig
	if assignment.ObjectIdAliasFromConfig != nil {
		objectIdAliasFromConfig := assignment.ObjectIdAliasFromConfig.Copy()
		destination.ObjectIdAliasFromConfig = &objectIdAliasFromConfig
	} else {
		destination.ObjectIdAliasFromConfig = nil
	}

	// ObjectIdFromConfig
	if assignment.ObjectIdFromConfig != nil {
		objectIdFromConfig := assignment.ObjectIdFromConfig.Copy()
		destination.ObjectIdFromConfig = &objectIdFromConfig
	} else {
		destination.ObjectIdFromConfig = nil
	}

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

	// OriginalVersion
	destination.OriginalVersion = assignment.OriginalVersion()

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

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

	// No error
	return nil
}

// Initialize_From_RedisAccessPolicyAssignment_STATUS populates our RedisAccessPolicyAssignment_Spec from the provided source RedisAccessPolicyAssignment_STATUS
func (assignment *RedisAccessPolicyAssignment_Spec) Initialize_From_RedisAccessPolicyAssignment_STATUS(source *RedisAccessPolicyAssignment_STATUS) error {

	// AccessPolicyName
	assignment.AccessPolicyName = genruntime.ClonePointerToString(source.AccessPolicyName)

	// ObjectId
	assignment.ObjectId = genruntime.ClonePointerToString(source.ObjectId)

	// ObjectIdAlias
	assignment.ObjectIdAlias = genruntime.ClonePointerToString(source.ObjectIdAlias)

	// No error
	return nil
}

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

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

type RedisAccessPolicyAssignment_STATUS struct {
	// AccessPolicyName: The name of the access policy that is being assigned
	AccessPolicyName *string `json:"accessPolicyName,omitempty"`

	// 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"`

	// ObjectId: Object Id to assign access policy to
	ObjectId *string `json:"objectId,omitempty"`

	// ObjectIdAlias: User friendly name for object id. Also represents username for token based authentication
	ObjectIdAlias *string `json:"objectIdAlias,omitempty"`

	// ProvisioningState: Provisioning state of an access policy assignment set
	ProvisioningState *AccessPolicyAssignmentProvisioningState_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 = &RedisAccessPolicyAssignment_STATUS{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.RedisAccessPolicyAssignment_STATUS{}
	err := assignment.AssignProperties_To_RedisAccessPolicyAssignment_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 = &RedisAccessPolicyAssignment_STATUS{}

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

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

	// Set property "AccessPolicyName":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.AccessPolicyName != nil {
			accessPolicyName := *typedInput.Properties.AccessPolicyName
			assignment.AccessPolicyName = &accessPolicyName
		}
	}

	// no assignment for property "Conditions"

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

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

	// Set property "ObjectId":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ObjectId != nil {
			objectId := *typedInput.Properties.ObjectId
			assignment.ObjectId = &objectId
		}
	}

	// Set property "ObjectIdAlias":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ObjectIdAlias != nil {
			objectIdAlias := *typedInput.Properties.ObjectIdAlias
			assignment.ObjectIdAlias = &objectIdAlias
		}
	}

	// Set property "ProvisioningState":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ProvisioningState != nil {
			var temp string
			temp = string(*typedInput.Properties.ProvisioningState)
			provisioningState := AccessPolicyAssignmentProvisioningState_STATUS(temp)
			assignment.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
		assignment.SystemData = &systemData
	}

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

	// No error
	return nil
}

// AssignProperties_From_RedisAccessPolicyAssignment_STATUS populates our RedisAccessPolicyAssignment_STATUS from the provided source RedisAccessPolicyAssignment_STATUS
func (assignment *RedisAccessPolicyAssignment_STATUS) AssignProperties_From_RedisAccessPolicyAssignment_STATUS(source *storage.RedisAccessPolicyAssignment_STATUS) error {

	// AccessPolicyName
	assignment.AccessPolicyName = genruntime.ClonePointerToString(source.AccessPolicyName)

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

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

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

	// ObjectId
	assignment.ObjectId = genruntime.ClonePointerToString(source.ObjectId)

	// ObjectIdAlias
	assignment.ObjectIdAlias = genruntime.ClonePointerToString(source.ObjectIdAlias)

	// ProvisioningState
	if source.ProvisioningState != nil {
		provisioningState := *source.ProvisioningState
		provisioningStateTemp := genruntime.ToEnum(provisioningState, accessPolicyAssignmentProvisioningState_STATUS_Values)
		assignment.ProvisioningState = &provisioningStateTemp
	} else {
		assignment.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")
		}
		assignment.SystemData = &systemDatum
	} else {
		assignment.SystemData = nil
	}

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

	// No error
	return nil
}

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

	// AccessPolicyName
	destination.AccessPolicyName = genruntime.ClonePointerToString(assignment.AccessPolicyName)

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

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

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

	// ObjectId
	destination.ObjectId = genruntime.ClonePointerToString(assignment.ObjectId)

	// ObjectIdAlias
	destination.ObjectIdAlias = genruntime.ClonePointerToString(assignment.ObjectIdAlias)

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

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

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

	// No error
	return nil
}

// Provisioning state of an access policy assignment set
type AccessPolicyAssignmentProvisioningState_STATUS string

const (
	AccessPolicyAssignmentProvisioningState_STATUS_Canceled  = AccessPolicyAssignmentProvisioningState_STATUS("Canceled")
	AccessPolicyAssignmentProvisioningState_STATUS_Deleted   = AccessPolicyAssignmentProvisioningState_STATUS("Deleted")
	AccessPolicyAssignmentProvisioningState_STATUS_Deleting  = AccessPolicyAssignmentProvisioningState_STATUS("Deleting")
	AccessPolicyAssignmentProvisioningState_STATUS_Failed    = AccessPolicyAssignmentProvisioningState_STATUS("Failed")
	AccessPolicyAssignmentProvisioningState_STATUS_Succeeded = AccessPolicyAssignmentProvisioningState_STATUS("Succeeded")
	AccessPolicyAssignmentProvisioningState_STATUS_Updating  = AccessPolicyAssignmentProvisioningState_STATUS("Updating")
)

// Mapping from string to AccessPolicyAssignmentProvisioningState_STATUS
var accessPolicyAssignmentProvisioningState_STATUS_Values = map[string]AccessPolicyAssignmentProvisioningState_STATUS{
	"canceled":  AccessPolicyAssignmentProvisioningState_STATUS_Canceled,
	"deleted":   AccessPolicyAssignmentProvisioningState_STATUS_Deleted,
	"deleting":  AccessPolicyAssignmentProvisioningState_STATUS_Deleting,
	"failed":    AccessPolicyAssignmentProvisioningState_STATUS_Failed,
	"succeeded": AccessPolicyAssignmentProvisioningState_STATUS_Succeeded,
	"updating":  AccessPolicyAssignmentProvisioningState_STATUS_Updating,
}

// Details for configuring operator behavior. Fields in this struct are interpreted by the operator directly rather than being passed to Azure
type RedisAccessPolicyAssignmentOperatorSpec 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_RedisAccessPolicyAssignmentOperatorSpec populates our RedisAccessPolicyAssignmentOperatorSpec from the provided source RedisAccessPolicyAssignmentOperatorSpec
func (operator *RedisAccessPolicyAssignmentOperatorSpec) AssignProperties_From_RedisAccessPolicyAssignmentOperatorSpec(source *storage.RedisAccessPolicyAssignmentOperatorSpec) 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_RedisAccessPolicyAssignmentOperatorSpec populates the provided destination RedisAccessPolicyAssignmentOperatorSpec from our RedisAccessPolicyAssignmentOperatorSpec
func (operator *RedisAccessPolicyAssignmentOperatorSpec) AssignProperties_To_RedisAccessPolicyAssignmentOperatorSpec(destination *storage.RedisAccessPolicyAssignmentOperatorSpec) 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(&RedisAccessPolicyAssignment{}, &RedisAccessPolicyAssignmentList{})
}
