// 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=kusto.azure.com,resources=principalassignments,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=kusto.azure.com,resources={principalassignments/status,principalassignments/finalizers},verbs=get;update;patch

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,kusto}
// +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 v1api20240413.PrincipalAssignment
// Generator information:
// - Generated from: /azure-kusto/resource-manager/Microsoft.Kusto/Kusto/stable/2024-04-13/kusto.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}
type PrincipalAssignment struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              PrincipalAssignment_Spec   `json:"spec,omitempty"`
	Status            PrincipalAssignment_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &PrincipalAssignment{}

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

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

var _ configmaps.Exporter = &PrincipalAssignment{}

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

var _ secrets.Exporter = &PrincipalAssignment{}

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

var _ genruntime.KubernetesResource = &PrincipalAssignment{}

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

// GetAPIVersion returns the ARM API version of the resource. This is always "2024-04-13"
func (assignment PrincipalAssignment) GetAPIVersion() string {
	return "2024-04-13"
}

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.Kusto/clusters/databases/principalAssignments"
func (assignment *PrincipalAssignment) GetType() string {
	return "Microsoft.Kusto/clusters/databases/principalAssignments"
}

// NewEmptyStatus returns a new empty (blank) status
func (assignment *PrincipalAssignment) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &PrincipalAssignment_STATUS{}
}

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

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

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

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

	assignment.Status = st
	return nil
}

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

// OriginalGVK returns a GroupValueKind for the original API version used to create the resource
func (assignment *PrincipalAssignment) OriginalGVK() *schema.GroupVersionKind {
	return &schema.GroupVersionKind{
		Group:   GroupVersion.Group,
		Version: assignment.Spec.OriginalVersion,
		Kind:    "PrincipalAssignment",
	}
}

// +kubebuilder:object:root=true
// Storage version of v1api20240413.PrincipalAssignment
// Generator information:
// - Generated from: /azure-kusto/resource-manager/Microsoft.Kusto/Kusto/stable/2024-04-13/kusto.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}
type PrincipalAssignmentList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []PrincipalAssignment `json:"items"`
}

// Storage version of v1api20240413.PrincipalAssignment_Spec
type PrincipalAssignment_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"`
	OperatorSpec    *PrincipalAssignmentOperatorSpec `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. Owner is expected to be a
	// reference to a kusto.azure.com/Database resource
	Owner                 *genruntime.KnownResourceReference `group:"kusto.azure.com" json:"owner,omitempty" kind:"Database"`
	PrincipalId           *string                            `json:"principalId,omitempty" optionalConfigMapPair:"PrincipalId"`
	PrincipalIdFromConfig *genruntime.ConfigMapReference     `json:"principalIdFromConfig,omitempty" optionalConfigMapPair:"PrincipalId"`
	PrincipalType         *string                            `json:"principalType,omitempty"`
	PropertyBag           genruntime.PropertyBag             `json:"$propertyBag,omitempty"`
	Role                  *string                            `json:"role,omitempty"`
	TenantId              *string                            `json:"tenantId,omitempty" optionalConfigMapPair:"TenantId"`
	TenantIdFromConfig    *genruntime.ConfigMapReference     `json:"tenantIdFromConfig,omitempty" optionalConfigMapPair:"TenantId"`
}

var _ genruntime.ConvertibleSpec = &PrincipalAssignment_Spec{}

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

	return source.ConvertSpecTo(assignment)
}

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

	return destination.ConvertSpecFrom(assignment)
}

// Storage version of v1api20240413.PrincipalAssignment_STATUS
type PrincipalAssignment_STATUS struct {
	AadObjectId       *string                `json:"aadObjectId,omitempty"`
	Conditions        []conditions.Condition `json:"conditions,omitempty"`
	Id                *string                `json:"id,omitempty"`
	Name              *string                `json:"name,omitempty"`
	PrincipalId       *string                `json:"principalId,omitempty"`
	PrincipalName     *string                `json:"principalName,omitempty"`
	PrincipalType     *string                `json:"principalType,omitempty"`
	PropertyBag       genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	ProvisioningState *string                `json:"provisioningState,omitempty"`
	Role              *string                `json:"role,omitempty"`
	TenantId          *string                `json:"tenantId,omitempty"`
	TenantName        *string                `json:"tenantName,omitempty"`
	Type              *string                `json:"type,omitempty"`
}

var _ genruntime.ConvertibleStatus = &PrincipalAssignment_STATUS{}

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

	return source.ConvertStatusTo(assignment)
}

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

	return destination.ConvertStatusFrom(assignment)
}

// Storage version of v1api20240413.PrincipalAssignmentOperatorSpec
// Details for configuring operator behavior. Fields in this struct are interpreted by the operator directly rather than being passed to Azure
type PrincipalAssignmentOperatorSpec struct {
	ConfigMapExpressions []*core.DestinationExpression `json:"configMapExpressions,omitempty"`
	PropertyBag          genruntime.PropertyBag        `json:"$propertyBag,omitempty"`
	SecretExpressions    []*core.DestinationExpression `json:"secretExpressions,omitempty"`
}

func init() {
	SchemeBuilder.Register(&PrincipalAssignment{}, &PrincipalAssignmentList{})
}
