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

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,compute}
// +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 v1api20240302.Snapshot
// Generator information:
// - Generated from: /compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/DiskRP.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}
type Snapshot struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              Snapshot_Spec   `json:"spec,omitempty"`
	Status            Snapshot_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &Snapshot{}

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

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

var _ configmaps.Exporter = &Snapshot{}

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

var _ secrets.Exporter = &Snapshot{}

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

var _ genruntime.KubernetesResource = &Snapshot{}

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

// GetAPIVersion returns the ARM API version of the resource. This is always "2024-03-02"
func (snapshot Snapshot) GetAPIVersion() string {
	return "2024-03-02"
}

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.Compute/snapshots"
func (snapshot *Snapshot) GetType() string {
	return "Microsoft.Compute/snapshots"
}

// NewEmptyStatus returns a new empty (blank) status
func (snapshot *Snapshot) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &Snapshot_STATUS{}
}

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

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

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

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

	snapshot.Status = st
	return nil
}

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

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

// +kubebuilder:object:root=true
// Storage version of v1api20240302.Snapshot
// Generator information:
// - Generated from: /compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/DiskRP.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}
type SnapshotList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []Snapshot `json:"items"`
}

// Storage version of v1api20240302.Snapshot_Spec
type Snapshot_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"`
	CompletionPercent   *float64             `json:"completionPercent,omitempty"`
	CopyCompletionError *CopyCompletionError `json:"copyCompletionError,omitempty"`
	CreationData        *CreationData        `json:"creationData,omitempty"`
	DataAccessAuthMode  *string              `json:"dataAccessAuthMode,omitempty"`

	// DiskAccessReference: ARM id of the DiskAccess resource for using private endpoints on disks.
	DiskAccessReference          *genruntime.ResourceReference `armReference:"DiskAccessId" json:"diskAccessReference,omitempty"`
	DiskSizeGB                   *int                          `json:"diskSizeGB,omitempty"`
	Encryption                   *Encryption                   `json:"encryption,omitempty"`
	EncryptionSettingsCollection *EncryptionSettingsCollection `json:"encryptionSettingsCollection,omitempty"`
	ExtendedLocation             *ExtendedLocation             `json:"extendedLocation,omitempty"`
	HyperVGeneration             *string                       `json:"hyperVGeneration,omitempty"`
	Incremental                  *bool                         `json:"incremental,omitempty"`
	Location                     *string                       `json:"location,omitempty"`
	NetworkAccessPolicy          *string                       `json:"networkAccessPolicy,omitempty"`
	OperatorSpec                 *SnapshotOperatorSpec         `json:"operatorSpec,omitempty"`
	OriginalVersion              string                        `json:"originalVersion,omitempty"`
	OsType                       *string                       `json:"osType,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"`
	PublicNetworkAccess   *string                            `json:"publicNetworkAccess,omitempty"`
	PurchasePlan          *DiskPurchasePlan                  `json:"purchasePlan,omitempty"`
	SecurityProfile       *DiskSecurityProfile               `json:"securityProfile,omitempty"`
	Sku                   *SnapshotSku                       `json:"sku,omitempty"`
	SupportedCapabilities *SupportedCapabilities             `json:"supportedCapabilities,omitempty"`
	SupportsHibernation   *bool                              `json:"supportsHibernation,omitempty"`
	Tags                  map[string]string                  `json:"tags,omitempty"`
}

var _ genruntime.ConvertibleSpec = &Snapshot_Spec{}

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

	return source.ConvertSpecTo(snapshot)
}

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

	return destination.ConvertSpecFrom(snapshot)
}

// Storage version of v1api20240302.Snapshot_STATUS
// Snapshot resource.
type Snapshot_STATUS struct {
	CompletionPercent            *float64                             `json:"completionPercent,omitempty"`
	Conditions                   []conditions.Condition               `json:"conditions,omitempty"`
	CopyCompletionError          *CopyCompletionError_STATUS          `json:"copyCompletionError,omitempty"`
	CreationData                 *CreationData_STATUS                 `json:"creationData,omitempty"`
	DataAccessAuthMode           *string                              `json:"dataAccessAuthMode,omitempty"`
	DiskAccessId                 *string                              `json:"diskAccessId,omitempty"`
	DiskSizeBytes                *int                                 `json:"diskSizeBytes,omitempty"`
	DiskSizeGB                   *int                                 `json:"diskSizeGB,omitempty"`
	DiskState                    *string                              `json:"diskState,omitempty"`
	Encryption                   *Encryption_STATUS                   `json:"encryption,omitempty"`
	EncryptionSettingsCollection *EncryptionSettingsCollection_STATUS `json:"encryptionSettingsCollection,omitempty"`
	ExtendedLocation             *ExtendedLocation_STATUS             `json:"extendedLocation,omitempty"`
	HyperVGeneration             *string                              `json:"hyperVGeneration,omitempty"`
	Id                           *string                              `json:"id,omitempty"`
	Incremental                  *bool                                `json:"incremental,omitempty"`
	IncrementalSnapshotFamilyId  *string                              `json:"incrementalSnapshotFamilyId,omitempty"`
	Location                     *string                              `json:"location,omitempty"`
	ManagedBy                    *string                              `json:"managedBy,omitempty"`
	Name                         *string                              `json:"name,omitempty"`
	NetworkAccessPolicy          *string                              `json:"networkAccessPolicy,omitempty"`
	OsType                       *string                              `json:"osType,omitempty"`
	PropertyBag                  genruntime.PropertyBag               `json:"$propertyBag,omitempty"`
	ProvisioningState            *string                              `json:"provisioningState,omitempty"`
	PublicNetworkAccess          *string                              `json:"publicNetworkAccess,omitempty"`
	PurchasePlan                 *DiskPurchasePlan_STATUS             `json:"purchasePlan,omitempty"`
	SecurityProfile              *DiskSecurityProfile_STATUS          `json:"securityProfile,omitempty"`
	Sku                          *SnapshotSku_STATUS                  `json:"sku,omitempty"`
	SupportedCapabilities        *SupportedCapabilities_STATUS        `json:"supportedCapabilities,omitempty"`
	SupportsHibernation          *bool                                `json:"supportsHibernation,omitempty"`
	SystemData                   *SystemData_STATUS                   `json:"systemData,omitempty"`
	Tags                         map[string]string                    `json:"tags,omitempty"`
	TimeCreated                  *string                              `json:"timeCreated,omitempty"`
	Type                         *string                              `json:"type,omitempty"`
	UniqueId                     *string                              `json:"uniqueId,omitempty"`
}

var _ genruntime.ConvertibleStatus = &Snapshot_STATUS{}

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

	return source.ConvertStatusTo(snapshot)
}

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

	return destination.ConvertStatusFrom(snapshot)
}

// Storage version of v1api20240302.CopyCompletionError
// Indicates the error details if the background copy of a resource created via the CopyStart operation fails.
type CopyCompletionError struct {
	ErrorCode    *string                `json:"errorCode,omitempty"`
	ErrorMessage *string                `json:"errorMessage,omitempty"`
	PropertyBag  genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20240302.CopyCompletionError_STATUS
// Indicates the error details if the background copy of a resource created via the CopyStart operation fails.
type CopyCompletionError_STATUS struct {
	ErrorCode    *string                `json:"errorCode,omitempty"`
	ErrorMessage *string                `json:"errorMessage,omitempty"`
	PropertyBag  genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

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

// Storage version of v1api20240302.SnapshotSku
// The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. This is an optional parameter for incremental
// snapshot and the default behavior is the SKU will be set to the same sku as the previous snapshot
type SnapshotSku struct {
	Name        *string                `json:"name,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20240302.SnapshotSku_STATUS
// The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. This is an optional parameter for incremental
// snapshot and the default behavior is the SKU will be set to the same sku as the previous snapshot
type SnapshotSku_STATUS struct {
	Name        *string                `json:"name,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	Tier        *string                `json:"tier,omitempty"`
}

func init() {
	SchemeBuilder.Register(&Snapshot{}, &SnapshotList{})
}
