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

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,cdn}
// +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 v1api20230501.AfdOrigin
// Generator information:
// - Generated from: /cdn/resource-manager/Microsoft.Cdn/Cdn/stable/2023-05-01/afdx.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}
type AfdOrigin struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              AfdOrigin_Spec   `json:"spec,omitempty"`
	Status            AfdOrigin_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &AfdOrigin{}

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

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

var _ configmaps.Exporter = &AfdOrigin{}

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

var _ secrets.Exporter = &AfdOrigin{}

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

var _ genruntime.KubernetesResource = &AfdOrigin{}

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

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

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.Cdn/profiles/originGroups/origins"
func (origin *AfdOrigin) GetType() string {
	return "Microsoft.Cdn/profiles/originGroups/origins"
}

// NewEmptyStatus returns a new empty (blank) status
func (origin *AfdOrigin) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &AfdOrigin_STATUS{}
}

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

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

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

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

	origin.Status = st
	return nil
}

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

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

// +kubebuilder:object:root=true
// Storage version of v1api20230501.AfdOrigin
// Generator information:
// - Generated from: /cdn/resource-manager/Microsoft.Cdn/Cdn/stable/2023-05-01/afdx.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}
type AfdOriginList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []AfdOrigin `json:"items"`
}

// Storage version of v1api20230501.AfdOrigin_Spec
type AfdOrigin_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"`
	AzureOrigin                 *ResourceReference             `json:"azureOrigin,omitempty"`
	EnabledState                *string                        `json:"enabledState,omitempty"`
	EnforceCertificateNameCheck *bool                          `json:"enforceCertificateNameCheck,omitempty"`
	HostName                    *string                        `json:"hostName,omitempty" optionalConfigMapPair:"HostName"`
	HostNameFromConfig          *genruntime.ConfigMapReference `json:"hostNameFromConfig,omitempty" optionalConfigMapPair:"HostName"`
	HttpPort                    *int                           `json:"httpPort,omitempty"`
	HttpsPort                   *int                           `json:"httpsPort,omitempty"`
	OperatorSpec                *AfdOriginOperatorSpec         `json:"operatorSpec,omitempty"`
	OriginHostHeader            *string                        `json:"originHostHeader,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 cdn.azure.com/AfdOriginGroup resource
	Owner                     *genruntime.KnownResourceReference   `group:"cdn.azure.com" json:"owner,omitempty" kind:"AfdOriginGroup"`
	Priority                  *int                                 `json:"priority,omitempty"`
	PropertyBag               genruntime.PropertyBag               `json:"$propertyBag,omitempty"`
	SharedPrivateLinkResource *SharedPrivateLinkResourceProperties `json:"sharedPrivateLinkResource,omitempty"`
	Weight                    *int                                 `json:"weight,omitempty"`
}

var _ genruntime.ConvertibleSpec = &AfdOrigin_Spec{}

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

	return source.ConvertSpecTo(origin)
}

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

	return destination.ConvertSpecFrom(origin)
}

// Storage version of v1api20230501.AfdOrigin_STATUS
type AfdOrigin_STATUS struct {
	AzureOrigin                 *ResourceReference_STATUS                   `json:"azureOrigin,omitempty"`
	Conditions                  []conditions.Condition                      `json:"conditions,omitempty"`
	DeploymentStatus            *string                                     `json:"deploymentStatus,omitempty"`
	EnabledState                *string                                     `json:"enabledState,omitempty"`
	EnforceCertificateNameCheck *bool                                       `json:"enforceCertificateNameCheck,omitempty"`
	HostName                    *string                                     `json:"hostName,omitempty"`
	HttpPort                    *int                                        `json:"httpPort,omitempty"`
	HttpsPort                   *int                                        `json:"httpsPort,omitempty"`
	Id                          *string                                     `json:"id,omitempty"`
	Name                        *string                                     `json:"name,omitempty"`
	OriginGroupName             *string                                     `json:"originGroupName,omitempty"`
	OriginHostHeader            *string                                     `json:"originHostHeader,omitempty"`
	Priority                    *int                                        `json:"priority,omitempty"`
	PropertyBag                 genruntime.PropertyBag                      `json:"$propertyBag,omitempty"`
	ProvisioningState           *string                                     `json:"provisioningState,omitempty"`
	SharedPrivateLinkResource   *SharedPrivateLinkResourceProperties_STATUS `json:"sharedPrivateLinkResource,omitempty"`
	SystemData                  *SystemData_STATUS                          `json:"systemData,omitempty"`
	Type                        *string                                     `json:"type,omitempty"`
	Weight                      *int                                        `json:"weight,omitempty"`
}

var _ genruntime.ConvertibleStatus = &AfdOrigin_STATUS{}

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

	return source.ConvertStatusTo(origin)
}

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

	return destination.ConvertStatusFrom(origin)
}

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

// Storage version of v1api20230501.SharedPrivateLinkResourceProperties
// Describes the properties of an existing Shared Private Link Resource to use when connecting to a private origin.
type SharedPrivateLinkResourceProperties struct {
	GroupId             *string                `json:"groupId,omitempty"`
	PrivateLink         *ResourceReference     `json:"privateLink,omitempty"`
	PrivateLinkLocation *string                `json:"privateLinkLocation,omitempty"`
	PropertyBag         genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	RequestMessage      *string                `json:"requestMessage,omitempty"`
	Status              *string                `json:"status,omitempty"`
}

// Storage version of v1api20230501.SharedPrivateLinkResourceProperties_STATUS
// Describes the properties of an existing Shared Private Link Resource to use when connecting to a private origin.
type SharedPrivateLinkResourceProperties_STATUS struct {
	GroupId             *string                   `json:"groupId,omitempty"`
	PrivateLink         *ResourceReference_STATUS `json:"privateLink,omitempty"`
	PrivateLinkLocation *string                   `json:"privateLinkLocation,omitempty"`
	PropertyBag         genruntime.PropertyBag    `json:"$propertyBag,omitempty"`
	RequestMessage      *string                   `json:"requestMessage,omitempty"`
	Status              *string                   `json:"status,omitempty"`
}

func init() {
	SchemeBuilder.Register(&AfdOrigin{}, &AfdOriginList{})
}
