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

import (
	"fmt"
	arm "github.com/Azure/azure-service-operator/v2/api/notificationhubs/v1api20230901/arm"
	storage "github.com/Azure/azure-service-operator/v2/api/notificationhubs/v1api20230901/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,notificationhubs}
// +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: /notificationhubs/resource-manager/Microsoft.NotificationHubs/NotificationHubs/stable/2023-09-01/notificationhubs.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName}
type NotificationHubsAuthorizationRule struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              NotificationHubsAuthorizationRule_Spec   `json:"spec,omitempty"`
	Status            NotificationHubsAuthorizationRule_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &NotificationHubsAuthorizationRule{}

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

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

var _ conversion.Convertible = &NotificationHubsAuthorizationRule{}

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

	return rule.AssignProperties_From_NotificationHubsAuthorizationRule(source)
}

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

	return rule.AssignProperties_To_NotificationHubsAuthorizationRule(destination)
}

var _ configmaps.Exporter = &NotificationHubsAuthorizationRule{}

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

var _ secrets.Exporter = &NotificationHubsAuthorizationRule{}

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

var _ genruntime.ImportableResource = &NotificationHubsAuthorizationRule{}

// InitializeSpec initializes the spec for this resource from the given status
func (rule *NotificationHubsAuthorizationRule) InitializeSpec(status genruntime.ConvertibleStatus) error {
	if s, ok := status.(*NotificationHubsAuthorizationRule_STATUS); ok {
		return rule.Spec.Initialize_From_NotificationHubsAuthorizationRule_STATUS(s)
	}

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

var _ genruntime.KubernetesResource = &NotificationHubsAuthorizationRule{}

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

// GetAPIVersion returns the ARM API version of the resource. This is always "2023-09-01"
func (rule NotificationHubsAuthorizationRule) GetAPIVersion() string {
	return "2023-09-01"
}

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.NotificationHubs/namespaces/notificationHubs/authorizationRules"
func (rule *NotificationHubsAuthorizationRule) GetType() string {
	return "Microsoft.NotificationHubs/namespaces/notificationHubs/authorizationRules"
}

// NewEmptyStatus returns a new empty (blank) status
func (rule *NotificationHubsAuthorizationRule) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &NotificationHubsAuthorizationRule_STATUS{}
}

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

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

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

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

	rule.Status = st
	return nil
}

// AssignProperties_From_NotificationHubsAuthorizationRule populates our NotificationHubsAuthorizationRule from the provided source NotificationHubsAuthorizationRule
func (rule *NotificationHubsAuthorizationRule) AssignProperties_From_NotificationHubsAuthorizationRule(source *storage.NotificationHubsAuthorizationRule) error {

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

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

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

	// No error
	return nil
}

// AssignProperties_To_NotificationHubsAuthorizationRule populates the provided destination NotificationHubsAuthorizationRule from our NotificationHubsAuthorizationRule
func (rule *NotificationHubsAuthorizationRule) AssignProperties_To_NotificationHubsAuthorizationRule(destination *storage.NotificationHubsAuthorizationRule) error {

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

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

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

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /notificationhubs/resource-manager/Microsoft.NotificationHubs/NotificationHubs/stable/2023-09-01/notificationhubs.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName}
type NotificationHubsAuthorizationRuleList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []NotificationHubsAuthorizationRule `json:"items"`
}

type NotificationHubsAuthorizationRule_Spec struct {
	// +kubebuilder:validation:MaxLength=256
	// +kubebuilder:validation:MinLength=1
	// +kubebuilder:validation:Pattern="^[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"`

	// Location: Deprecated - only for compatibility.
	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 *NotificationHubsAuthorizationRuleOperatorSpec `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 notificationhubs.azure.com/NotificationHub resource
	Owner *genruntime.KnownResourceReference `group:"notificationhubs.azure.com" json:"owner,omitempty" kind:"NotificationHub"`

	// Properties: SharedAccessAuthorizationRule properties.
	Properties *SharedAccessAuthorizationRuleProperties `json:"properties,omitempty"`

	// Tags: Deprecated - only for compatibility.
	Tags map[string]string `json:"tags,omitempty"`
}

var _ genruntime.ARMTransformer = &NotificationHubsAuthorizationRule_Spec{}

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

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

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

	// Set property "Properties":
	if rule.Properties != nil {
		properties_ARM, err := rule.Properties.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		properties := *properties_ARM.(*arm.SharedAccessAuthorizationRuleProperties)
		result.Properties = &properties
	}

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

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

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

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

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

	// no assignment for property "OperatorSpec"

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

	// Set property "Properties":
	if typedInput.Properties != nil {
		var properties1 SharedAccessAuthorizationRuleProperties
		err := properties1.PopulateFromARM(owner, *typedInput.Properties)
		if err != nil {
			return err
		}
		properties := properties1
		rule.Properties = &properties
	}

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

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &NotificationHubsAuthorizationRule_Spec{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.NotificationHubsAuthorizationRule_Spec{}
	err := rule.AssignProperties_To_NotificationHubsAuthorizationRule_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_NotificationHubsAuthorizationRule_Spec populates our NotificationHubsAuthorizationRule_Spec from the provided source NotificationHubsAuthorizationRule_Spec
func (rule *NotificationHubsAuthorizationRule_Spec) AssignProperties_From_NotificationHubsAuthorizationRule_Spec(source *storage.NotificationHubsAuthorizationRule_Spec) error {

	// AzureName
	rule.AzureName = source.AzureName

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

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

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

	// Properties
	if source.Properties != nil {
		var property SharedAccessAuthorizationRuleProperties
		err := property.AssignProperties_From_SharedAccessAuthorizationRuleProperties(source.Properties)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_SharedAccessAuthorizationRuleProperties() to populate field Properties")
		}
		rule.Properties = &property
	} else {
		rule.Properties = nil
	}

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

	// No error
	return nil
}

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

	// AzureName
	destination.AzureName = rule.AzureName

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

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

	// OriginalVersion
	destination.OriginalVersion = rule.OriginalVersion()

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

	// Properties
	if rule.Properties != nil {
		var property storage.SharedAccessAuthorizationRuleProperties
		err := rule.Properties.AssignProperties_To_SharedAccessAuthorizationRuleProperties(&property)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_SharedAccessAuthorizationRuleProperties() to populate field Properties")
		}
		destination.Properties = &property
	} else {
		destination.Properties = nil
	}

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

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

	// No error
	return nil
}

// Initialize_From_NotificationHubsAuthorizationRule_STATUS populates our NotificationHubsAuthorizationRule_Spec from the provided source NotificationHubsAuthorizationRule_STATUS
func (rule *NotificationHubsAuthorizationRule_Spec) Initialize_From_NotificationHubsAuthorizationRule_STATUS(source *NotificationHubsAuthorizationRule_STATUS) error {

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

	// Properties
	if source.Properties != nil {
		var property SharedAccessAuthorizationRuleProperties
		err := property.Initialize_From_SharedAccessAuthorizationRuleProperties_STATUS(source.Properties)
		if err != nil {
			return eris.Wrap(err, "calling Initialize_From_SharedAccessAuthorizationRuleProperties_STATUS() to populate field Properties")
		}
		rule.Properties = &property
	} else {
		rule.Properties = nil
	}

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

	// No error
	return nil
}

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

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

type NotificationHubsAuthorizationRule_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: Deprecated - only for compatibility.
	Location *string `json:"location,omitempty"`

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

	// Properties: SharedAccessAuthorizationRule properties.
	Properties *SharedAccessAuthorizationRuleProperties_STATUS `json:"properties,omitempty"`

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

	// Tags: Deprecated - only for compatibility.
	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 = &NotificationHubsAuthorizationRule_STATUS{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.NotificationHubsAuthorizationRule_STATUS{}
	err := rule.AssignProperties_To_NotificationHubsAuthorizationRule_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 = &NotificationHubsAuthorizationRule_STATUS{}

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

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

	// no assignment for property "Conditions"

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

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

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

	// Set property "Properties":
	if typedInput.Properties != nil {
		var properties1 SharedAccessAuthorizationRuleProperties_STATUS
		err := properties1.PopulateFromARM(owner, *typedInput.Properties)
		if err != nil {
			return err
		}
		properties := properties1
		rule.Properties = &properties
	}

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

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

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

	// No error
	return nil
}

// AssignProperties_From_NotificationHubsAuthorizationRule_STATUS populates our NotificationHubsAuthorizationRule_STATUS from the provided source NotificationHubsAuthorizationRule_STATUS
func (rule *NotificationHubsAuthorizationRule_STATUS) AssignProperties_From_NotificationHubsAuthorizationRule_STATUS(source *storage.NotificationHubsAuthorizationRule_STATUS) error {

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

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

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

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

	// Properties
	if source.Properties != nil {
		var property SharedAccessAuthorizationRuleProperties_STATUS
		err := property.AssignProperties_From_SharedAccessAuthorizationRuleProperties_STATUS(source.Properties)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_SharedAccessAuthorizationRuleProperties_STATUS() to populate field Properties")
		}
		rule.Properties = &property
	} else {
		rule.Properties = 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")
		}
		rule.SystemData = &systemDatum
	} else {
		rule.SystemData = nil
	}

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

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

	// No error
	return nil
}

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

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

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

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

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

	// Properties
	if rule.Properties != nil {
		var property storage.SharedAccessAuthorizationRuleProperties_STATUS
		err := rule.Properties.AssignProperties_To_SharedAccessAuthorizationRuleProperties_STATUS(&property)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_SharedAccessAuthorizationRuleProperties_STATUS() to populate field Properties")
		}
		destination.Properties = &property
	} else {
		destination.Properties = nil
	}

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

	// Type
	destination.Type = genruntime.ClonePointerToString(rule.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 NotificationHubsAuthorizationRuleOperatorSpec 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_NotificationHubsAuthorizationRuleOperatorSpec populates our NotificationHubsAuthorizationRuleOperatorSpec from the provided source NotificationHubsAuthorizationRuleOperatorSpec
func (operator *NotificationHubsAuthorizationRuleOperatorSpec) AssignProperties_From_NotificationHubsAuthorizationRuleOperatorSpec(source *storage.NotificationHubsAuthorizationRuleOperatorSpec) 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_NotificationHubsAuthorizationRuleOperatorSpec populates the provided destination NotificationHubsAuthorizationRuleOperatorSpec from our NotificationHubsAuthorizationRuleOperatorSpec
func (operator *NotificationHubsAuthorizationRuleOperatorSpec) AssignProperties_To_NotificationHubsAuthorizationRuleOperatorSpec(destination *storage.NotificationHubsAuthorizationRuleOperatorSpec) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// ConfigMapExpressions
	if operator.ConfigMapExpressions != nil {
		configMapExpressionList := make([]*core.DestinationExpression, len(operator.ConfigMapExpressions))
		for configMapExpressionIndex, configMapExpressionItem := range operator.ConfigMapExpressions {
			if configMapExpressionItem != nil {
				configMapExpression := *configMapExpressionItem.DeepCopy()
				configMapExpressionList[configMapExpressionIndex] = &configMapExpression
			} else {
				configMapExpressionList[configMapExpressionIndex] = nil
			}
		}
		destination.ConfigMapExpressions = configMapExpressionList
	} else {
		destination.ConfigMapExpressions = nil
	}

	// SecretExpressions
	if operator.SecretExpressions != nil {
		secretExpressionList := make([]*core.DestinationExpression, len(operator.SecretExpressions))
		for secretExpressionIndex, secretExpressionItem := range operator.SecretExpressions {
			if secretExpressionItem != nil {
				secretExpression := *secretExpressionItem.DeepCopy()
				secretExpressionList[secretExpressionIndex] = &secretExpression
			} else {
				secretExpressionList[secretExpressionIndex] = nil
			}
		}
		destination.SecretExpressions = secretExpressionList
	} else {
		destination.SecretExpressions = nil
	}

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

	// No error
	return nil
}

func init() {
	SchemeBuilder.Register(&NotificationHubsAuthorizationRule{}, &NotificationHubsAuthorizationRuleList{})
}
