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

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,cognitiveservices}
// +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 v1api20250601.Deployment
// Generator information:
// - Generated from: /cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2025-06-01/cognitiveservices.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}
type Deployment struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              Deployment_Spec   `json:"spec,omitempty"`
	Status            Deployment_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &Deployment{}

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

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

var _ configmaps.Exporter = &Deployment{}

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

var _ secrets.Exporter = &Deployment{}

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

var _ genruntime.KubernetesResource = &Deployment{}

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

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

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.CognitiveServices/accounts/deployments"
func (deployment *Deployment) GetType() string {
	return "Microsoft.CognitiveServices/accounts/deployments"
}

// NewEmptyStatus returns a new empty (blank) status
func (deployment *Deployment) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &Deployment_STATUS{}
}

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

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

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

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

	deployment.Status = st
	return nil
}

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

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

// +kubebuilder:object:root=true
// Storage version of v1api20250601.Deployment
// Generator information:
// - Generated from: /cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2025-06-01/cognitiveservices.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}
type DeploymentList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []Deployment `json:"items"`
}

// Storage version of v1api20250601.Deployment_Spec
type Deployment_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    *DeploymentOperatorSpec `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 cognitiveservices.azure.com/Account resource
	Owner       *genruntime.KnownResourceReference `group:"cognitiveservices.azure.com" json:"owner,omitempty" kind:"Account"`
	Properties  *DeploymentProperties              `json:"properties,omitempty"`
	PropertyBag genruntime.PropertyBag             `json:"$propertyBag,omitempty"`
	Sku         *Sku                               `json:"sku,omitempty"`
	Tags        map[string]string                  `json:"tags,omitempty"`
}

var _ genruntime.ConvertibleSpec = &Deployment_Spec{}

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

	return source.ConvertSpecTo(deployment)
}

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

	return destination.ConvertSpecFrom(deployment)
}

// Storage version of v1api20250601.Deployment_STATUS
type Deployment_STATUS struct {
	Conditions  []conditions.Condition       `json:"conditions,omitempty"`
	Etag        *string                      `json:"etag,omitempty"`
	Id          *string                      `json:"id,omitempty"`
	Name        *string                      `json:"name,omitempty"`
	Properties  *DeploymentProperties_STATUS `json:"properties,omitempty"`
	PropertyBag genruntime.PropertyBag       `json:"$propertyBag,omitempty"`
	Sku         *Sku_STATUS                  `json:"sku,omitempty"`
	SystemData  *SystemData_STATUS           `json:"systemData,omitempty"`
	Tags        map[string]string            `json:"tags,omitempty"`
	Type        *string                      `json:"type,omitempty"`
}

var _ genruntime.ConvertibleStatus = &Deployment_STATUS{}

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

	return source.ConvertStatusTo(deployment)
}

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

	return destination.ConvertStatusFrom(deployment)
}

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

// Storage version of v1api20250601.DeploymentProperties
// Properties of Cognitive Services account deployment.
type DeploymentProperties struct {
	CapacitySettings        *DeploymentCapacitySettings `json:"capacitySettings,omitempty"`
	Model                   *DeploymentModel            `json:"model,omitempty"`
	ParentDeploymentName    *string                     `json:"parentDeploymentName,omitempty"`
	PropertyBag             genruntime.PropertyBag      `json:"$propertyBag,omitempty"`
	RaiPolicyName           *string                     `json:"raiPolicyName,omitempty"`
	ScaleSettings           *DeploymentScaleSettings    `json:"scaleSettings,omitempty"`
	SpilloverDeploymentName *string                     `json:"spilloverDeploymentName,omitempty"`
	VersionUpgradeOption    *string                     `json:"versionUpgradeOption,omitempty"`
}

// Storage version of v1api20250601.DeploymentProperties_STATUS
// Properties of Cognitive Services account deployment.
type DeploymentProperties_STATUS struct {
	CallRateLimit            *CallRateLimit_STATUS              `json:"callRateLimit,omitempty"`
	Capabilities             map[string]string                  `json:"capabilities,omitempty"`
	CapacitySettings         *DeploymentCapacitySettings_STATUS `json:"capacitySettings,omitempty"`
	CurrentCapacity          *int                               `json:"currentCapacity,omitempty"`
	DynamicThrottlingEnabled *bool                              `json:"dynamicThrottlingEnabled,omitempty"`
	Model                    *DeploymentModel_STATUS            `json:"model,omitempty"`
	ParentDeploymentName     *string                            `json:"parentDeploymentName,omitempty"`
	PropertyBag              genruntime.PropertyBag             `json:"$propertyBag,omitempty"`
	ProvisioningState        *string                            `json:"provisioningState,omitempty"`
	RaiPolicyName            *string                            `json:"raiPolicyName,omitempty"`
	RateLimits               []ThrottlingRule_STATUS            `json:"rateLimits,omitempty"`
	ScaleSettings            *DeploymentScaleSettings_STATUS    `json:"scaleSettings,omitempty"`
	SpilloverDeploymentName  *string                            `json:"spilloverDeploymentName,omitempty"`
	VersionUpgradeOption     *string                            `json:"versionUpgradeOption,omitempty"`
}

// Storage version of v1api20250601.DeploymentCapacitySettings
// Internal use only.
type DeploymentCapacitySettings struct {
	DesignatedCapacity *int                   `json:"designatedCapacity,omitempty"`
	Priority           *int                   `json:"priority,omitempty"`
	PropertyBag        genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20250601.DeploymentCapacitySettings_STATUS
// Internal use only.
type DeploymentCapacitySettings_STATUS struct {
	DesignatedCapacity *int                   `json:"designatedCapacity,omitempty"`
	Priority           *int                   `json:"priority,omitempty"`
	PropertyBag        genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20250601.DeploymentModel
// Properties of Cognitive Services account deployment model.
type DeploymentModel struct {
	Format              *string                        `json:"format,omitempty" optionalConfigMapPair:"Format"`
	FormatFromConfig    *genruntime.ConfigMapReference `json:"formatFromConfig,omitempty" optionalConfigMapPair:"Format"`
	Name                *string                        `json:"name,omitempty" optionalConfigMapPair:"Name"`
	NameFromConfig      *genruntime.ConfigMapReference `json:"nameFromConfig,omitempty" optionalConfigMapPair:"Name"`
	PropertyBag         genruntime.PropertyBag         `json:"$propertyBag,omitempty"`
	Publisher           *string                        `json:"publisher,omitempty" optionalConfigMapPair:"Publisher"`
	PublisherFromConfig *genruntime.ConfigMapReference `json:"publisherFromConfig,omitempty" optionalConfigMapPair:"Publisher"`

	// SourceAccountReference: Optional. Source of the model, another Microsoft.CognitiveServices accounts ARM resource ID.
	SourceAccountReference *genruntime.ResourceReference `armReference:"SourceAccount" json:"sourceAccountReference,omitempty"`

	// SourceReference: Optional. Deployment model source ARM resource ID.
	SourceReference   *genruntime.ResourceReference  `armReference:"Source" json:"sourceReference,omitempty"`
	Version           *string                        `json:"version,omitempty" optionalConfigMapPair:"Version"`
	VersionFromConfig *genruntime.ConfigMapReference `json:"versionFromConfig,omitempty" optionalConfigMapPair:"Version"`
}

// Storage version of v1api20250601.DeploymentModel_STATUS
// Properties of Cognitive Services account deployment model.
type DeploymentModel_STATUS struct {
	CallRateLimit *CallRateLimit_STATUS  `json:"callRateLimit,omitempty"`
	Format        *string                `json:"format,omitempty"`
	Name          *string                `json:"name,omitempty"`
	PropertyBag   genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	Publisher     *string                `json:"publisher,omitempty"`
	Source        *string                `json:"source,omitempty"`
	SourceAccount *string                `json:"sourceAccount,omitempty"`
	Version       *string                `json:"version,omitempty"`
}

// Storage version of v1api20250601.DeploymentScaleSettings
// Properties of Cognitive Services account deployment model. (Deprecated, please use Deployment.sku instead.)
type DeploymentScaleSettings struct {
	Capacity    *int                   `json:"capacity,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	ScaleType   *string                `json:"scaleType,omitempty"`
}

// Storage version of v1api20250601.DeploymentScaleSettings_STATUS
// Properties of Cognitive Services account deployment model. (Deprecated, please use Deployment.sku instead.)
type DeploymentScaleSettings_STATUS struct {
	ActiveCapacity *int                   `json:"activeCapacity,omitempty"`
	Capacity       *int                   `json:"capacity,omitempty"`
	PropertyBag    genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	ScaleType      *string                `json:"scaleType,omitempty"`
}

// Storage version of v1api20250601.ThrottlingRule_STATUS
type ThrottlingRule_STATUS struct {
	Count                    *float64                     `json:"count,omitempty"`
	DynamicThrottlingEnabled *bool                        `json:"dynamicThrottlingEnabled,omitempty"`
	Key                      *string                      `json:"key,omitempty"`
	MatchPatterns            []RequestMatchPattern_STATUS `json:"matchPatterns,omitempty"`
	MinCount                 *float64                     `json:"minCount,omitempty"`
	PropertyBag              genruntime.PropertyBag       `json:"$propertyBag,omitempty"`
	RenewalPeriod            *float64                     `json:"renewalPeriod,omitempty"`
}

// Storage version of v1api20250601.RequestMatchPattern_STATUS
type RequestMatchPattern_STATUS struct {
	Method      *string                `json:"method,omitempty"`
	Path        *string                `json:"path,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

func init() {
	SchemeBuilder.Register(&Deployment{}, &DeploymentList{})
}
