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

import (
	v20220701s "github.com/Azure/azure-service-operator/v2/api/network/v1api20220701/storage"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime/conditions"
	"github.com/pkg/errors"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/runtime/schema"
)

// +kubebuilder:rbac:groups=network.azure.com,resources=publicipaddresses,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=network.azure.com,resources={publicipaddresses/status,publicipaddresses/finalizers},verbs=get;update;patch

// +kubebuilder:object:root=true
// +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 v1api20201101.PublicIPAddress
// Generator information:
// - Generated from: /network/resource-manager/Microsoft.Network/stable/2020-11-01/publicIpAddress.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}
type PublicIPAddress struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              PublicIPAddress_Spec                                       `json:"spec,omitempty"`
	Status            PublicIPAddress_STATUS_PublicIPAddress_SubResourceEmbedded `json:"status,omitempty"`
}

var _ conditions.Conditioner = &PublicIPAddress{}

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

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

var _ genruntime.KubernetesResource = &PublicIPAddress{}

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

// GetAPIVersion returns the ARM API version of the resource. This is always "2020-11-01"
func (address PublicIPAddress) GetAPIVersion() string {
	return string(APIVersion_Value)
}

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

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

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

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

// NewEmptyStatus returns a new empty (blank) status
func (address *PublicIPAddress) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &PublicIPAddress_STATUS_PublicIPAddress_SubResourceEmbedded{}
}

// Owner returns the ResourceReference of the owner
func (address *PublicIPAddress) Owner() *genruntime.ResourceReference {
	group, kind := genruntime.LookupOwnerGroupKind(address.Spec)
	return address.Spec.Owner.AsResourceReference(group, kind)
}

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

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

	address.Status = st
	return nil
}

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

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

// +kubebuilder:object:root=true
// Storage version of v1api20201101.PublicIPAddress
// Generator information:
// - Generated from: /network/resource-manager/Microsoft.Network/stable/2020-11-01/publicIpAddress.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}
type PublicIPAddressList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []PublicIPAddress `json:"items"`
}

// Storage version of v1api20201101.PublicIPAddress_Spec
type PublicIPAddress_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"`
	DdosSettings          *DdosSettings                                            `json:"ddosSettings,omitempty"`
	DnsSettings           *PublicIPAddressDnsSettings                              `json:"dnsSettings,omitempty"`
	ExtendedLocation      *ExtendedLocation                                        `json:"extendedLocation,omitempty"`
	IdleTimeoutInMinutes  *int                                                     `json:"idleTimeoutInMinutes,omitempty"`
	IpAddress             *string                                                  `json:"ipAddress,omitempty"`
	IpTags                []IpTag                                                  `json:"ipTags,omitempty"`
	LinkedPublicIPAddress *PublicIPAddressSpec_PublicIPAddress_SubResourceEmbedded `json:"linkedPublicIPAddress,omitempty"`
	Location              *string                                                  `json:"location,omitempty"`
	NatGateway            *NatGatewaySpec_PublicIPAddress_SubResourceEmbedded      `json:"natGateway,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"`
	PublicIPAddressVersion   *string                                                  `json:"publicIPAddressVersion,omitempty"`
	PublicIPAllocationMethod *string                                                  `json:"publicIPAllocationMethod,omitempty"`
	PublicIPPrefix           *SubResource                                             `json:"publicIPPrefix,omitempty"`
	ServicePublicIPAddress   *PublicIPAddressSpec_PublicIPAddress_SubResourceEmbedded `json:"servicePublicIPAddress,omitempty"`
	Sku                      *PublicIPAddressSku                                      `json:"sku,omitempty"`
	Tags                     map[string]string                                        `json:"tags,omitempty"`
	Zones                    []string                                                 `json:"zones,omitempty"`
}

var _ genruntime.ConvertibleSpec = &PublicIPAddress_Spec{}

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

	return source.ConvertSpecTo(address)
}

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

	return destination.ConvertSpecFrom(address)
}

// Storage version of v1api20201101.PublicIPAddress_STATUS_PublicIPAddress_SubResourceEmbedded
// Public IP address resource.
type PublicIPAddress_STATUS_PublicIPAddress_SubResourceEmbedded struct {
	Conditions               []conditions.Condition                                      `json:"conditions,omitempty"`
	DdosSettings             *DdosSettings_STATUS                                        `json:"ddosSettings,omitempty"`
	DnsSettings              *PublicIPAddressDnsSettings_STATUS                          `json:"dnsSettings,omitempty"`
	Etag                     *string                                                     `json:"etag,omitempty"`
	ExtendedLocation         *ExtendedLocation_STATUS                                    `json:"extendedLocation,omitempty"`
	Id                       *string                                                     `json:"id,omitempty"`
	IdleTimeoutInMinutes     *int                                                        `json:"idleTimeoutInMinutes,omitempty"`
	IpAddress                *string                                                     `json:"ipAddress,omitempty"`
	IpConfiguration          *IPConfiguration_STATUS_PublicIPAddress_SubResourceEmbedded `json:"ipConfiguration,omitempty"`
	IpTags                   []IpTag_STATUS                                              `json:"ipTags,omitempty"`
	Location                 *string                                                     `json:"location,omitempty"`
	MigrationPhase           *string                                                     `json:"migrationPhase,omitempty"`
	Name                     *string                                                     `json:"name,omitempty"`
	NatGateway               *NatGateway_STATUS_PublicIPAddress_SubResourceEmbedded      `json:"natGateway,omitempty"`
	PropertyBag              genruntime.PropertyBag                                      `json:"$propertyBag,omitempty"`
	ProvisioningState        *string                                                     `json:"provisioningState,omitempty"`
	PublicIPAddressVersion   *string                                                     `json:"publicIPAddressVersion,omitempty"`
	PublicIPAllocationMethod *string                                                     `json:"publicIPAllocationMethod,omitempty"`
	PublicIPPrefix           *SubResource_STATUS                                         `json:"publicIPPrefix,omitempty"`
	ResourceGuid             *string                                                     `json:"resourceGuid,omitempty"`
	Sku                      *PublicIPAddressSku_STATUS                                  `json:"sku,omitempty"`
	Tags                     map[string]string                                           `json:"tags,omitempty"`
	Type                     *string                                                     `json:"type,omitempty"`
	Zones                    []string                                                    `json:"zones,omitempty"`
}

var _ genruntime.ConvertibleStatus = &PublicIPAddress_STATUS_PublicIPAddress_SubResourceEmbedded{}

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

	return source.ConvertStatusTo(embedded)
}

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

	return destination.ConvertStatusFrom(embedded)
}

// Storage version of v1api20201101.DdosSettings
// Contains the DDoS protection settings of the public IP.
type DdosSettings struct {
	DdosCustomPolicy   *SubResource           `json:"ddosCustomPolicy,omitempty"`
	PropertyBag        genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	ProtectedIP        *bool                  `json:"protectedIP,omitempty"`
	ProtectionCoverage *string                `json:"protectionCoverage,omitempty"`
}

// Storage version of v1api20201101.DdosSettings_STATUS
// Contains the DDoS protection settings of the public IP.
type DdosSettings_STATUS struct {
	DdosCustomPolicy   *SubResource_STATUS    `json:"ddosCustomPolicy,omitempty"`
	PropertyBag        genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	ProtectedIP        *bool                  `json:"protectedIP,omitempty"`
	ProtectionCoverage *string                `json:"protectionCoverage,omitempty"`
}

// Storage version of v1api20201101.IPConfiguration_STATUS_PublicIPAddress_SubResourceEmbedded
// IP configuration.
type IPConfiguration_STATUS_PublicIPAddress_SubResourceEmbedded struct {
	Id          *string                `json:"id,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20201101.IpTag
// Contains the IpTag associated with the object.
type IpTag struct {
	IpTagType   *string                `json:"ipTagType,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	Tag         *string                `json:"tag,omitempty"`
}

// AssignProperties_From_IpTag populates our IpTag from the provided source IpTag
func (ipTag *IpTag) AssignProperties_From_IpTag(source *v20220701s.IpTag) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(source.PropertyBag)

	// IpTagType
	ipTag.IpTagType = genruntime.ClonePointerToString(source.IpTagType)

	// Tag
	ipTag.Tag = genruntime.ClonePointerToString(source.Tag)

	// Update the property bag
	if len(propertyBag) > 0 {
		ipTag.PropertyBag = propertyBag
	} else {
		ipTag.PropertyBag = nil
	}

	// Invoke the augmentConversionForIpTag interface (if implemented) to customize the conversion
	var ipTagAsAny any = ipTag
	if augmentedIpTag, ok := ipTagAsAny.(augmentConversionForIpTag); ok {
		err := augmentedIpTag.AssignPropertiesFrom(source)
		if err != nil {
			return errors.Wrap(err, "calling augmented AssignPropertiesFrom() for conversion")
		}
	}

	// No error
	return nil
}

// AssignProperties_To_IpTag populates the provided destination IpTag from our IpTag
func (ipTag *IpTag) AssignProperties_To_IpTag(destination *v20220701s.IpTag) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(ipTag.PropertyBag)

	// IpTagType
	destination.IpTagType = genruntime.ClonePointerToString(ipTag.IpTagType)

	// Tag
	destination.Tag = genruntime.ClonePointerToString(ipTag.Tag)

	// Update the property bag
	if len(propertyBag) > 0 {
		destination.PropertyBag = propertyBag
	} else {
		destination.PropertyBag = nil
	}

	// Invoke the augmentConversionForIpTag interface (if implemented) to customize the conversion
	var ipTagAsAny any = ipTag
	if augmentedIpTag, ok := ipTagAsAny.(augmentConversionForIpTag); ok {
		err := augmentedIpTag.AssignPropertiesTo(destination)
		if err != nil {
			return errors.Wrap(err, "calling augmented AssignPropertiesTo() for conversion")
		}
	}

	// No error
	return nil
}

// Storage version of v1api20201101.IpTag_STATUS
// Contains the IpTag associated with the object.
type IpTag_STATUS struct {
	IpTagType   *string                `json:"ipTagType,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	Tag         *string                `json:"tag,omitempty"`
}

// AssignProperties_From_IpTag_STATUS populates our IpTag_STATUS from the provided source IpTag_STATUS
func (ipTag *IpTag_STATUS) AssignProperties_From_IpTag_STATUS(source *v20220701s.IpTag_STATUS) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(source.PropertyBag)

	// IpTagType
	ipTag.IpTagType = genruntime.ClonePointerToString(source.IpTagType)

	// Tag
	ipTag.Tag = genruntime.ClonePointerToString(source.Tag)

	// Update the property bag
	if len(propertyBag) > 0 {
		ipTag.PropertyBag = propertyBag
	} else {
		ipTag.PropertyBag = nil
	}

	// Invoke the augmentConversionForIpTag_STATUS interface (if implemented) to customize the conversion
	var ipTagAsAny any = ipTag
	if augmentedIpTag, ok := ipTagAsAny.(augmentConversionForIpTag_STATUS); ok {
		err := augmentedIpTag.AssignPropertiesFrom(source)
		if err != nil {
			return errors.Wrap(err, "calling augmented AssignPropertiesFrom() for conversion")
		}
	}

	// No error
	return nil
}

// AssignProperties_To_IpTag_STATUS populates the provided destination IpTag_STATUS from our IpTag_STATUS
func (ipTag *IpTag_STATUS) AssignProperties_To_IpTag_STATUS(destination *v20220701s.IpTag_STATUS) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(ipTag.PropertyBag)

	// IpTagType
	destination.IpTagType = genruntime.ClonePointerToString(ipTag.IpTagType)

	// Tag
	destination.Tag = genruntime.ClonePointerToString(ipTag.Tag)

	// Update the property bag
	if len(propertyBag) > 0 {
		destination.PropertyBag = propertyBag
	} else {
		destination.PropertyBag = nil
	}

	// Invoke the augmentConversionForIpTag_STATUS interface (if implemented) to customize the conversion
	var ipTagAsAny any = ipTag
	if augmentedIpTag, ok := ipTagAsAny.(augmentConversionForIpTag_STATUS); ok {
		err := augmentedIpTag.AssignPropertiesTo(destination)
		if err != nil {
			return errors.Wrap(err, "calling augmented AssignPropertiesTo() for conversion")
		}
	}

	// No error
	return nil
}

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

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

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

// Storage version of v1api20201101.PublicIPAddressDnsSettings
// Contains FQDN of the DNS record associated with the public IP address.
type PublicIPAddressDnsSettings struct {
	DomainNameLabel *string                `json:"domainNameLabel,omitempty"`
	Fqdn            *string                `json:"fqdn,omitempty"`
	PropertyBag     genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	ReverseFqdn     *string                `json:"reverseFqdn,omitempty"`
}

// Storage version of v1api20201101.PublicIPAddressDnsSettings_STATUS
// Contains FQDN of the DNS record associated with the public IP address.
type PublicIPAddressDnsSettings_STATUS struct {
	DomainNameLabel *string                `json:"domainNameLabel,omitempty"`
	Fqdn            *string                `json:"fqdn,omitempty"`
	PropertyBag     genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	ReverseFqdn     *string                `json:"reverseFqdn,omitempty"`
}

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

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

// Storage version of v1api20201101.PublicIPAddressSpec_PublicIPAddress_SubResourceEmbedded
// Public IP address resource.
type PublicIPAddressSpec_PublicIPAddress_SubResourceEmbedded struct {
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`

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

type augmentConversionForIpTag interface {
	AssignPropertiesFrom(src *v20220701s.IpTag) error
	AssignPropertiesTo(dst *v20220701s.IpTag) error
}

type augmentConversionForIpTag_STATUS interface {
	AssignPropertiesFrom(src *v20220701s.IpTag_STATUS) error
	AssignPropertiesTo(dst *v20220701s.IpTag_STATUS) error
}

func init() {
	SchemeBuilder.Register(&PublicIPAddress{}, &PublicIPAddressList{})
}
