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

var _ conditions.Conditioner = &PublicIPPrefix{}

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

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

var _ configmaps.Exporter = &PublicIPPrefix{}

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

var _ secrets.Exporter = &PublicIPPrefix{}

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

var _ genruntime.KubernetesResource = &PublicIPPrefix{}

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

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

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

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

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

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

// NewEmptyStatus returns a new empty (blank) status
func (prefix *PublicIPPrefix) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &PublicIPPrefix_STATUS{}
}

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

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

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

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

	prefix.Status = st
	return nil
}

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

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

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

// Storage version of v1api20240301.PublicIPPrefix_Spec
type PublicIPPrefix_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"`
	CustomIPPrefix   *SubResource                                       `json:"customIPPrefix,omitempty"`
	ExtendedLocation *ExtendedLocation                                  `json:"extendedLocation,omitempty"`
	IpTags           []IpTag                                            `json:"ipTags,omitempty"`
	Location         *string                                            `json:"location,omitempty"`
	NatGateway       *NatGatewaySpec_PublicIPPrefix_SubResourceEmbedded `json:"natGateway,omitempty"`
	OperatorSpec     *PublicIPPrefixOperatorSpec                        `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"`
	PrefixLength           *int                               `json:"prefixLength,omitempty"`
	PropertyBag            genruntime.PropertyBag             `json:"$propertyBag,omitempty"`
	PublicIPAddressVersion *string                            `json:"publicIPAddressVersion,omitempty"`
	Sku                    *PublicIPPrefixSku                 `json:"sku,omitempty"`
	Tags                   map[string]string                  `json:"tags,omitempty"`
	Zones                  []string                           `json:"zones,omitempty"`
}

var _ genruntime.ConvertibleSpec = &PublicIPPrefix_Spec{}

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

	return source.ConvertSpecTo(prefix)
}

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

	return destination.ConvertSpecFrom(prefix)
}

// Storage version of v1api20240301.PublicIPPrefix_STATUS
// Public IP prefix resource.
type PublicIPPrefix_STATUS struct {
	Conditions                          []conditions.Condition                                `json:"conditions,omitempty"`
	CustomIPPrefix                      *SubResource_STATUS                                   `json:"customIPPrefix,omitempty"`
	Etag                                *string                                               `json:"etag,omitempty"`
	ExtendedLocation                    *ExtendedLocation_STATUS                              `json:"extendedLocation,omitempty"`
	Id                                  *string                                               `json:"id,omitempty"`
	IpPrefix                            *string                                               `json:"ipPrefix,omitempty"`
	IpTags                              []IpTag_STATUS                                        `json:"ipTags,omitempty"`
	LoadBalancerFrontendIpConfiguration *SubResource_STATUS                                   `json:"loadBalancerFrontendIpConfiguration,omitempty"`
	Location                            *string                                               `json:"location,omitempty"`
	Name                                *string                                               `json:"name,omitempty"`
	NatGateway                          *NatGateway_STATUS_PublicIPPrefix_SubResourceEmbedded `json:"natGateway,omitempty"`
	PrefixLength                        *int                                                  `json:"prefixLength,omitempty"`
	PropertyBag                         genruntime.PropertyBag                                `json:"$propertyBag,omitempty"`
	ProvisioningState                   *string                                               `json:"provisioningState,omitempty"`
	PublicIPAddressVersion              *string                                               `json:"publicIPAddressVersion,omitempty"`
	PublicIPAddresses                   []ReferencedPublicIpAddress_STATUS                    `json:"publicIPAddresses,omitempty"`
	ResourceGuid                        *string                                               `json:"resourceGuid,omitempty"`
	Sku                                 *PublicIPPrefixSku_STATUS                             `json:"sku,omitempty"`
	Tags                                map[string]string                                     `json:"tags,omitempty"`
	Type                                *string                                               `json:"type,omitempty"`
	Zones                               []string                                              `json:"zones,omitempty"`
}

var _ genruntime.ConvertibleStatus = &PublicIPPrefix_STATUS{}

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

	return source.ConvertStatusTo(prefix)
}

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

	return destination.ConvertStatusFrom(prefix)
}

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

// Storage version of v1api20240301.NatGatewaySpec_PublicIPPrefix_SubResourceEmbedded
// Nat Gateway resource.
type NatGatewaySpec_PublicIPPrefix_SubResourceEmbedded struct {
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`

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

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

// Storage version of v1api20240301.PublicIPPrefixSku
// SKU of a public IP prefix.
type PublicIPPrefixSku struct {
	Name        *string                `json:"name,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	Tier        *string                `json:"tier,omitempty"`
}

// Storage version of v1api20240301.PublicIPPrefixSku_STATUS
// SKU of a public IP prefix.
type PublicIPPrefixSku_STATUS struct {
	Name        *string                `json:"name,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	Tier        *string                `json:"tier,omitempty"`
}

// Storage version of v1api20240301.ReferencedPublicIpAddress_STATUS
// Reference to a public IP address.
type ReferencedPublicIpAddress_STATUS struct {
	Id          *string                `json:"id,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

func init() {
	SchemeBuilder.Register(&PublicIPPrefix{}, &PublicIPPrefixList{})
}
