// 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=storageaccountstableservicestables,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=storage.azure.com,resources={storageaccountstableservicestables/status,storageaccountstableservicestables/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.StorageAccountsTableServicesTable
// Generator information:
// - Generated from: /storage/resource-manager/Microsoft.Storage/stable/2022-09-01/table.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}
type StorageAccountsTableServicesTable struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              StorageAccounts_TableServices_Table_Spec   `json:"spec,omitempty"`
	Status            StorageAccounts_TableServices_Table_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &StorageAccountsTableServicesTable{}

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

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

var _ genruntime.KubernetesResource = &StorageAccountsTableServicesTable{}

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

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.Storage/storageAccounts/tableServices/tables"
func (table *StorageAccountsTableServicesTable) GetType() string {
	return "Microsoft.Storage/storageAccounts/tableServices/tables"
}

// NewEmptyStatus returns a new empty (blank) status
func (table *StorageAccountsTableServicesTable) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &StorageAccounts_TableServices_Table_STATUS{}
}

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

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

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

	table.Status = st
	return nil
}

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

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

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

// Storage version of v1api20220901.StorageAccounts_TableServices_Table_Spec
type StorageAccounts_TableServices_Table_Spec struct {
	// +kubebuilder:validation:MaxLength=63
	// +kubebuilder:validation:MinLength=3
	// +kubebuilder:validation:Pattern="^[A-Za-z][A-Za-z0-9]{2,62}$"
	// 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"`
	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/StorageAccountsTableService resource
	Owner             *genruntime.KnownResourceReference `group:"storage.azure.com" json:"owner,omitempty" kind:"StorageAccountsTableService"`
	PropertyBag       genruntime.PropertyBag             `json:"$propertyBag,omitempty"`
	SignedIdentifiers []TableSignedIdentifier            `json:"signedIdentifiers,omitempty"`
}

var _ genruntime.ConvertibleSpec = &StorageAccounts_TableServices_Table_Spec{}

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

	return source.ConvertSpecTo(table)
}

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

	return destination.ConvertSpecFrom(table)
}

// Storage version of v1api20220901.StorageAccounts_TableServices_Table_STATUS
type StorageAccounts_TableServices_Table_STATUS struct {
	Conditions        []conditions.Condition         `json:"conditions,omitempty"`
	Id                *string                        `json:"id,omitempty"`
	Name              *string                        `json:"name,omitempty"`
	PropertyBag       genruntime.PropertyBag         `json:"$propertyBag,omitempty"`
	SignedIdentifiers []TableSignedIdentifier_STATUS `json:"signedIdentifiers,omitempty"`
	TableName         *string                        `json:"tableName,omitempty"`
	Type              *string                        `json:"type,omitempty"`
}

var _ genruntime.ConvertibleStatus = &StorageAccounts_TableServices_Table_STATUS{}

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

	return source.ConvertStatusTo(table)
}

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

	return destination.ConvertStatusFrom(table)
}

// Storage version of v1api20220901.TableSignedIdentifier
// Object to set Table Access Policy.
type TableSignedIdentifier struct {
	AccessPolicy *TableAccessPolicy     `json:"accessPolicy,omitempty"`
	PropertyBag  genruntime.PropertyBag `json:"$propertyBag,omitempty"`

	// +kubebuilder:validation:Required
	// Reference: unique-64-character-value of the stored access policy.
	Reference *genruntime.ResourceReference `armReference:"Id" json:"reference,omitempty"`
}

// Storage version of v1api20220901.TableSignedIdentifier_STATUS
// Object to set Table Access Policy.
type TableSignedIdentifier_STATUS struct {
	AccessPolicy *TableAccessPolicy_STATUS `json:"accessPolicy,omitempty"`
	Id           *string                   `json:"id,omitempty"`
	PropertyBag  genruntime.PropertyBag    `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20220901.TableAccessPolicy
// Table Access Policy Properties Object.
type TableAccessPolicy struct {
	ExpiryTime  *string                `json:"expiryTime,omitempty"`
	Permission  *string                `json:"permission,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	StartTime   *string                `json:"startTime,omitempty"`
}

// Storage version of v1api20220901.TableAccessPolicy_STATUS
// Table Access Policy Properties Object.
type TableAccessPolicy_STATUS struct {
	ExpiryTime  *string                `json:"expiryTime,omitempty"`
	Permission  *string                `json:"permission,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	StartTime   *string                `json:"startTime,omitempty"`
}

func init() {
	SchemeBuilder.Register(&StorageAccountsTableServicesTable{}, &StorageAccountsTableServicesTableList{})
}
