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

import (
	storage "github.com/Azure/azure-service-operator/v2/api/documentdb/v1api20240815/storage"
	"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=documentdb.azure.com,resources=mongoclusters,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=documentdb.azure.com,resources={mongoclusters/status,mongoclusters/finalizers},verbs=get;update;patch

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,documentdb}
// +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 v1api20240701.MongoCluster
// Generator information:
// - Generated from: /mongocluster/resource-manager/Microsoft.DocumentDB/MongoCluster/stable/2024-07-01/mongoCluster.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}
type MongoCluster struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              MongoCluster_Spec   `json:"spec,omitempty"`
	Status            MongoCluster_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &MongoCluster{}

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

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

var _ configmaps.Exporter = &MongoCluster{}

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

var _ secrets.Exporter = &MongoCluster{}

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

var _ genruntime.KubernetesResource = &MongoCluster{}

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

// GetAPIVersion returns the ARM API version of the resource. This is always "2024-07-01"
func (cluster MongoCluster) GetAPIVersion() string {
	return "2024-07-01"
}

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.DocumentDB/mongoClusters"
func (cluster *MongoCluster) GetType() string {
	return "Microsoft.DocumentDB/mongoClusters"
}

// NewEmptyStatus returns a new empty (blank) status
func (cluster *MongoCluster) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &MongoCluster_STATUS{}
}

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

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

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

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

	cluster.Status = st
	return nil
}

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

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

// +kubebuilder:object:root=true
// Storage version of v1api20240701.MongoCluster
// Generator information:
// - Generated from: /mongocluster/resource-manager/Microsoft.DocumentDB/MongoCluster/stable/2024-07-01/mongoCluster.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}
type MongoClusterList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []MongoCluster `json:"items"`
}

// Storage version of v1api20240701.MongoCluster_Spec
type MongoCluster_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"`
	Location        *string                   `json:"location,omitempty"`
	OperatorSpec    *MongoClusterOperatorSpec `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"`
	Properties  *MongoClusterProperties            `json:"properties,omitempty"`
	PropertyBag genruntime.PropertyBag             `json:"$propertyBag,omitempty"`
	Tags        map[string]string                  `json:"tags,omitempty"`
}

var _ genruntime.ConvertibleSpec = &MongoCluster_Spec{}

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

	return source.ConvertSpecTo(cluster)
}

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

	return destination.ConvertSpecFrom(cluster)
}

// Storage version of v1api20240701.MongoCluster_STATUS
// Represents a mongo cluster resource.
type MongoCluster_STATUS struct {
	Conditions  []conditions.Condition         `json:"conditions,omitempty"`
	Id          *string                        `json:"id,omitempty"`
	Location    *string                        `json:"location,omitempty"`
	Name        *string                        `json:"name,omitempty"`
	Properties  *MongoClusterProperties_STATUS `json:"properties,omitempty"`
	PropertyBag genruntime.PropertyBag         `json:"$propertyBag,omitempty"`
	SystemData  *SystemData_STATUS             `json:"systemData,omitempty"`
	Tags        map[string]string              `json:"tags,omitempty"`
	Type        *string                        `json:"type,omitempty"`
}

var _ genruntime.ConvertibleStatus = &MongoCluster_STATUS{}

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

	return source.ConvertStatusTo(cluster)
}

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

	return destination.ConvertStatusFrom(cluster)
}

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

// Storage version of v1api20240701.MongoClusterProperties
// The properties of a mongo cluster.
type MongoClusterProperties struct {
	Administrator       *AdministratorProperties       `json:"administrator,omitempty"`
	Compute             *ComputeProperties             `json:"compute,omitempty"`
	CreateMode          *string                        `json:"createMode,omitempty"`
	HighAvailability    *HighAvailabilityProperties    `json:"highAvailability,omitempty"`
	PreviewFeatures     []string                       `json:"previewFeatures,omitempty"`
	PropertyBag         genruntime.PropertyBag         `json:"$propertyBag,omitempty"`
	PublicNetworkAccess *string                        `json:"publicNetworkAccess,omitempty"`
	ReplicaParameters   *MongoClusterReplicaParameters `json:"replicaParameters,omitempty"`
	RestoreParameters   *MongoClusterRestoreParameters `json:"restoreParameters,omitempty"`
	ServerVersion       *string                        `json:"serverVersion,omitempty"`
	Sharding            *ShardingProperties            `json:"sharding,omitempty"`
	Storage             *StorageProperties             `json:"storage,omitempty"`
}

// Storage version of v1api20240701.MongoClusterProperties_STATUS
// The properties of a mongo cluster.
type MongoClusterProperties_STATUS struct {
	Administrator              *AdministratorProperties_STATUS       `json:"administrator,omitempty"`
	Backup                     *BackupProperties_STATUS              `json:"backup,omitempty"`
	ClusterStatus              *string                               `json:"clusterStatus,omitempty"`
	Compute                    *ComputeProperties_STATUS             `json:"compute,omitempty"`
	ConnectionString           *string                               `json:"connectionString,omitempty"`
	CreateMode                 *string                               `json:"createMode,omitempty"`
	HighAvailability           *HighAvailabilityProperties_STATUS    `json:"highAvailability,omitempty"`
	InfrastructureVersion      *string                               `json:"infrastructureVersion,omitempty"`
	PreviewFeatures            []string                              `json:"previewFeatures,omitempty"`
	PrivateEndpointConnections []PrivateEndpointConnection_STATUS    `json:"privateEndpointConnections,omitempty"`
	PropertyBag                genruntime.PropertyBag                `json:"$propertyBag,omitempty"`
	ProvisioningState          *string                               `json:"provisioningState,omitempty"`
	PublicNetworkAccess        *string                               `json:"publicNetworkAccess,omitempty"`
	Replica                    *ReplicationProperties_STATUS         `json:"replica,omitempty"`
	ReplicaParameters          *MongoClusterReplicaParameters_STATUS `json:"replicaParameters,omitempty"`
	RestoreParameters          *MongoClusterRestoreParameters_STATUS `json:"restoreParameters,omitempty"`
	ServerVersion              *string                               `json:"serverVersion,omitempty"`
	Sharding                   *ShardingProperties_STATUS            `json:"sharding,omitempty"`
	Storage                    *StorageProperties_STATUS             `json:"storage,omitempty"`
}

// Storage version of v1api20240701.AdministratorProperties
// The local administrator login properties.
type AdministratorProperties struct {
	Password    *genruntime.SecretReference `json:"password,omitempty"`
	PropertyBag genruntime.PropertyBag      `json:"$propertyBag,omitempty"`
	UserName    *string                     `json:"userName,omitempty"`
}

// Storage version of v1api20240701.AdministratorProperties_STATUS
// The local administrator login properties.
type AdministratorProperties_STATUS struct {
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	UserName    *string                `json:"userName,omitempty"`
}

// Storage version of v1api20240701.BackupProperties_STATUS
// The backup properties of the cluster. This includes the earliest restore time and retention settings.
type BackupProperties_STATUS struct {
	EarliestRestoreTime *string                `json:"earliestRestoreTime,omitempty"`
	PropertyBag         genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20240701.ComputeProperties
// The compute properties of the cluster. This includes the virtual-cores/memory and scaling options applied to servers in
// the cluster.
type ComputeProperties struct {
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	Tier        *string                `json:"tier,omitempty"`
}

// Storage version of v1api20240701.ComputeProperties_STATUS
// The compute properties of the cluster. This includes the virtual-cores/memory and scaling options applied to servers in
// the cluster.
type ComputeProperties_STATUS struct {
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	Tier        *string                `json:"tier,omitempty"`
}

// Storage version of v1api20240701.HighAvailabilityProperties
// The high availability properties of the cluster.
type HighAvailabilityProperties struct {
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	TargetMode  *string                `json:"targetMode,omitempty"`
}

// Storage version of v1api20240701.HighAvailabilityProperties_STATUS
// The high availability properties of the cluster.
type HighAvailabilityProperties_STATUS struct {
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	TargetMode  *string                `json:"targetMode,omitempty"`
}

// Storage version of v1api20240701.MongoClusterReplicaParameters
// Parameters used for replica operations.
type MongoClusterReplicaParameters struct {
	PropertyBag    genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	SourceLocation *string                `json:"sourceLocation,omitempty"`

	// +kubebuilder:validation:Required
	// SourceResourceReference: The id of the replication source cluster.
	SourceResourceReference *genruntime.ResourceReference `armReference:"SourceResourceId" json:"sourceResourceReference,omitempty"`
}

// Storage version of v1api20240701.MongoClusterReplicaParameters_STATUS
// Parameters used for replica operations.
type MongoClusterReplicaParameters_STATUS struct {
	PropertyBag      genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	SourceLocation   *string                `json:"sourceLocation,omitempty"`
	SourceResourceId *string                `json:"sourceResourceId,omitempty"`
}

// Storage version of v1api20240701.MongoClusterRestoreParameters
// Parameters used for restore operations
type MongoClusterRestoreParameters struct {
	PointInTimeUTC *string                `json:"pointInTimeUTC,omitempty"`
	PropertyBag    genruntime.PropertyBag `json:"$propertyBag,omitempty"`

	// SourceResourceReference: Resource ID to locate the source cluster to restore
	SourceResourceReference *genruntime.ResourceReference `armReference:"SourceResourceId" json:"sourceResourceReference,omitempty"`
}

// Storage version of v1api20240701.MongoClusterRestoreParameters_STATUS
// Parameters used for restore operations
type MongoClusterRestoreParameters_STATUS struct {
	PointInTimeUTC   *string                `json:"pointInTimeUTC,omitempty"`
	PropertyBag      genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	SourceResourceId *string                `json:"sourceResourceId,omitempty"`
}

// Storage version of v1api20240701.PrivateEndpointConnection_STATUS
// The private endpoint connection resource.
type PrivateEndpointConnection_STATUS struct {
	Id          *string                `json:"id,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// AssignProperties_From_PrivateEndpointConnection_STATUS populates our PrivateEndpointConnection_STATUS from the provided source PrivateEndpointConnection_STATUS
func (connection *PrivateEndpointConnection_STATUS) AssignProperties_From_PrivateEndpointConnection_STATUS(source *storage.PrivateEndpointConnection_STATUS) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(source.PropertyBag)

	// Id
	connection.Id = genruntime.ClonePointerToString(source.Id)

	// Update the property bag
	if len(propertyBag) > 0 {
		connection.PropertyBag = propertyBag
	} else {
		connection.PropertyBag = nil
	}

	// Invoke the augmentConversionForPrivateEndpointConnection_STATUS interface (if implemented) to customize the conversion
	var connectionAsAny any = connection
	if augmentedConnection, ok := connectionAsAny.(augmentConversionForPrivateEndpointConnection_STATUS); ok {
		err := augmentedConnection.AssignPropertiesFrom(source)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesFrom() for conversion")
		}
	}

	// No error
	return nil
}

// AssignProperties_To_PrivateEndpointConnection_STATUS populates the provided destination PrivateEndpointConnection_STATUS from our PrivateEndpointConnection_STATUS
func (connection *PrivateEndpointConnection_STATUS) AssignProperties_To_PrivateEndpointConnection_STATUS(destination *storage.PrivateEndpointConnection_STATUS) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(connection.PropertyBag)

	// Id
	destination.Id = genruntime.ClonePointerToString(connection.Id)

	// Update the property bag
	if len(propertyBag) > 0 {
		destination.PropertyBag = propertyBag
	} else {
		destination.PropertyBag = nil
	}

	// Invoke the augmentConversionForPrivateEndpointConnection_STATUS interface (if implemented) to customize the conversion
	var connectionAsAny any = connection
	if augmentedConnection, ok := connectionAsAny.(augmentConversionForPrivateEndpointConnection_STATUS); ok {
		err := augmentedConnection.AssignPropertiesTo(destination)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesTo() for conversion")
		}
	}

	// No error
	return nil
}

// Storage version of v1api20240701.ReplicationProperties_STATUS
// Replica properties of the mongo cluster.
type ReplicationProperties_STATUS struct {
	PropertyBag      genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	ReplicationState *string                `json:"replicationState,omitempty"`
	Role             *string                `json:"role,omitempty"`
	SourceResourceId *string                `json:"sourceResourceId,omitempty"`
}

// Storage version of v1api20240701.ShardingProperties
// The sharding properties of the cluster. This includes the shard count and scaling options for the cluster.
type ShardingProperties struct {
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	ShardCount  *int                   `json:"shardCount,omitempty"`
}

// Storage version of v1api20240701.ShardingProperties_STATUS
// The sharding properties of the cluster. This includes the shard count and scaling options for the cluster.
type ShardingProperties_STATUS struct {
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	ShardCount  *int                   `json:"shardCount,omitempty"`
}

// Storage version of v1api20240701.StorageProperties
// The storage properties of the cluster. This includes the data storage size and scaling applied to servers in the cluster.
type StorageProperties struct {
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	SizeGb      *int                   `json:"sizeGb,omitempty"`
}

// Storage version of v1api20240701.StorageProperties_STATUS
// The storage properties of the cluster. This includes the data storage size and scaling applied to servers in the cluster.
type StorageProperties_STATUS struct {
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	SizeGb      *int                   `json:"sizeGb,omitempty"`
}

type augmentConversionForPrivateEndpointConnection_STATUS interface {
	AssignPropertiesFrom(src *storage.PrivateEndpointConnection_STATUS) error
	AssignPropertiesTo(dst *storage.PrivateEndpointConnection_STATUS) error
}

func init() {
	SchemeBuilder.Register(&MongoCluster{}, &MongoClusterList{})
}
