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

import (
	"fmt"
	arm "github.com/Azure/azure-service-operator/v2/api/managedidentity/v1api20220131preview/arm"
	storage "github.com/Azure/azure-service-operator/v2/api/managedidentity/v1api20220131preview/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,managedidentity}
// +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: /msi/resource-manager/Microsoft.ManagedIdentity/ManagedIdentity/preview/2022-01-31-preview/ManagedIdentity.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}/federatedIdentityCredentials/{federatedIdentityCredentialResourceName}
type FederatedIdentityCredential struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              FederatedIdentityCredential_Spec   `json:"spec,omitempty"`
	Status            FederatedIdentityCredential_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &FederatedIdentityCredential{}

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

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

var _ conversion.Convertible = &FederatedIdentityCredential{}

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

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

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

	return nil
}

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

	return nil
}

var _ configmaps.Exporter = &FederatedIdentityCredential{}

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

var _ secrets.Exporter = &FederatedIdentityCredential{}

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

var _ genruntime.KubernetesResource = &FederatedIdentityCredential{}

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

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

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.ManagedIdentity/userAssignedIdentities/federatedIdentityCredentials"
func (credential *FederatedIdentityCredential) GetType() string {
	return "Microsoft.ManagedIdentity/userAssignedIdentities/federatedIdentityCredentials"
}

// NewEmptyStatus returns a new empty (blank) status
func (credential *FederatedIdentityCredential) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &FederatedIdentityCredential_STATUS{}
}

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

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

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

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

	credential.Status = st
	return nil
}

// AssignProperties_From_FederatedIdentityCredential populates our FederatedIdentityCredential from the provided source FederatedIdentityCredential
func (credential *FederatedIdentityCredential) AssignProperties_From_FederatedIdentityCredential(source *storage.FederatedIdentityCredential) error {

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

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

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

	// No error
	return nil
}

// AssignProperties_To_FederatedIdentityCredential populates the provided destination FederatedIdentityCredential from our FederatedIdentityCredential
func (credential *FederatedIdentityCredential) AssignProperties_To_FederatedIdentityCredential(destination *storage.FederatedIdentityCredential) error {

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

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

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

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /msi/resource-manager/Microsoft.ManagedIdentity/ManagedIdentity/preview/2022-01-31-preview/ManagedIdentity.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}/federatedIdentityCredentials/{federatedIdentityCredentialResourceName}
type FederatedIdentityCredentialList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []FederatedIdentityCredential `json:"items"`
}

// +kubebuilder:validation:Enum={"2022-01-31-preview"}
type APIVersion string

const APIVersion_Value = APIVersion("2022-01-31-preview")

type FederatedIdentityCredential_Spec struct {
	// +kubebuilder:validation:Required
	// Audiences: The list of audiences that can appear in the issued token.
	Audiences []string `json:"audiences,omitempty"`

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

	// +kubebuilder:validation:Pattern="^[a-zA-Z][a-zA-Z0-9+-.]*:[^\\s]*$"
	// Issuer: The URL of the issuer to be trusted.
	Issuer *string `json:"issuer,omitempty" optionalConfigMapPair:"Issuer"`

	// IssuerFromConfig: The URL of the issuer to be trusted.
	IssuerFromConfig *genruntime.ConfigMapReference `json:"issuerFromConfig,omitempty" optionalConfigMapPair:"Issuer"`

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

	// Subject: The identifier of the external identity.
	Subject *string `json:"subject,omitempty" optionalConfigMapPair:"Subject"`

	// SubjectFromConfig: The identifier of the external identity.
	SubjectFromConfig *genruntime.ConfigMapReference `json:"subjectFromConfig,omitempty" optionalConfigMapPair:"Subject"`
}

var _ genruntime.ARMTransformer = &FederatedIdentityCredential_Spec{}

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

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

	// Set property "Properties":
	if credential.Audiences != nil ||
		credential.Issuer != nil ||
		credential.IssuerFromConfig != nil ||
		credential.Subject != nil ||
		credential.SubjectFromConfig != nil {
		result.Properties = &arm.FederatedIdentityCredentialProperties{}
	}
	for _, item := range credential.Audiences {
		result.Properties.Audiences = append(result.Properties.Audiences, item)
	}
	if credential.Issuer != nil {
		issuer := *credential.Issuer
		result.Properties.Issuer = &issuer
	}
	if credential.IssuerFromConfig != nil {
		issuerValue, err := resolved.ResolvedConfigMaps.Lookup(*credential.IssuerFromConfig)
		if err != nil {
			return nil, eris.Wrap(err, "looking up configmap for property Issuer")
		}
		issuer := issuerValue
		result.Properties.Issuer = &issuer
	}
	if credential.Subject != nil {
		subject := *credential.Subject
		result.Properties.Subject = &subject
	}
	if credential.SubjectFromConfig != nil {
		subjectValue, err := resolved.ResolvedConfigMaps.Lookup(*credential.SubjectFromConfig)
		if err != nil {
			return nil, eris.Wrap(err, "looking up configmap for property Subject")
		}
		subject := subjectValue
		result.Properties.Subject = &subject
	}
	return result, nil
}

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

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

	// Set property "Audiences":
	// copying flattened property:
	if typedInput.Properties != nil {
		for _, item := range typedInput.Properties.Audiences {
			credential.Audiences = append(credential.Audiences, item)
		}
	}

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

	// Set property "Issuer":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Issuer != nil {
			issuer := *typedInput.Properties.Issuer
			credential.Issuer = &issuer
		}
	}

	// no assignment for property "IssuerFromConfig"

	// no assignment for property "OperatorSpec"

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

	// Set property "Subject":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Subject != nil {
			subject := *typedInput.Properties.Subject
			credential.Subject = &subject
		}
	}

	// no assignment for property "SubjectFromConfig"

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &FederatedIdentityCredential_Spec{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.FederatedIdentityCredential_Spec{}
	err := credential.AssignProperties_To_FederatedIdentityCredential_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_FederatedIdentityCredential_Spec populates our FederatedIdentityCredential_Spec from the provided source FederatedIdentityCredential_Spec
func (credential *FederatedIdentityCredential_Spec) AssignProperties_From_FederatedIdentityCredential_Spec(source *storage.FederatedIdentityCredential_Spec) error {

	// Audiences
	credential.Audiences = genruntime.CloneSliceOfString(source.Audiences)

	// AzureName
	credential.AzureName = source.AzureName

	// Issuer
	credential.Issuer = genruntime.ClonePointerToString(source.Issuer)

	// IssuerFromConfig
	if source.IssuerFromConfig != nil {
		issuerFromConfig := source.IssuerFromConfig.Copy()
		credential.IssuerFromConfig = &issuerFromConfig
	} else {
		credential.IssuerFromConfig = nil
	}

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

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

	// Subject
	credential.Subject = genruntime.ClonePointerToString(source.Subject)

	// SubjectFromConfig
	if source.SubjectFromConfig != nil {
		subjectFromConfig := source.SubjectFromConfig.Copy()
		credential.SubjectFromConfig = &subjectFromConfig
	} else {
		credential.SubjectFromConfig = nil
	}

	// No error
	return nil
}

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

	// Audiences
	destination.Audiences = genruntime.CloneSliceOfString(credential.Audiences)

	// AzureName
	destination.AzureName = credential.AzureName

	// Issuer
	destination.Issuer = genruntime.ClonePointerToString(credential.Issuer)

	// IssuerFromConfig
	if credential.IssuerFromConfig != nil {
		issuerFromConfig := credential.IssuerFromConfig.Copy()
		destination.IssuerFromConfig = &issuerFromConfig
	} else {
		destination.IssuerFromConfig = nil
	}

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

	// OriginalVersion
	destination.OriginalVersion = credential.OriginalVersion()

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

	// Subject
	destination.Subject = genruntime.ClonePointerToString(credential.Subject)

	// SubjectFromConfig
	if credential.SubjectFromConfig != nil {
		subjectFromConfig := credential.SubjectFromConfig.Copy()
		destination.SubjectFromConfig = &subjectFromConfig
	} else {
		destination.SubjectFromConfig = nil
	}

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

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

type FederatedIdentityCredential_STATUS struct {
	// Audiences: The list of audiences that can appear in the issued token.
	Audiences []string `json:"audiences,omitempty"`

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

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

	// Issuer: The URL of the issuer to be trusted.
	Issuer *string `json:"issuer,omitempty"`

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

	// Subject: The identifier of the external identity.
	Subject *string `json:"subject,omitempty"`

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

var _ genruntime.ConvertibleStatus = &FederatedIdentityCredential_STATUS{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.FederatedIdentityCredential_STATUS{}
	err := credential.AssignProperties_To_FederatedIdentityCredential_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 = &FederatedIdentityCredential_STATUS{}

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

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

	// Set property "Audiences":
	// copying flattened property:
	if typedInput.Properties != nil {
		for _, item := range typedInput.Properties.Audiences {
			credential.Audiences = append(credential.Audiences, item)
		}
	}

	// no assignment for property "Conditions"

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

	// Set property "Issuer":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Issuer != nil {
			issuer := *typedInput.Properties.Issuer
			credential.Issuer = &issuer
		}
	}

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

	// Set property "Subject":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Subject != nil {
			subject := *typedInput.Properties.Subject
			credential.Subject = &subject
		}
	}

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

	// No error
	return nil
}

// AssignProperties_From_FederatedIdentityCredential_STATUS populates our FederatedIdentityCredential_STATUS from the provided source FederatedIdentityCredential_STATUS
func (credential *FederatedIdentityCredential_STATUS) AssignProperties_From_FederatedIdentityCredential_STATUS(source *storage.FederatedIdentityCredential_STATUS) error {

	// Audiences
	credential.Audiences = genruntime.CloneSliceOfString(source.Audiences)

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

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

	// Issuer
	credential.Issuer = genruntime.ClonePointerToString(source.Issuer)

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

	// Subject
	credential.Subject = genruntime.ClonePointerToString(source.Subject)

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

	// No error
	return nil
}

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

	// Audiences
	destination.Audiences = genruntime.CloneSliceOfString(credential.Audiences)

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

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

	// Issuer
	destination.Issuer = genruntime.ClonePointerToString(credential.Issuer)

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

	// Subject
	destination.Subject = genruntime.ClonePointerToString(credential.Subject)

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

	// 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 FederatedIdentityCredentialOperatorSpec 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_FederatedIdentityCredentialOperatorSpec populates our FederatedIdentityCredentialOperatorSpec from the provided source FederatedIdentityCredentialOperatorSpec
func (operator *FederatedIdentityCredentialOperatorSpec) AssignProperties_From_FederatedIdentityCredentialOperatorSpec(source *storage.FederatedIdentityCredentialOperatorSpec) 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_FederatedIdentityCredentialOperatorSpec populates the provided destination FederatedIdentityCredentialOperatorSpec from our FederatedIdentityCredentialOperatorSpec
func (operator *FederatedIdentityCredentialOperatorSpec) AssignProperties_To_FederatedIdentityCredentialOperatorSpec(destination *storage.FederatedIdentityCredentialOperatorSpec) 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(&FederatedIdentityCredential{}, &FederatedIdentityCredentialList{})
}
