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

import (
	"fmt"
	arm "github.com/Azure/azure-service-operator/v2/api/insights/v1api20230311/arm"
	storage "github.com/Azure/azure-service-operator/v2/api/insights/v1api20230311/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,insights}
// +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: /monitor/resource-manager/Microsoft.Insights/stable/2023-03-11/dataCollectionRuleAssociations_API.json
// - ARM URI: /{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}
type DataCollectionRuleAssociation struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              DataCollectionRuleAssociation_Spec                    `json:"spec,omitempty"`
	Status            DataCollectionRuleAssociationProxyOnlyResource_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &DataCollectionRuleAssociation{}

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

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

var _ conversion.Convertible = &DataCollectionRuleAssociation{}

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

	return association.AssignProperties_From_DataCollectionRuleAssociation(source)
}

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

	return association.AssignProperties_To_DataCollectionRuleAssociation(destination)
}

var _ configmaps.Exporter = &DataCollectionRuleAssociation{}

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

var _ secrets.Exporter = &DataCollectionRuleAssociation{}

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

var _ genruntime.ImportableResource = &DataCollectionRuleAssociation{}

// InitializeSpec initializes the spec for this resource from the given status
func (association *DataCollectionRuleAssociation) InitializeSpec(status genruntime.ConvertibleStatus) error {
	if s, ok := status.(*DataCollectionRuleAssociationProxyOnlyResource_STATUS); ok {
		return association.Spec.Initialize_From_DataCollectionRuleAssociationProxyOnlyResource_STATUS(s)
	}

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

var _ genruntime.KubernetesResource = &DataCollectionRuleAssociation{}

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

// GetAPIVersion returns the ARM API version of the resource. This is always "2023-03-11"
func (association DataCollectionRuleAssociation) GetAPIVersion() string {
	return "2023-03-11"
}

// GetResourceScope returns the scope of the resource
func (association *DataCollectionRuleAssociation) GetResourceScope() genruntime.ResourceScope {
	return genruntime.ResourceScopeExtension
}

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.Insights/dataCollectionRuleAssociations"
func (association *DataCollectionRuleAssociation) GetType() string {
	return "Microsoft.Insights/dataCollectionRuleAssociations"
}

// NewEmptyStatus returns a new empty (blank) status
func (association *DataCollectionRuleAssociation) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &DataCollectionRuleAssociationProxyOnlyResource_STATUS{}
}

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

	return association.Spec.Owner.AsResourceReference()
}

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

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

	association.Status = st
	return nil
}

// AssignProperties_From_DataCollectionRuleAssociation populates our DataCollectionRuleAssociation from the provided source DataCollectionRuleAssociation
func (association *DataCollectionRuleAssociation) AssignProperties_From_DataCollectionRuleAssociation(source *storage.DataCollectionRuleAssociation) error {

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

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

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

	// No error
	return nil
}

// AssignProperties_To_DataCollectionRuleAssociation populates the provided destination DataCollectionRuleAssociation from our DataCollectionRuleAssociation
func (association *DataCollectionRuleAssociation) AssignProperties_To_DataCollectionRuleAssociation(destination *storage.DataCollectionRuleAssociation) error {

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

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

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

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /monitor/resource-manager/Microsoft.Insights/stable/2023-03-11/dataCollectionRuleAssociations_API.json
// - ARM URI: /{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}
type DataCollectionRuleAssociationList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []DataCollectionRuleAssociation `json:"items"`
}

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

	// DataCollectionEndpointReference: The resource ID of the data collection endpoint that is to be associated.
	DataCollectionEndpointReference *genruntime.ResourceReference `armReference:"DataCollectionEndpointId" json:"dataCollectionEndpointReference,omitempty"`

	// DataCollectionRuleReference: The resource ID of the data collection rule that is to be associated.
	DataCollectionRuleReference *genruntime.ResourceReference `armReference:"DataCollectionRuleId" json:"dataCollectionRuleReference,omitempty"`

	// Description: Description of the association.
	Description *string `json:"description,omitempty"`

	// OperatorSpec: The specification for configuring operator behavior. This field is interpreted by the operator and not
	// passed directly to Azure
	OperatorSpec *DataCollectionRuleAssociationOperatorSpec `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. This resource is an
	// extension resource, which means that any other Azure resource can be its owner.
	Owner *genruntime.ArbitraryOwnerReference `json:"owner,omitempty"`
}

var _ genruntime.ARMTransformer = &DataCollectionRuleAssociation_Spec{}

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

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

	// Set property "Properties":
	if association.DataCollectionEndpointReference != nil ||
		association.DataCollectionRuleReference != nil ||
		association.Description != nil {
		result.Properties = &arm.DataCollectionRuleAssociationSpec{}
	}
	if association.DataCollectionEndpointReference != nil {
		dataCollectionEndpointIdARMID, err := resolved.ResolvedReferences.Lookup(*association.DataCollectionEndpointReference)
		if err != nil {
			return nil, err
		}
		dataCollectionEndpointId := dataCollectionEndpointIdARMID
		result.Properties.DataCollectionEndpointId = &dataCollectionEndpointId
	}
	if association.DataCollectionRuleReference != nil {
		dataCollectionRuleIdARMID, err := resolved.ResolvedReferences.Lookup(*association.DataCollectionRuleReference)
		if err != nil {
			return nil, err
		}
		dataCollectionRuleId := dataCollectionRuleIdARMID
		result.Properties.DataCollectionRuleId = &dataCollectionRuleId
	}
	if association.Description != nil {
		description := *association.Description
		result.Properties.Description = &description
	}
	return result, nil
}

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

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

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

	// no assignment for property "DataCollectionEndpointReference"

	// no assignment for property "DataCollectionRuleReference"

	// Set property "Description":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Description != nil {
			description := *typedInput.Properties.Description
			association.Description = &description
		}
	}

	// no assignment for property "OperatorSpec"

	// Set property "Owner":
	association.Owner = &owner

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &DataCollectionRuleAssociation_Spec{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.DataCollectionRuleAssociation_Spec{}
	err := association.AssignProperties_To_DataCollectionRuleAssociation_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_DataCollectionRuleAssociation_Spec populates our DataCollectionRuleAssociation_Spec from the provided source DataCollectionRuleAssociation_Spec
func (association *DataCollectionRuleAssociation_Spec) AssignProperties_From_DataCollectionRuleAssociation_Spec(source *storage.DataCollectionRuleAssociation_Spec) error {

	// AzureName
	association.AzureName = source.AzureName

	// DataCollectionEndpointReference
	if source.DataCollectionEndpointReference != nil {
		dataCollectionEndpointReference := source.DataCollectionEndpointReference.Copy()
		association.DataCollectionEndpointReference = &dataCollectionEndpointReference
	} else {
		association.DataCollectionEndpointReference = nil
	}

	// DataCollectionRuleReference
	if source.DataCollectionRuleReference != nil {
		dataCollectionRuleReference := source.DataCollectionRuleReference.Copy()
		association.DataCollectionRuleReference = &dataCollectionRuleReference
	} else {
		association.DataCollectionRuleReference = nil
	}

	// Description
	association.Description = genruntime.ClonePointerToString(source.Description)

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

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

	// No error
	return nil
}

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

	// AzureName
	destination.AzureName = association.AzureName

	// DataCollectionEndpointReference
	if association.DataCollectionEndpointReference != nil {
		dataCollectionEndpointReference := association.DataCollectionEndpointReference.Copy()
		destination.DataCollectionEndpointReference = &dataCollectionEndpointReference
	} else {
		destination.DataCollectionEndpointReference = nil
	}

	// DataCollectionRuleReference
	if association.DataCollectionRuleReference != nil {
		dataCollectionRuleReference := association.DataCollectionRuleReference.Copy()
		destination.DataCollectionRuleReference = &dataCollectionRuleReference
	} else {
		destination.DataCollectionRuleReference = nil
	}

	// Description
	destination.Description = genruntime.ClonePointerToString(association.Description)

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

	// OriginalVersion
	destination.OriginalVersion = association.OriginalVersion()

	// Owner
	if association.Owner != nil {
		owner := association.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_DataCollectionRuleAssociationProxyOnlyResource_STATUS populates our DataCollectionRuleAssociation_Spec from the provided source DataCollectionRuleAssociationProxyOnlyResource_STATUS
func (association *DataCollectionRuleAssociation_Spec) Initialize_From_DataCollectionRuleAssociationProxyOnlyResource_STATUS(source *DataCollectionRuleAssociationProxyOnlyResource_STATUS) error {

	// DataCollectionEndpointReference
	if source.DataCollectionEndpointId != nil {
		dataCollectionEndpointReference := genruntime.CreateResourceReferenceFromARMID(*source.DataCollectionEndpointId)
		association.DataCollectionEndpointReference = &dataCollectionEndpointReference
	} else {
		association.DataCollectionEndpointReference = nil
	}

	// DataCollectionRuleReference
	if source.DataCollectionRuleId != nil {
		dataCollectionRuleReference := genruntime.CreateResourceReferenceFromARMID(*source.DataCollectionRuleId)
		association.DataCollectionRuleReference = &dataCollectionRuleReference
	} else {
		association.DataCollectionRuleReference = nil
	}

	// Description
	association.Description = genruntime.ClonePointerToString(source.Description)

	// No error
	return nil
}

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

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

// Definition of generic ARM proxy resource.
type DataCollectionRuleAssociationProxyOnlyResource_STATUS struct {
	// Conditions: The observed state of the resource
	Conditions []conditions.Condition `json:"conditions,omitempty"`

	// DataCollectionEndpointId: The resource ID of the data collection endpoint that is to be associated.
	DataCollectionEndpointId *string `json:"dataCollectionEndpointId,omitempty"`

	// DataCollectionRuleId: The resource ID of the data collection rule that is to be associated.
	DataCollectionRuleId *string `json:"dataCollectionRuleId,omitempty"`

	// Description: Description of the association.
	Description *string `json:"description,omitempty"`

	// Etag: Resource entity tag (ETag).
	Etag *string `json:"etag,omitempty"`

	// Id: Fully qualified ID of the resource.
	Id *string `json:"id,omitempty"`

	// Metadata: Metadata about the resource
	Metadata *Metadata_STATUS `json:"metadata,omitempty"`

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

	// ProvisioningState: The resource provisioning state.
	ProvisioningState *DataCollectionRuleAssociation_ProvisioningState_STATUS `json:"provisioningState,omitempty"`

	// SystemData: Metadata pertaining to creation and last modification of the resource.
	SystemData *SystemData_STATUS `json:"systemData,omitempty"`

	// Type: The type of the resource.
	Type *string `json:"type,omitempty"`
}

var _ genruntime.ConvertibleStatus = &DataCollectionRuleAssociationProxyOnlyResource_STATUS{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.DataCollectionRuleAssociationProxyOnlyResource_STATUS{}
	err := resource.AssignProperties_To_DataCollectionRuleAssociationProxyOnlyResource_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 = &DataCollectionRuleAssociationProxyOnlyResource_STATUS{}

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

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

	// no assignment for property "Conditions"

	// Set property "DataCollectionEndpointId":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.DataCollectionEndpointId != nil {
			dataCollectionEndpointId := *typedInput.Properties.DataCollectionEndpointId
			resource.DataCollectionEndpointId = &dataCollectionEndpointId
		}
	}

	// Set property "DataCollectionRuleId":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.DataCollectionRuleId != nil {
			dataCollectionRuleId := *typedInput.Properties.DataCollectionRuleId
			resource.DataCollectionRuleId = &dataCollectionRuleId
		}
	}

	// Set property "Description":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Description != nil {
			description := *typedInput.Properties.Description
			resource.Description = &description
		}
	}

	// Set property "Etag":
	if typedInput.Etag != nil {
		etag := *typedInput.Etag
		resource.Etag = &etag
	}

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

	// Set property "Metadata":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Metadata != nil {
			var metadata1 Metadata_STATUS
			err := metadata1.PopulateFromARM(owner, *typedInput.Properties.Metadata)
			if err != nil {
				return err
			}
			metadata := metadata1
			resource.Metadata = &metadata
		}
	}

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

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

	// No error
	return nil
}

// AssignProperties_From_DataCollectionRuleAssociationProxyOnlyResource_STATUS populates our DataCollectionRuleAssociationProxyOnlyResource_STATUS from the provided source DataCollectionRuleAssociationProxyOnlyResource_STATUS
func (resource *DataCollectionRuleAssociationProxyOnlyResource_STATUS) AssignProperties_From_DataCollectionRuleAssociationProxyOnlyResource_STATUS(source *storage.DataCollectionRuleAssociationProxyOnlyResource_STATUS) error {

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

	// DataCollectionEndpointId
	resource.DataCollectionEndpointId = genruntime.ClonePointerToString(source.DataCollectionEndpointId)

	// DataCollectionRuleId
	resource.DataCollectionRuleId = genruntime.ClonePointerToString(source.DataCollectionRuleId)

	// Description
	resource.Description = genruntime.ClonePointerToString(source.Description)

	// Etag
	resource.Etag = genruntime.ClonePointerToString(source.Etag)

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

	// Metadata
	if source.Metadata != nil {
		var metadatum Metadata_STATUS
		err := metadatum.AssignProperties_From_Metadata_STATUS(source.Metadata)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_Metadata_STATUS() to populate field Metadata")
		}
		resource.Metadata = &metadatum
	} else {
		resource.Metadata = nil
	}

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

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

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

	// No error
	return nil
}

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

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

	// DataCollectionEndpointId
	destination.DataCollectionEndpointId = genruntime.ClonePointerToString(resource.DataCollectionEndpointId)

	// DataCollectionRuleId
	destination.DataCollectionRuleId = genruntime.ClonePointerToString(resource.DataCollectionRuleId)

	// Description
	destination.Description = genruntime.ClonePointerToString(resource.Description)

	// Etag
	destination.Etag = genruntime.ClonePointerToString(resource.Etag)

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

	// Metadata
	if resource.Metadata != nil {
		var metadatum storage.Metadata_STATUS
		err := resource.Metadata.AssignProperties_To_Metadata_STATUS(&metadatum)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_Metadata_STATUS() to populate field Metadata")
		}
		destination.Metadata = &metadatum
	} else {
		destination.Metadata = nil
	}

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

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

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

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

	// No error
	return nil
}

type DataCollectionRuleAssociation_ProvisioningState_STATUS string

const (
	DataCollectionRuleAssociation_ProvisioningState_STATUS_Canceled  = DataCollectionRuleAssociation_ProvisioningState_STATUS("Canceled")
	DataCollectionRuleAssociation_ProvisioningState_STATUS_Creating  = DataCollectionRuleAssociation_ProvisioningState_STATUS("Creating")
	DataCollectionRuleAssociation_ProvisioningState_STATUS_Deleting  = DataCollectionRuleAssociation_ProvisioningState_STATUS("Deleting")
	DataCollectionRuleAssociation_ProvisioningState_STATUS_Failed    = DataCollectionRuleAssociation_ProvisioningState_STATUS("Failed")
	DataCollectionRuleAssociation_ProvisioningState_STATUS_Succeeded = DataCollectionRuleAssociation_ProvisioningState_STATUS("Succeeded")
	DataCollectionRuleAssociation_ProvisioningState_STATUS_Updating  = DataCollectionRuleAssociation_ProvisioningState_STATUS("Updating")
)

// Mapping from string to DataCollectionRuleAssociation_ProvisioningState_STATUS
var dataCollectionRuleAssociation_ProvisioningState_STATUS_Values = map[string]DataCollectionRuleAssociation_ProvisioningState_STATUS{
	"canceled":  DataCollectionRuleAssociation_ProvisioningState_STATUS_Canceled,
	"creating":  DataCollectionRuleAssociation_ProvisioningState_STATUS_Creating,
	"deleting":  DataCollectionRuleAssociation_ProvisioningState_STATUS_Deleting,
	"failed":    DataCollectionRuleAssociation_ProvisioningState_STATUS_Failed,
	"succeeded": DataCollectionRuleAssociation_ProvisioningState_STATUS_Succeeded,
	"updating":  DataCollectionRuleAssociation_ProvisioningState_STATUS_Updating,
}

// Details for configuring operator behavior. Fields in this struct are interpreted by the operator directly rather than being passed to Azure
type DataCollectionRuleAssociationOperatorSpec 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_DataCollectionRuleAssociationOperatorSpec populates our DataCollectionRuleAssociationOperatorSpec from the provided source DataCollectionRuleAssociationOperatorSpec
func (operator *DataCollectionRuleAssociationOperatorSpec) AssignProperties_From_DataCollectionRuleAssociationOperatorSpec(source *storage.DataCollectionRuleAssociationOperatorSpec) 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_DataCollectionRuleAssociationOperatorSpec populates the provided destination DataCollectionRuleAssociationOperatorSpec from our DataCollectionRuleAssociationOperatorSpec
func (operator *DataCollectionRuleAssociationOperatorSpec) AssignProperties_To_DataCollectionRuleAssociationOperatorSpec(destination *storage.DataCollectionRuleAssociationOperatorSpec) 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(&DataCollectionRuleAssociation{}, &DataCollectionRuleAssociationList{})
}
