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

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,app}
// +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 v1api20250101.ManagedEnvironment
// Generator information:
// - Generated from: /app/resource-manager/Microsoft.App/ContainerApps/stable/2025-01-01/ManagedEnvironments.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}
type ManagedEnvironment struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              ManagedEnvironment_Spec   `json:"spec,omitempty"`
	Status            ManagedEnvironment_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &ManagedEnvironment{}

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

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

var _ configmaps.Exporter = &ManagedEnvironment{}

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

var _ secrets.Exporter = &ManagedEnvironment{}

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

var _ genruntime.KubernetesResource = &ManagedEnvironment{}

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

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

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.App/managedEnvironments"
func (environment *ManagedEnvironment) GetType() string {
	return "Microsoft.App/managedEnvironments"
}

// NewEmptyStatus returns a new empty (blank) status
func (environment *ManagedEnvironment) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &ManagedEnvironment_STATUS{}
}

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

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

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

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

	environment.Status = st
	return nil
}

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

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

// +kubebuilder:object:root=true
// Storage version of v1api20250101.ManagedEnvironment
// Generator information:
// - Generated from: /app/resource-manager/Microsoft.App/ContainerApps/stable/2025-01-01/ManagedEnvironments.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}
type ManagedEnvironmentList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []ManagedEnvironment `json:"items"`
}

// Storage version of v1api20250101.ManagedEnvironment_Spec
type ManagedEnvironment_Spec struct {
	AppLogsConfiguration *AppLogsConfiguration `json:"appLogsConfiguration,omitempty"`

	// 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"`
	CustomDomainConfiguration   *CustomDomainConfiguration      `json:"customDomainConfiguration,omitempty"`
	DaprAIConnectionString      *genruntime.SecretReference     `json:"daprAIConnectionString,omitempty"`
	DaprAIInstrumentationKey    *genruntime.SecretReference     `json:"daprAIInstrumentationKey,omitempty"`
	Identity                    *ManagedServiceIdentity         `json:"identity,omitempty"`
	InfrastructureResourceGroup *string                         `json:"infrastructureResourceGroup,omitempty"`
	Kind                        *string                         `json:"kind,omitempty"`
	Location                    *string                         `json:"location,omitempty"`
	OperatorSpec                *ManagedEnvironmentOperatorSpec `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"`
	PeerAuthentication       *ManagedEnvironment_Properties_PeerAuthentication_Spec       `json:"peerAuthentication,omitempty"`
	PeerTrafficConfiguration *ManagedEnvironment_Properties_PeerTrafficConfiguration_Spec `json:"peerTrafficConfiguration,omitempty"`
	PropertyBag              genruntime.PropertyBag                                       `json:"$propertyBag,omitempty"`
	Tags                     map[string]string                                            `json:"tags,omitempty"`
	VnetConfiguration        *VnetConfiguration                                           `json:"vnetConfiguration,omitempty"`
	WorkloadProfiles         []WorkloadProfile                                            `json:"workloadProfiles,omitempty"`
	ZoneRedundant            *bool                                                        `json:"zoneRedundant,omitempty"`
}

var _ genruntime.ConvertibleSpec = &ManagedEnvironment_Spec{}

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

	return source.ConvertSpecTo(environment)
}

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

	return destination.ConvertSpecFrom(environment)
}

// Storage version of v1api20250101.ManagedEnvironment_STATUS
// An environment for hosting container apps
type ManagedEnvironment_STATUS struct {
	AppLogsConfiguration        *AppLogsConfiguration_STATUS                                   `json:"appLogsConfiguration,omitempty"`
	Conditions                  []conditions.Condition                                         `json:"conditions,omitempty"`
	CustomDomainConfiguration   *CustomDomainConfiguration_STATUS                              `json:"customDomainConfiguration,omitempty"`
	DaprConfiguration           *DaprConfiguration_STATUS                                      `json:"daprConfiguration,omitempty"`
	DefaultDomain               *string                                                        `json:"defaultDomain,omitempty"`
	DeploymentErrors            *string                                                        `json:"deploymentErrors,omitempty"`
	EventStreamEndpoint         *string                                                        `json:"eventStreamEndpoint,omitempty"`
	Id                          *string                                                        `json:"id,omitempty"`
	Identity                    *ManagedServiceIdentity_STATUS                                 `json:"identity,omitempty"`
	InfrastructureResourceGroup *string                                                        `json:"infrastructureResourceGroup,omitempty"`
	KedaConfiguration           *KedaConfiguration_STATUS                                      `json:"kedaConfiguration,omitempty"`
	Kind                        *string                                                        `json:"kind,omitempty"`
	Location                    *string                                                        `json:"location,omitempty"`
	Name                        *string                                                        `json:"name,omitempty"`
	PeerAuthentication          *ManagedEnvironment_Properties_PeerAuthentication_STATUS       `json:"peerAuthentication,omitempty"`
	PeerTrafficConfiguration    *ManagedEnvironment_Properties_PeerTrafficConfiguration_STATUS `json:"peerTrafficConfiguration,omitempty"`
	PropertyBag                 genruntime.PropertyBag                                         `json:"$propertyBag,omitempty"`
	ProvisioningState           *string                                                        `json:"provisioningState,omitempty"`
	StaticIp                    *string                                                        `json:"staticIp,omitempty"`
	SystemData                  *SystemData_STATUS                                             `json:"systemData,omitempty"`
	Tags                        map[string]string                                              `json:"tags,omitempty"`
	Type                        *string                                                        `json:"type,omitempty"`
	VnetConfiguration           *VnetConfiguration_STATUS                                      `json:"vnetConfiguration,omitempty"`
	WorkloadProfiles            []WorkloadProfile_STATUS                                       `json:"workloadProfiles,omitempty"`
	ZoneRedundant               *bool                                                          `json:"zoneRedundant,omitempty"`
}

var _ genruntime.ConvertibleStatus = &ManagedEnvironment_STATUS{}

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

	return source.ConvertStatusTo(environment)
}

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

	return destination.ConvertStatusFrom(environment)
}

// Storage version of v1api20250101.AppLogsConfiguration
// Configuration of application logs
type AppLogsConfiguration struct {
	Destination               *string                    `json:"destination,omitempty"`
	LogAnalyticsConfiguration *LogAnalyticsConfiguration `json:"logAnalyticsConfiguration,omitempty"`
	PropertyBag               genruntime.PropertyBag     `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20250101.AppLogsConfiguration_STATUS
// Configuration of application logs
type AppLogsConfiguration_STATUS struct {
	Destination               *string                           `json:"destination,omitempty"`
	LogAnalyticsConfiguration *LogAnalyticsConfiguration_STATUS `json:"logAnalyticsConfiguration,omitempty"`
	PropertyBag               genruntime.PropertyBag            `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20250101.CustomDomainConfiguration
// Configuration properties for apps environment custom domain
type CustomDomainConfiguration struct {
	CertificateKeyVaultProperties *CertificateKeyVaultProperties `json:"certificateKeyVaultProperties,omitempty"`
	CertificatePassword           *genruntime.SecretReference    `json:"certificatePassword,omitempty"`
	CertificateValue              *genruntime.SecretReference    `json:"certificateValue,omitempty"`
	DnsSuffix                     *string                        `json:"dnsSuffix,omitempty"`
	PropertyBag                   genruntime.PropertyBag         `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20250101.CustomDomainConfiguration_STATUS
// Configuration properties for apps environment custom domain
type CustomDomainConfiguration_STATUS struct {
	CertificateKeyVaultProperties *CertificateKeyVaultProperties_STATUS `json:"certificateKeyVaultProperties,omitempty"`
	CustomDomainVerificationId    *string                               `json:"customDomainVerificationId,omitempty"`
	DnsSuffix                     *string                               `json:"dnsSuffix,omitempty"`
	ExpirationDate                *string                               `json:"expirationDate,omitempty"`
	PropertyBag                   genruntime.PropertyBag                `json:"$propertyBag,omitempty"`
	SubjectName                   *string                               `json:"subjectName,omitempty"`
	Thumbprint                    *string                               `json:"thumbprint,omitempty"`
}

// Storage version of v1api20250101.DaprConfiguration_STATUS
// Configuration properties Dapr component
type DaprConfiguration_STATUS struct {
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	Version     *string                `json:"version,omitempty"`
}

// Storage version of v1api20250101.KedaConfiguration_STATUS
// Configuration properties Keda component
type KedaConfiguration_STATUS struct {
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	Version     *string                `json:"version,omitempty"`
}

// Storage version of v1api20250101.ManagedEnvironment_Properties_PeerAuthentication_Spec
type ManagedEnvironment_Properties_PeerAuthentication_Spec struct {
	Mtls        *Mtls                  `json:"mtls,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20250101.ManagedEnvironment_Properties_PeerAuthentication_STATUS
type ManagedEnvironment_Properties_PeerAuthentication_STATUS struct {
	Mtls        *Mtls_STATUS           `json:"mtls,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20250101.ManagedEnvironment_Properties_PeerTrafficConfiguration_Spec
type ManagedEnvironment_Properties_PeerTrafficConfiguration_Spec struct {
	Encryption  *ManagedEnvironment_Properties_PeerTrafficConfiguration_Encryption_Spec `json:"encryption,omitempty"`
	PropertyBag genruntime.PropertyBag                                                  `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20250101.ManagedEnvironment_Properties_PeerTrafficConfiguration_STATUS
type ManagedEnvironment_Properties_PeerTrafficConfiguration_STATUS struct {
	Encryption  *ManagedEnvironment_Properties_PeerTrafficConfiguration_Encryption_STATUS `json:"encryption,omitempty"`
	PropertyBag genruntime.PropertyBag                                                    `json:"$propertyBag,omitempty"`
}

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

// Storage version of v1api20250101.VnetConfiguration
// Configuration properties for apps environment to join a Virtual Network
type VnetConfiguration struct {
	DockerBridgeCidr *string `json:"dockerBridgeCidr,omitempty"`

	// InfrastructureSubnetReference: Resource ID of a subnet for infrastructure components. Must not overlap with any other
	// provided IP ranges.
	InfrastructureSubnetReference *genruntime.ResourceReference `armReference:"InfrastructureSubnetId" json:"infrastructureSubnetReference,omitempty"`
	Internal                      *bool                         `json:"internal,omitempty"`
	PlatformReservedCidr          *string                       `json:"platformReservedCidr,omitempty"`
	PlatformReservedDnsIP         *string                       `json:"platformReservedDnsIP,omitempty"`
	PropertyBag                   genruntime.PropertyBag        `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20250101.VnetConfiguration_STATUS
// Configuration properties for apps environment to join a Virtual Network
type VnetConfiguration_STATUS struct {
	DockerBridgeCidr       *string                `json:"dockerBridgeCidr,omitempty"`
	InfrastructureSubnetId *string                `json:"infrastructureSubnetId,omitempty"`
	Internal               *bool                  `json:"internal,omitempty"`
	PlatformReservedCidr   *string                `json:"platformReservedCidr,omitempty"`
	PlatformReservedDnsIP  *string                `json:"platformReservedDnsIP,omitempty"`
	PropertyBag            genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20250101.WorkloadProfile
// Workload profile to scope container app execution.
type WorkloadProfile struct {
	MaximumCount        *int                   `json:"maximumCount,omitempty"`
	MinimumCount        *int                   `json:"minimumCount,omitempty"`
	Name                *string                `json:"name,omitempty"`
	PropertyBag         genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	WorkloadProfileType *string                `json:"workloadProfileType,omitempty"`
}

// Storage version of v1api20250101.WorkloadProfile_STATUS
// Workload profile to scope container app execution.
type WorkloadProfile_STATUS struct {
	MaximumCount        *int                   `json:"maximumCount,omitempty"`
	MinimumCount        *int                   `json:"minimumCount,omitempty"`
	Name                *string                `json:"name,omitempty"`
	PropertyBag         genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	WorkloadProfileType *string                `json:"workloadProfileType,omitempty"`
}

// Storage version of v1api20250101.CertificateKeyVaultProperties
// Properties for a certificate stored in a Key Vault.
type CertificateKeyVaultProperties struct {
	// IdentityReference: Resource ID of a managed identity to authenticate with Azure Key Vault, or System to use a
	// system-assigned identity.
	IdentityReference *genruntime.WellKnownResourceReference `armReference:"Identity" json:"identityReference,omitempty"`
	KeyVaultUrl       *string                                `json:"keyVaultUrl,omitempty"`
	PropertyBag       genruntime.PropertyBag                 `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20250101.CertificateKeyVaultProperties_STATUS
// Properties for a certificate stored in a Key Vault.
type CertificateKeyVaultProperties_STATUS struct {
	Identity    *string                `json:"identity,omitempty"`
	KeyVaultUrl *string                `json:"keyVaultUrl,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20250101.LogAnalyticsConfiguration
// Log Analytics configuration, must only be provided when destination is configured as 'log-analytics'
type LogAnalyticsConfiguration struct {
	CustomerId  *string                     `json:"customerId,omitempty"`
	PropertyBag genruntime.PropertyBag      `json:"$propertyBag,omitempty"`
	SharedKey   *genruntime.SecretReference `json:"sharedKey,omitempty"`
}

// Storage version of v1api20250101.LogAnalyticsConfiguration_STATUS
// Log Analytics configuration, must only be provided when destination is configured as 'log-analytics'
type LogAnalyticsConfiguration_STATUS struct {
	CustomerId  *string                `json:"customerId,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20250101.ManagedEnvironment_Properties_PeerTrafficConfiguration_Encryption_Spec
type ManagedEnvironment_Properties_PeerTrafficConfiguration_Encryption_Spec struct {
	Enabled     *bool                  `json:"enabled,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20250101.ManagedEnvironment_Properties_PeerTrafficConfiguration_Encryption_STATUS
type ManagedEnvironment_Properties_PeerTrafficConfiguration_Encryption_STATUS struct {
	Enabled     *bool                  `json:"enabled,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20250101.Mtls
// Configuration properties for mutual TLS authentication
type Mtls struct {
	Enabled     *bool                  `json:"enabled,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20250101.Mtls_STATUS
// Configuration properties for mutual TLS authentication
type Mtls_STATUS struct {
	Enabled     *bool                  `json:"enabled,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

func init() {
	SchemeBuilder.Register(&ManagedEnvironment{}, &ManagedEnvironmentList{})
}
