// Code generated by azure-service-operator-codegen. DO NOT EDIT.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
package storage

import (
	"context"
	"github.com/Azure/azure-service-operator/v2/internal/genericarmclient"
	"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/go-logr/logr"
	"github.com/rotisserie/eris"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/runtime/schema"
	"sigs.k8s.io/controller-runtime/pkg/client"
)

// +kubebuilder:rbac:groups=network.azure.com,resources=privatelinkservices,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=network.azure.com,resources={privatelinkservices/status,privatelinkservices/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 v1api20240301.PrivateLinkService
// Generator information:
// - Generated from: /network/resource-manager/Microsoft.Network/stable/2024-03-01/privateLinkService.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateLinkServices/{serviceName}
type PrivateLinkService struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              PrivateLinkService_Spec   `json:"spec,omitempty"`
	Status            PrivateLinkService_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &PrivateLinkService{}

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

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

var _ configmaps.Exporter = &PrivateLinkService{}

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

var _ secrets.Exporter = &PrivateLinkService{}

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

var _ genruntime.KubernetesConfigExporter = &PrivateLinkService{}

// ExportKubernetesConfigMaps defines a resource which can create ConfigMaps in Kubernetes.
func (service *PrivateLinkService) ExportKubernetesConfigMaps(_ context.Context, _ genruntime.MetaObject, _ *genericarmclient.GenericClient, _ logr.Logger) ([]client.Object, error) {
	collector := configmaps.NewCollector(service.Namespace)
	if service.Spec.OperatorSpec != nil && service.Spec.OperatorSpec.ConfigMaps != nil {
		if service.Status.Alias != nil {
			collector.AddValue(service.Spec.OperatorSpec.ConfigMaps.Alias, *service.Status.Alias)
		}
	}
	result, err := collector.Values()
	if err != nil {
		return nil, err
	}
	return configmaps.SliceToClientObjectSlice(result), nil
}

var _ genruntime.KubernetesResource = &PrivateLinkService{}

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

// GetAPIVersion returns the ARM API version of the resource. This is always "2024-03-01"
func (service PrivateLinkService) GetAPIVersion() string {
	return "2024-03-01"
}

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

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

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

// GetSupportedOperations returns the operations supported by the resource
func (service *PrivateLinkService) 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/privateLinkServices"
func (service *PrivateLinkService) GetType() string {
	return "Microsoft.Network/privateLinkServices"
}

// NewEmptyStatus returns a new empty (blank) status
func (service *PrivateLinkService) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &PrivateLinkService_STATUS{}
}

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

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

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

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

	service.Status = st
	return nil
}

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

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

// +kubebuilder:object:root=true
// Storage version of v1api20240301.PrivateLinkService
// Generator information:
// - Generated from: /network/resource-manager/Microsoft.Network/stable/2024-03-01/privateLinkService.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateLinkServices/{serviceName}
type PrivateLinkServiceList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []PrivateLinkService `json:"items"`
}

// Storage version of v1api20240301.PrivateLinkService_Spec
type PrivateLinkService_Spec struct {
	AutoApproval *ResourceSet `json:"autoApproval,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"`
	DestinationIPAddress                 *string                                                          `json:"destinationIPAddress,omitempty"`
	EnableProxyProtocol                  *bool                                                            `json:"enableProxyProtocol,omitempty"`
	ExtendedLocation                     *ExtendedLocation                                                `json:"extendedLocation,omitempty"`
	Fqdns                                []string                                                         `json:"fqdns,omitempty"`
	IpConfigurations                     []PrivateLinkServiceIpConfiguration                              `json:"ipConfigurations,omitempty"`
	LoadBalancerFrontendIpConfigurations []FrontendIPConfiguration_PrivateLinkService_SubResourceEmbedded `json:"loadBalancerFrontendIpConfigurations,omitempty"`
	Location                             *string                                                          `json:"location,omitempty"`
	OperatorSpec                         *PrivateLinkServiceOperatorSpec                                  `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"`
	Tags        map[string]string                  `json:"tags,omitempty"`
	Visibility  *ResourceSet                       `json:"visibility,omitempty"`
}

var _ genruntime.ConvertibleSpec = &PrivateLinkService_Spec{}

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

	return source.ConvertSpecTo(service)
}

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

	return destination.ConvertSpecFrom(service)
}

// Storage version of v1api20240301.PrivateLinkService_STATUS
// Private link service resource.
type PrivateLinkService_STATUS struct {
	Alias                                *string                                                                 `json:"alias,omitempty"`
	AutoApproval                         *ResourceSet_STATUS                                                     `json:"autoApproval,omitempty"`
	Conditions                           []conditions.Condition                                                  `json:"conditions,omitempty"`
	DestinationIPAddress                 *string                                                                 `json:"destinationIPAddress,omitempty"`
	EnableProxyProtocol                  *bool                                                                   `json:"enableProxyProtocol,omitempty"`
	Etag                                 *string                                                                 `json:"etag,omitempty"`
	ExtendedLocation                     *ExtendedLocation_STATUS                                                `json:"extendedLocation,omitempty"`
	Fqdns                                []string                                                                `json:"fqdns,omitempty"`
	Id                                   *string                                                                 `json:"id,omitempty"`
	IpConfigurations                     []PrivateLinkServiceIpConfiguration_STATUS                              `json:"ipConfigurations,omitempty"`
	LoadBalancerFrontendIpConfigurations []FrontendIPConfiguration_STATUS_PrivateLinkService_SubResourceEmbedded `json:"loadBalancerFrontendIpConfigurations,omitempty"`
	Location                             *string                                                                 `json:"location,omitempty"`
	Name                                 *string                                                                 `json:"name,omitempty"`
	NetworkInterfaces                    []NetworkInterface_STATUS_PrivateLinkService_SubResourceEmbedded        `json:"networkInterfaces,omitempty"`
	PrivateEndpointConnections           []PrivateEndpointConnection_STATUS                                      `json:"privateEndpointConnections,omitempty"`
	PropertyBag                          genruntime.PropertyBag                                                  `json:"$propertyBag,omitempty"`
	ProvisioningState                    *string                                                                 `json:"provisioningState,omitempty"`
	Tags                                 map[string]string                                                       `json:"tags,omitempty"`
	Type                                 *string                                                                 `json:"type,omitempty"`
	Visibility                           *ResourceSet_STATUS                                                     `json:"visibility,omitempty"`
}

var _ genruntime.ConvertibleStatus = &PrivateLinkService_STATUS{}

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

	return source.ConvertStatusTo(service)
}

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

	return destination.ConvertStatusFrom(service)
}

// Storage version of v1api20240301.FrontendIPConfiguration_PrivateLinkService_SubResourceEmbedded
// Frontend IP address of the load balancer.
type FrontendIPConfiguration_PrivateLinkService_SubResourceEmbedded struct {
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`

	// Reference: Resource ID.
	Reference *genruntime.ResourceReference `armReference:"Id" json:"reference,omitempty"`
}

// Storage version of v1api20240301.FrontendIPConfiguration_STATUS_PrivateLinkService_SubResourceEmbedded
// Frontend IP address of the load balancer.
type FrontendIPConfiguration_STATUS_PrivateLinkService_SubResourceEmbedded struct {
	Id          *string                `json:"id,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20240301.NetworkInterface_STATUS_PrivateLinkService_SubResourceEmbedded
// A network interface in a resource group.
type NetworkInterface_STATUS_PrivateLinkService_SubResourceEmbedded struct {
	Id          *string                `json:"id,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20240301.PrivateEndpointConnection_STATUS
// PrivateEndpointConnection resource.
type PrivateEndpointConnection_STATUS struct {
	Id          *string                `json:"id,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20240301.PrivateLinkServiceIpConfiguration
// The private link service ip configuration.
type PrivateLinkServiceIpConfiguration struct {
	Name                      *string                                        `json:"name,omitempty"`
	Primary                   *bool                                          `json:"primary,omitempty"`
	PrivateIPAddress          *string                                        `json:"privateIPAddress,omitempty"`
	PrivateIPAddressVersion   *string                                        `json:"privateIPAddressVersion,omitempty"`
	PrivateIPAllocationMethod *string                                        `json:"privateIPAllocationMethod,omitempty"`
	PropertyBag               genruntime.PropertyBag                         `json:"$propertyBag,omitempty"`
	Subnet                    *Subnet_PrivateLinkService_SubResourceEmbedded `json:"subnet,omitempty"`
}

// Storage version of v1api20240301.PrivateLinkServiceIpConfiguration_STATUS
// The private link service ip configuration.
type PrivateLinkServiceIpConfiguration_STATUS struct {
	Etag                      *string                                               `json:"etag,omitempty"`
	Id                        *string                                               `json:"id,omitempty"`
	Name                      *string                                               `json:"name,omitempty"`
	Primary                   *bool                                                 `json:"primary,omitempty"`
	PrivateIPAddress          *string                                               `json:"privateIPAddress,omitempty"`
	PrivateIPAddressVersion   *string                                               `json:"privateIPAddressVersion,omitempty"`
	PrivateIPAllocationMethod *string                                               `json:"privateIPAllocationMethod,omitempty"`
	PropertyBag               genruntime.PropertyBag                                `json:"$propertyBag,omitempty"`
	ProvisioningState         *string                                               `json:"provisioningState,omitempty"`
	Subnet                    *Subnet_STATUS_PrivateLinkService_SubResourceEmbedded `json:"subnet,omitempty"`
	Type                      *string                                               `json:"type,omitempty"`
}

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

// Storage version of v1api20240301.ResourceSet
// The base resource set for visibility and auto-approval.
type ResourceSet struct {
	PropertyBag   genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	Subscriptions []string               `json:"subscriptions,omitempty"`
}

// Storage version of v1api20240301.ResourceSet_STATUS
// The base resource set for visibility and auto-approval.
type ResourceSet_STATUS struct {
	PropertyBag   genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	Subscriptions []string               `json:"subscriptions,omitempty"`
}

// Storage version of v1api20240301.PrivateLinkServiceOperatorConfigMaps
type PrivateLinkServiceOperatorConfigMaps struct {
	Alias       *genruntime.ConfigMapDestination `json:"alias,omitempty"`
	PropertyBag genruntime.PropertyBag           `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20240301.Subnet_PrivateLinkService_SubResourceEmbedded
// Subnet in a virtual network resource.
type Subnet_PrivateLinkService_SubResourceEmbedded struct {
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`

	// Reference: Resource ID.
	Reference *genruntime.ResourceReference `armReference:"Id" json:"reference,omitempty"`
}

// Storage version of v1api20240301.Subnet_STATUS_PrivateLinkService_SubResourceEmbedded
// Subnet in a virtual network resource.
type Subnet_STATUS_PrivateLinkService_SubResourceEmbedded struct {
	Id          *string                `json:"id,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

func init() {
	SchemeBuilder.Register(&PrivateLinkService{}, &PrivateLinkServiceList{})
}
