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

import (
	"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"
)

// +kubebuilder:rbac:groups=insights.azure.com,resources=datacollectionruleassociations,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=insights.azure.com,resources={datacollectionruleassociations/status,datacollectionruleassociations/finalizers},verbs=get;update;patch

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,insights}
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// +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"
// Storage version of v1api20230311.DataCollectionRuleAssociation
// 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 _ 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.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
}

// Hub marks that this DataCollectionRuleAssociation is the hub type for conversion
func (association *DataCollectionRuleAssociation) Hub() {}

// 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
// Storage version of v1api20230311.DataCollectionRuleAssociation
// 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"`
}

// Storage version of v1api20230311.DataCollectionRuleAssociation_Spec
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                 *string                                    `json:"description,omitempty"`
	OperatorSpec                *DataCollectionRuleAssociationOperatorSpec `json:"operatorSpec,omitempty"`
	OriginalVersion             string                                     `json:"originalVersion,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"`
	PropertyBag genruntime.PropertyBag              `json:"$propertyBag,omitempty"`
}

var _ genruntime.ConvertibleSpec = &DataCollectionRuleAssociation_Spec{}

// ConvertSpecFrom populates our DataCollectionRuleAssociation_Spec from the provided source
func (association *DataCollectionRuleAssociation_Spec) ConvertSpecFrom(source genruntime.ConvertibleSpec) error {
	if source == association {
		return eris.New("attempted conversion between unrelated implementations of github.com/Azure/azure-service-operator/v2/pkg/genruntime/ConvertibleSpec")
	}

	return source.ConvertSpecTo(association)
}

// ConvertSpecTo populates the provided destination from our DataCollectionRuleAssociation_Spec
func (association *DataCollectionRuleAssociation_Spec) ConvertSpecTo(destination genruntime.ConvertibleSpec) error {
	if destination == association {
		return eris.New("attempted conversion between unrelated implementations of github.com/Azure/azure-service-operator/v2/pkg/genruntime/ConvertibleSpec")
	}

	return destination.ConvertSpecFrom(association)
}

// Storage version of v1api20230311.DataCollectionRuleAssociationProxyOnlyResource_STATUS
// Definition of generic ARM proxy resource.
type DataCollectionRuleAssociationProxyOnlyResource_STATUS struct {
	Conditions               []conditions.Condition `json:"conditions,omitempty"`
	DataCollectionEndpointId *string                `json:"dataCollectionEndpointId,omitempty"`
	DataCollectionRuleId     *string                `json:"dataCollectionRuleId,omitempty"`
	Description              *string                `json:"description,omitempty"`
	Etag                     *string                `json:"etag,omitempty"`
	Id                       *string                `json:"id,omitempty"`
	Metadata                 *Metadata_STATUS       `json:"metadata,omitempty"`
	Name                     *string                `json:"name,omitempty"`
	PropertyBag              genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	ProvisioningState        *string                `json:"provisioningState,omitempty"`
	SystemData               *SystemData_STATUS     `json:"systemData,omitempty"`
	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 {
	if source == resource {
		return eris.New("attempted conversion between unrelated implementations of github.com/Azure/azure-service-operator/v2/pkg/genruntime/ConvertibleStatus")
	}

	return source.ConvertStatusTo(resource)
}

// ConvertStatusTo populates the provided destination from our DataCollectionRuleAssociationProxyOnlyResource_STATUS
func (resource *DataCollectionRuleAssociationProxyOnlyResource_STATUS) ConvertStatusTo(destination genruntime.ConvertibleStatus) error {
	if destination == resource {
		return eris.New("attempted conversion between unrelated implementations of github.com/Azure/azure-service-operator/v2/pkg/genruntime/ConvertibleStatus")
	}

	return destination.ConvertStatusFrom(resource)
}

// Storage version of v1api20230311.DataCollectionRuleAssociationOperatorSpec
// 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 []*core.DestinationExpression `json:"configMapExpressions,omitempty"`
	PropertyBag          genruntime.PropertyBag        `json:"$propertyBag,omitempty"`
	SecretExpressions    []*core.DestinationExpression `json:"secretExpressions,omitempty"`
}

func init() {
	SchemeBuilder.Register(&DataCollectionRuleAssociation{}, &DataCollectionRuleAssociationList{})
}
