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

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,network}
// +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 v1api20220401.TrafficManagerProfilesExternalEndpoint
// Generator information:
// - Generated from: /trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/trafficmanager.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/ExternalEndpoints/{endpointName}
type TrafficManagerProfilesExternalEndpoint struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              TrafficManagerProfilesExternalEndpoint_Spec   `json:"spec,omitempty"`
	Status            TrafficManagerProfilesExternalEndpoint_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &TrafficManagerProfilesExternalEndpoint{}

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

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

var _ configmaps.Exporter = &TrafficManagerProfilesExternalEndpoint{}

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

var _ secrets.Exporter = &TrafficManagerProfilesExternalEndpoint{}

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

var _ genruntime.KubernetesResource = &TrafficManagerProfilesExternalEndpoint{}

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

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

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.Network/trafficmanagerprofiles/ExternalEndpoints"
func (endpoint *TrafficManagerProfilesExternalEndpoint) GetType() string {
	return "Microsoft.Network/trafficmanagerprofiles/ExternalEndpoints"
}

// NewEmptyStatus returns a new empty (blank) status
func (endpoint *TrafficManagerProfilesExternalEndpoint) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &TrafficManagerProfilesExternalEndpoint_STATUS{}
}

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

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

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

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

	endpoint.Status = st
	return nil
}

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

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

// +kubebuilder:object:root=true
// Storage version of v1api20220401.TrafficManagerProfilesExternalEndpoint
// Generator information:
// - Generated from: /trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/trafficmanager.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/ExternalEndpoints/{endpointName}
type TrafficManagerProfilesExternalEndpointList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []TrafficManagerProfilesExternalEndpoint `json:"items"`
}

// Storage version of v1api20220401.TrafficManagerProfilesExternalEndpoint_Spec
type TrafficManagerProfilesExternalEndpoint_Spec struct {
	AlwaysServe *string `json:"alwaysServe,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"`
	CustomHeaders         []EndpointProperties_CustomHeaders                  `json:"customHeaders,omitempty"`
	EndpointLocation      *string                                             `json:"endpointLocation,omitempty"`
	EndpointMonitorStatus *string                                             `json:"endpointMonitorStatus,omitempty"`
	EndpointStatus        *string                                             `json:"endpointStatus,omitempty"`
	GeoMapping            []string                                            `json:"geoMapping,omitempty"`
	MinChildEndpoints     *int                                                `json:"minChildEndpoints,omitempty"`
	MinChildEndpointsIPv4 *int                                                `json:"minChildEndpointsIPv4,omitempty"`
	MinChildEndpointsIPv6 *int                                                `json:"minChildEndpointsIPv6,omitempty"`
	OperatorSpec          *TrafficManagerProfilesExternalEndpointOperatorSpec `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 network.azure.com/TrafficManagerProfile resource
	Owner       *genruntime.KnownResourceReference `group:"network.azure.com" json:"owner,omitempty" kind:"TrafficManagerProfile"`
	Priority    *int                               `json:"priority,omitempty"`
	PropertyBag genruntime.PropertyBag             `json:"$propertyBag,omitempty"`
	Subnets     []EndpointProperties_Subnets       `json:"subnets,omitempty"`
	Target      *string                            `json:"target,omitempty"`

	// TargetResourceReference: The Azure Resource URI of the of the endpoint. Not applicable to endpoints of type
	// 'ExternalEndpoints'.
	TargetResourceReference *genruntime.ResourceReference `armReference:"TargetResourceId" json:"targetResourceReference,omitempty"`
	Type                    *string                       `json:"type,omitempty"`
	Weight                  *int                          `json:"weight,omitempty"`
}

var _ genruntime.ConvertibleSpec = &TrafficManagerProfilesExternalEndpoint_Spec{}

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

	return source.ConvertSpecTo(endpoint)
}

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

	return destination.ConvertSpecFrom(endpoint)
}

// Storage version of v1api20220401.TrafficManagerProfilesExternalEndpoint_STATUS
type TrafficManagerProfilesExternalEndpoint_STATUS struct {
	AlwaysServe           *string                                   `json:"alwaysServe,omitempty"`
	Conditions            []conditions.Condition                    `json:"conditions,omitempty"`
	CustomHeaders         []EndpointProperties_CustomHeaders_STATUS `json:"customHeaders,omitempty"`
	EndpointLocation      *string                                   `json:"endpointLocation,omitempty"`
	EndpointMonitorStatus *string                                   `json:"endpointMonitorStatus,omitempty"`
	EndpointStatus        *string                                   `json:"endpointStatus,omitempty"`
	GeoMapping            []string                                  `json:"geoMapping,omitempty"`
	Id                    *string                                   `json:"id,omitempty"`
	MinChildEndpoints     *int                                      `json:"minChildEndpoints,omitempty"`
	MinChildEndpointsIPv4 *int                                      `json:"minChildEndpointsIPv4,omitempty"`
	MinChildEndpointsIPv6 *int                                      `json:"minChildEndpointsIPv6,omitempty"`
	Name                  *string                                   `json:"name,omitempty"`
	Priority              *int                                      `json:"priority,omitempty"`
	PropertyBag           genruntime.PropertyBag                    `json:"$propertyBag,omitempty"`
	Subnets               []EndpointProperties_Subnets_STATUS       `json:"subnets,omitempty"`
	Target                *string                                   `json:"target,omitempty"`
	TargetResourceId      *string                                   `json:"targetResourceId,omitempty"`
	Type                  *string                                   `json:"type,omitempty"`
	Weight                *int                                      `json:"weight,omitempty"`
}

var _ genruntime.ConvertibleStatus = &TrafficManagerProfilesExternalEndpoint_STATUS{}

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

	return source.ConvertStatusTo(endpoint)
}

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

	return destination.ConvertStatusFrom(endpoint)
}

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

func init() {
	SchemeBuilder.Register(&TrafficManagerProfilesExternalEndpoint{}, &TrafficManagerProfilesExternalEndpointList{})
}
