// 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}/replicas/{replicaName}
type Replica struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              Replica_Spec   `json:"spec,omitempty"`
	Status            Replica_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &Replica{}

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

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

var _ conversion.Convertible = &Replica{}

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

	return replica.AssignProperties_From_Replica(source)
}

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

	return replica.AssignProperties_To_Replica(destination)
}

var _ configmaps.Exporter = &Replica{}

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

var _ secrets.Exporter = &Replica{}

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

var _ genruntime.ImportableResource = &Replica{}

// InitializeSpec initializes the spec for this resource from the given status
func (replica *Replica) InitializeSpec(status genruntime.ConvertibleStatus) error {
	if s, ok := status.(*Replica_STATUS); ok {
		return replica.Spec.Initialize_From_Replica_STATUS(s)
	}

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

var _ genruntime.KubernetesResource = &Replica{}

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

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

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

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

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

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

// NewEmptyStatus returns a new empty (blank) status
func (replica *Replica) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &Replica_STATUS{}
}

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

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

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

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

	replica.Status = st
	return nil
}

// AssignProperties_From_Replica populates our Replica from the provided source Replica
func (replica *Replica) AssignProperties_From_Replica(source *storage.Replica) error {

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

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

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

	// No error
	return nil
}

// AssignProperties_To_Replica populates the provided destination Replica from our Replica
func (replica *Replica) AssignProperties_To_Replica(destination *storage.Replica) error {

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

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

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

// +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}/replicas/{replicaName}
type ReplicaList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []Replica `json:"items"`
}

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

	// +kubebuilder:validation:Required
	// Location: The geo-location where the resource lives
	Location *string `json:"location,omitempty"`

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

	// RegionEndpointEnabled: Enable or disable the regional endpoint. Default to "Enabled".
	// When it's Disabled, new connections will not be routed to this endpoint, however existing connections will not be
	// affected.
	RegionEndpointEnabled *string `json:"regionEndpointEnabled,omitempty"`

	// ResourceStopped: Stop or start the resource.  Default to "false".
	// When it's true, the data plane of the resource is shutdown.
	// When it's false, the data plane of the resource is started.
	ResourceStopped *string `json:"resourceStopped,omitempty"`

	// +kubebuilder:validation:Required
	// Sku: The billing information of the resource.
	Sku *ResourceSku `json:"sku,omitempty"`

	// Tags: Resource tags.
	Tags map[string]string `json:"tags,omitempty"`
}

var _ genruntime.ARMTransformer = &Replica_Spec{}

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

	// Set property "Location":
	if replica.Location != nil {
		location := *replica.Location
		result.Location = &location
	}

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

	// Set property "Properties":
	if replica.RegionEndpointEnabled != nil || replica.ResourceStopped != nil {
		result.Properties = &arm.ReplicaProperties{}
	}
	if replica.RegionEndpointEnabled != nil {
		regionEndpointEnabled := *replica.RegionEndpointEnabled
		result.Properties.RegionEndpointEnabled = &regionEndpointEnabled
	}
	if replica.ResourceStopped != nil {
		resourceStopped := *replica.ResourceStopped
		result.Properties.ResourceStopped = &resourceStopped
	}

	// Set property "Sku":
	if replica.Sku != nil {
		sku_ARM, err := replica.Sku.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		sku := *sku_ARM.(*arm.ResourceSku)
		result.Sku = &sku
	}

	// Set property "Tags":
	if replica.Tags != nil {
		result.Tags = make(map[string]string, len(replica.Tags))
		for key, value := range replica.Tags {
			result.Tags[key] = value
		}
	}
	return result, nil
}

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

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

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

	// Set property "Location":
	if typedInput.Location != nil {
		location := *typedInput.Location
		replica.Location = &location
	}

	// no assignment for property "OperatorSpec"

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

	// Set property "RegionEndpointEnabled":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.RegionEndpointEnabled != nil {
			regionEndpointEnabled := *typedInput.Properties.RegionEndpointEnabled
			replica.RegionEndpointEnabled = &regionEndpointEnabled
		}
	}

	// Set property "ResourceStopped":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ResourceStopped != nil {
			resourceStopped := *typedInput.Properties.ResourceStopped
			replica.ResourceStopped = &resourceStopped
		}
	}

	// Set property "Sku":
	if typedInput.Sku != nil {
		var sku1 ResourceSku
		err := sku1.PopulateFromARM(owner, *typedInput.Sku)
		if err != nil {
			return err
		}
		sku := sku1
		replica.Sku = &sku
	}

	// Set property "Tags":
	if typedInput.Tags != nil {
		replica.Tags = make(map[string]string, len(typedInput.Tags))
		for key, value := range typedInput.Tags {
			replica.Tags[key] = value
		}
	}

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &Replica_Spec{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.Replica_Spec{}
	err := replica.AssignProperties_To_Replica_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_Replica_Spec populates our Replica_Spec from the provided source Replica_Spec
func (replica *Replica_Spec) AssignProperties_From_Replica_Spec(source *storage.Replica_Spec) error {

	// AzureName
	replica.AzureName = source.AzureName

	// Location
	replica.Location = genruntime.ClonePointerToString(source.Location)

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

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

	// RegionEndpointEnabled
	replica.RegionEndpointEnabled = genruntime.ClonePointerToString(source.RegionEndpointEnabled)

	// ResourceStopped
	replica.ResourceStopped = genruntime.ClonePointerToString(source.ResourceStopped)

	// Sku
	if source.Sku != nil {
		var sku ResourceSku
		err := sku.AssignProperties_From_ResourceSku(source.Sku)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_ResourceSku() to populate field Sku")
		}
		replica.Sku = &sku
	} else {
		replica.Sku = nil
	}

	// Tags
	replica.Tags = genruntime.CloneMapOfStringToString(source.Tags)

	// No error
	return nil
}

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

	// AzureName
	destination.AzureName = replica.AzureName

	// Location
	destination.Location = genruntime.ClonePointerToString(replica.Location)

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

	// OriginalVersion
	destination.OriginalVersion = replica.OriginalVersion()

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

	// RegionEndpointEnabled
	destination.RegionEndpointEnabled = genruntime.ClonePointerToString(replica.RegionEndpointEnabled)

	// ResourceStopped
	destination.ResourceStopped = genruntime.ClonePointerToString(replica.ResourceStopped)

	// Sku
	if replica.Sku != nil {
		var sku storage.ResourceSku
		err := replica.Sku.AssignProperties_To_ResourceSku(&sku)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_ResourceSku() to populate field Sku")
		}
		destination.Sku = &sku
	} else {
		destination.Sku = nil
	}

	// Tags
	destination.Tags = genruntime.CloneMapOfStringToString(replica.Tags)

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

	// No error
	return nil
}

// Initialize_From_Replica_STATUS populates our Replica_Spec from the provided source Replica_STATUS
func (replica *Replica_Spec) Initialize_From_Replica_STATUS(source *Replica_STATUS) error {

	// Location
	replica.Location = genruntime.ClonePointerToString(source.Location)

	// RegionEndpointEnabled
	replica.RegionEndpointEnabled = genruntime.ClonePointerToString(source.RegionEndpointEnabled)

	// ResourceStopped
	replica.ResourceStopped = genruntime.ClonePointerToString(source.ResourceStopped)

	// Sku
	if source.Sku != nil {
		var sku ResourceSku
		err := sku.Initialize_From_ResourceSku_STATUS(source.Sku)
		if err != nil {
			return eris.Wrap(err, "calling Initialize_From_ResourceSku_STATUS() to populate field Sku")
		}
		replica.Sku = &sku
	} else {
		replica.Sku = nil
	}

	// Tags
	replica.Tags = genruntime.CloneMapOfStringToString(source.Tags)

	// No error
	return nil
}

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

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

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

	// Location: The geo-location where the resource lives
	Location *string `json:"location,omitempty"`

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

	// ProvisioningState: Provisioning state of the resource.
	ProvisioningState *ProvisioningState_STATUS `json:"provisioningState,omitempty"`

	// RegionEndpointEnabled: Enable or disable the regional endpoint. Default to "Enabled".
	// When it's Disabled, new connections will not be routed to this endpoint, however existing connections will not be
	// affected.
	RegionEndpointEnabled *string `json:"regionEndpointEnabled,omitempty"`

	// ResourceStopped: Stop or start the resource.  Default to "false".
	// When it's true, the data plane of the resource is shutdown.
	// When it's false, the data plane of the resource is started.
	ResourceStopped *string `json:"resourceStopped,omitempty"`

	// Sku: The billing information of the resource.
	Sku *ResourceSku_STATUS `json:"sku,omitempty"`

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

	// Tags: Resource tags.
	Tags map[string]string `json:"tags,omitempty"`

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

var _ genruntime.ConvertibleStatus = &Replica_STATUS{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.Replica_STATUS{}
	err := replica.AssignProperties_To_Replica_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 = &Replica_STATUS{}

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

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

	// no assignment for property "Conditions"

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

	// Set property "Location":
	if typedInput.Location != nil {
		location := *typedInput.Location
		replica.Location = &location
	}

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

	// Set property "RegionEndpointEnabled":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.RegionEndpointEnabled != nil {
			regionEndpointEnabled := *typedInput.Properties.RegionEndpointEnabled
			replica.RegionEndpointEnabled = &regionEndpointEnabled
		}
	}

	// Set property "ResourceStopped":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ResourceStopped != nil {
			resourceStopped := *typedInput.Properties.ResourceStopped
			replica.ResourceStopped = &resourceStopped
		}
	}

	// Set property "Sku":
	if typedInput.Sku != nil {
		var sku1 ResourceSku_STATUS
		err := sku1.PopulateFromARM(owner, *typedInput.Sku)
		if err != nil {
			return err
		}
		sku := sku1
		replica.Sku = &sku
	}

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

	// Set property "Tags":
	if typedInput.Tags != nil {
		replica.Tags = make(map[string]string, len(typedInput.Tags))
		for key, value := range typedInput.Tags {
			replica.Tags[key] = value
		}
	}

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

	// No error
	return nil
}

// AssignProperties_From_Replica_STATUS populates our Replica_STATUS from the provided source Replica_STATUS
func (replica *Replica_STATUS) AssignProperties_From_Replica_STATUS(source *storage.Replica_STATUS) error {

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

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

	// Location
	replica.Location = genruntime.ClonePointerToString(source.Location)

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

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

	// RegionEndpointEnabled
	replica.RegionEndpointEnabled = genruntime.ClonePointerToString(source.RegionEndpointEnabled)

	// ResourceStopped
	replica.ResourceStopped = genruntime.ClonePointerToString(source.ResourceStopped)

	// Sku
	if source.Sku != nil {
		var sku ResourceSku_STATUS
		err := sku.AssignProperties_From_ResourceSku_STATUS(source.Sku)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_ResourceSku_STATUS() to populate field Sku")
		}
		replica.Sku = &sku
	} else {
		replica.Sku = 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")
		}
		replica.SystemData = &systemDatum
	} else {
		replica.SystemData = nil
	}

	// Tags
	replica.Tags = genruntime.CloneMapOfStringToString(source.Tags)

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

	// No error
	return nil
}

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

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

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

	// Location
	destination.Location = genruntime.ClonePointerToString(replica.Location)

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

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

	// RegionEndpointEnabled
	destination.RegionEndpointEnabled = genruntime.ClonePointerToString(replica.RegionEndpointEnabled)

	// ResourceStopped
	destination.ResourceStopped = genruntime.ClonePointerToString(replica.ResourceStopped)

	// Sku
	if replica.Sku != nil {
		var sku storage.ResourceSku_STATUS
		err := replica.Sku.AssignProperties_To_ResourceSku_STATUS(&sku)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_ResourceSku_STATUS() to populate field Sku")
		}
		destination.Sku = &sku
	} else {
		destination.Sku = nil
	}

	// SystemData
	if replica.SystemData != nil {
		var systemDatum storage.SystemData_STATUS
		err := replica.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
	}

	// Tags
	destination.Tags = genruntime.CloneMapOfStringToString(replica.Tags)

	// Type
	destination.Type = genruntime.ClonePointerToString(replica.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 ReplicaOperatorSpec 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_ReplicaOperatorSpec populates our ReplicaOperatorSpec from the provided source ReplicaOperatorSpec
func (operator *ReplicaOperatorSpec) AssignProperties_From_ReplicaOperatorSpec(source *storage.ReplicaOperatorSpec) 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_ReplicaOperatorSpec populates the provided destination ReplicaOperatorSpec from our ReplicaOperatorSpec
func (operator *ReplicaOperatorSpec) AssignProperties_To_ReplicaOperatorSpec(destination *storage.ReplicaOperatorSpec) 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
}

// The billing information of the resource.
type ResourceSku struct {
	// Capacity: Optional, integer. The unit count of the resource.
	// 1 for Free_F1/Standard_S1/Premium_P1, 100 for Premium_P2 by default.
	// If present, following values are allowed:
	// Free_F1: 1;
	// Standard_S1: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100;
	// Premium_P1:  1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100;
	// Premium_P2:  100,200,300,400,500,600,700,800,900,1000;
	Capacity *int `json:"capacity,omitempty"`

	// +kubebuilder:validation:Required
	// Name: The name of the SKU. Required.
	// Allowed values: Standard_S1, Free_F1, Premium_P1, Premium_P2
	Name *string `json:"name,omitempty"`

	// Tier: Optional tier of this particular SKU. 'Standard' or 'Free'.
	// `Basic` is deprecated, use `Standard` instead.
	Tier *SignalRSkuTier `json:"tier,omitempty"`
}

var _ genruntime.ARMTransformer = &ResourceSku{}

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

	// Set property "Capacity":
	if resourceSku.Capacity != nil {
		capacity := *resourceSku.Capacity
		result.Capacity = &capacity
	}

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

	// Set property "Tier":
	if resourceSku.Tier != nil {
		var temp string
		temp = string(*resourceSku.Tier)
		tier := arm.SignalRSkuTier(temp)
		result.Tier = &tier
	}
	return result, nil
}

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

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

	// Set property "Capacity":
	if typedInput.Capacity != nil {
		capacity := *typedInput.Capacity
		resourceSku.Capacity = &capacity
	}

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

	// Set property "Tier":
	if typedInput.Tier != nil {
		var temp string
		temp = string(*typedInput.Tier)
		tier := SignalRSkuTier(temp)
		resourceSku.Tier = &tier
	}

	// No error
	return nil
}

// AssignProperties_From_ResourceSku populates our ResourceSku from the provided source ResourceSku
func (resourceSku *ResourceSku) AssignProperties_From_ResourceSku(source *storage.ResourceSku) error {

	// Capacity
	resourceSku.Capacity = genruntime.ClonePointerToInt(source.Capacity)

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

	// Tier
	if source.Tier != nil {
		tier := *source.Tier
		tierTemp := genruntime.ToEnum(tier, signalRSkuTier_Values)
		resourceSku.Tier = &tierTemp
	} else {
		resourceSku.Tier = nil
	}

	// No error
	return nil
}

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

	// Capacity
	destination.Capacity = genruntime.ClonePointerToInt(resourceSku.Capacity)

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

	// Tier
	if resourceSku.Tier != nil {
		tier := string(*resourceSku.Tier)
		destination.Tier = &tier
	} else {
		destination.Tier = nil
	}

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

	// No error
	return nil
}

// Initialize_From_ResourceSku_STATUS populates our ResourceSku from the provided source ResourceSku_STATUS
func (resourceSku *ResourceSku) Initialize_From_ResourceSku_STATUS(source *ResourceSku_STATUS) error {

	// Capacity
	resourceSku.Capacity = genruntime.ClonePointerToInt(source.Capacity)

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

	// Tier
	if source.Tier != nil {
		tier := genruntime.ToEnum(string(*source.Tier), signalRSkuTier_Values)
		resourceSku.Tier = &tier
	} else {
		resourceSku.Tier = nil
	}

	// No error
	return nil
}

// The billing information of the resource.
type ResourceSku_STATUS struct {
	// Capacity: Optional, integer. The unit count of the resource.
	// 1 for Free_F1/Standard_S1/Premium_P1, 100 for Premium_P2 by default.
	// If present, following values are allowed:
	// Free_F1: 1;
	// Standard_S1: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100;
	// Premium_P1:  1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100;
	// Premium_P2:  100,200,300,400,500,600,700,800,900,1000;
	Capacity *int `json:"capacity,omitempty"`

	// Family: Not used. Retained for future use.
	Family *string `json:"family,omitempty"`

	// Name: The name of the SKU. Required.
	// Allowed values: Standard_S1, Free_F1, Premium_P1, Premium_P2
	Name *string `json:"name,omitempty"`

	// Size: Not used. Retained for future use.
	Size *string `json:"size,omitempty"`

	// Tier: Optional tier of this particular SKU. 'Standard' or 'Free'.
	// `Basic` is deprecated, use `Standard` instead.
	Tier *SignalRSkuTier_STATUS `json:"tier,omitempty"`
}

var _ genruntime.FromARMConverter = &ResourceSku_STATUS{}

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

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

	// Set property "Capacity":
	if typedInput.Capacity != nil {
		capacity := *typedInput.Capacity
		resourceSku.Capacity = &capacity
	}

	// Set property "Family":
	if typedInput.Family != nil {
		family := *typedInput.Family
		resourceSku.Family = &family
	}

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

	// Set property "Size":
	if typedInput.Size != nil {
		size := *typedInput.Size
		resourceSku.Size = &size
	}

	// Set property "Tier":
	if typedInput.Tier != nil {
		var temp string
		temp = string(*typedInput.Tier)
		tier := SignalRSkuTier_STATUS(temp)
		resourceSku.Tier = &tier
	}

	// No error
	return nil
}

// AssignProperties_From_ResourceSku_STATUS populates our ResourceSku_STATUS from the provided source ResourceSku_STATUS
func (resourceSku *ResourceSku_STATUS) AssignProperties_From_ResourceSku_STATUS(source *storage.ResourceSku_STATUS) error {

	// Capacity
	resourceSku.Capacity = genruntime.ClonePointerToInt(source.Capacity)

	// Family
	resourceSku.Family = genruntime.ClonePointerToString(source.Family)

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

	// Size
	resourceSku.Size = genruntime.ClonePointerToString(source.Size)

	// Tier
	if source.Tier != nil {
		tier := *source.Tier
		tierTemp := genruntime.ToEnum(tier, signalRSkuTier_STATUS_Values)
		resourceSku.Tier = &tierTemp
	} else {
		resourceSku.Tier = nil
	}

	// No error
	return nil
}

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

	// Capacity
	destination.Capacity = genruntime.ClonePointerToInt(resourceSku.Capacity)

	// Family
	destination.Family = genruntime.ClonePointerToString(resourceSku.Family)

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

	// Size
	destination.Size = genruntime.ClonePointerToString(resourceSku.Size)

	// Tier
	if resourceSku.Tier != nil {
		tier := string(*resourceSku.Tier)
		destination.Tier = &tier
	} else {
		destination.Tier = nil
	}

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

	// No error
	return nil
}

// Optional tier of this particular SKU. 'Standard' or 'Free'.
// `Basic` is deprecated, use `Standard` instead.
// +kubebuilder:validation:Enum={"Basic","Free","Premium","Standard"}
type SignalRSkuTier string

const (
	SignalRSkuTier_Basic    = SignalRSkuTier("Basic")
	SignalRSkuTier_Free     = SignalRSkuTier("Free")
	SignalRSkuTier_Premium  = SignalRSkuTier("Premium")
	SignalRSkuTier_Standard = SignalRSkuTier("Standard")
)

// Mapping from string to SignalRSkuTier
var signalRSkuTier_Values = map[string]SignalRSkuTier{
	"basic":    SignalRSkuTier_Basic,
	"free":     SignalRSkuTier_Free,
	"premium":  SignalRSkuTier_Premium,
	"standard": SignalRSkuTier_Standard,
}

// Optional tier of this particular SKU. 'Standard' or 'Free'.
// `Basic` is deprecated, use `Standard` instead.
type SignalRSkuTier_STATUS string

const (
	SignalRSkuTier_STATUS_Basic    = SignalRSkuTier_STATUS("Basic")
	SignalRSkuTier_STATUS_Free     = SignalRSkuTier_STATUS("Free")
	SignalRSkuTier_STATUS_Premium  = SignalRSkuTier_STATUS("Premium")
	SignalRSkuTier_STATUS_Standard = SignalRSkuTier_STATUS("Standard")
)

// Mapping from string to SignalRSkuTier_STATUS
var signalRSkuTier_STATUS_Values = map[string]SignalRSkuTier_STATUS{
	"basic":    SignalRSkuTier_STATUS_Basic,
	"free":     SignalRSkuTier_STATUS_Free,
	"premium":  SignalRSkuTier_STATUS_Premium,
	"standard": SignalRSkuTier_STATUS_Standard,
}

func init() {
	SchemeBuilder.Register(&Replica{}, &ReplicaList{})
}
