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

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,sql}
// +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 v1api20211101.ServersAuditingSetting
// Generator information:
// - Generated from: /sql/resource-manager/Microsoft.Sql/stable/2021-11-01/BlobAuditing.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/auditingSettings/default
type ServersAuditingSetting struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              ServersAuditingSetting_Spec   `json:"spec,omitempty"`
	Status            ServersAuditingSetting_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &ServersAuditingSetting{}

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

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

var _ configmaps.Exporter = &ServersAuditingSetting{}

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

var _ secrets.Exporter = &ServersAuditingSetting{}

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

var _ genruntime.KubernetesResource = &ServersAuditingSetting{}

// AzureName returns the Azure name of the resource (always "default")
func (setting *ServersAuditingSetting) AzureName() string {
	return "default"
}

// GetAPIVersion returns the ARM API version of the resource. This is always "2021-11-01"
func (setting ServersAuditingSetting) GetAPIVersion() string {
	return "2021-11-01"
}

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.Sql/servers/auditingSettings"
func (setting *ServersAuditingSetting) GetType() string {
	return "Microsoft.Sql/servers/auditingSettings"
}

// NewEmptyStatus returns a new empty (blank) status
func (setting *ServersAuditingSetting) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &ServersAuditingSetting_STATUS{}
}

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

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

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

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

	setting.Status = st
	return nil
}

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

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

// +kubebuilder:object:root=true
// Storage version of v1api20211101.ServersAuditingSetting
// Generator information:
// - Generated from: /sql/resource-manager/Microsoft.Sql/stable/2021-11-01/BlobAuditing.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/auditingSettings/default
type ServersAuditingSettingList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []ServersAuditingSetting `json:"items"`
}

// Storage version of v1api20211101.ServersAuditingSetting_Spec
type ServersAuditingSetting_Spec struct {
	AuditActionsAndGroups       []string                            `json:"auditActionsAndGroups,omitempty"`
	IsAzureMonitorTargetEnabled *bool                               `json:"isAzureMonitorTargetEnabled,omitempty"`
	IsDevopsAuditEnabled        *bool                               `json:"isDevopsAuditEnabled,omitempty"`
	IsManagedIdentityInUse      *bool                               `json:"isManagedIdentityInUse,omitempty"`
	IsStorageSecondaryKeyInUse  *bool                               `json:"isStorageSecondaryKeyInUse,omitempty"`
	OperatorSpec                *ServersAuditingSettingOperatorSpec `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 sql.azure.com/Server resource
	Owner                        *genruntime.KnownResourceReference `group:"sql.azure.com" json:"owner,omitempty" kind:"Server"`
	PropertyBag                  genruntime.PropertyBag             `json:"$propertyBag,omitempty"`
	QueueDelayMs                 *int                               `json:"queueDelayMs,omitempty"`
	RetentionDays                *int                               `json:"retentionDays,omitempty"`
	State                        *string                            `json:"state,omitempty"`
	StorageAccountAccessKey      *genruntime.SecretReference        `json:"storageAccountAccessKey,omitempty"`
	StorageAccountSubscriptionId *string                            `json:"storageAccountSubscriptionId,omitempty"`
	StorageEndpoint              *string                            `json:"storageEndpoint,omitempty"`
}

var _ genruntime.ConvertibleSpec = &ServersAuditingSetting_Spec{}

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

	return source.ConvertSpecTo(setting)
}

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

	return destination.ConvertSpecFrom(setting)
}

// Storage version of v1api20211101.ServersAuditingSetting_STATUS
type ServersAuditingSetting_STATUS struct {
	AuditActionsAndGroups        []string               `json:"auditActionsAndGroups,omitempty"`
	Conditions                   []conditions.Condition `json:"conditions,omitempty"`
	Id                           *string                `json:"id,omitempty"`
	IsAzureMonitorTargetEnabled  *bool                  `json:"isAzureMonitorTargetEnabled,omitempty"`
	IsDevopsAuditEnabled         *bool                  `json:"isDevopsAuditEnabled,omitempty"`
	IsManagedIdentityInUse       *bool                  `json:"isManagedIdentityInUse,omitempty"`
	IsStorageSecondaryKeyInUse   *bool                  `json:"isStorageSecondaryKeyInUse,omitempty"`
	Name                         *string                `json:"name,omitempty"`
	PropertyBag                  genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	QueueDelayMs                 *int                   `json:"queueDelayMs,omitempty"`
	RetentionDays                *int                   `json:"retentionDays,omitempty"`
	State                        *string                `json:"state,omitempty"`
	StorageAccountSubscriptionId *string                `json:"storageAccountSubscriptionId,omitempty"`
	StorageEndpoint              *string                `json:"storageEndpoint,omitempty"`
	Type                         *string                `json:"type,omitempty"`
}

var _ genruntime.ConvertibleStatus = &ServersAuditingSetting_STATUS{}

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

	return source.ConvertStatusTo(setting)
}

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

	return destination.ConvertStatusFrom(setting)
}

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

func init() {
	SchemeBuilder.Register(&ServersAuditingSetting{}, &ServersAuditingSettingList{})
}
