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

import (
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime/conditions"
	"github.com/pkg/errors"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/runtime/schema"
)

// +kubebuilder:rbac:groups=storage.azure.com,resources=storageaccountsmanagementpolicies,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=storage.azure.com,resources={storageaccountsmanagementpolicies/status,storageaccountsmanagementpolicies/finalizers},verbs=get;update;patch

// +kubebuilder:object:root=true
// +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 v1api20220901.StorageAccountsManagementPolicy
// Generator information:
// - Generated from: /storage/resource-manager/Microsoft.Storage/stable/2022-09-01/storage.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/default
type StorageAccountsManagementPolicy struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              StorageAccounts_ManagementPolicy_Spec   `json:"spec,omitempty"`
	Status            StorageAccounts_ManagementPolicy_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &StorageAccountsManagementPolicy{}

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

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

var _ genruntime.KubernetesResource = &StorageAccountsManagementPolicy{}

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

// GetAPIVersion returns the ARM API version of the resource. This is always "2022-09-01"
func (policy StorageAccountsManagementPolicy) GetAPIVersion() string {
	return string(APIVersion_Value)
}

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.Storage/storageAccounts/managementPolicies"
func (policy *StorageAccountsManagementPolicy) GetType() string {
	return "Microsoft.Storage/storageAccounts/managementPolicies"
}

// NewEmptyStatus returns a new empty (blank) status
func (policy *StorageAccountsManagementPolicy) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &StorageAccounts_ManagementPolicy_STATUS{}
}

// Owner returns the ResourceReference of the owner
func (policy *StorageAccountsManagementPolicy) Owner() *genruntime.ResourceReference {
	group, kind := genruntime.LookupOwnerGroupKind(policy.Spec)
	return policy.Spec.Owner.AsResourceReference(group, kind)
}

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

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

	policy.Status = st
	return nil
}

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

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

// +kubebuilder:object:root=true
// Storage version of v1api20220901.StorageAccountsManagementPolicy
// Generator information:
// - Generated from: /storage/resource-manager/Microsoft.Storage/stable/2022-09-01/storage.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/default
type StorageAccountsManagementPolicyList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []StorageAccountsManagementPolicy `json:"items"`
}

// Storage version of v1api20220901.StorageAccounts_ManagementPolicy_Spec
type StorageAccounts_ManagementPolicy_Spec struct {
	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 storage.azure.com/StorageAccount resource
	Owner       *genruntime.KnownResourceReference `group:"storage.azure.com" json:"owner,omitempty" kind:"StorageAccount"`
	Policy      *ManagementPolicySchema            `json:"policy,omitempty"`
	PropertyBag genruntime.PropertyBag             `json:"$propertyBag,omitempty"`
}

var _ genruntime.ConvertibleSpec = &StorageAccounts_ManagementPolicy_Spec{}

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

	return source.ConvertSpecTo(policy)
}

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

	return destination.ConvertSpecFrom(policy)
}

// Storage version of v1api20220901.StorageAccounts_ManagementPolicy_STATUS
type StorageAccounts_ManagementPolicy_STATUS struct {
	Conditions       []conditions.Condition         `json:"conditions,omitempty"`
	Id               *string                        `json:"id,omitempty"`
	LastModifiedTime *string                        `json:"lastModifiedTime,omitempty"`
	Name             *string                        `json:"name,omitempty"`
	Policy           *ManagementPolicySchema_STATUS `json:"policy,omitempty"`
	PropertyBag      genruntime.PropertyBag         `json:"$propertyBag,omitempty"`
	Type             *string                        `json:"type,omitempty"`
}

var _ genruntime.ConvertibleStatus = &StorageAccounts_ManagementPolicy_STATUS{}

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

	return source.ConvertStatusTo(policy)
}

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

	return destination.ConvertStatusFrom(policy)
}

// Storage version of v1api20220901.ManagementPolicySchema
// The Storage Account ManagementPolicies Rules. See more details in:
// https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts.
type ManagementPolicySchema struct {
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	Rules       []ManagementPolicyRule `json:"rules,omitempty"`
}

// Storage version of v1api20220901.ManagementPolicySchema_STATUS
// The Storage Account ManagementPolicies Rules. See more details in:
// https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts.
type ManagementPolicySchema_STATUS struct {
	PropertyBag genruntime.PropertyBag        `json:"$propertyBag,omitempty"`
	Rules       []ManagementPolicyRule_STATUS `json:"rules,omitempty"`
}

// Storage version of v1api20220901.ManagementPolicyRule
// An object that wraps the Lifecycle rule. Each rule is uniquely defined by name.
type ManagementPolicyRule struct {
	Definition  *ManagementPolicyDefinition `json:"definition,omitempty"`
	Enabled     *bool                       `json:"enabled,omitempty"`
	Name        *string                     `json:"name,omitempty"`
	PropertyBag genruntime.PropertyBag      `json:"$propertyBag,omitempty"`
	Type        *string                     `json:"type,omitempty"`
}

// Storage version of v1api20220901.ManagementPolicyRule_STATUS
// An object that wraps the Lifecycle rule. Each rule is uniquely defined by name.
type ManagementPolicyRule_STATUS struct {
	Definition  *ManagementPolicyDefinition_STATUS `json:"definition,omitempty"`
	Enabled     *bool                              `json:"enabled,omitempty"`
	Name        *string                            `json:"name,omitempty"`
	PropertyBag genruntime.PropertyBag             `json:"$propertyBag,omitempty"`
	Type        *string                            `json:"type,omitempty"`
}

// Storage version of v1api20220901.ManagementPolicyDefinition
// An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set.
type ManagementPolicyDefinition struct {
	Actions     *ManagementPolicyAction `json:"actions,omitempty"`
	Filters     *ManagementPolicyFilter `json:"filters,omitempty"`
	PropertyBag genruntime.PropertyBag  `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20220901.ManagementPolicyDefinition_STATUS
// An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set.
type ManagementPolicyDefinition_STATUS struct {
	Actions     *ManagementPolicyAction_STATUS `json:"actions,omitempty"`
	Filters     *ManagementPolicyFilter_STATUS `json:"filters,omitempty"`
	PropertyBag genruntime.PropertyBag         `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20220901.ManagementPolicyAction
// Actions are applied to the filtered blobs when the execution condition is met.
type ManagementPolicyAction struct {
	BaseBlob    *ManagementPolicyBaseBlob `json:"baseBlob,omitempty"`
	PropertyBag genruntime.PropertyBag    `json:"$propertyBag,omitempty"`
	Snapshot    *ManagementPolicySnapShot `json:"snapshot,omitempty"`
	Version     *ManagementPolicyVersion  `json:"version,omitempty"`
}

// Storage version of v1api20220901.ManagementPolicyAction_STATUS
// Actions are applied to the filtered blobs when the execution condition is met.
type ManagementPolicyAction_STATUS struct {
	BaseBlob    *ManagementPolicyBaseBlob_STATUS `json:"baseBlob,omitempty"`
	PropertyBag genruntime.PropertyBag           `json:"$propertyBag,omitempty"`
	Snapshot    *ManagementPolicySnapShot_STATUS `json:"snapshot,omitempty"`
	Version     *ManagementPolicyVersion_STATUS  `json:"version,omitempty"`
}

// Storage version of v1api20220901.ManagementPolicyFilter
// Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical
// AND is performed on all filters.
type ManagementPolicyFilter struct {
	BlobIndexMatch []TagFilter            `json:"blobIndexMatch,omitempty"`
	BlobTypes      []string               `json:"blobTypes,omitempty"`
	PrefixMatch    []string               `json:"prefixMatch,omitempty"`
	PropertyBag    genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20220901.ManagementPolicyFilter_STATUS
// Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical
// AND is performed on all filters.
type ManagementPolicyFilter_STATUS struct {
	BlobIndexMatch []TagFilter_STATUS     `json:"blobIndexMatch,omitempty"`
	BlobTypes      []string               `json:"blobTypes,omitempty"`
	PrefixMatch    []string               `json:"prefixMatch,omitempty"`
	PropertyBag    genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20220901.ManagementPolicyBaseBlob
// Management policy action for base blob.
type ManagementPolicyBaseBlob struct {
	Delete                      *DateAfterModification `json:"delete,omitempty"`
	EnableAutoTierToHotFromCool *bool                  `json:"enableAutoTierToHotFromCool,omitempty"`
	PropertyBag                 genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	TierToArchive               *DateAfterModification `json:"tierToArchive,omitempty"`
	TierToCold                  *DateAfterModification `json:"tierToCold,omitempty"`
	TierToCool                  *DateAfterModification `json:"tierToCool,omitempty"`
	TierToHot                   *DateAfterModification `json:"tierToHot,omitempty"`
}

// Storage version of v1api20220901.ManagementPolicyBaseBlob_STATUS
// Management policy action for base blob.
type ManagementPolicyBaseBlob_STATUS struct {
	Delete                      *DateAfterModification_STATUS `json:"delete,omitempty"`
	EnableAutoTierToHotFromCool *bool                         `json:"enableAutoTierToHotFromCool,omitempty"`
	PropertyBag                 genruntime.PropertyBag        `json:"$propertyBag,omitempty"`
	TierToArchive               *DateAfterModification_STATUS `json:"tierToArchive,omitempty"`
	TierToCold                  *DateAfterModification_STATUS `json:"tierToCold,omitempty"`
	TierToCool                  *DateAfterModification_STATUS `json:"tierToCool,omitempty"`
	TierToHot                   *DateAfterModification_STATUS `json:"tierToHot,omitempty"`
}

// Storage version of v1api20220901.ManagementPolicySnapShot
// Management policy action for snapshot.
type ManagementPolicySnapShot struct {
	Delete        *DateAfterCreation     `json:"delete,omitempty"`
	PropertyBag   genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	TierToArchive *DateAfterCreation     `json:"tierToArchive,omitempty"`
	TierToCold    *DateAfterCreation     `json:"tierToCold,omitempty"`
	TierToCool    *DateAfterCreation     `json:"tierToCool,omitempty"`
	TierToHot     *DateAfterCreation     `json:"tierToHot,omitempty"`
}

// Storage version of v1api20220901.ManagementPolicySnapShot_STATUS
// Management policy action for snapshot.
type ManagementPolicySnapShot_STATUS struct {
	Delete        *DateAfterCreation_STATUS `json:"delete,omitempty"`
	PropertyBag   genruntime.PropertyBag    `json:"$propertyBag,omitempty"`
	TierToArchive *DateAfterCreation_STATUS `json:"tierToArchive,omitempty"`
	TierToCold    *DateAfterCreation_STATUS `json:"tierToCold,omitempty"`
	TierToCool    *DateAfterCreation_STATUS `json:"tierToCool,omitempty"`
	TierToHot     *DateAfterCreation_STATUS `json:"tierToHot,omitempty"`
}

// Storage version of v1api20220901.ManagementPolicyVersion
// Management policy action for blob version.
type ManagementPolicyVersion struct {
	Delete        *DateAfterCreation     `json:"delete,omitempty"`
	PropertyBag   genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	TierToArchive *DateAfterCreation     `json:"tierToArchive,omitempty"`
	TierToCold    *DateAfterCreation     `json:"tierToCold,omitempty"`
	TierToCool    *DateAfterCreation     `json:"tierToCool,omitempty"`
	TierToHot     *DateAfterCreation     `json:"tierToHot,omitempty"`
}

// Storage version of v1api20220901.ManagementPolicyVersion_STATUS
// Management policy action for blob version.
type ManagementPolicyVersion_STATUS struct {
	Delete        *DateAfterCreation_STATUS `json:"delete,omitempty"`
	PropertyBag   genruntime.PropertyBag    `json:"$propertyBag,omitempty"`
	TierToArchive *DateAfterCreation_STATUS `json:"tierToArchive,omitempty"`
	TierToCold    *DateAfterCreation_STATUS `json:"tierToCold,omitempty"`
	TierToCool    *DateAfterCreation_STATUS `json:"tierToCool,omitempty"`
	TierToHot     *DateAfterCreation_STATUS `json:"tierToHot,omitempty"`
}

// Storage version of v1api20220901.TagFilter
// Blob index tag based filtering for blob objects
type TagFilter struct {
	Name        *string                `json:"name,omitempty"`
	Op          *string                `json:"op,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	Value       *string                `json:"value,omitempty"`
}

// Storage version of v1api20220901.TagFilter_STATUS
// Blob index tag based filtering for blob objects
type TagFilter_STATUS struct {
	Name        *string                `json:"name,omitempty"`
	Op          *string                `json:"op,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	Value       *string                `json:"value,omitempty"`
}

// Storage version of v1api20220901.DateAfterCreation
// Object to define snapshot and version action conditions.
type DateAfterCreation struct {
	DaysAfterCreationGreaterThan       *int                   `json:"daysAfterCreationGreaterThan,omitempty"`
	DaysAfterLastTierChangeGreaterThan *int                   `json:"daysAfterLastTierChangeGreaterThan,omitempty"`
	PropertyBag                        genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20220901.DateAfterCreation_STATUS
// Object to define snapshot and version action conditions.
type DateAfterCreation_STATUS struct {
	DaysAfterCreationGreaterThan       *float64               `json:"daysAfterCreationGreaterThan,omitempty"`
	DaysAfterLastTierChangeGreaterThan *float64               `json:"daysAfterLastTierChangeGreaterThan,omitempty"`
	PropertyBag                        genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20220901.DateAfterModification
// Object to define the base blob action conditions. Properties daysAfterModificationGreaterThan,
// daysAfterLastAccessTimeGreaterThan and daysAfterCreationGreaterThan are mutually exclusive. The
// daysAfterLastTierChangeGreaterThan property is only applicable for tierToArchive actions which requires
// daysAfterModificationGreaterThan to be set, also it cannot be used in conjunction with
// daysAfterLastAccessTimeGreaterThan or daysAfterCreationGreaterThan.
type DateAfterModification struct {
	DaysAfterCreationGreaterThan       *int                   `json:"daysAfterCreationGreaterThan,omitempty"`
	DaysAfterLastAccessTimeGreaterThan *int                   `json:"daysAfterLastAccessTimeGreaterThan,omitempty"`
	DaysAfterLastTierChangeGreaterThan *int                   `json:"daysAfterLastTierChangeGreaterThan,omitempty"`
	DaysAfterModificationGreaterThan   *int                   `json:"daysAfterModificationGreaterThan,omitempty"`
	PropertyBag                        genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20220901.DateAfterModification_STATUS
// Object to define the base blob action conditions. Properties daysAfterModificationGreaterThan,
// daysAfterLastAccessTimeGreaterThan and daysAfterCreationGreaterThan are mutually exclusive. The
// daysAfterLastTierChangeGreaterThan property is only applicable for tierToArchive actions which requires
// daysAfterModificationGreaterThan to be set, also it cannot be used in conjunction with
// daysAfterLastAccessTimeGreaterThan or daysAfterCreationGreaterThan.
type DateAfterModification_STATUS struct {
	DaysAfterCreationGreaterThan       *float64               `json:"daysAfterCreationGreaterThan,omitempty"`
	DaysAfterLastAccessTimeGreaterThan *float64               `json:"daysAfterLastAccessTimeGreaterThan,omitempty"`
	DaysAfterLastTierChangeGreaterThan *float64               `json:"daysAfterLastTierChangeGreaterThan,omitempty"`
	DaysAfterModificationGreaterThan   *float64               `json:"daysAfterModificationGreaterThan,omitempty"`
	PropertyBag                        genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

func init() {
	SchemeBuilder.Register(&StorageAccountsManagementPolicy{}, &StorageAccountsManagementPolicyList{})
}
