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

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,cache}
// +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 v1api20250401.RedisEnterprise
// Generator information:
// - Generated from: /redisenterprise/resource-manager/Microsoft.Cache/RedisEnterprise/stable/2025-04-01/redisenterprise.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}
type RedisEnterprise struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              RedisEnterprise_Spec   `json:"spec,omitempty"`
	Status            RedisEnterprise_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &RedisEnterprise{}

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

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

var _ configmaps.Exporter = &RedisEnterprise{}

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

var _ secrets.Exporter = &RedisEnterprise{}

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

var _ genruntime.KubernetesResource = &RedisEnterprise{}

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

// GetAPIVersion returns the ARM API version of the resource. This is always "2025-04-01"
func (enterprise RedisEnterprise) GetAPIVersion() string {
	return "2025-04-01"
}

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.Cache/redisEnterprise"
func (enterprise *RedisEnterprise) GetType() string {
	return "Microsoft.Cache/redisEnterprise"
}

// NewEmptyStatus returns a new empty (blank) status
func (enterprise *RedisEnterprise) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &RedisEnterprise_STATUS{}
}

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

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

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

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

	enterprise.Status = st
	return nil
}

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

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

// +kubebuilder:object:root=true
// Storage version of v1api20250401.RedisEnterprise
// Generator information:
// - Generated from: /redisenterprise/resource-manager/Microsoft.Cache/RedisEnterprise/stable/2025-04-01/redisenterprise.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}
type RedisEnterpriseList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []RedisEnterprise `json:"items"`
}

// Storage version of v1api20250401.APIVersion
// +kubebuilder:validation:Enum={"2025-04-01"}
type APIVersion string

const APIVersion_Value = APIVersion("2025-04-01")

// Storage version of v1api20250401.RedisEnterprise_Spec
type RedisEnterprise_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"`
	Encryption        *ClusterProperties_Encryption `json:"encryption,omitempty"`
	HighAvailability  *string                       `json:"highAvailability,omitempty"`
	Identity          *ManagedServiceIdentity       `json:"identity,omitempty"`
	Kind              *string                       `json:"kind,omitempty"`
	Location          *string                       `json:"location,omitempty"`
	MinimumTlsVersion *string                       `json:"minimumTlsVersion,omitempty"`
	OperatorSpec      *RedisEnterpriseOperatorSpec  `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 resources.azure.com/ResourceGroup resource
	Owner       *genruntime.KnownResourceReference `group:"resources.azure.com" json:"owner,omitempty" kind:"ResourceGroup"`
	PropertyBag genruntime.PropertyBag             `json:"$propertyBag,omitempty"`
	Sku         *Sku                               `json:"sku,omitempty"`
	Tags        map[string]string                  `json:"tags,omitempty"`
	Zones       []string                           `json:"zones,omitempty"`
}

var _ genruntime.ConvertibleSpec = &RedisEnterprise_Spec{}

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

	return source.ConvertSpecTo(enterprise)
}

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

	return destination.ConvertSpecFrom(enterprise)
}

// Storage version of v1api20250401.RedisEnterprise_STATUS
type RedisEnterprise_STATUS struct {
	Conditions                 []conditions.Condition               `json:"conditions,omitempty"`
	Encryption                 *ClusterProperties_Encryption_STATUS `json:"encryption,omitempty"`
	HighAvailability           *string                              `json:"highAvailability,omitempty"`
	HostName                   *string                              `json:"hostName,omitempty"`
	Id                         *string                              `json:"id,omitempty"`
	Identity                   *ManagedServiceIdentity_STATUS       `json:"identity,omitempty"`
	Kind                       *string                              `json:"kind,omitempty"`
	Location                   *string                              `json:"location,omitempty"`
	MinimumTlsVersion          *string                              `json:"minimumTlsVersion,omitempty"`
	Name                       *string                              `json:"name,omitempty"`
	PrivateEndpointConnections []PrivateEndpointConnection_STATUS   `json:"privateEndpointConnections,omitempty"`
	PropertyBag                genruntime.PropertyBag               `json:"$propertyBag,omitempty"`
	ProvisioningState          *string                              `json:"provisioningState,omitempty"`
	RedisVersion               *string                              `json:"redisVersion,omitempty"`
	RedundancyMode             *string                              `json:"redundancyMode,omitempty"`
	ResourceState              *string                              `json:"resourceState,omitempty"`
	Sku                        *Sku_STATUS                          `json:"sku,omitempty"`
	Tags                       map[string]string                    `json:"tags,omitempty"`
	Type                       *string                              `json:"type,omitempty"`
	Zones                      []string                             `json:"zones,omitempty"`
}

var _ genruntime.ConvertibleStatus = &RedisEnterprise_STATUS{}

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

	return source.ConvertStatusTo(enterprise)
}

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

	return destination.ConvertStatusFrom(enterprise)
}

// Storage version of v1api20250401.ClusterProperties_Encryption
type ClusterProperties_Encryption struct {
	CustomerManagedKeyEncryption *ClusterProperties_Encryption_CustomerManagedKeyEncryption `json:"customerManagedKeyEncryption,omitempty"`
	PropertyBag                  genruntime.PropertyBag                                     `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20250401.ClusterProperties_Encryption_STATUS
type ClusterProperties_Encryption_STATUS struct {
	CustomerManagedKeyEncryption *ClusterProperties_Encryption_CustomerManagedKeyEncryption_STATUS `json:"customerManagedKeyEncryption,omitempty"`
	PropertyBag                  genruntime.PropertyBag                                            `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20250401.ManagedServiceIdentity
// Managed service identity (system assigned and/or user assigned identities)
type ManagedServiceIdentity struct {
	PropertyBag            genruntime.PropertyBag        `json:"$propertyBag,omitempty"`
	Type                   *string                       `json:"type,omitempty"`
	UserAssignedIdentities []UserAssignedIdentityDetails `json:"userAssignedIdentities,omitempty"`
}

// Storage version of v1api20250401.ManagedServiceIdentity_STATUS
// Managed service identity (system assigned and/or user assigned identities)
type ManagedServiceIdentity_STATUS struct {
	PrincipalId            *string                                `json:"principalId,omitempty"`
	PropertyBag            genruntime.PropertyBag                 `json:"$propertyBag,omitempty"`
	TenantId               *string                                `json:"tenantId,omitempty"`
	Type                   *string                                `json:"type,omitempty"`
	UserAssignedIdentities map[string]UserAssignedIdentity_STATUS `json:"userAssignedIdentities,omitempty"`
}

// Storage version of v1api20250401.PrivateEndpointConnection_STATUS
// The Private Endpoint Connection resource.
type PrivateEndpointConnection_STATUS struct {
	Id          *string                `json:"id,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

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

// Storage version of v1api20250401.Sku
// SKU parameters supplied to the create Redis Enterprise cluster operation.
type Sku struct {
	Capacity    *int                   `json:"capacity,omitempty"`
	Name        *string                `json:"name,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20250401.Sku_STATUS
// SKU parameters supplied to the create Redis Enterprise cluster operation.
type Sku_STATUS struct {
	Capacity    *int                   `json:"capacity,omitempty"`
	Name        *string                `json:"name,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20250401.ClusterProperties_Encryption_CustomerManagedKeyEncryption
type ClusterProperties_Encryption_CustomerManagedKeyEncryption struct {
	KeyEncryptionKeyIdentity *ClusterProperties_Encryption_CustomerManagedKeyEncryption_KeyEncryptionKeyIdentity `json:"keyEncryptionKeyIdentity,omitempty"`
	KeyEncryptionKeyUrl      *string                                                                             `json:"keyEncryptionKeyUrl,omitempty"`
	PropertyBag              genruntime.PropertyBag                                                              `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20250401.ClusterProperties_Encryption_CustomerManagedKeyEncryption_STATUS
type ClusterProperties_Encryption_CustomerManagedKeyEncryption_STATUS struct {
	KeyEncryptionKeyIdentity *ClusterProperties_Encryption_CustomerManagedKeyEncryption_KeyEncryptionKeyIdentity_STATUS `json:"keyEncryptionKeyIdentity,omitempty"`
	KeyEncryptionKeyUrl      *string                                                                                    `json:"keyEncryptionKeyUrl,omitempty"`
	PropertyBag              genruntime.PropertyBag                                                                     `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20250401.UserAssignedIdentity_STATUS
// User assigned identity properties
type UserAssignedIdentity_STATUS struct {
	ClientId    *string                `json:"clientId,omitempty"`
	PrincipalId *string                `json:"principalId,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20250401.UserAssignedIdentityDetails
// Information about the user assigned identity for the resource
type UserAssignedIdentityDetails struct {
	PropertyBag genruntime.PropertyBag       `json:"$propertyBag,omitempty"`
	Reference   genruntime.ResourceReference `armReference:"Reference" json:"reference,omitempty"`
}

// Storage version of v1api20250401.ClusterProperties_Encryption_CustomerManagedKeyEncryption_KeyEncryptionKeyIdentity
type ClusterProperties_Encryption_CustomerManagedKeyEncryption_KeyEncryptionKeyIdentity struct {
	IdentityType *string                `json:"identityType,omitempty"`
	PropertyBag  genruntime.PropertyBag `json:"$propertyBag,omitempty"`

	// UserAssignedIdentityResourceReference: User assigned identity to use for accessing key encryption key Url. Ex:
	// /subscriptions/<sub uuid>/resourceGroups/<resource
	// group>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId.
	UserAssignedIdentityResourceReference *genruntime.ResourceReference `armReference:"UserAssignedIdentityResourceId" json:"userAssignedIdentityResourceReference,omitempty"`
}

// Storage version of v1api20250401.ClusterProperties_Encryption_CustomerManagedKeyEncryption_KeyEncryptionKeyIdentity_STATUS
type ClusterProperties_Encryption_CustomerManagedKeyEncryption_KeyEncryptionKeyIdentity_STATUS struct {
	IdentityType                   *string                `json:"identityType,omitempty"`
	PropertyBag                    genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	UserAssignedIdentityResourceId *string                `json:"userAssignedIdentityResourceId,omitempty"`
}

func init() {
	SchemeBuilder.Register(&RedisEnterprise{}, &RedisEnterpriseList{})
}
