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

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,appconfiguration}
// +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 v1api20220501.ConfigurationStore
// Generator information:
// - Generated from: /appconfiguration/resource-manager/Microsoft.AppConfiguration/AppConfiguration/stable/2022-05-01/appconfiguration.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}
type ConfigurationStore struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              ConfigurationStore_Spec   `json:"spec,omitempty"`
	Status            ConfigurationStore_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &ConfigurationStore{}

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

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

var _ configmaps.Exporter = &ConfigurationStore{}

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

var _ secrets.Exporter = &ConfigurationStore{}

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

var _ genruntime.KubernetesResource = &ConfigurationStore{}

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

// GetAPIVersion returns the ARM API version of the resource. This is always "2022-05-01"
func (store ConfigurationStore) GetAPIVersion() string {
	return "2022-05-01"
}

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.AppConfiguration/configurationStores"
func (store *ConfigurationStore) GetType() string {
	return "Microsoft.AppConfiguration/configurationStores"
}

// NewEmptyStatus returns a new empty (blank) status
func (store *ConfigurationStore) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &ConfigurationStore_STATUS{}
}

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

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

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

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

	store.Status = st
	return nil
}

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

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

// +kubebuilder:object:root=true
// Storage version of v1api20220501.ConfigurationStore
// Generator information:
// - Generated from: /appconfiguration/resource-manager/Microsoft.AppConfiguration/AppConfiguration/stable/2022-05-01/appconfiguration.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}
type ConfigurationStoreList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []ConfigurationStore `json:"items"`
}

// Storage version of v1api20220501.APIVersion
// +kubebuilder:validation:Enum={"2022-05-01"}
type APIVersion string

const APIVersion_Value = APIVersion("2022-05-01")

// Storage version of v1api20220501.ConfigurationStore_Spec
type ConfigurationStore_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"`
	CreateMode            *string                         `json:"createMode,omitempty"`
	DisableLocalAuth      *bool                           `json:"disableLocalAuth,omitempty"`
	EnablePurgeProtection *bool                           `json:"enablePurgeProtection,omitempty"`
	Encryption            *EncryptionProperties           `json:"encryption,omitempty"`
	Identity              *ResourceIdentity               `json:"identity,omitempty"`
	Location              *string                         `json:"location,omitempty"`
	OperatorSpec          *ConfigurationStoreOperatorSpec `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"`
	PropertyBag               genruntime.PropertyBag             `json:"$propertyBag,omitempty"`
	PublicNetworkAccess       *string                            `json:"publicNetworkAccess,omitempty"`
	Sku                       *Sku                               `json:"sku,omitempty"`
	SoftDeleteRetentionInDays *int                               `json:"softDeleteRetentionInDays,omitempty"`
	SystemData                *SystemData                        `json:"systemData,omitempty"`
	Tags                      map[string]string                  `json:"tags,omitempty"`
}

var _ genruntime.ConvertibleSpec = &ConfigurationStore_Spec{}

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

	return source.ConvertSpecTo(store)
}

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

	return destination.ConvertSpecFrom(store)
}

// Storage version of v1api20220501.ConfigurationStore_STATUS
// The configuration store along with all resource properties. The Configuration Store will have all information to begin
// utilizing it.
type ConfigurationStore_STATUS struct {
	Conditions                 []conditions.Condition                      `json:"conditions,omitempty"`
	CreateMode                 *string                                     `json:"createMode,omitempty"`
	CreationDate               *string                                     `json:"creationDate,omitempty"`
	DisableLocalAuth           *bool                                       `json:"disableLocalAuth,omitempty"`
	EnablePurgeProtection      *bool                                       `json:"enablePurgeProtection,omitempty"`
	Encryption                 *EncryptionProperties_STATUS                `json:"encryption,omitempty"`
	Endpoint                   *string                                     `json:"endpoint,omitempty"`
	Id                         *string                                     `json:"id,omitempty"`
	Identity                   *ResourceIdentity_STATUS                    `json:"identity,omitempty"`
	Location                   *string                                     `json:"location,omitempty"`
	Name                       *string                                     `json:"name,omitempty"`
	PrivateEndpointConnections []PrivateEndpointConnectionReference_STATUS `json:"privateEndpointConnections,omitempty"`
	PropertyBag                genruntime.PropertyBag                      `json:"$propertyBag,omitempty"`
	ProvisioningState          *string                                     `json:"provisioningState,omitempty"`
	PublicNetworkAccess        *string                                     `json:"publicNetworkAccess,omitempty"`
	Sku                        *Sku_STATUS                                 `json:"sku,omitempty"`
	SoftDeleteRetentionInDays  *int                                        `json:"softDeleteRetentionInDays,omitempty"`
	SystemData                 *SystemData_STATUS                          `json:"systemData,omitempty"`
	Tags                       map[string]string                           `json:"tags,omitempty"`
	Type                       *string                                     `json:"type,omitempty"`
}

var _ genruntime.ConvertibleStatus = &ConfigurationStore_STATUS{}

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

	return source.ConvertStatusTo(store)
}

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

	return destination.ConvertStatusFrom(store)
}

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

// Storage version of v1api20220501.EncryptionProperties
// The encryption settings for a configuration store.
type EncryptionProperties struct {
	KeyVaultProperties *KeyVaultProperties    `json:"keyVaultProperties,omitempty"`
	PropertyBag        genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20220501.EncryptionProperties_STATUS
// The encryption settings for a configuration store.
type EncryptionProperties_STATUS struct {
	KeyVaultProperties *KeyVaultProperties_STATUS `json:"keyVaultProperties,omitempty"`
	PropertyBag        genruntime.PropertyBag     `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20220501.PrivateEndpointConnectionReference_STATUS
// A reference to a related private endpoint connection.
type PrivateEndpointConnectionReference_STATUS struct {
	Id          *string                `json:"id,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20220501.ResourceIdentity
// An identity that can be associated with a resource.
type ResourceIdentity struct {
	PropertyBag            genruntime.PropertyBag        `json:"$propertyBag,omitempty"`
	Type                   *string                       `json:"type,omitempty"`
	UserAssignedIdentities []UserAssignedIdentityDetails `json:"userAssignedIdentities,omitempty"`
}

// Storage version of v1api20220501.ResourceIdentity_STATUS
// An identity that can be associated with a resource.
type ResourceIdentity_STATUS struct {
	PrincipalId            *string                        `json:"principalId,omitempty"`
	PropertyBag            genruntime.PropertyBag         `json:"$propertyBag,omitempty"`
	TenantId               *string                        `json:"tenantId,omitempty"`
	Type                   *string                        `json:"type,omitempty"`
	UserAssignedIdentities map[string]UserIdentity_STATUS `json:"userAssignedIdentities,omitempty"`
}

// Storage version of v1api20220501.Sku
// Describes a configuration store SKU.
type Sku struct {
	Name        *string                `json:"name,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20220501.Sku_STATUS
// Describes a configuration store SKU.
type Sku_STATUS struct {
	Name        *string                `json:"name,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20220501.SystemData
// Metadata pertaining to creation and last modification of the resource.
type SystemData struct {
	CreatedAt          *string                `json:"createdAt,omitempty"`
	CreatedBy          *string                `json:"createdBy,omitempty"`
	CreatedByType      *string                `json:"createdByType,omitempty"`
	LastModifiedAt     *string                `json:"lastModifiedAt,omitempty"`
	LastModifiedBy     *string                `json:"lastModifiedBy,omitempty"`
	LastModifiedByType *string                `json:"lastModifiedByType,omitempty"`
	PropertyBag        genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20220501.SystemData_STATUS
// Metadata pertaining to creation and last modification of the resource.
type SystemData_STATUS struct {
	CreatedAt          *string                `json:"createdAt,omitempty"`
	CreatedBy          *string                `json:"createdBy,omitempty"`
	CreatedByType      *string                `json:"createdByType,omitempty"`
	LastModifiedAt     *string                `json:"lastModifiedAt,omitempty"`
	LastModifiedBy     *string                `json:"lastModifiedBy,omitempty"`
	LastModifiedByType *string                `json:"lastModifiedByType,omitempty"`
	PropertyBag        genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20220501.ConfigurationStoreOperatorSecrets
type ConfigurationStoreOperatorSecrets struct {
	PrimaryConnectionString           *genruntime.SecretDestination `json:"primaryConnectionString,omitempty"`
	PrimaryKey                        *genruntime.SecretDestination `json:"primaryKey,omitempty"`
	PrimaryKeyID                      *genruntime.SecretDestination `json:"primaryKeyID,omitempty"`
	PrimaryReadOnlyConnectionString   *genruntime.SecretDestination `json:"primaryReadOnlyConnectionString,omitempty"`
	PrimaryReadOnlyKey                *genruntime.SecretDestination `json:"primaryReadOnlyKey,omitempty"`
	PrimaryReadOnlyKeyID              *genruntime.SecretDestination `json:"primaryReadOnlyKeyID,omitempty"`
	PropertyBag                       genruntime.PropertyBag        `json:"$propertyBag,omitempty"`
	SecondaryConnectionString         *genruntime.SecretDestination `json:"secondaryConnectionString,omitempty"`
	SecondaryKey                      *genruntime.SecretDestination `json:"secondaryKey,omitempty"`
	SecondaryKeyID                    *genruntime.SecretDestination `json:"secondaryKeyID,omitempty"`
	SecondaryReadOnlyConnectionString *genruntime.SecretDestination `json:"secondaryReadOnlyConnectionString,omitempty"`
	SecondaryReadOnlyKey              *genruntime.SecretDestination `json:"secondaryReadOnlyKey,omitempty"`
	SecondaryReadOnlyKeyID            *genruntime.SecretDestination `json:"secondaryReadOnlyKeyID,omitempty"`
}

// Storage version of v1api20220501.KeyVaultProperties
// Settings concerning key vault encryption for a configuration store.
type KeyVaultProperties struct {
	IdentityClientId *string                `json:"identityClientId,omitempty"`
	KeyIdentifier    *string                `json:"keyIdentifier,omitempty"`
	PropertyBag      genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20220501.KeyVaultProperties_STATUS
// Settings concerning key vault encryption for a configuration store.
type KeyVaultProperties_STATUS struct {
	IdentityClientId *string                `json:"identityClientId,omitempty"`
	KeyIdentifier    *string                `json:"keyIdentifier,omitempty"`
	PropertyBag      genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20220501.UserAssignedIdentityDetails
// Information about the user assigned identity for the resource
type UserAssignedIdentityDetails struct {
	PropertyBag genruntime.PropertyBag       `json:"$propertyBag,omitempty"`
	Reference   genruntime.ResourceReference `armReference:"Reference" json:"reference,omitempty"`
}

// Storage version of v1api20220501.UserIdentity_STATUS
// A resource identity that is managed by the user of the service.
type UserIdentity_STATUS struct {
	ClientId    *string                `json:"clientId,omitempty"`
	PrincipalId *string                `json:"principalId,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

func init() {
	SchemeBuilder.Register(&ConfigurationStore{}, &ConfigurationStoreList{})
}
