// 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}/customDomains/{name}
type CustomDomain struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              CustomDomain_Spec   `json:"spec,omitempty"`
	Status            CustomDomain_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &CustomDomain{}

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

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

var _ conversion.Convertible = &CustomDomain{}

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

	return domain.AssignProperties_From_CustomDomain(source)
}

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

	return domain.AssignProperties_To_CustomDomain(destination)
}

var _ configmaps.Exporter = &CustomDomain{}

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

var _ secrets.Exporter = &CustomDomain{}

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

var _ genruntime.ImportableResource = &CustomDomain{}

// InitializeSpec initializes the spec for this resource from the given status
func (domain *CustomDomain) InitializeSpec(status genruntime.ConvertibleStatus) error {
	if s, ok := status.(*CustomDomain_STATUS); ok {
		return domain.Spec.Initialize_From_CustomDomain_STATUS(s)
	}

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

var _ genruntime.KubernetesResource = &CustomDomain{}

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

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

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

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

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

// GetSupportedOperations returns the operations supported by the resource
func (domain *CustomDomain) 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/customDomains"
func (domain *CustomDomain) GetType() string {
	return "Microsoft.SignalRService/signalR/customDomains"
}

// NewEmptyStatus returns a new empty (blank) status
func (domain *CustomDomain) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &CustomDomain_STATUS{}
}

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

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

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

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

	domain.Status = st
	return nil
}

// AssignProperties_From_CustomDomain populates our CustomDomain from the provided source CustomDomain
func (domain *CustomDomain) AssignProperties_From_CustomDomain(source *storage.CustomDomain) error {

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

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

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

	// No error
	return nil
}

// AssignProperties_To_CustomDomain populates the provided destination CustomDomain from our CustomDomain
func (domain *CustomDomain) AssignProperties_To_CustomDomain(destination *storage.CustomDomain) error {

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

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

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

// +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}/customDomains/{name}
type CustomDomainList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []CustomDomain `json:"items"`
}

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

	// +kubebuilder:validation:Required
	// CustomCertificate: Reference to a resource.
	CustomCertificate *ResourceReference `json:"customCertificate,omitempty"`

	// +kubebuilder:validation:Required
	// DomainName: The custom domain name.
	DomainName *string `json:"domainName,omitempty"`

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

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

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

	// Set property "Properties":
	if domain.CustomCertificate != nil || domain.DomainName != nil {
		result.Properties = &arm.CustomDomainProperties{}
	}
	if domain.CustomCertificate != nil {
		customCertificate_ARM, err := domain.CustomCertificate.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		customCertificate := *customCertificate_ARM.(*arm.ResourceReference)
		result.Properties.CustomCertificate = &customCertificate
	}
	if domain.DomainName != nil {
		domainName := *domain.DomainName
		result.Properties.DomainName = &domainName
	}
	return result, nil
}

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

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

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

	// Set property "CustomCertificate":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.CustomCertificate != nil {
			var customCertificate1 ResourceReference
			err := customCertificate1.PopulateFromARM(owner, *typedInput.Properties.CustomCertificate)
			if err != nil {
				return err
			}
			customCertificate := customCertificate1
			domain.CustomCertificate = &customCertificate
		}
	}

	// Set property "DomainName":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.DomainName != nil {
			domainName := *typedInput.Properties.DomainName
			domain.DomainName = &domainName
		}
	}

	// no assignment for property "OperatorSpec"

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

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &CustomDomain_Spec{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.CustomDomain_Spec{}
	err := domain.AssignProperties_To_CustomDomain_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_CustomDomain_Spec populates our CustomDomain_Spec from the provided source CustomDomain_Spec
func (domain *CustomDomain_Spec) AssignProperties_From_CustomDomain_Spec(source *storage.CustomDomain_Spec) error {

	// AzureName
	domain.AzureName = source.AzureName

	// CustomCertificate
	if source.CustomCertificate != nil {
		var customCertificate ResourceReference
		err := customCertificate.AssignProperties_From_ResourceReference(source.CustomCertificate)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_ResourceReference() to populate field CustomCertificate")
		}
		domain.CustomCertificate = &customCertificate
	} else {
		domain.CustomCertificate = nil
	}

	// DomainName
	domain.DomainName = genruntime.ClonePointerToString(source.DomainName)

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

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

	// No error
	return nil
}

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

	// AzureName
	destination.AzureName = domain.AzureName

	// CustomCertificate
	if domain.CustomCertificate != nil {
		var customCertificate storage.ResourceReference
		err := domain.CustomCertificate.AssignProperties_To_ResourceReference(&customCertificate)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_ResourceReference() to populate field CustomCertificate")
		}
		destination.CustomCertificate = &customCertificate
	} else {
		destination.CustomCertificate = nil
	}

	// DomainName
	destination.DomainName = genruntime.ClonePointerToString(domain.DomainName)

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

	// OriginalVersion
	destination.OriginalVersion = domain.OriginalVersion()

	// Owner
	if domain.Owner != nil {
		owner := domain.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_CustomDomain_STATUS populates our CustomDomain_Spec from the provided source CustomDomain_STATUS
func (domain *CustomDomain_Spec) Initialize_From_CustomDomain_STATUS(source *CustomDomain_STATUS) error {

	// CustomCertificate
	if source.CustomCertificate != nil {
		var customCertificate ResourceReference
		err := customCertificate.Initialize_From_ResourceReference_STATUS(source.CustomCertificate)
		if err != nil {
			return eris.Wrap(err, "calling Initialize_From_ResourceReference_STATUS() to populate field CustomCertificate")
		}
		domain.CustomCertificate = &customCertificate
	} else {
		domain.CustomCertificate = nil
	}

	// DomainName
	domain.DomainName = genruntime.ClonePointerToString(source.DomainName)

	// No error
	return nil
}

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

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

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

	// CustomCertificate: Reference to a resource.
	CustomCertificate *ResourceReference_STATUS `json:"customCertificate,omitempty"`

	// DomainName: The custom domain name.
	DomainName *string `json:"domainName,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"`

	// 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 = &CustomDomain_STATUS{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.CustomDomain_STATUS{}
	err := domain.AssignProperties_To_CustomDomain_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 = &CustomDomain_STATUS{}

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

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

	// no assignment for property "Conditions"

	// Set property "CustomCertificate":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.CustomCertificate != nil {
			var customCertificate1 ResourceReference_STATUS
			err := customCertificate1.PopulateFromARM(owner, *typedInput.Properties.CustomCertificate)
			if err != nil {
				return err
			}
			customCertificate := customCertificate1
			domain.CustomCertificate = &customCertificate
		}
	}

	// Set property "DomainName":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.DomainName != nil {
			domainName := *typedInput.Properties.DomainName
			domain.DomainName = &domainName
		}
	}

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

	// Set property "Name":
	if typedInput.Name != nil {
		name := *typedInput.Name
		domain.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)
			domain.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
		domain.SystemData = &systemData
	}

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

	// No error
	return nil
}

// AssignProperties_From_CustomDomain_STATUS populates our CustomDomain_STATUS from the provided source CustomDomain_STATUS
func (domain *CustomDomain_STATUS) AssignProperties_From_CustomDomain_STATUS(source *storage.CustomDomain_STATUS) error {

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

	// CustomCertificate
	if source.CustomCertificate != nil {
		var customCertificate ResourceReference_STATUS
		err := customCertificate.AssignProperties_From_ResourceReference_STATUS(source.CustomCertificate)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_ResourceReference_STATUS() to populate field CustomCertificate")
		}
		domain.CustomCertificate = &customCertificate
	} else {
		domain.CustomCertificate = nil
	}

	// DomainName
	domain.DomainName = genruntime.ClonePointerToString(source.DomainName)

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

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

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

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

	// No error
	return nil
}

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

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

	// CustomCertificate
	if domain.CustomCertificate != nil {
		var customCertificate storage.ResourceReference_STATUS
		err := domain.CustomCertificate.AssignProperties_To_ResourceReference_STATUS(&customCertificate)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_ResourceReference_STATUS() to populate field CustomCertificate")
		}
		destination.CustomCertificate = &customCertificate
	} else {
		destination.CustomCertificate = nil
	}

	// DomainName
	destination.DomainName = genruntime.ClonePointerToString(domain.DomainName)

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

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

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

	// SystemData
	if domain.SystemData != nil {
		var systemDatum storage.SystemData_STATUS
		err := domain.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(domain.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 CustomDomainOperatorSpec 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_CustomDomainOperatorSpec populates our CustomDomainOperatorSpec from the provided source CustomDomainOperatorSpec
func (operator *CustomDomainOperatorSpec) AssignProperties_From_CustomDomainOperatorSpec(source *storage.CustomDomainOperatorSpec) 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_CustomDomainOperatorSpec populates the provided destination CustomDomainOperatorSpec from our CustomDomainOperatorSpec
func (operator *CustomDomainOperatorSpec) AssignProperties_To_CustomDomainOperatorSpec(destination *storage.CustomDomainOperatorSpec) 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
}

// Reference to a resource.
type ResourceReference struct {
	// Reference: Resource ID.
	Reference *genruntime.ResourceReference `armReference:"Id" json:"reference,omitempty"`
}

var _ genruntime.ARMTransformer = &ResourceReference{}

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

	// Set property "Id":
	if reference.Reference != nil {
		referenceARMID, err := resolved.ResolvedReferences.Lookup(*reference.Reference)
		if err != nil {
			return nil, err
		}
		reference1 := referenceARMID
		result.Id = &reference1
	}
	return result, nil
}

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

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

	// no assignment for property "Reference"

	// No error
	return nil
}

// AssignProperties_From_ResourceReference populates our ResourceReference from the provided source ResourceReference
func (reference *ResourceReference) AssignProperties_From_ResourceReference(source *storage.ResourceReference) error {

	// Reference
	if source.Reference != nil {
		referenceTemp := source.Reference.Copy()
		reference.Reference = &referenceTemp
	} else {
		reference.Reference = nil
	}

	// No error
	return nil
}

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

	// Reference
	if reference.Reference != nil {
		referenceTemp := reference.Reference.Copy()
		destination.Reference = &referenceTemp
	} else {
		destination.Reference = nil
	}

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

	// No error
	return nil
}

// Initialize_From_ResourceReference_STATUS populates our ResourceReference from the provided source ResourceReference_STATUS
func (reference *ResourceReference) Initialize_From_ResourceReference_STATUS(source *ResourceReference_STATUS) error {

	// Reference
	if source.Id != nil {
		referenceTemp := genruntime.CreateResourceReferenceFromARMID(*source.Id)
		reference.Reference = &referenceTemp
	} else {
		reference.Reference = nil
	}

	// No error
	return nil
}

// Reference to a resource.
type ResourceReference_STATUS struct {
	// Id: Resource ID.
	Id *string `json:"id,omitempty"`
}

var _ genruntime.FromARMConverter = &ResourceReference_STATUS{}

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

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

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

	// No error
	return nil
}

// AssignProperties_From_ResourceReference_STATUS populates our ResourceReference_STATUS from the provided source ResourceReference_STATUS
func (reference *ResourceReference_STATUS) AssignProperties_From_ResourceReference_STATUS(source *storage.ResourceReference_STATUS) error {

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

	// No error
	return nil
}

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

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

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

	// No error
	return nil
}

func init() {
	SchemeBuilder.Register(&CustomDomain{}, &CustomDomainList{})
}
