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

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,dbformysql}
// +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 v1api20231230.FlexibleServersAdministrator
// Generator information:
// - Generated from: /mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/AzureADAdministrator.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}
type FlexibleServersAdministrator struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              FlexibleServersAdministrator_Spec   `json:"spec,omitempty"`
	Status            FlexibleServersAdministrator_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &FlexibleServersAdministrator{}

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

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

var _ configmaps.Exporter = &FlexibleServersAdministrator{}

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

var _ secrets.Exporter = &FlexibleServersAdministrator{}

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

var _ genruntime.KubernetesResource = &FlexibleServersAdministrator{}

// AzureName returns the Azure name of the resource (always "ActiveDirectory")
func (administrator *FlexibleServersAdministrator) AzureName() string {
	return "ActiveDirectory"
}

// GetAPIVersion returns the ARM API version of the resource. This is always "2023-12-30"
func (administrator FlexibleServersAdministrator) GetAPIVersion() string {
	return "2023-12-30"
}

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.DBforMySQL/flexibleServers/administrators"
func (administrator *FlexibleServersAdministrator) GetType() string {
	return "Microsoft.DBforMySQL/flexibleServers/administrators"
}

// NewEmptyStatus returns a new empty (blank) status
func (administrator *FlexibleServersAdministrator) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &FlexibleServersAdministrator_STATUS{}
}

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

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

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

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

	administrator.Status = st
	return nil
}

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

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

// +kubebuilder:object:root=true
// Storage version of v1api20231230.FlexibleServersAdministrator
// Generator information:
// - Generated from: /mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/AzureADAdministrator.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}
type FlexibleServersAdministratorList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []FlexibleServersAdministrator `json:"items"`
}

// Storage version of v1api20231230.FlexibleServersAdministrator_Spec
type FlexibleServersAdministrator_Spec struct {
	AdministratorType *string `json:"administratorType,omitempty"`

	// IdentityResourceReference: The resource id of the identity used for AAD Authentication.
	IdentityResourceReference *genruntime.ResourceReference             `armReference:"IdentityResourceId" json:"identityResourceReference,omitempty"`
	Login                     *string                                   `json:"login,omitempty"`
	OperatorSpec              *FlexibleServersAdministratorOperatorSpec `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 dbformysql.azure.com/FlexibleServer resource
	Owner              *genruntime.KnownResourceReference `group:"dbformysql.azure.com" json:"owner,omitempty" kind:"FlexibleServer"`
	PropertyBag        genruntime.PropertyBag             `json:"$propertyBag,omitempty"`
	Sid                *string                            `json:"sid,omitempty" optionalConfigMapPair:"Sid"`
	SidFromConfig      *genruntime.ConfigMapReference     `json:"sidFromConfig,omitempty" optionalConfigMapPair:"Sid"`
	TenantId           *string                            `json:"tenantId,omitempty" optionalConfigMapPair:"TenantId"`
	TenantIdFromConfig *genruntime.ConfigMapReference     `json:"tenantIdFromConfig,omitempty" optionalConfigMapPair:"TenantId"`
}

var _ genruntime.ConvertibleSpec = &FlexibleServersAdministrator_Spec{}

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

	return source.ConvertSpecTo(administrator)
}

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

	return destination.ConvertSpecFrom(administrator)
}

// Storage version of v1api20231230.FlexibleServersAdministrator_STATUS
type FlexibleServersAdministrator_STATUS struct {
	AdministratorType  *string                `json:"administratorType,omitempty"`
	Conditions         []conditions.Condition `json:"conditions,omitempty"`
	Id                 *string                `json:"id,omitempty"`
	IdentityResourceId *string                `json:"identityResourceId,omitempty"`
	Login              *string                `json:"login,omitempty"`
	Name               *string                `json:"name,omitempty"`
	PropertyBag        genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	Sid                *string                `json:"sid,omitempty"`
	SystemData         *SystemData_STATUS     `json:"systemData,omitempty"`
	TenantId           *string                `json:"tenantId,omitempty"`
	Type               *string                `json:"type,omitempty"`
}

var _ genruntime.ConvertibleStatus = &FlexibleServersAdministrator_STATUS{}

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

	return source.ConvertStatusTo(administrator)
}

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

	return destination.ConvertStatusFrom(administrator)
}

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

func init() {
	SchemeBuilder.Register(&FlexibleServersAdministrator{}, &FlexibleServersAdministratorList{})
}
