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

import (
	"fmt"
	arm "github.com/Azure/azure-service-operator/v2/api/network/v1api20200601/arm"
	storage "github.com/Azure/azure-service-operator/v2/api/network/v1api20200601/storage"
	"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"
	"sigs.k8s.io/controller-runtime/pkg/conversion"
)

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,network}
// +kubebuilder:subresource:status
// +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"
// Generator information:
// - Generated from: /privatedns/resource-manager/Microsoft.Network/PrivateDns/stable/2020-06-01/privatedns.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateDnsZones/{privateZoneName}/virtualNetworkLinks/{virtualNetworkLinkName}
type PrivateDnsZonesVirtualNetworkLink struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              PrivateDnsZonesVirtualNetworkLink_Spec   `json:"spec,omitempty"`
	Status            PrivateDnsZonesVirtualNetworkLink_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &PrivateDnsZonesVirtualNetworkLink{}

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

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

var _ conversion.Convertible = &PrivateDnsZonesVirtualNetworkLink{}

// ConvertFrom populates our PrivateDnsZonesVirtualNetworkLink from the provided hub PrivateDnsZonesVirtualNetworkLink
func (link *PrivateDnsZonesVirtualNetworkLink) ConvertFrom(hub conversion.Hub) error {
	// intermediate variable for conversion
	var source storage.PrivateDnsZonesVirtualNetworkLink

	err := source.ConvertFrom(hub)
	if err != nil {
		return eris.Wrap(err, "converting from hub to source")
	}

	err = link.AssignProperties_From_PrivateDnsZonesVirtualNetworkLink(&source)
	if err != nil {
		return eris.Wrap(err, "converting from source to link")
	}

	return nil
}

// ConvertTo populates the provided hub PrivateDnsZonesVirtualNetworkLink from our PrivateDnsZonesVirtualNetworkLink
func (link *PrivateDnsZonesVirtualNetworkLink) ConvertTo(hub conversion.Hub) error {
	// intermediate variable for conversion
	var destination storage.PrivateDnsZonesVirtualNetworkLink
	err := link.AssignProperties_To_PrivateDnsZonesVirtualNetworkLink(&destination)
	if err != nil {
		return eris.Wrap(err, "converting to destination from link")
	}
	err = destination.ConvertTo(hub)
	if err != nil {
		return eris.Wrap(err, "converting from destination to hub")
	}

	return nil
}

var _ configmaps.Exporter = &PrivateDnsZonesVirtualNetworkLink{}

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

var _ secrets.Exporter = &PrivateDnsZonesVirtualNetworkLink{}

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

var _ genruntime.KubernetesResource = &PrivateDnsZonesVirtualNetworkLink{}

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

// GetAPIVersion returns the ARM API version of the resource. This is always "2020-06-01"
func (link PrivateDnsZonesVirtualNetworkLink) GetAPIVersion() string {
	return "2020-06-01"
}

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

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

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

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

// NewEmptyStatus returns a new empty (blank) status
func (link *PrivateDnsZonesVirtualNetworkLink) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &PrivateDnsZonesVirtualNetworkLink_STATUS{}
}

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

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

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

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

	link.Status = st
	return nil
}

// AssignProperties_From_PrivateDnsZonesVirtualNetworkLink populates our PrivateDnsZonesVirtualNetworkLink from the provided source PrivateDnsZonesVirtualNetworkLink
func (link *PrivateDnsZonesVirtualNetworkLink) AssignProperties_From_PrivateDnsZonesVirtualNetworkLink(source *storage.PrivateDnsZonesVirtualNetworkLink) error {

	// ObjectMeta
	link.ObjectMeta = *source.ObjectMeta.DeepCopy()

	// Spec
	var spec PrivateDnsZonesVirtualNetworkLink_Spec
	err := spec.AssignProperties_From_PrivateDnsZonesVirtualNetworkLink_Spec(&source.Spec)
	if err != nil {
		return eris.Wrap(err, "calling AssignProperties_From_PrivateDnsZonesVirtualNetworkLink_Spec() to populate field Spec")
	}
	link.Spec = spec

	// Status
	var status PrivateDnsZonesVirtualNetworkLink_STATUS
	err = status.AssignProperties_From_PrivateDnsZonesVirtualNetworkLink_STATUS(&source.Status)
	if err != nil {
		return eris.Wrap(err, "calling AssignProperties_From_PrivateDnsZonesVirtualNetworkLink_STATUS() to populate field Status")
	}
	link.Status = status

	// No error
	return nil
}

// AssignProperties_To_PrivateDnsZonesVirtualNetworkLink populates the provided destination PrivateDnsZonesVirtualNetworkLink from our PrivateDnsZonesVirtualNetworkLink
func (link *PrivateDnsZonesVirtualNetworkLink) AssignProperties_To_PrivateDnsZonesVirtualNetworkLink(destination *storage.PrivateDnsZonesVirtualNetworkLink) error {

	// ObjectMeta
	destination.ObjectMeta = *link.ObjectMeta.DeepCopy()

	// Spec
	var spec storage.PrivateDnsZonesVirtualNetworkLink_Spec
	err := link.Spec.AssignProperties_To_PrivateDnsZonesVirtualNetworkLink_Spec(&spec)
	if err != nil {
		return eris.Wrap(err, "calling AssignProperties_To_PrivateDnsZonesVirtualNetworkLink_Spec() to populate field Spec")
	}
	destination.Spec = spec

	// Status
	var status storage.PrivateDnsZonesVirtualNetworkLink_STATUS
	err = link.Status.AssignProperties_To_PrivateDnsZonesVirtualNetworkLink_STATUS(&status)
	if err != nil {
		return eris.Wrap(err, "calling AssignProperties_To_PrivateDnsZonesVirtualNetworkLink_STATUS() to populate field Status")
	}
	destination.Status = status

	// No error
	return nil
}

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

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /privatedns/resource-manager/Microsoft.Network/PrivateDns/stable/2020-06-01/privatedns.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateDnsZones/{privateZoneName}/virtualNetworkLinks/{virtualNetworkLinkName}
type PrivateDnsZonesVirtualNetworkLinkList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []PrivateDnsZonesVirtualNetworkLink `json:"items"`
}

type PrivateDnsZonesVirtualNetworkLink_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"`

	// Etag: The ETag of the virtual network link.
	Etag *string `json:"etag,omitempty"`

	// Location: The Azure Region where the resource lives
	Location *string `json:"location,omitempty"`

	// OperatorSpec: The specification for configuring operator behavior. This field is interpreted by the operator and not
	// passed directly to Azure
	OperatorSpec *PrivateDnsZonesVirtualNetworkLinkOperatorSpec `json:"operatorSpec,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/PrivateDnsZone resource
	Owner *genruntime.KnownResourceReference `group:"network.azure.com" json:"owner,omitempty" kind:"PrivateDnsZone"`

	// RegistrationEnabled: Is auto-registration of virtual machine records in the virtual network in the Private DNS zone
	// enabled?
	RegistrationEnabled *bool `json:"registrationEnabled,omitempty"`

	// Tags: Resource tags.
	Tags map[string]string `json:"tags,omitempty"`

	// VirtualNetwork: The reference of the virtual network.
	VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"`
}

var _ genruntime.ARMTransformer = &PrivateDnsZonesVirtualNetworkLink_Spec{}

// ConvertToARM converts from a Kubernetes CRD object to an ARM object
func (link *PrivateDnsZonesVirtualNetworkLink_Spec) ConvertToARM(resolved genruntime.ConvertToARMResolvedDetails) (interface{}, error) {
	if link == nil {
		return nil, nil
	}
	result := &arm.PrivateDnsZonesVirtualNetworkLink_Spec{}

	// Set property "Etag":
	if link.Etag != nil {
		etag := *link.Etag
		result.Etag = &etag
	}

	// Set property "Location":
	if link.Location != nil {
		location := *link.Location
		result.Location = &location
	}

	// Set property "Name":
	result.Name = resolved.Name

	// Set property "Properties":
	if link.RegistrationEnabled != nil || link.VirtualNetwork != nil {
		result.Properties = &arm.VirtualNetworkLinkProperties{}
	}
	if link.RegistrationEnabled != nil {
		registrationEnabled := *link.RegistrationEnabled
		result.Properties.RegistrationEnabled = &registrationEnabled
	}
	if link.VirtualNetwork != nil {
		virtualNetwork_ARM, err := link.VirtualNetwork.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		virtualNetwork := *virtualNetwork_ARM.(*arm.SubResource)
		result.Properties.VirtualNetwork = &virtualNetwork
	}

	// Set property "Tags":
	if link.Tags != nil {
		result.Tags = make(map[string]string, len(link.Tags))
		for key, value := range link.Tags {
			result.Tags[key] = value
		}
	}
	return result, nil
}

// NewEmptyARMValue returns an empty ARM value suitable for deserializing into
func (link *PrivateDnsZonesVirtualNetworkLink_Spec) NewEmptyARMValue() genruntime.ARMResourceStatus {
	return &arm.PrivateDnsZonesVirtualNetworkLink_Spec{}
}

// PopulateFromARM populates a Kubernetes CRD object from an Azure ARM object
func (link *PrivateDnsZonesVirtualNetworkLink_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerReference, armInput interface{}) error {
	typedInput, ok := armInput.(arm.PrivateDnsZonesVirtualNetworkLink_Spec)
	if !ok {
		return fmt.Errorf("unexpected type supplied for PopulateFromARM() function. Expected arm.PrivateDnsZonesVirtualNetworkLink_Spec, got %T", armInput)
	}

	// Set property "AzureName":
	link.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name))

	// Set property "Etag":
	if typedInput.Etag != nil {
		etag := *typedInput.Etag
		link.Etag = &etag
	}

	// Set property "Location":
	if typedInput.Location != nil {
		location := *typedInput.Location
		link.Location = &location
	}

	// no assignment for property "OperatorSpec"

	// Set property "Owner":
	link.Owner = &genruntime.KnownResourceReference{
		Name:  owner.Name,
		ARMID: owner.ARMID,
	}

	// Set property "RegistrationEnabled":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.RegistrationEnabled != nil {
			registrationEnabled := *typedInput.Properties.RegistrationEnabled
			link.RegistrationEnabled = &registrationEnabled
		}
	}

	// Set property "Tags":
	if typedInput.Tags != nil {
		link.Tags = make(map[string]string, len(typedInput.Tags))
		for key, value := range typedInput.Tags {
			link.Tags[key] = value
		}
	}

	// Set property "VirtualNetwork":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.VirtualNetwork != nil {
			var virtualNetwork1 SubResource
			err := virtualNetwork1.PopulateFromARM(owner, *typedInput.Properties.VirtualNetwork)
			if err != nil {
				return err
			}
			virtualNetwork := virtualNetwork1
			link.VirtualNetwork = &virtualNetwork
		}
	}

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &PrivateDnsZonesVirtualNetworkLink_Spec{}

// ConvertSpecFrom populates our PrivateDnsZonesVirtualNetworkLink_Spec from the provided source
func (link *PrivateDnsZonesVirtualNetworkLink_Spec) ConvertSpecFrom(source genruntime.ConvertibleSpec) error {
	src, ok := source.(*storage.PrivateDnsZonesVirtualNetworkLink_Spec)
	if ok {
		// Populate our instance from source
		return link.AssignProperties_From_PrivateDnsZonesVirtualNetworkLink_Spec(src)
	}

	// Convert to an intermediate form
	src = &storage.PrivateDnsZonesVirtualNetworkLink_Spec{}
	err := src.ConvertSpecFrom(source)
	if err != nil {
		return eris.Wrap(err, "initial step of conversion in ConvertSpecFrom()")
	}

	// Update our instance from src
	err = link.AssignProperties_From_PrivateDnsZonesVirtualNetworkLink_Spec(src)
	if err != nil {
		return eris.Wrap(err, "final step of conversion in ConvertSpecFrom()")
	}

	return nil
}

// ConvertSpecTo populates the provided destination from our PrivateDnsZonesVirtualNetworkLink_Spec
func (link *PrivateDnsZonesVirtualNetworkLink_Spec) ConvertSpecTo(destination genruntime.ConvertibleSpec) error {
	dst, ok := destination.(*storage.PrivateDnsZonesVirtualNetworkLink_Spec)
	if ok {
		// Populate destination from our instance
		return link.AssignProperties_To_PrivateDnsZonesVirtualNetworkLink_Spec(dst)
	}

	// Convert to an intermediate form
	dst = &storage.PrivateDnsZonesVirtualNetworkLink_Spec{}
	err := link.AssignProperties_To_PrivateDnsZonesVirtualNetworkLink_Spec(dst)
	if err != nil {
		return eris.Wrap(err, "initial step of conversion in ConvertSpecTo()")
	}

	// Update dst from our instance
	err = dst.ConvertSpecTo(destination)
	if err != nil {
		return eris.Wrap(err, "final step of conversion in ConvertSpecTo()")
	}

	return nil
}

// AssignProperties_From_PrivateDnsZonesVirtualNetworkLink_Spec populates our PrivateDnsZonesVirtualNetworkLink_Spec from the provided source PrivateDnsZonesVirtualNetworkLink_Spec
func (link *PrivateDnsZonesVirtualNetworkLink_Spec) AssignProperties_From_PrivateDnsZonesVirtualNetworkLink_Spec(source *storage.PrivateDnsZonesVirtualNetworkLink_Spec) error {

	// AzureName
	link.AzureName = source.AzureName

	// Etag
	link.Etag = genruntime.ClonePointerToString(source.Etag)

	// Location
	link.Location = genruntime.ClonePointerToString(source.Location)

	// OperatorSpec
	if source.OperatorSpec != nil {
		var operatorSpec PrivateDnsZonesVirtualNetworkLinkOperatorSpec
		err := operatorSpec.AssignProperties_From_PrivateDnsZonesVirtualNetworkLinkOperatorSpec(source.OperatorSpec)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_PrivateDnsZonesVirtualNetworkLinkOperatorSpec() to populate field OperatorSpec")
		}
		link.OperatorSpec = &operatorSpec
	} else {
		link.OperatorSpec = nil
	}

	// Owner
	if source.Owner != nil {
		owner := source.Owner.Copy()
		link.Owner = &owner
	} else {
		link.Owner = nil
	}

	// RegistrationEnabled
	if source.RegistrationEnabled != nil {
		registrationEnabled := *source.RegistrationEnabled
		link.RegistrationEnabled = &registrationEnabled
	} else {
		link.RegistrationEnabled = nil
	}

	// Tags
	link.Tags = genruntime.CloneMapOfStringToString(source.Tags)

	// VirtualNetwork
	if source.VirtualNetwork != nil {
		var virtualNetwork SubResource
		err := virtualNetwork.AssignProperties_From_SubResource(source.VirtualNetwork)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_SubResource() to populate field VirtualNetwork")
		}
		link.VirtualNetwork = &virtualNetwork
	} else {
		link.VirtualNetwork = nil
	}

	// No error
	return nil
}

// AssignProperties_To_PrivateDnsZonesVirtualNetworkLink_Spec populates the provided destination PrivateDnsZonesVirtualNetworkLink_Spec from our PrivateDnsZonesVirtualNetworkLink_Spec
func (link *PrivateDnsZonesVirtualNetworkLink_Spec) AssignProperties_To_PrivateDnsZonesVirtualNetworkLink_Spec(destination *storage.PrivateDnsZonesVirtualNetworkLink_Spec) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// AzureName
	destination.AzureName = link.AzureName

	// Etag
	destination.Etag = genruntime.ClonePointerToString(link.Etag)

	// Location
	destination.Location = genruntime.ClonePointerToString(link.Location)

	// OperatorSpec
	if link.OperatorSpec != nil {
		var operatorSpec storage.PrivateDnsZonesVirtualNetworkLinkOperatorSpec
		err := link.OperatorSpec.AssignProperties_To_PrivateDnsZonesVirtualNetworkLinkOperatorSpec(&operatorSpec)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_PrivateDnsZonesVirtualNetworkLinkOperatorSpec() to populate field OperatorSpec")
		}
		destination.OperatorSpec = &operatorSpec
	} else {
		destination.OperatorSpec = nil
	}

	// OriginalVersion
	destination.OriginalVersion = link.OriginalVersion()

	// Owner
	if link.Owner != nil {
		owner := link.Owner.Copy()
		destination.Owner = &owner
	} else {
		destination.Owner = nil
	}

	// RegistrationEnabled
	if link.RegistrationEnabled != nil {
		registrationEnabled := *link.RegistrationEnabled
		destination.RegistrationEnabled = &registrationEnabled
	} else {
		destination.RegistrationEnabled = nil
	}

	// Tags
	destination.Tags = genruntime.CloneMapOfStringToString(link.Tags)

	// VirtualNetwork
	if link.VirtualNetwork != nil {
		var virtualNetwork storage.SubResource
		err := link.VirtualNetwork.AssignProperties_To_SubResource(&virtualNetwork)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_SubResource() to populate field VirtualNetwork")
		}
		destination.VirtualNetwork = &virtualNetwork
	} else {
		destination.VirtualNetwork = nil
	}

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

	// No error
	return nil
}

// OriginalVersion returns the original API version used to create the resource.
func (link *PrivateDnsZonesVirtualNetworkLink_Spec) OriginalVersion() string {
	return GroupVersion.Version
}

// SetAzureName sets the Azure name of the resource
func (link *PrivateDnsZonesVirtualNetworkLink_Spec) SetAzureName(azureName string) {
	link.AzureName = azureName
}

type PrivateDnsZonesVirtualNetworkLink_STATUS struct {
	// Conditions: The observed state of the resource
	Conditions []conditions.Condition `json:"conditions,omitempty"`

	// Etag: The ETag of the virtual network link.
	Etag *string `json:"etag,omitempty"`

	// Id: Fully qualified resource Id for the resource. Example -
	// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateDnsZones/{privateDnsZoneName}'.
	Id *string `json:"id,omitempty"`

	// Location: The Azure Region where the resource lives
	Location *string `json:"location,omitempty"`

	// Name: The name of the resource
	Name *string `json:"name,omitempty"`

	// ProvisioningState: The provisioning state of the resource. This is a read-only property and any attempt to set this
	// value will be ignored.
	ProvisioningState *VirtualNetworkLinkProperties_ProvisioningState_STATUS `json:"provisioningState,omitempty"`

	// RegistrationEnabled: Is auto-registration of virtual machine records in the virtual network in the Private DNS zone
	// enabled?
	RegistrationEnabled *bool `json:"registrationEnabled,omitempty"`

	// Tags: Resource tags.
	Tags map[string]string `json:"tags,omitempty"`

	// Type: The type of the resource. Example - 'Microsoft.Network/privateDnsZones'.
	Type *string `json:"type,omitempty"`

	// VirtualNetwork: The reference of the virtual network.
	VirtualNetwork *SubResource_STATUS `json:"virtualNetwork,omitempty"`

	// VirtualNetworkLinkState: The status of the virtual network link to the Private DNS zone. Possible values are
	// 'InProgress' and 'Done'. This is a read-only property and any attempt to set this value will be ignored.
	VirtualNetworkLinkState *VirtualNetworkLinkProperties_VirtualNetworkLinkState_STATUS `json:"virtualNetworkLinkState,omitempty"`
}

var _ genruntime.ConvertibleStatus = &PrivateDnsZonesVirtualNetworkLink_STATUS{}

// ConvertStatusFrom populates our PrivateDnsZonesVirtualNetworkLink_STATUS from the provided source
func (link *PrivateDnsZonesVirtualNetworkLink_STATUS) ConvertStatusFrom(source genruntime.ConvertibleStatus) error {
	src, ok := source.(*storage.PrivateDnsZonesVirtualNetworkLink_STATUS)
	if ok {
		// Populate our instance from source
		return link.AssignProperties_From_PrivateDnsZonesVirtualNetworkLink_STATUS(src)
	}

	// Convert to an intermediate form
	src = &storage.PrivateDnsZonesVirtualNetworkLink_STATUS{}
	err := src.ConvertStatusFrom(source)
	if err != nil {
		return eris.Wrap(err, "initial step of conversion in ConvertStatusFrom()")
	}

	// Update our instance from src
	err = link.AssignProperties_From_PrivateDnsZonesVirtualNetworkLink_STATUS(src)
	if err != nil {
		return eris.Wrap(err, "final step of conversion in ConvertStatusFrom()")
	}

	return nil
}

// ConvertStatusTo populates the provided destination from our PrivateDnsZonesVirtualNetworkLink_STATUS
func (link *PrivateDnsZonesVirtualNetworkLink_STATUS) ConvertStatusTo(destination genruntime.ConvertibleStatus) error {
	dst, ok := destination.(*storage.PrivateDnsZonesVirtualNetworkLink_STATUS)
	if ok {
		// Populate destination from our instance
		return link.AssignProperties_To_PrivateDnsZonesVirtualNetworkLink_STATUS(dst)
	}

	// Convert to an intermediate form
	dst = &storage.PrivateDnsZonesVirtualNetworkLink_STATUS{}
	err := link.AssignProperties_To_PrivateDnsZonesVirtualNetworkLink_STATUS(dst)
	if err != nil {
		return eris.Wrap(err, "initial step of conversion in ConvertStatusTo()")
	}

	// Update dst from our instance
	err = dst.ConvertStatusTo(destination)
	if err != nil {
		return eris.Wrap(err, "final step of conversion in ConvertStatusTo()")
	}

	return nil
}

var _ genruntime.FromARMConverter = &PrivateDnsZonesVirtualNetworkLink_STATUS{}

// NewEmptyARMValue returns an empty ARM value suitable for deserializing into
func (link *PrivateDnsZonesVirtualNetworkLink_STATUS) NewEmptyARMValue() genruntime.ARMResourceStatus {
	return &arm.PrivateDnsZonesVirtualNetworkLink_STATUS{}
}

// PopulateFromARM populates a Kubernetes CRD object from an Azure ARM object
func (link *PrivateDnsZonesVirtualNetworkLink_STATUS) PopulateFromARM(owner genruntime.ArbitraryOwnerReference, armInput interface{}) error {
	typedInput, ok := armInput.(arm.PrivateDnsZonesVirtualNetworkLink_STATUS)
	if !ok {
		return fmt.Errorf("unexpected type supplied for PopulateFromARM() function. Expected arm.PrivateDnsZonesVirtualNetworkLink_STATUS, got %T", armInput)
	}

	// no assignment for property "Conditions"

	// Set property "Etag":
	if typedInput.Etag != nil {
		etag := *typedInput.Etag
		link.Etag = &etag
	}

	// Set property "Id":
	if typedInput.Id != nil {
		id := *typedInput.Id
		link.Id = &id
	}

	// Set property "Location":
	if typedInput.Location != nil {
		location := *typedInput.Location
		link.Location = &location
	}

	// Set property "Name":
	if typedInput.Name != nil {
		name := *typedInput.Name
		link.Name = &name
	}

	// Set property "ProvisioningState":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ProvisioningState != nil {
			var temp string
			temp = string(*typedInput.Properties.ProvisioningState)
			provisioningState := VirtualNetworkLinkProperties_ProvisioningState_STATUS(temp)
			link.ProvisioningState = &provisioningState
		}
	}

	// Set property "RegistrationEnabled":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.RegistrationEnabled != nil {
			registrationEnabled := *typedInput.Properties.RegistrationEnabled
			link.RegistrationEnabled = &registrationEnabled
		}
	}

	// Set property "Tags":
	if typedInput.Tags != nil {
		link.Tags = make(map[string]string, len(typedInput.Tags))
		for key, value := range typedInput.Tags {
			link.Tags[key] = value
		}
	}

	// Set property "Type":
	if typedInput.Type != nil {
		typeVar := *typedInput.Type
		link.Type = &typeVar
	}

	// Set property "VirtualNetwork":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.VirtualNetwork != nil {
			var virtualNetwork1 SubResource_STATUS
			err := virtualNetwork1.PopulateFromARM(owner, *typedInput.Properties.VirtualNetwork)
			if err != nil {
				return err
			}
			virtualNetwork := virtualNetwork1
			link.VirtualNetwork = &virtualNetwork
		}
	}

	// Set property "VirtualNetworkLinkState":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.VirtualNetworkLinkState != nil {
			var temp string
			temp = string(*typedInput.Properties.VirtualNetworkLinkState)
			virtualNetworkLinkState := VirtualNetworkLinkProperties_VirtualNetworkLinkState_STATUS(temp)
			link.VirtualNetworkLinkState = &virtualNetworkLinkState
		}
	}

	// No error
	return nil
}

// AssignProperties_From_PrivateDnsZonesVirtualNetworkLink_STATUS populates our PrivateDnsZonesVirtualNetworkLink_STATUS from the provided source PrivateDnsZonesVirtualNetworkLink_STATUS
func (link *PrivateDnsZonesVirtualNetworkLink_STATUS) AssignProperties_From_PrivateDnsZonesVirtualNetworkLink_STATUS(source *storage.PrivateDnsZonesVirtualNetworkLink_STATUS) error {

	// Conditions
	link.Conditions = genruntime.CloneSliceOfCondition(source.Conditions)

	// Etag
	link.Etag = genruntime.ClonePointerToString(source.Etag)

	// Id
	link.Id = genruntime.ClonePointerToString(source.Id)

	// Location
	link.Location = genruntime.ClonePointerToString(source.Location)

	// Name
	link.Name = genruntime.ClonePointerToString(source.Name)

	// ProvisioningState
	if source.ProvisioningState != nil {
		provisioningState := *source.ProvisioningState
		provisioningStateTemp := genruntime.ToEnum(provisioningState, virtualNetworkLinkProperties_ProvisioningState_STATUS_Values)
		link.ProvisioningState = &provisioningStateTemp
	} else {
		link.ProvisioningState = nil
	}

	// RegistrationEnabled
	if source.RegistrationEnabled != nil {
		registrationEnabled := *source.RegistrationEnabled
		link.RegistrationEnabled = &registrationEnabled
	} else {
		link.RegistrationEnabled = nil
	}

	// Tags
	link.Tags = genruntime.CloneMapOfStringToString(source.Tags)

	// Type
	link.Type = genruntime.ClonePointerToString(source.Type)

	// VirtualNetwork
	if source.VirtualNetwork != nil {
		var virtualNetwork SubResource_STATUS
		err := virtualNetwork.AssignProperties_From_SubResource_STATUS(source.VirtualNetwork)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_SubResource_STATUS() to populate field VirtualNetwork")
		}
		link.VirtualNetwork = &virtualNetwork
	} else {
		link.VirtualNetwork = nil
	}

	// VirtualNetworkLinkState
	if source.VirtualNetworkLinkState != nil {
		virtualNetworkLinkState := *source.VirtualNetworkLinkState
		virtualNetworkLinkStateTemp := genruntime.ToEnum(virtualNetworkLinkState, virtualNetworkLinkProperties_VirtualNetworkLinkState_STATUS_Values)
		link.VirtualNetworkLinkState = &virtualNetworkLinkStateTemp
	} else {
		link.VirtualNetworkLinkState = nil
	}

	// No error
	return nil
}

// AssignProperties_To_PrivateDnsZonesVirtualNetworkLink_STATUS populates the provided destination PrivateDnsZonesVirtualNetworkLink_STATUS from our PrivateDnsZonesVirtualNetworkLink_STATUS
func (link *PrivateDnsZonesVirtualNetworkLink_STATUS) AssignProperties_To_PrivateDnsZonesVirtualNetworkLink_STATUS(destination *storage.PrivateDnsZonesVirtualNetworkLink_STATUS) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// Conditions
	destination.Conditions = genruntime.CloneSliceOfCondition(link.Conditions)

	// Etag
	destination.Etag = genruntime.ClonePointerToString(link.Etag)

	// Id
	destination.Id = genruntime.ClonePointerToString(link.Id)

	// Location
	destination.Location = genruntime.ClonePointerToString(link.Location)

	// Name
	destination.Name = genruntime.ClonePointerToString(link.Name)

	// ProvisioningState
	if link.ProvisioningState != nil {
		provisioningState := string(*link.ProvisioningState)
		destination.ProvisioningState = &provisioningState
	} else {
		destination.ProvisioningState = nil
	}

	// RegistrationEnabled
	if link.RegistrationEnabled != nil {
		registrationEnabled := *link.RegistrationEnabled
		destination.RegistrationEnabled = &registrationEnabled
	} else {
		destination.RegistrationEnabled = nil
	}

	// Tags
	destination.Tags = genruntime.CloneMapOfStringToString(link.Tags)

	// Type
	destination.Type = genruntime.ClonePointerToString(link.Type)

	// VirtualNetwork
	if link.VirtualNetwork != nil {
		var virtualNetwork storage.SubResource_STATUS
		err := link.VirtualNetwork.AssignProperties_To_SubResource_STATUS(&virtualNetwork)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_SubResource_STATUS() to populate field VirtualNetwork")
		}
		destination.VirtualNetwork = &virtualNetwork
	} else {
		destination.VirtualNetwork = nil
	}

	// VirtualNetworkLinkState
	if link.VirtualNetworkLinkState != nil {
		virtualNetworkLinkState := string(*link.VirtualNetworkLinkState)
		destination.VirtualNetworkLinkState = &virtualNetworkLinkState
	} else {
		destination.VirtualNetworkLinkState = nil
	}

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

	// No error
	return nil
}

// Details for configuring operator behavior. Fields in this struct are interpreted by the operator directly rather than being passed to Azure
type PrivateDnsZonesVirtualNetworkLinkOperatorSpec struct {
	// ConfigMapExpressions: configures where to place operator written dynamic ConfigMaps (created with CEL expressions).
	ConfigMapExpressions []*core.DestinationExpression `json:"configMapExpressions,omitempty"`

	// SecretExpressions: configures where to place operator written dynamic secrets (created with CEL expressions).
	SecretExpressions []*core.DestinationExpression `json:"secretExpressions,omitempty"`
}

// AssignProperties_From_PrivateDnsZonesVirtualNetworkLinkOperatorSpec populates our PrivateDnsZonesVirtualNetworkLinkOperatorSpec from the provided source PrivateDnsZonesVirtualNetworkLinkOperatorSpec
func (operator *PrivateDnsZonesVirtualNetworkLinkOperatorSpec) AssignProperties_From_PrivateDnsZonesVirtualNetworkLinkOperatorSpec(source *storage.PrivateDnsZonesVirtualNetworkLinkOperatorSpec) error {

	// ConfigMapExpressions
	if source.ConfigMapExpressions != nil {
		configMapExpressionList := make([]*core.DestinationExpression, len(source.ConfigMapExpressions))
		for configMapExpressionIndex, configMapExpressionItem := range source.ConfigMapExpressions {
			if configMapExpressionItem != nil {
				configMapExpression := *configMapExpressionItem.DeepCopy()
				configMapExpressionList[configMapExpressionIndex] = &configMapExpression
			} else {
				configMapExpressionList[configMapExpressionIndex] = nil
			}
		}
		operator.ConfigMapExpressions = configMapExpressionList
	} else {
		operator.ConfigMapExpressions = nil
	}

	// SecretExpressions
	if source.SecretExpressions != nil {
		secretExpressionList := make([]*core.DestinationExpression, len(source.SecretExpressions))
		for secretExpressionIndex, secretExpressionItem := range source.SecretExpressions {
			if secretExpressionItem != nil {
				secretExpression := *secretExpressionItem.DeepCopy()
				secretExpressionList[secretExpressionIndex] = &secretExpression
			} else {
				secretExpressionList[secretExpressionIndex] = nil
			}
		}
		operator.SecretExpressions = secretExpressionList
	} else {
		operator.SecretExpressions = nil
	}

	// No error
	return nil
}

// AssignProperties_To_PrivateDnsZonesVirtualNetworkLinkOperatorSpec populates the provided destination PrivateDnsZonesVirtualNetworkLinkOperatorSpec from our PrivateDnsZonesVirtualNetworkLinkOperatorSpec
func (operator *PrivateDnsZonesVirtualNetworkLinkOperatorSpec) AssignProperties_To_PrivateDnsZonesVirtualNetworkLinkOperatorSpec(destination *storage.PrivateDnsZonesVirtualNetworkLinkOperatorSpec) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// ConfigMapExpressions
	if operator.ConfigMapExpressions != nil {
		configMapExpressionList := make([]*core.DestinationExpression, len(operator.ConfigMapExpressions))
		for configMapExpressionIndex, configMapExpressionItem := range operator.ConfigMapExpressions {
			if configMapExpressionItem != nil {
				configMapExpression := *configMapExpressionItem.DeepCopy()
				configMapExpressionList[configMapExpressionIndex] = &configMapExpression
			} else {
				configMapExpressionList[configMapExpressionIndex] = nil
			}
		}
		destination.ConfigMapExpressions = configMapExpressionList
	} else {
		destination.ConfigMapExpressions = nil
	}

	// SecretExpressions
	if operator.SecretExpressions != nil {
		secretExpressionList := make([]*core.DestinationExpression, len(operator.SecretExpressions))
		for secretExpressionIndex, secretExpressionItem := range operator.SecretExpressions {
			if secretExpressionItem != nil {
				secretExpression := *secretExpressionItem.DeepCopy()
				secretExpressionList[secretExpressionIndex] = &secretExpression
			} else {
				secretExpressionList[secretExpressionIndex] = nil
			}
		}
		destination.SecretExpressions = secretExpressionList
	} else {
		destination.SecretExpressions = nil
	}

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

	// No error
	return nil
}

// Reference to another subresource.
type SubResource struct {
	// Reference: Resource ID.
	Reference *genruntime.ResourceReference `armReference:"Id" json:"reference,omitempty"`
}

var _ genruntime.ARMTransformer = &SubResource{}

// ConvertToARM converts from a Kubernetes CRD object to an ARM object
func (resource *SubResource) ConvertToARM(resolved genruntime.ConvertToARMResolvedDetails) (interface{}, error) {
	if resource == nil {
		return nil, nil
	}
	result := &arm.SubResource{}

	// Set property "Id":
	if resource.Reference != nil {
		referenceARMID, err := resolved.ResolvedReferences.Lookup(*resource.Reference)
		if err != nil {
			return nil, err
		}
		reference := referenceARMID
		result.Id = &reference
	}
	return result, nil
}

// NewEmptyARMValue returns an empty ARM value suitable for deserializing into
func (resource *SubResource) NewEmptyARMValue() genruntime.ARMResourceStatus {
	return &arm.SubResource{}
}

// PopulateFromARM populates a Kubernetes CRD object from an Azure ARM object
func (resource *SubResource) PopulateFromARM(owner genruntime.ArbitraryOwnerReference, armInput interface{}) error {
	_, ok := armInput.(arm.SubResource)
	if !ok {
		return fmt.Errorf("unexpected type supplied for PopulateFromARM() function. Expected arm.SubResource, got %T", armInput)
	}

	// no assignment for property "Reference"

	// No error
	return nil
}

// AssignProperties_From_SubResource populates our SubResource from the provided source SubResource
func (resource *SubResource) AssignProperties_From_SubResource(source *storage.SubResource) error {

	// Reference
	if source.Reference != nil {
		reference := source.Reference.Copy()
		resource.Reference = &reference
	} else {
		resource.Reference = nil
	}

	// No error
	return nil
}

// AssignProperties_To_SubResource populates the provided destination SubResource from our SubResource
func (resource *SubResource) AssignProperties_To_SubResource(destination *storage.SubResource) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// Reference
	if resource.Reference != nil {
		reference := resource.Reference.Copy()
		destination.Reference = &reference
	} else {
		destination.Reference = nil
	}

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

	// No error
	return nil
}

// Reference to another subresource.
type SubResource_STATUS struct {
	// Id: Resource ID.
	Id *string `json:"id,omitempty"`
}

var _ genruntime.FromARMConverter = &SubResource_STATUS{}

// NewEmptyARMValue returns an empty ARM value suitable for deserializing into
func (resource *SubResource_STATUS) NewEmptyARMValue() genruntime.ARMResourceStatus {
	return &arm.SubResource_STATUS{}
}

// PopulateFromARM populates a Kubernetes CRD object from an Azure ARM object
func (resource *SubResource_STATUS) PopulateFromARM(owner genruntime.ArbitraryOwnerReference, armInput interface{}) error {
	typedInput, ok := armInput.(arm.SubResource_STATUS)
	if !ok {
		return fmt.Errorf("unexpected type supplied for PopulateFromARM() function. Expected arm.SubResource_STATUS, got %T", armInput)
	}

	// Set property "Id":
	if typedInput.Id != nil {
		id := *typedInput.Id
		resource.Id = &id
	}

	// No error
	return nil
}

// AssignProperties_From_SubResource_STATUS populates our SubResource_STATUS from the provided source SubResource_STATUS
func (resource *SubResource_STATUS) AssignProperties_From_SubResource_STATUS(source *storage.SubResource_STATUS) error {

	// Id
	resource.Id = genruntime.ClonePointerToString(source.Id)

	// No error
	return nil
}

// AssignProperties_To_SubResource_STATUS populates the provided destination SubResource_STATUS from our SubResource_STATUS
func (resource *SubResource_STATUS) AssignProperties_To_SubResource_STATUS(destination *storage.SubResource_STATUS) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// Id
	destination.Id = genruntime.ClonePointerToString(resource.Id)

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

	// No error
	return nil
}

type VirtualNetworkLinkProperties_ProvisioningState_STATUS string

const (
	VirtualNetworkLinkProperties_ProvisioningState_STATUS_Canceled  = VirtualNetworkLinkProperties_ProvisioningState_STATUS("Canceled")
	VirtualNetworkLinkProperties_ProvisioningState_STATUS_Creating  = VirtualNetworkLinkProperties_ProvisioningState_STATUS("Creating")
	VirtualNetworkLinkProperties_ProvisioningState_STATUS_Deleting  = VirtualNetworkLinkProperties_ProvisioningState_STATUS("Deleting")
	VirtualNetworkLinkProperties_ProvisioningState_STATUS_Failed    = VirtualNetworkLinkProperties_ProvisioningState_STATUS("Failed")
	VirtualNetworkLinkProperties_ProvisioningState_STATUS_Succeeded = VirtualNetworkLinkProperties_ProvisioningState_STATUS("Succeeded")
	VirtualNetworkLinkProperties_ProvisioningState_STATUS_Updating  = VirtualNetworkLinkProperties_ProvisioningState_STATUS("Updating")
)

// Mapping from string to VirtualNetworkLinkProperties_ProvisioningState_STATUS
var virtualNetworkLinkProperties_ProvisioningState_STATUS_Values = map[string]VirtualNetworkLinkProperties_ProvisioningState_STATUS{
	"canceled":  VirtualNetworkLinkProperties_ProvisioningState_STATUS_Canceled,
	"creating":  VirtualNetworkLinkProperties_ProvisioningState_STATUS_Creating,
	"deleting":  VirtualNetworkLinkProperties_ProvisioningState_STATUS_Deleting,
	"failed":    VirtualNetworkLinkProperties_ProvisioningState_STATUS_Failed,
	"succeeded": VirtualNetworkLinkProperties_ProvisioningState_STATUS_Succeeded,
	"updating":  VirtualNetworkLinkProperties_ProvisioningState_STATUS_Updating,
}

type VirtualNetworkLinkProperties_VirtualNetworkLinkState_STATUS string

const (
	VirtualNetworkLinkProperties_VirtualNetworkLinkState_STATUS_Completed  = VirtualNetworkLinkProperties_VirtualNetworkLinkState_STATUS("Completed")
	VirtualNetworkLinkProperties_VirtualNetworkLinkState_STATUS_InProgress = VirtualNetworkLinkProperties_VirtualNetworkLinkState_STATUS("InProgress")
)

// Mapping from string to VirtualNetworkLinkProperties_VirtualNetworkLinkState_STATUS
var virtualNetworkLinkProperties_VirtualNetworkLinkState_STATUS_Values = map[string]VirtualNetworkLinkProperties_VirtualNetworkLinkState_STATUS{
	"completed":  VirtualNetworkLinkProperties_VirtualNetworkLinkState_STATUS_Completed,
	"inprogress": VirtualNetworkLinkProperties_VirtualNetworkLinkState_STATUS_InProgress,
}

func init() {
	SchemeBuilder.Register(&PrivateDnsZonesVirtualNetworkLink{}, &PrivateDnsZonesVirtualNetworkLinkList{})
}
