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

import (
	"fmt"
	arm "github.com/Azure/azure-service-operator/v2/api/signalrservice/v1api20240301/arm"
	storage "github.com/Azure/azure-service-operator/v2/api/signalrservice/v1api20240301/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,signalrservice}
// +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: /signalr/resource-manager/Microsoft.SignalRService/SignalRService/stable/2024-03-01/signalr.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}
type CustomCertificate struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              CustomCertificate_Spec   `json:"spec,omitempty"`
	Status            CustomCertificate_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &CustomCertificate{}

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

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

var _ conversion.Convertible = &CustomCertificate{}

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

	return certificate.AssignProperties_From_CustomCertificate(source)
}

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

	return certificate.AssignProperties_To_CustomCertificate(destination)
}

var _ configmaps.Exporter = &CustomCertificate{}

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

var _ secrets.Exporter = &CustomCertificate{}

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

var _ genruntime.ImportableResource = &CustomCertificate{}

// InitializeSpec initializes the spec for this resource from the given status
func (certificate *CustomCertificate) InitializeSpec(status genruntime.ConvertibleStatus) error {
	if s, ok := status.(*CustomCertificate_STATUS); ok {
		return certificate.Spec.Initialize_From_CustomCertificate_STATUS(s)
	}

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

var _ genruntime.KubernetesResource = &CustomCertificate{}

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

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

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.SignalRService/signalR/customCertificates"
func (certificate *CustomCertificate) GetType() string {
	return "Microsoft.SignalRService/signalR/customCertificates"
}

// NewEmptyStatus returns a new empty (blank) status
func (certificate *CustomCertificate) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &CustomCertificate_STATUS{}
}

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

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

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

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

	certificate.Status = st
	return nil
}

// AssignProperties_From_CustomCertificate populates our CustomCertificate from the provided source CustomCertificate
func (certificate *CustomCertificate) AssignProperties_From_CustomCertificate(source *storage.CustomCertificate) error {

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

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

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

	// No error
	return nil
}

// AssignProperties_To_CustomCertificate populates the provided destination CustomCertificate from our CustomCertificate
func (certificate *CustomCertificate) AssignProperties_To_CustomCertificate(destination *storage.CustomCertificate) error {

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

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

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

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /signalr/resource-manager/Microsoft.SignalRService/SignalRService/stable/2024-03-01/signalr.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}
type CustomCertificateList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []CustomCertificate `json:"items"`
}

// +kubebuilder:validation:Enum={"2024-03-01"}
type APIVersion string

const APIVersion_Value = APIVersion("2024-03-01")

type CustomCertificate_Spec struct {
	// AzureName: The name of the resource in Azure. This is often the same as the name of the resource in Kubernetes but it
	// doesn't have to be.
	AzureName string `json:"azureName,omitempty"`

	// KeyVaultBaseUri: Base uri of the KeyVault that stores certificate.
	KeyVaultBaseUri *string `json:"keyVaultBaseUri,omitempty" optionalConfigMapPair:"KeyVaultBaseUri"`

	// KeyVaultBaseUriFromConfig: Base uri of the KeyVault that stores certificate.
	KeyVaultBaseUriFromConfig *genruntime.ConfigMapReference `json:"keyVaultBaseUriFromConfig,omitempty" optionalConfigMapPair:"KeyVaultBaseUri"`

	// +kubebuilder:validation:Required
	// KeyVaultSecretName: Certificate secret name.
	KeyVaultSecretName *string `json:"keyVaultSecretName,omitempty"`

	// KeyVaultSecretVersion: Certificate secret version.
	KeyVaultSecretVersion *string `json:"keyVaultSecretVersion,omitempty"`

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

var _ genruntime.ARMTransformer = &CustomCertificate_Spec{}

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

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

	// Set property "Properties":
	if certificate.KeyVaultBaseUri != nil ||
		certificate.KeyVaultBaseUriFromConfig != nil ||
		certificate.KeyVaultSecretName != nil ||
		certificate.KeyVaultSecretVersion != nil {
		result.Properties = &arm.CustomCertificateProperties{}
	}
	if certificate.KeyVaultBaseUri != nil {
		keyVaultBaseUri := *certificate.KeyVaultBaseUri
		result.Properties.KeyVaultBaseUri = &keyVaultBaseUri
	}
	if certificate.KeyVaultBaseUriFromConfig != nil {
		keyVaultBaseUriValue, err := resolved.ResolvedConfigMaps.Lookup(*certificate.KeyVaultBaseUriFromConfig)
		if err != nil {
			return nil, eris.Wrap(err, "looking up configmap for property KeyVaultBaseUri")
		}
		keyVaultBaseUri := keyVaultBaseUriValue
		result.Properties.KeyVaultBaseUri = &keyVaultBaseUri
	}
	if certificate.KeyVaultSecretName != nil {
		keyVaultSecretName := *certificate.KeyVaultSecretName
		result.Properties.KeyVaultSecretName = &keyVaultSecretName
	}
	if certificate.KeyVaultSecretVersion != nil {
		keyVaultSecretVersion := *certificate.KeyVaultSecretVersion
		result.Properties.KeyVaultSecretVersion = &keyVaultSecretVersion
	}
	return result, nil
}

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

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

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

	// Set property "KeyVaultBaseUri":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.KeyVaultBaseUri != nil {
			keyVaultBaseUri := *typedInput.Properties.KeyVaultBaseUri
			certificate.KeyVaultBaseUri = &keyVaultBaseUri
		}
	}

	// no assignment for property "KeyVaultBaseUriFromConfig"

	// Set property "KeyVaultSecretName":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.KeyVaultSecretName != nil {
			keyVaultSecretName := *typedInput.Properties.KeyVaultSecretName
			certificate.KeyVaultSecretName = &keyVaultSecretName
		}
	}

	// Set property "KeyVaultSecretVersion":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.KeyVaultSecretVersion != nil {
			keyVaultSecretVersion := *typedInput.Properties.KeyVaultSecretVersion
			certificate.KeyVaultSecretVersion = &keyVaultSecretVersion
		}
	}

	// no assignment for property "OperatorSpec"

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

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &CustomCertificate_Spec{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.CustomCertificate_Spec{}
	err := certificate.AssignProperties_To_CustomCertificate_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_CustomCertificate_Spec populates our CustomCertificate_Spec from the provided source CustomCertificate_Spec
func (certificate *CustomCertificate_Spec) AssignProperties_From_CustomCertificate_Spec(source *storage.CustomCertificate_Spec) error {

	// AzureName
	certificate.AzureName = source.AzureName

	// KeyVaultBaseUri
	certificate.KeyVaultBaseUri = genruntime.ClonePointerToString(source.KeyVaultBaseUri)

	// KeyVaultBaseUriFromConfig
	if source.KeyVaultBaseUriFromConfig != nil {
		keyVaultBaseUriFromConfig := source.KeyVaultBaseUriFromConfig.Copy()
		certificate.KeyVaultBaseUriFromConfig = &keyVaultBaseUriFromConfig
	} else {
		certificate.KeyVaultBaseUriFromConfig = nil
	}

	// KeyVaultSecretName
	certificate.KeyVaultSecretName = genruntime.ClonePointerToString(source.KeyVaultSecretName)

	// KeyVaultSecretVersion
	certificate.KeyVaultSecretVersion = genruntime.ClonePointerToString(source.KeyVaultSecretVersion)

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

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

	// No error
	return nil
}

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

	// AzureName
	destination.AzureName = certificate.AzureName

	// KeyVaultBaseUri
	destination.KeyVaultBaseUri = genruntime.ClonePointerToString(certificate.KeyVaultBaseUri)

	// KeyVaultBaseUriFromConfig
	if certificate.KeyVaultBaseUriFromConfig != nil {
		keyVaultBaseUriFromConfig := certificate.KeyVaultBaseUriFromConfig.Copy()
		destination.KeyVaultBaseUriFromConfig = &keyVaultBaseUriFromConfig
	} else {
		destination.KeyVaultBaseUriFromConfig = nil
	}

	// KeyVaultSecretName
	destination.KeyVaultSecretName = genruntime.ClonePointerToString(certificate.KeyVaultSecretName)

	// KeyVaultSecretVersion
	destination.KeyVaultSecretVersion = genruntime.ClonePointerToString(certificate.KeyVaultSecretVersion)

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

	// OriginalVersion
	destination.OriginalVersion = certificate.OriginalVersion()

	// Owner
	if certificate.Owner != nil {
		owner := certificate.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_CustomCertificate_STATUS populates our CustomCertificate_Spec from the provided source CustomCertificate_STATUS
func (certificate *CustomCertificate_Spec) Initialize_From_CustomCertificate_STATUS(source *CustomCertificate_STATUS) error {

	// KeyVaultBaseUri
	certificate.KeyVaultBaseUri = genruntime.ClonePointerToString(source.KeyVaultBaseUri)

	// KeyVaultSecretName
	certificate.KeyVaultSecretName = genruntime.ClonePointerToString(source.KeyVaultSecretName)

	// KeyVaultSecretVersion
	certificate.KeyVaultSecretVersion = genruntime.ClonePointerToString(source.KeyVaultSecretVersion)

	// No error
	return nil
}

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

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

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

	// KeyVaultBaseUri: Base uri of the KeyVault that stores certificate.
	KeyVaultBaseUri *string `json:"keyVaultBaseUri,omitempty"`

	// KeyVaultSecretName: Certificate secret name.
	KeyVaultSecretName *string `json:"keyVaultSecretName,omitempty"`

	// KeyVaultSecretVersion: Certificate secret version.
	KeyVaultSecretVersion *string `json:"keyVaultSecretVersion,omitempty"`

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

	// ProvisioningState: Provisioning state of the resource.
	ProvisioningState *ProvisioningState_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 = &CustomCertificate_STATUS{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.CustomCertificate_STATUS{}
	err := certificate.AssignProperties_To_CustomCertificate_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 = &CustomCertificate_STATUS{}

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

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

	// no assignment for property "Conditions"

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

	// Set property "KeyVaultBaseUri":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.KeyVaultBaseUri != nil {
			keyVaultBaseUri := *typedInput.Properties.KeyVaultBaseUri
			certificate.KeyVaultBaseUri = &keyVaultBaseUri
		}
	}

	// Set property "KeyVaultSecretName":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.KeyVaultSecretName != nil {
			keyVaultSecretName := *typedInput.Properties.KeyVaultSecretName
			certificate.KeyVaultSecretName = &keyVaultSecretName
		}
	}

	// Set property "KeyVaultSecretVersion":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.KeyVaultSecretVersion != nil {
			keyVaultSecretVersion := *typedInput.Properties.KeyVaultSecretVersion
			certificate.KeyVaultSecretVersion = &keyVaultSecretVersion
		}
	}

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

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

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

	// No error
	return nil
}

// AssignProperties_From_CustomCertificate_STATUS populates our CustomCertificate_STATUS from the provided source CustomCertificate_STATUS
func (certificate *CustomCertificate_STATUS) AssignProperties_From_CustomCertificate_STATUS(source *storage.CustomCertificate_STATUS) error {

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

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

	// KeyVaultBaseUri
	certificate.KeyVaultBaseUri = genruntime.ClonePointerToString(source.KeyVaultBaseUri)

	// KeyVaultSecretName
	certificate.KeyVaultSecretName = genruntime.ClonePointerToString(source.KeyVaultSecretName)

	// KeyVaultSecretVersion
	certificate.KeyVaultSecretVersion = genruntime.ClonePointerToString(source.KeyVaultSecretVersion)

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

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

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

	// No error
	return nil
}

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

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

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

	// KeyVaultBaseUri
	destination.KeyVaultBaseUri = genruntime.ClonePointerToString(certificate.KeyVaultBaseUri)

	// KeyVaultSecretName
	destination.KeyVaultSecretName = genruntime.ClonePointerToString(certificate.KeyVaultSecretName)

	// KeyVaultSecretVersion
	destination.KeyVaultSecretVersion = genruntime.ClonePointerToString(certificate.KeyVaultSecretVersion)

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

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

	// SystemData
	if certificate.SystemData != nil {
		var systemDatum storage.SystemData_STATUS
		err := certificate.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(certificate.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 CustomCertificateOperatorSpec 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_CustomCertificateOperatorSpec populates our CustomCertificateOperatorSpec from the provided source CustomCertificateOperatorSpec
func (operator *CustomCertificateOperatorSpec) AssignProperties_From_CustomCertificateOperatorSpec(source *storage.CustomCertificateOperatorSpec) 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_CustomCertificateOperatorSpec populates the provided destination CustomCertificateOperatorSpec from our CustomCertificateOperatorSpec
func (operator *CustomCertificateOperatorSpec) AssignProperties_To_CustomCertificateOperatorSpec(destination *storage.CustomCertificateOperatorSpec) 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
}

// Provisioning state of the resource.
type ProvisioningState_STATUS string

const (
	ProvisioningState_STATUS_Canceled  = ProvisioningState_STATUS("Canceled")
	ProvisioningState_STATUS_Creating  = ProvisioningState_STATUS("Creating")
	ProvisioningState_STATUS_Deleting  = ProvisioningState_STATUS("Deleting")
	ProvisioningState_STATUS_Failed    = ProvisioningState_STATUS("Failed")
	ProvisioningState_STATUS_Moving    = ProvisioningState_STATUS("Moving")
	ProvisioningState_STATUS_Running   = ProvisioningState_STATUS("Running")
	ProvisioningState_STATUS_Succeeded = ProvisioningState_STATUS("Succeeded")
	ProvisioningState_STATUS_Unknown   = ProvisioningState_STATUS("Unknown")
	ProvisioningState_STATUS_Updating  = ProvisioningState_STATUS("Updating")
)

// Mapping from string to ProvisioningState_STATUS
var provisioningState_STATUS_Values = map[string]ProvisioningState_STATUS{
	"canceled":  ProvisioningState_STATUS_Canceled,
	"creating":  ProvisioningState_STATUS_Creating,
	"deleting":  ProvisioningState_STATUS_Deleting,
	"failed":    ProvisioningState_STATUS_Failed,
	"moving":    ProvisioningState_STATUS_Moving,
	"running":   ProvisioningState_STATUS_Running,
	"succeeded": ProvisioningState_STATUS_Succeeded,
	"unknown":   ProvisioningState_STATUS_Unknown,
	"updating":  ProvisioningState_STATUS_Updating,
}

// Metadata pertaining to creation and last modification of the resource.
type SystemData_STATUS struct {
	// CreatedAt: The timestamp of resource creation (UTC).
	CreatedAt *string `json:"createdAt,omitempty"`

	// CreatedBy: The identity that created the resource.
	CreatedBy *string `json:"createdBy,omitempty"`

	// CreatedByType: The type of identity that created the resource.
	CreatedByType *SystemData_CreatedByType_STATUS `json:"createdByType,omitempty"`

	// LastModifiedAt: The timestamp of resource last modification (UTC)
	LastModifiedAt *string `json:"lastModifiedAt,omitempty"`

	// LastModifiedBy: The identity that last modified the resource.
	LastModifiedBy *string `json:"lastModifiedBy,omitempty"`

	// LastModifiedByType: The type of identity that last modified the resource.
	LastModifiedByType *SystemData_LastModifiedByType_STATUS `json:"lastModifiedByType,omitempty"`
}

var _ genruntime.FromARMConverter = &SystemData_STATUS{}

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

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

	// Set property "CreatedAt":
	if typedInput.CreatedAt != nil {
		createdAt := *typedInput.CreatedAt
		data.CreatedAt = &createdAt
	}

	// Set property "CreatedBy":
	if typedInput.CreatedBy != nil {
		createdBy := *typedInput.CreatedBy
		data.CreatedBy = &createdBy
	}

	// Set property "CreatedByType":
	if typedInput.CreatedByType != nil {
		var temp string
		temp = string(*typedInput.CreatedByType)
		createdByType := SystemData_CreatedByType_STATUS(temp)
		data.CreatedByType = &createdByType
	}

	// Set property "LastModifiedAt":
	if typedInput.LastModifiedAt != nil {
		lastModifiedAt := *typedInput.LastModifiedAt
		data.LastModifiedAt = &lastModifiedAt
	}

	// Set property "LastModifiedBy":
	if typedInput.LastModifiedBy != nil {
		lastModifiedBy := *typedInput.LastModifiedBy
		data.LastModifiedBy = &lastModifiedBy
	}

	// Set property "LastModifiedByType":
	if typedInput.LastModifiedByType != nil {
		var temp string
		temp = string(*typedInput.LastModifiedByType)
		lastModifiedByType := SystemData_LastModifiedByType_STATUS(temp)
		data.LastModifiedByType = &lastModifiedByType
	}

	// No error
	return nil
}

// AssignProperties_From_SystemData_STATUS populates our SystemData_STATUS from the provided source SystemData_STATUS
func (data *SystemData_STATUS) AssignProperties_From_SystemData_STATUS(source *storage.SystemData_STATUS) error {

	// CreatedAt
	data.CreatedAt = genruntime.ClonePointerToString(source.CreatedAt)

	// CreatedBy
	data.CreatedBy = genruntime.ClonePointerToString(source.CreatedBy)

	// CreatedByType
	if source.CreatedByType != nil {
		createdByType := *source.CreatedByType
		createdByTypeTemp := genruntime.ToEnum(createdByType, systemData_CreatedByType_STATUS_Values)
		data.CreatedByType = &createdByTypeTemp
	} else {
		data.CreatedByType = nil
	}

	// LastModifiedAt
	data.LastModifiedAt = genruntime.ClonePointerToString(source.LastModifiedAt)

	// LastModifiedBy
	data.LastModifiedBy = genruntime.ClonePointerToString(source.LastModifiedBy)

	// LastModifiedByType
	if source.LastModifiedByType != nil {
		lastModifiedByType := *source.LastModifiedByType
		lastModifiedByTypeTemp := genruntime.ToEnum(lastModifiedByType, systemData_LastModifiedByType_STATUS_Values)
		data.LastModifiedByType = &lastModifiedByTypeTemp
	} else {
		data.LastModifiedByType = nil
	}

	// No error
	return nil
}

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

	// CreatedAt
	destination.CreatedAt = genruntime.ClonePointerToString(data.CreatedAt)

	// CreatedBy
	destination.CreatedBy = genruntime.ClonePointerToString(data.CreatedBy)

	// CreatedByType
	if data.CreatedByType != nil {
		createdByType := string(*data.CreatedByType)
		destination.CreatedByType = &createdByType
	} else {
		destination.CreatedByType = nil
	}

	// LastModifiedAt
	destination.LastModifiedAt = genruntime.ClonePointerToString(data.LastModifiedAt)

	// LastModifiedBy
	destination.LastModifiedBy = genruntime.ClonePointerToString(data.LastModifiedBy)

	// LastModifiedByType
	if data.LastModifiedByType != nil {
		lastModifiedByType := string(*data.LastModifiedByType)
		destination.LastModifiedByType = &lastModifiedByType
	} else {
		destination.LastModifiedByType = nil
	}

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

	// No error
	return nil
}

type SystemData_CreatedByType_STATUS string

const (
	SystemData_CreatedByType_STATUS_Application     = SystemData_CreatedByType_STATUS("Application")
	SystemData_CreatedByType_STATUS_Key             = SystemData_CreatedByType_STATUS("Key")
	SystemData_CreatedByType_STATUS_ManagedIdentity = SystemData_CreatedByType_STATUS("ManagedIdentity")
	SystemData_CreatedByType_STATUS_User            = SystemData_CreatedByType_STATUS("User")
)

// Mapping from string to SystemData_CreatedByType_STATUS
var systemData_CreatedByType_STATUS_Values = map[string]SystemData_CreatedByType_STATUS{
	"application":     SystemData_CreatedByType_STATUS_Application,
	"key":             SystemData_CreatedByType_STATUS_Key,
	"managedidentity": SystemData_CreatedByType_STATUS_ManagedIdentity,
	"user":            SystemData_CreatedByType_STATUS_User,
}

type SystemData_LastModifiedByType_STATUS string

const (
	SystemData_LastModifiedByType_STATUS_Application     = SystemData_LastModifiedByType_STATUS("Application")
	SystemData_LastModifiedByType_STATUS_Key             = SystemData_LastModifiedByType_STATUS("Key")
	SystemData_LastModifiedByType_STATUS_ManagedIdentity = SystemData_LastModifiedByType_STATUS("ManagedIdentity")
	SystemData_LastModifiedByType_STATUS_User            = SystemData_LastModifiedByType_STATUS("User")
)

// Mapping from string to SystemData_LastModifiedByType_STATUS
var systemData_LastModifiedByType_STATUS_Values = map[string]SystemData_LastModifiedByType_STATUS{
	"application":     SystemData_LastModifiedByType_STATUS_Application,
	"key":             SystemData_LastModifiedByType_STATUS_Key,
	"managedidentity": SystemData_LastModifiedByType_STATUS_ManagedIdentity,
	"user":            SystemData_LastModifiedByType_STATUS_User,
}

func init() {
	SchemeBuilder.Register(&CustomCertificate{}, &CustomCertificateList{})
}
