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

import (
	"fmt"
	v20220701s "github.com/Azure/azure-service-operator/v2/api/network/v1api20220701/storage"
	v20240101s "github.com/Azure/azure-service-operator/v2/api/network/v1api20240101/storage"
	v20240301s "github.com/Azure/azure-service-operator/v2/api/network/v1api20240301/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"
// Storage version of v1api20201101.VirtualNetwork
// Generator information:
// - Generated from: /network/resource-manager/Microsoft.Network/stable/2020-11-01/virtualNetwork.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}
type VirtualNetwork struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              VirtualNetwork_Spec   `json:"spec,omitempty"`
	Status            VirtualNetwork_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &VirtualNetwork{}

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

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

var _ conversion.Convertible = &VirtualNetwork{}

// ConvertFrom populates our VirtualNetwork from the provided hub VirtualNetwork
func (network *VirtualNetwork) ConvertFrom(hub conversion.Hub) error {
	source, ok := hub.(*v20240301s.VirtualNetwork)
	if !ok {
		return fmt.Errorf("expected network/v1api20240301/storage/VirtualNetwork but received %T instead", hub)
	}

	return network.AssignProperties_From_VirtualNetwork(source)
}

// ConvertTo populates the provided hub VirtualNetwork from our VirtualNetwork
func (network *VirtualNetwork) ConvertTo(hub conversion.Hub) error {
	destination, ok := hub.(*v20240301s.VirtualNetwork)
	if !ok {
		return fmt.Errorf("expected network/v1api20240301/storage/VirtualNetwork but received %T instead", hub)
	}

	return network.AssignProperties_To_VirtualNetwork(destination)
}

var _ configmaps.Exporter = &VirtualNetwork{}

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

var _ secrets.Exporter = &VirtualNetwork{}

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

var _ genruntime.KubernetesResource = &VirtualNetwork{}

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

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

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

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

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

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

// NewEmptyStatus returns a new empty (blank) status
func (network *VirtualNetwork) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &VirtualNetwork_STATUS{}
}

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

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

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

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

	network.Status = st
	return nil
}

// AssignProperties_From_VirtualNetwork populates our VirtualNetwork from the provided source VirtualNetwork
func (network *VirtualNetwork) AssignProperties_From_VirtualNetwork(source *v20240301s.VirtualNetwork) error {

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

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

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

	// Invoke the augmentConversionForVirtualNetwork interface (if implemented) to customize the conversion
	var networkAsAny any = network
	if augmentedNetwork, ok := networkAsAny.(augmentConversionForVirtualNetwork); ok {
		err := augmentedNetwork.AssignPropertiesFrom(source)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesFrom() for conversion")
		}
	}

	// No error
	return nil
}

// AssignProperties_To_VirtualNetwork populates the provided destination VirtualNetwork from our VirtualNetwork
func (network *VirtualNetwork) AssignProperties_To_VirtualNetwork(destination *v20240301s.VirtualNetwork) error {

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

	// Spec
	var spec v20240301s.VirtualNetwork_Spec
	err := network.Spec.AssignProperties_To_VirtualNetwork_Spec(&spec)
	if err != nil {
		return eris.Wrap(err, "calling AssignProperties_To_VirtualNetwork_Spec() to populate field Spec")
	}
	destination.Spec = spec

	// Status
	var status v20240301s.VirtualNetwork_STATUS
	err = network.Status.AssignProperties_To_VirtualNetwork_STATUS(&status)
	if err != nil {
		return eris.Wrap(err, "calling AssignProperties_To_VirtualNetwork_STATUS() to populate field Status")
	}
	destination.Status = status

	// Invoke the augmentConversionForVirtualNetwork interface (if implemented) to customize the conversion
	var networkAsAny any = network
	if augmentedNetwork, ok := networkAsAny.(augmentConversionForVirtualNetwork); ok {
		err := augmentedNetwork.AssignPropertiesTo(destination)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesTo() for conversion")
		}
	}

	// No error
	return nil
}

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

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

type augmentConversionForVirtualNetwork interface {
	AssignPropertiesFrom(src *v20240301s.VirtualNetwork) error
	AssignPropertiesTo(dst *v20240301s.VirtualNetwork) error
}

// Storage version of v1api20201101.VirtualNetwork_Spec
type VirtualNetwork_Spec struct {
	AddressSpace *AddressSpace `json:"addressSpace,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"`
	BgpCommunities       *VirtualNetworkBgpCommunities `json:"bgpCommunities,omitempty"`
	DdosProtectionPlan   *SubResource                  `json:"ddosProtectionPlan,omitempty"`
	DhcpOptions          *DhcpOptions                  `json:"dhcpOptions,omitempty"`
	EnableDdosProtection *bool                         `json:"enableDdosProtection,omitempty"`
	EnableVmProtection   *bool                         `json:"enableVmProtection,omitempty"`
	ExtendedLocation     *ExtendedLocation             `json:"extendedLocation,omitempty"`
	IpAllocations        []SubResource                 `json:"ipAllocations,omitempty"`
	Location             *string                       `json:"location,omitempty"`
	OperatorSpec         *VirtualNetworkOperatorSpec   `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"`
}

var _ genruntime.ConvertibleSpec = &VirtualNetwork_Spec{}

// ConvertSpecFrom populates our VirtualNetwork_Spec from the provided source
func (network *VirtualNetwork_Spec) ConvertSpecFrom(source genruntime.ConvertibleSpec) error {
	src, ok := source.(*v20240301s.VirtualNetwork_Spec)
	if ok {
		// Populate our instance from source
		return network.AssignProperties_From_VirtualNetwork_Spec(src)
	}

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

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

	return nil
}

// ConvertSpecTo populates the provided destination from our VirtualNetwork_Spec
func (network *VirtualNetwork_Spec) ConvertSpecTo(destination genruntime.ConvertibleSpec) error {
	dst, ok := destination.(*v20240301s.VirtualNetwork_Spec)
	if ok {
		// Populate destination from our instance
		return network.AssignProperties_To_VirtualNetwork_Spec(dst)
	}

	// Convert to an intermediate form
	dst = &v20240301s.VirtualNetwork_Spec{}
	err := network.AssignProperties_To_VirtualNetwork_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_VirtualNetwork_Spec populates our VirtualNetwork_Spec from the provided source VirtualNetwork_Spec
func (network *VirtualNetwork_Spec) AssignProperties_From_VirtualNetwork_Spec(source *v20240301s.VirtualNetwork_Spec) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(source.PropertyBag)

	// AddressSpace
	if source.AddressSpace != nil {
		var addressSpace AddressSpace
		err := addressSpace.AssignProperties_From_AddressSpace(source.AddressSpace)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_AddressSpace() to populate field AddressSpace")
		}
		network.AddressSpace = &addressSpace
	} else {
		network.AddressSpace = nil
	}

	// AzureName
	network.AzureName = source.AzureName

	// BgpCommunities
	if source.BgpCommunities != nil {
		var bgpCommunity VirtualNetworkBgpCommunities
		err := bgpCommunity.AssignProperties_From_VirtualNetworkBgpCommunities(source.BgpCommunities)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_VirtualNetworkBgpCommunities() to populate field BgpCommunities")
		}
		network.BgpCommunities = &bgpCommunity
	} else {
		network.BgpCommunities = nil
	}

	// DdosProtectionPlan
	if source.DdosProtectionPlan != nil {
		var subResourceStash v20220701s.SubResource
		err := subResourceStash.AssignProperties_From_SubResource(source.DdosProtectionPlan)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_SubResource() to populate field SubResourceStash from DdosProtectionPlan")
		}
		var ddosProtectionPlan SubResource
		err = ddosProtectionPlan.AssignProperties_From_SubResource(&subResourceStash)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_SubResource() to populate field DdosProtectionPlan from SubResourceStash")
		}
		network.DdosProtectionPlan = &ddosProtectionPlan
	} else {
		network.DdosProtectionPlan = nil
	}

	// DhcpOptions
	if source.DhcpOptions != nil {
		var dhcpOption DhcpOptions
		err := dhcpOption.AssignProperties_From_DhcpOptions(source.DhcpOptions)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_DhcpOptions() to populate field DhcpOptions")
		}
		network.DhcpOptions = &dhcpOption
	} else {
		network.DhcpOptions = nil
	}

	// EnableDdosProtection
	if source.EnableDdosProtection != nil {
		enableDdosProtection := *source.EnableDdosProtection
		network.EnableDdosProtection = &enableDdosProtection
	} else {
		network.EnableDdosProtection = nil
	}

	// EnableVmProtection
	if source.EnableVmProtection != nil {
		enableVmProtection := *source.EnableVmProtection
		network.EnableVmProtection = &enableVmProtection
	} else {
		network.EnableVmProtection = nil
	}

	// Encryption
	if source.Encryption != nil {
		propertyBag.Add("Encryption", *source.Encryption)
	} else {
		propertyBag.Remove("Encryption")
	}

	// ExtendedLocation
	if source.ExtendedLocation != nil {
		var extendedLocationStash v20220701s.ExtendedLocation
		err := extendedLocationStash.AssignProperties_From_ExtendedLocation(source.ExtendedLocation)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_ExtendedLocation() to populate field ExtendedLocationStash from ExtendedLocation")
		}
		var extendedLocation ExtendedLocation
		err = extendedLocation.AssignProperties_From_ExtendedLocation(&extendedLocationStash)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_ExtendedLocation() to populate field ExtendedLocation from ExtendedLocationStash")
		}
		network.ExtendedLocation = &extendedLocation
	} else {
		network.ExtendedLocation = nil
	}

	// FlowTimeoutInMinutes
	if source.FlowTimeoutInMinutes != nil {
		propertyBag.Add("FlowTimeoutInMinutes", *source.FlowTimeoutInMinutes)
	} else {
		propertyBag.Remove("FlowTimeoutInMinutes")
	}

	// IpAllocations
	if source.IpAllocations != nil {
		ipAllocationList := make([]SubResource, len(source.IpAllocations))
		for ipAllocationIndex, ipAllocationItem := range source.IpAllocations {
			var subResourceStash v20220701s.SubResource
			err := subResourceStash.AssignProperties_From_SubResource(&ipAllocationItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_SubResource() to populate field SubResourceStash from IpAllocations")
			}
			var ipAllocation SubResource
			err = ipAllocation.AssignProperties_From_SubResource(&subResourceStash)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_SubResource() to populate field IpAllocations from SubResourceStash")
			}
			ipAllocationList[ipAllocationIndex] = ipAllocation
		}
		network.IpAllocations = ipAllocationList
	} else {
		network.IpAllocations = nil
	}

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

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

	// OriginalVersion
	network.OriginalVersion = source.OriginalVersion

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

	// PrivateEndpointVNetPolicies
	if source.PrivateEndpointVNetPolicies != nil {
		propertyBag.Add("PrivateEndpointVNetPolicies", *source.PrivateEndpointVNetPolicies)
	} else {
		propertyBag.Remove("PrivateEndpointVNetPolicies")
	}

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

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

	// Invoke the augmentConversionForVirtualNetwork_Spec interface (if implemented) to customize the conversion
	var networkAsAny any = network
	if augmentedNetwork, ok := networkAsAny.(augmentConversionForVirtualNetwork_Spec); ok {
		err := augmentedNetwork.AssignPropertiesFrom(source)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesFrom() for conversion")
		}
	}

	// No error
	return nil
}

// AssignProperties_To_VirtualNetwork_Spec populates the provided destination VirtualNetwork_Spec from our VirtualNetwork_Spec
func (network *VirtualNetwork_Spec) AssignProperties_To_VirtualNetwork_Spec(destination *v20240301s.VirtualNetwork_Spec) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(network.PropertyBag)

	// AddressSpace
	if network.AddressSpace != nil {
		var addressSpace v20240301s.AddressSpace
		err := network.AddressSpace.AssignProperties_To_AddressSpace(&addressSpace)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_AddressSpace() to populate field AddressSpace")
		}
		destination.AddressSpace = &addressSpace
	} else {
		destination.AddressSpace = nil
	}

	// AzureName
	destination.AzureName = network.AzureName

	// BgpCommunities
	if network.BgpCommunities != nil {
		var bgpCommunity v20240301s.VirtualNetworkBgpCommunities
		err := network.BgpCommunities.AssignProperties_To_VirtualNetworkBgpCommunities(&bgpCommunity)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_VirtualNetworkBgpCommunities() to populate field BgpCommunities")
		}
		destination.BgpCommunities = &bgpCommunity
	} else {
		destination.BgpCommunities = nil
	}

	// DdosProtectionPlan
	if network.DdosProtectionPlan != nil {
		var subResourceStash v20220701s.SubResource
		err := network.DdosProtectionPlan.AssignProperties_To_SubResource(&subResourceStash)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_SubResource() to populate field SubResourceStash from DdosProtectionPlan")
		}
		var ddosProtectionPlan v20240301s.SubResource
		err = subResourceStash.AssignProperties_To_SubResource(&ddosProtectionPlan)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_SubResource() to populate field DdosProtectionPlan from SubResourceStash")
		}
		destination.DdosProtectionPlan = &ddosProtectionPlan
	} else {
		destination.DdosProtectionPlan = nil
	}

	// DhcpOptions
	if network.DhcpOptions != nil {
		var dhcpOption v20240301s.DhcpOptions
		err := network.DhcpOptions.AssignProperties_To_DhcpOptions(&dhcpOption)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_DhcpOptions() to populate field DhcpOptions")
		}
		destination.DhcpOptions = &dhcpOption
	} else {
		destination.DhcpOptions = nil
	}

	// EnableDdosProtection
	if network.EnableDdosProtection != nil {
		enableDdosProtection := *network.EnableDdosProtection
		destination.EnableDdosProtection = &enableDdosProtection
	} else {
		destination.EnableDdosProtection = nil
	}

	// EnableVmProtection
	if network.EnableVmProtection != nil {
		enableVmProtection := *network.EnableVmProtection
		destination.EnableVmProtection = &enableVmProtection
	} else {
		destination.EnableVmProtection = nil
	}

	// Encryption
	if propertyBag.Contains("Encryption") {
		var encryption v20240301s.VirtualNetworkEncryption
		err := propertyBag.Pull("Encryption", &encryption)
		if err != nil {
			return eris.Wrap(err, "pulling 'Encryption' from propertyBag")
		}

		destination.Encryption = &encryption
	} else {
		destination.Encryption = nil
	}

	// ExtendedLocation
	if network.ExtendedLocation != nil {
		var extendedLocationStash v20220701s.ExtendedLocation
		err := network.ExtendedLocation.AssignProperties_To_ExtendedLocation(&extendedLocationStash)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_ExtendedLocation() to populate field ExtendedLocationStash from ExtendedLocation")
		}
		var extendedLocation v20240301s.ExtendedLocation
		err = extendedLocationStash.AssignProperties_To_ExtendedLocation(&extendedLocation)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_ExtendedLocation() to populate field ExtendedLocation from ExtendedLocationStash")
		}
		destination.ExtendedLocation = &extendedLocation
	} else {
		destination.ExtendedLocation = nil
	}

	// FlowTimeoutInMinutes
	if propertyBag.Contains("FlowTimeoutInMinutes") {
		var flowTimeoutInMinute int
		err := propertyBag.Pull("FlowTimeoutInMinutes", &flowTimeoutInMinute)
		if err != nil {
			return eris.Wrap(err, "pulling 'FlowTimeoutInMinutes' from propertyBag")
		}

		destination.FlowTimeoutInMinutes = &flowTimeoutInMinute
	} else {
		destination.FlowTimeoutInMinutes = nil
	}

	// IpAllocations
	if network.IpAllocations != nil {
		ipAllocationList := make([]v20240301s.SubResource, len(network.IpAllocations))
		for ipAllocationIndex, ipAllocationItem := range network.IpAllocations {
			var subResourceStash v20220701s.SubResource
			err := ipAllocationItem.AssignProperties_To_SubResource(&subResourceStash)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_SubResource() to populate field SubResourceStash from IpAllocations")
			}
			var ipAllocation v20240301s.SubResource
			err = subResourceStash.AssignProperties_To_SubResource(&ipAllocation)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_SubResource() to populate field IpAllocations from SubResourceStash")
			}
			ipAllocationList[ipAllocationIndex] = ipAllocation
		}
		destination.IpAllocations = ipAllocationList
	} else {
		destination.IpAllocations = nil
	}

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

	// OperatorSpec
	if network.OperatorSpec != nil {
		var operatorSpec v20240301s.VirtualNetworkOperatorSpec
		err := network.OperatorSpec.AssignProperties_To_VirtualNetworkOperatorSpec(&operatorSpec)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_VirtualNetworkOperatorSpec() to populate field OperatorSpec")
		}
		destination.OperatorSpec = &operatorSpec
	} else {
		destination.OperatorSpec = nil
	}

	// OriginalVersion
	destination.OriginalVersion = network.OriginalVersion

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

	// PrivateEndpointVNetPolicies
	if propertyBag.Contains("PrivateEndpointVNetPolicies") {
		var privateEndpointVNetPolicy string
		err := propertyBag.Pull("PrivateEndpointVNetPolicies", &privateEndpointVNetPolicy)
		if err != nil {
			return eris.Wrap(err, "pulling 'PrivateEndpointVNetPolicies' from propertyBag")
		}

		destination.PrivateEndpointVNetPolicies = &privateEndpointVNetPolicy
	} else {
		destination.PrivateEndpointVNetPolicies = nil
	}

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

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

	// Invoke the augmentConversionForVirtualNetwork_Spec interface (if implemented) to customize the conversion
	var networkAsAny any = network
	if augmentedNetwork, ok := networkAsAny.(augmentConversionForVirtualNetwork_Spec); ok {
		err := augmentedNetwork.AssignPropertiesTo(destination)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesTo() for conversion")
		}
	}

	// No error
	return nil
}

// Storage version of v1api20201101.VirtualNetwork_STATUS
// Virtual Network resource.
type VirtualNetwork_STATUS struct {
	AddressSpace         *AddressSpace_STATUS                 `json:"addressSpace,omitempty"`
	BgpCommunities       *VirtualNetworkBgpCommunities_STATUS `json:"bgpCommunities,omitempty"`
	Conditions           []conditions.Condition               `json:"conditions,omitempty"`
	DdosProtectionPlan   *SubResource_STATUS                  `json:"ddosProtectionPlan,omitempty"`
	DhcpOptions          *DhcpOptions_STATUS                  `json:"dhcpOptions,omitempty"`
	EnableDdosProtection *bool                                `json:"enableDdosProtection,omitempty"`
	EnableVmProtection   *bool                                `json:"enableVmProtection,omitempty"`
	Etag                 *string                              `json:"etag,omitempty"`
	ExtendedLocation     *ExtendedLocation_STATUS             `json:"extendedLocation,omitempty"`
	Id                   *string                              `json:"id,omitempty"`
	IpAllocations        []SubResource_STATUS                 `json:"ipAllocations,omitempty"`
	Location             *string                              `json:"location,omitempty"`
	Name                 *string                              `json:"name,omitempty"`
	PropertyBag          genruntime.PropertyBag               `json:"$propertyBag,omitempty"`
	ProvisioningState    *string                              `json:"provisioningState,omitempty"`
	ResourceGuid         *string                              `json:"resourceGuid,omitempty"`
	Tags                 map[string]string                    `json:"tags,omitempty"`
	Type                 *string                              `json:"type,omitempty"`
}

var _ genruntime.ConvertibleStatus = &VirtualNetwork_STATUS{}

// ConvertStatusFrom populates our VirtualNetwork_STATUS from the provided source
func (network *VirtualNetwork_STATUS) ConvertStatusFrom(source genruntime.ConvertibleStatus) error {
	src, ok := source.(*v20240301s.VirtualNetwork_STATUS)
	if ok {
		// Populate our instance from source
		return network.AssignProperties_From_VirtualNetwork_STATUS(src)
	}

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

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

	return nil
}

// ConvertStatusTo populates the provided destination from our VirtualNetwork_STATUS
func (network *VirtualNetwork_STATUS) ConvertStatusTo(destination genruntime.ConvertibleStatus) error {
	dst, ok := destination.(*v20240301s.VirtualNetwork_STATUS)
	if ok {
		// Populate destination from our instance
		return network.AssignProperties_To_VirtualNetwork_STATUS(dst)
	}

	// Convert to an intermediate form
	dst = &v20240301s.VirtualNetwork_STATUS{}
	err := network.AssignProperties_To_VirtualNetwork_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
}

// AssignProperties_From_VirtualNetwork_STATUS populates our VirtualNetwork_STATUS from the provided source VirtualNetwork_STATUS
func (network *VirtualNetwork_STATUS) AssignProperties_From_VirtualNetwork_STATUS(source *v20240301s.VirtualNetwork_STATUS) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(source.PropertyBag)

	// AddressSpace
	if source.AddressSpace != nil {
		var addressSpace AddressSpace_STATUS
		err := addressSpace.AssignProperties_From_AddressSpace_STATUS(source.AddressSpace)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_AddressSpace_STATUS() to populate field AddressSpace")
		}
		network.AddressSpace = &addressSpace
	} else {
		network.AddressSpace = nil
	}

	// BgpCommunities
	if source.BgpCommunities != nil {
		var bgpCommunity VirtualNetworkBgpCommunities_STATUS
		err := bgpCommunity.AssignProperties_From_VirtualNetworkBgpCommunities_STATUS(source.BgpCommunities)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_VirtualNetworkBgpCommunities_STATUS() to populate field BgpCommunities")
		}
		network.BgpCommunities = &bgpCommunity
	} else {
		network.BgpCommunities = nil
	}

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

	// DdosProtectionPlan
	if source.DdosProtectionPlan != nil {
		var subResourceSTATUSStash v20240101s.SubResource_STATUS
		err := subResourceSTATUSStash.AssignProperties_From_SubResource_STATUS(source.DdosProtectionPlan)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_SubResource_STATUS() to populate field SubResource_STATUSStash from DdosProtectionPlan")
		}
		var subResourceSTATUSStashLocal v20220701s.SubResource_STATUS
		err = subResourceSTATUSStashLocal.AssignProperties_From_SubResource_STATUS(&subResourceSTATUSStash)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_SubResource_STATUS() to populate field SubResource_STATUSStash")
		}
		var ddosProtectionPlan SubResource_STATUS
		err = ddosProtectionPlan.AssignProperties_From_SubResource_STATUS(&subResourceSTATUSStashLocal)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_SubResource_STATUS() to populate field DdosProtectionPlan from SubResource_STATUSStash")
		}
		network.DdosProtectionPlan = &ddosProtectionPlan
	} else {
		network.DdosProtectionPlan = nil
	}

	// DhcpOptions
	if source.DhcpOptions != nil {
		var dhcpOption DhcpOptions_STATUS
		err := dhcpOption.AssignProperties_From_DhcpOptions_STATUS(source.DhcpOptions)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_DhcpOptions_STATUS() to populate field DhcpOptions")
		}
		network.DhcpOptions = &dhcpOption
	} else {
		network.DhcpOptions = nil
	}

	// EnableDdosProtection
	if source.EnableDdosProtection != nil {
		enableDdosProtection := *source.EnableDdosProtection
		network.EnableDdosProtection = &enableDdosProtection
	} else {
		network.EnableDdosProtection = nil
	}

	// EnableVmProtection
	if source.EnableVmProtection != nil {
		enableVmProtection := *source.EnableVmProtection
		network.EnableVmProtection = &enableVmProtection
	} else {
		network.EnableVmProtection = nil
	}

	// Encryption
	if source.Encryption != nil {
		propertyBag.Add("Encryption", *source.Encryption)
	} else {
		propertyBag.Remove("Encryption")
	}

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

	// ExtendedLocation
	if source.ExtendedLocation != nil {
		var extendedLocationSTATUSStash v20220701s.ExtendedLocation_STATUS
		err := extendedLocationSTATUSStash.AssignProperties_From_ExtendedLocation_STATUS(source.ExtendedLocation)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_ExtendedLocation_STATUS() to populate field ExtendedLocation_STATUSStash from ExtendedLocation")
		}
		var extendedLocation ExtendedLocation_STATUS
		err = extendedLocation.AssignProperties_From_ExtendedLocation_STATUS(&extendedLocationSTATUSStash)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_ExtendedLocation_STATUS() to populate field ExtendedLocation from ExtendedLocation_STATUSStash")
		}
		network.ExtendedLocation = &extendedLocation
	} else {
		network.ExtendedLocation = nil
	}

	// FlowLogs
	if len(source.FlowLogs) > 0 {
		propertyBag.Add("FlowLogs", source.FlowLogs)
	} else {
		propertyBag.Remove("FlowLogs")
	}

	// FlowTimeoutInMinutes
	if source.FlowTimeoutInMinutes != nil {
		propertyBag.Add("FlowTimeoutInMinutes", *source.FlowTimeoutInMinutes)
	} else {
		propertyBag.Remove("FlowTimeoutInMinutes")
	}

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

	// IpAllocations
	if source.IpAllocations != nil {
		ipAllocationList := make([]SubResource_STATUS, len(source.IpAllocations))
		for ipAllocationIndex, ipAllocationItem := range source.IpAllocations {
			var subResourceSTATUSStash v20240101s.SubResource_STATUS
			err := subResourceSTATUSStash.AssignProperties_From_SubResource_STATUS(&ipAllocationItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_SubResource_STATUS() to populate field SubResource_STATUSStash from IpAllocations")
			}
			var subResourceSTATUSStashLocal v20220701s.SubResource_STATUS
			err = subResourceSTATUSStashLocal.AssignProperties_From_SubResource_STATUS(&subResourceSTATUSStash)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_SubResource_STATUS() to populate field SubResource_STATUSStash")
			}
			var ipAllocation SubResource_STATUS
			err = ipAllocation.AssignProperties_From_SubResource_STATUS(&subResourceSTATUSStashLocal)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_SubResource_STATUS() to populate field IpAllocations from SubResource_STATUSStash")
			}
			ipAllocationList[ipAllocationIndex] = ipAllocation
		}
		network.IpAllocations = ipAllocationList
	} else {
		network.IpAllocations = nil
	}

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

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

	// PrivateEndpointVNetPolicies
	if source.PrivateEndpointVNetPolicies != nil {
		propertyBag.Add("PrivateEndpointVNetPolicies", *source.PrivateEndpointVNetPolicies)
	} else {
		propertyBag.Remove("PrivateEndpointVNetPolicies")
	}

	// ProvisioningState
	network.ProvisioningState = genruntime.ClonePointerToString(source.ProvisioningState)

	// ResourceGuid
	network.ResourceGuid = genruntime.ClonePointerToString(source.ResourceGuid)

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

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

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

	// Invoke the augmentConversionForVirtualNetwork_STATUS interface (if implemented) to customize the conversion
	var networkAsAny any = network
	if augmentedNetwork, ok := networkAsAny.(augmentConversionForVirtualNetwork_STATUS); ok {
		err := augmentedNetwork.AssignPropertiesFrom(source)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesFrom() for conversion")
		}
	}

	// No error
	return nil
}

// AssignProperties_To_VirtualNetwork_STATUS populates the provided destination VirtualNetwork_STATUS from our VirtualNetwork_STATUS
func (network *VirtualNetwork_STATUS) AssignProperties_To_VirtualNetwork_STATUS(destination *v20240301s.VirtualNetwork_STATUS) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(network.PropertyBag)

	// AddressSpace
	if network.AddressSpace != nil {
		var addressSpace v20240301s.AddressSpace_STATUS
		err := network.AddressSpace.AssignProperties_To_AddressSpace_STATUS(&addressSpace)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_AddressSpace_STATUS() to populate field AddressSpace")
		}
		destination.AddressSpace = &addressSpace
	} else {
		destination.AddressSpace = nil
	}

	// BgpCommunities
	if network.BgpCommunities != nil {
		var bgpCommunity v20240301s.VirtualNetworkBgpCommunities_STATUS
		err := network.BgpCommunities.AssignProperties_To_VirtualNetworkBgpCommunities_STATUS(&bgpCommunity)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_VirtualNetworkBgpCommunities_STATUS() to populate field BgpCommunities")
		}
		destination.BgpCommunities = &bgpCommunity
	} else {
		destination.BgpCommunities = nil
	}

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

	// DdosProtectionPlan
	if network.DdosProtectionPlan != nil {
		var subResourceSTATUSStash v20220701s.SubResource_STATUS
		err := network.DdosProtectionPlan.AssignProperties_To_SubResource_STATUS(&subResourceSTATUSStash)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_SubResource_STATUS() to populate field SubResource_STATUSStash from DdosProtectionPlan")
		}
		var subResourceSTATUSStashLocal v20240101s.SubResource_STATUS
		err = subResourceSTATUSStash.AssignProperties_To_SubResource_STATUS(&subResourceSTATUSStashLocal)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_SubResource_STATUS() to populate field SubResource_STATUSStash")
		}
		var ddosProtectionPlan v20240301s.SubResource_STATUS
		err = subResourceSTATUSStashLocal.AssignProperties_To_SubResource_STATUS(&ddosProtectionPlan)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_SubResource_STATUS() to populate field DdosProtectionPlan from SubResource_STATUSStash")
		}
		destination.DdosProtectionPlan = &ddosProtectionPlan
	} else {
		destination.DdosProtectionPlan = nil
	}

	// DhcpOptions
	if network.DhcpOptions != nil {
		var dhcpOption v20240301s.DhcpOptions_STATUS
		err := network.DhcpOptions.AssignProperties_To_DhcpOptions_STATUS(&dhcpOption)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_DhcpOptions_STATUS() to populate field DhcpOptions")
		}
		destination.DhcpOptions = &dhcpOption
	} else {
		destination.DhcpOptions = nil
	}

	// EnableDdosProtection
	if network.EnableDdosProtection != nil {
		enableDdosProtection := *network.EnableDdosProtection
		destination.EnableDdosProtection = &enableDdosProtection
	} else {
		destination.EnableDdosProtection = nil
	}

	// EnableVmProtection
	if network.EnableVmProtection != nil {
		enableVmProtection := *network.EnableVmProtection
		destination.EnableVmProtection = &enableVmProtection
	} else {
		destination.EnableVmProtection = nil
	}

	// Encryption
	if propertyBag.Contains("Encryption") {
		var encryption v20240301s.VirtualNetworkEncryption_STATUS
		err := propertyBag.Pull("Encryption", &encryption)
		if err != nil {
			return eris.Wrap(err, "pulling 'Encryption' from propertyBag")
		}

		destination.Encryption = &encryption
	} else {
		destination.Encryption = nil
	}

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

	// ExtendedLocation
	if network.ExtendedLocation != nil {
		var extendedLocationSTATUSStash v20220701s.ExtendedLocation_STATUS
		err := network.ExtendedLocation.AssignProperties_To_ExtendedLocation_STATUS(&extendedLocationSTATUSStash)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_ExtendedLocation_STATUS() to populate field ExtendedLocation_STATUSStash from ExtendedLocation")
		}
		var extendedLocation v20240301s.ExtendedLocation_STATUS
		err = extendedLocationSTATUSStash.AssignProperties_To_ExtendedLocation_STATUS(&extendedLocation)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_ExtendedLocation_STATUS() to populate field ExtendedLocation from ExtendedLocation_STATUSStash")
		}
		destination.ExtendedLocation = &extendedLocation
	} else {
		destination.ExtendedLocation = nil
	}

	// FlowLogs
	if propertyBag.Contains("FlowLogs") {
		var flowLog []v20240301s.FlowLog_STATUS_SubResourceEmbedded
		err := propertyBag.Pull("FlowLogs", &flowLog)
		if err != nil {
			return eris.Wrap(err, "pulling 'FlowLogs' from propertyBag")
		}

		destination.FlowLogs = flowLog
	} else {
		destination.FlowLogs = nil
	}

	// FlowTimeoutInMinutes
	if propertyBag.Contains("FlowTimeoutInMinutes") {
		var flowTimeoutInMinute int
		err := propertyBag.Pull("FlowTimeoutInMinutes", &flowTimeoutInMinute)
		if err != nil {
			return eris.Wrap(err, "pulling 'FlowTimeoutInMinutes' from propertyBag")
		}

		destination.FlowTimeoutInMinutes = &flowTimeoutInMinute
	} else {
		destination.FlowTimeoutInMinutes = nil
	}

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

	// IpAllocations
	if network.IpAllocations != nil {
		ipAllocationList := make([]v20240301s.SubResource_STATUS, len(network.IpAllocations))
		for ipAllocationIndex, ipAllocationItem := range network.IpAllocations {
			var subResourceSTATUSStash v20220701s.SubResource_STATUS
			err := ipAllocationItem.AssignProperties_To_SubResource_STATUS(&subResourceSTATUSStash)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_SubResource_STATUS() to populate field SubResource_STATUSStash from IpAllocations")
			}
			var subResourceSTATUSStashLocal v20240101s.SubResource_STATUS
			err = subResourceSTATUSStash.AssignProperties_To_SubResource_STATUS(&subResourceSTATUSStashLocal)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_SubResource_STATUS() to populate field SubResource_STATUSStash")
			}
			var ipAllocation v20240301s.SubResource_STATUS
			err = subResourceSTATUSStashLocal.AssignProperties_To_SubResource_STATUS(&ipAllocation)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_SubResource_STATUS() to populate field IpAllocations from SubResource_STATUSStash")
			}
			ipAllocationList[ipAllocationIndex] = ipAllocation
		}
		destination.IpAllocations = ipAllocationList
	} else {
		destination.IpAllocations = nil
	}

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

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

	// PrivateEndpointVNetPolicies
	if propertyBag.Contains("PrivateEndpointVNetPolicies") {
		var privateEndpointVNetPolicy string
		err := propertyBag.Pull("PrivateEndpointVNetPolicies", &privateEndpointVNetPolicy)
		if err != nil {
			return eris.Wrap(err, "pulling 'PrivateEndpointVNetPolicies' from propertyBag")
		}

		destination.PrivateEndpointVNetPolicies = &privateEndpointVNetPolicy
	} else {
		destination.PrivateEndpointVNetPolicies = nil
	}

	// ProvisioningState
	destination.ProvisioningState = genruntime.ClonePointerToString(network.ProvisioningState)

	// ResourceGuid
	destination.ResourceGuid = genruntime.ClonePointerToString(network.ResourceGuid)

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

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

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

	// Invoke the augmentConversionForVirtualNetwork_STATUS interface (if implemented) to customize the conversion
	var networkAsAny any = network
	if augmentedNetwork, ok := networkAsAny.(augmentConversionForVirtualNetwork_STATUS); ok {
		err := augmentedNetwork.AssignPropertiesTo(destination)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesTo() for conversion")
		}
	}

	// No error
	return nil
}

// Storage version of v1api20201101.AddressSpace
// AddressSpace contains an array of IP address ranges that can be used by subnets of the virtual network.
type AddressSpace struct {
	AddressPrefixes []string               `json:"addressPrefixes,omitempty"`
	PropertyBag     genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// AssignProperties_From_AddressSpace populates our AddressSpace from the provided source AddressSpace
func (space *AddressSpace) AssignProperties_From_AddressSpace(source *v20240301s.AddressSpace) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(source.PropertyBag)

	// AddressPrefixes
	space.AddressPrefixes = genruntime.CloneSliceOfString(source.AddressPrefixes)

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

	// Invoke the augmentConversionForAddressSpace interface (if implemented) to customize the conversion
	var spaceAsAny any = space
	if augmentedSpace, ok := spaceAsAny.(augmentConversionForAddressSpace); ok {
		err := augmentedSpace.AssignPropertiesFrom(source)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesFrom() for conversion")
		}
	}

	// No error
	return nil
}

// AssignProperties_To_AddressSpace populates the provided destination AddressSpace from our AddressSpace
func (space *AddressSpace) AssignProperties_To_AddressSpace(destination *v20240301s.AddressSpace) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(space.PropertyBag)

	// AddressPrefixes
	destination.AddressPrefixes = genruntime.CloneSliceOfString(space.AddressPrefixes)

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

	// Invoke the augmentConversionForAddressSpace interface (if implemented) to customize the conversion
	var spaceAsAny any = space
	if augmentedSpace, ok := spaceAsAny.(augmentConversionForAddressSpace); ok {
		err := augmentedSpace.AssignPropertiesTo(destination)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesTo() for conversion")
		}
	}

	// No error
	return nil
}

// Storage version of v1api20201101.AddressSpace_STATUS
// AddressSpace contains an array of IP address ranges that can be used by subnets of the virtual network.
type AddressSpace_STATUS struct {
	AddressPrefixes []string               `json:"addressPrefixes,omitempty"`
	PropertyBag     genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// AssignProperties_From_AddressSpace_STATUS populates our AddressSpace_STATUS from the provided source AddressSpace_STATUS
func (space *AddressSpace_STATUS) AssignProperties_From_AddressSpace_STATUS(source *v20240301s.AddressSpace_STATUS) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(source.PropertyBag)

	// AddressPrefixes
	space.AddressPrefixes = genruntime.CloneSliceOfString(source.AddressPrefixes)

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

	// Invoke the augmentConversionForAddressSpace_STATUS interface (if implemented) to customize the conversion
	var spaceAsAny any = space
	if augmentedSpace, ok := spaceAsAny.(augmentConversionForAddressSpace_STATUS); ok {
		err := augmentedSpace.AssignPropertiesFrom(source)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesFrom() for conversion")
		}
	}

	// No error
	return nil
}

// AssignProperties_To_AddressSpace_STATUS populates the provided destination AddressSpace_STATUS from our AddressSpace_STATUS
func (space *AddressSpace_STATUS) AssignProperties_To_AddressSpace_STATUS(destination *v20240301s.AddressSpace_STATUS) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(space.PropertyBag)

	// AddressPrefixes
	destination.AddressPrefixes = genruntime.CloneSliceOfString(space.AddressPrefixes)

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

	// Invoke the augmentConversionForAddressSpace_STATUS interface (if implemented) to customize the conversion
	var spaceAsAny any = space
	if augmentedSpace, ok := spaceAsAny.(augmentConversionForAddressSpace_STATUS); ok {
		err := augmentedSpace.AssignPropertiesTo(destination)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesTo() for conversion")
		}
	}

	// No error
	return nil
}

type augmentConversionForVirtualNetwork_Spec interface {
	AssignPropertiesFrom(src *v20240301s.VirtualNetwork_Spec) error
	AssignPropertiesTo(dst *v20240301s.VirtualNetwork_Spec) error
}

type augmentConversionForVirtualNetwork_STATUS interface {
	AssignPropertiesFrom(src *v20240301s.VirtualNetwork_STATUS) error
	AssignPropertiesTo(dst *v20240301s.VirtualNetwork_STATUS) error
}

// Storage version of v1api20201101.DhcpOptions
// DhcpOptions contains an array of DNS servers available to VMs deployed in the virtual network. Standard DHCP option for
// a subnet overrides VNET DHCP options.
type DhcpOptions struct {
	DnsServers  []string               `json:"dnsServers,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// AssignProperties_From_DhcpOptions populates our DhcpOptions from the provided source DhcpOptions
func (options *DhcpOptions) AssignProperties_From_DhcpOptions(source *v20240301s.DhcpOptions) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(source.PropertyBag)

	// DnsServers
	options.DnsServers = genruntime.CloneSliceOfString(source.DnsServers)

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

	// Invoke the augmentConversionForDhcpOptions interface (if implemented) to customize the conversion
	var optionsAsAny any = options
	if augmentedOptions, ok := optionsAsAny.(augmentConversionForDhcpOptions); ok {
		err := augmentedOptions.AssignPropertiesFrom(source)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesFrom() for conversion")
		}
	}

	// No error
	return nil
}

// AssignProperties_To_DhcpOptions populates the provided destination DhcpOptions from our DhcpOptions
func (options *DhcpOptions) AssignProperties_To_DhcpOptions(destination *v20240301s.DhcpOptions) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(options.PropertyBag)

	// DnsServers
	destination.DnsServers = genruntime.CloneSliceOfString(options.DnsServers)

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

	// Invoke the augmentConversionForDhcpOptions interface (if implemented) to customize the conversion
	var optionsAsAny any = options
	if augmentedOptions, ok := optionsAsAny.(augmentConversionForDhcpOptions); ok {
		err := augmentedOptions.AssignPropertiesTo(destination)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesTo() for conversion")
		}
	}

	// No error
	return nil
}

// Storage version of v1api20201101.DhcpOptions_STATUS
// DhcpOptions contains an array of DNS servers available to VMs deployed in the virtual network. Standard DHCP option for
// a subnet overrides VNET DHCP options.
type DhcpOptions_STATUS struct {
	DnsServers  []string               `json:"dnsServers,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// AssignProperties_From_DhcpOptions_STATUS populates our DhcpOptions_STATUS from the provided source DhcpOptions_STATUS
func (options *DhcpOptions_STATUS) AssignProperties_From_DhcpOptions_STATUS(source *v20240301s.DhcpOptions_STATUS) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(source.PropertyBag)

	// DnsServers
	options.DnsServers = genruntime.CloneSliceOfString(source.DnsServers)

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

	// Invoke the augmentConversionForDhcpOptions_STATUS interface (if implemented) to customize the conversion
	var optionsAsAny any = options
	if augmentedOptions, ok := optionsAsAny.(augmentConversionForDhcpOptions_STATUS); ok {
		err := augmentedOptions.AssignPropertiesFrom(source)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesFrom() for conversion")
		}
	}

	// No error
	return nil
}

// AssignProperties_To_DhcpOptions_STATUS populates the provided destination DhcpOptions_STATUS from our DhcpOptions_STATUS
func (options *DhcpOptions_STATUS) AssignProperties_To_DhcpOptions_STATUS(destination *v20240301s.DhcpOptions_STATUS) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(options.PropertyBag)

	// DnsServers
	destination.DnsServers = genruntime.CloneSliceOfString(options.DnsServers)

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

	// Invoke the augmentConversionForDhcpOptions_STATUS interface (if implemented) to customize the conversion
	var optionsAsAny any = options
	if augmentedOptions, ok := optionsAsAny.(augmentConversionForDhcpOptions_STATUS); ok {
		err := augmentedOptions.AssignPropertiesTo(destination)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesTo() for conversion")
		}
	}

	// No error
	return nil
}

// Storage version of v1api20201101.VirtualNetworkBgpCommunities
// Bgp Communities sent over ExpressRoute with each route corresponding to a prefix in this VNET.
type VirtualNetworkBgpCommunities struct {
	PropertyBag             genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	VirtualNetworkCommunity *string                `json:"virtualNetworkCommunity,omitempty"`
}

// AssignProperties_From_VirtualNetworkBgpCommunities populates our VirtualNetworkBgpCommunities from the provided source VirtualNetworkBgpCommunities
func (communities *VirtualNetworkBgpCommunities) AssignProperties_From_VirtualNetworkBgpCommunities(source *v20240301s.VirtualNetworkBgpCommunities) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(source.PropertyBag)

	// VirtualNetworkCommunity
	communities.VirtualNetworkCommunity = genruntime.ClonePointerToString(source.VirtualNetworkCommunity)

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

	// Invoke the augmentConversionForVirtualNetworkBgpCommunities interface (if implemented) to customize the conversion
	var communitiesAsAny any = communities
	if augmentedCommunities, ok := communitiesAsAny.(augmentConversionForVirtualNetworkBgpCommunities); ok {
		err := augmentedCommunities.AssignPropertiesFrom(source)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesFrom() for conversion")
		}
	}

	// No error
	return nil
}

// AssignProperties_To_VirtualNetworkBgpCommunities populates the provided destination VirtualNetworkBgpCommunities from our VirtualNetworkBgpCommunities
func (communities *VirtualNetworkBgpCommunities) AssignProperties_To_VirtualNetworkBgpCommunities(destination *v20240301s.VirtualNetworkBgpCommunities) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(communities.PropertyBag)

	// VirtualNetworkCommunity
	destination.VirtualNetworkCommunity = genruntime.ClonePointerToString(communities.VirtualNetworkCommunity)

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

	// Invoke the augmentConversionForVirtualNetworkBgpCommunities interface (if implemented) to customize the conversion
	var communitiesAsAny any = communities
	if augmentedCommunities, ok := communitiesAsAny.(augmentConversionForVirtualNetworkBgpCommunities); ok {
		err := augmentedCommunities.AssignPropertiesTo(destination)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesTo() for conversion")
		}
	}

	// No error
	return nil
}

// Storage version of v1api20201101.VirtualNetworkBgpCommunities_STATUS
// Bgp Communities sent over ExpressRoute with each route corresponding to a prefix in this VNET.
type VirtualNetworkBgpCommunities_STATUS struct {
	PropertyBag             genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	RegionalCommunity       *string                `json:"regionalCommunity,omitempty"`
	VirtualNetworkCommunity *string                `json:"virtualNetworkCommunity,omitempty"`
}

// AssignProperties_From_VirtualNetworkBgpCommunities_STATUS populates our VirtualNetworkBgpCommunities_STATUS from the provided source VirtualNetworkBgpCommunities_STATUS
func (communities *VirtualNetworkBgpCommunities_STATUS) AssignProperties_From_VirtualNetworkBgpCommunities_STATUS(source *v20240301s.VirtualNetworkBgpCommunities_STATUS) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(source.PropertyBag)

	// RegionalCommunity
	communities.RegionalCommunity = genruntime.ClonePointerToString(source.RegionalCommunity)

	// VirtualNetworkCommunity
	communities.VirtualNetworkCommunity = genruntime.ClonePointerToString(source.VirtualNetworkCommunity)

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

	// Invoke the augmentConversionForVirtualNetworkBgpCommunities_STATUS interface (if implemented) to customize the conversion
	var communitiesAsAny any = communities
	if augmentedCommunities, ok := communitiesAsAny.(augmentConversionForVirtualNetworkBgpCommunities_STATUS); ok {
		err := augmentedCommunities.AssignPropertiesFrom(source)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesFrom() for conversion")
		}
	}

	// No error
	return nil
}

// AssignProperties_To_VirtualNetworkBgpCommunities_STATUS populates the provided destination VirtualNetworkBgpCommunities_STATUS from our VirtualNetworkBgpCommunities_STATUS
func (communities *VirtualNetworkBgpCommunities_STATUS) AssignProperties_To_VirtualNetworkBgpCommunities_STATUS(destination *v20240301s.VirtualNetworkBgpCommunities_STATUS) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(communities.PropertyBag)

	// RegionalCommunity
	destination.RegionalCommunity = genruntime.ClonePointerToString(communities.RegionalCommunity)

	// VirtualNetworkCommunity
	destination.VirtualNetworkCommunity = genruntime.ClonePointerToString(communities.VirtualNetworkCommunity)

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

	// Invoke the augmentConversionForVirtualNetworkBgpCommunities_STATUS interface (if implemented) to customize the conversion
	var communitiesAsAny any = communities
	if augmentedCommunities, ok := communitiesAsAny.(augmentConversionForVirtualNetworkBgpCommunities_STATUS); ok {
		err := augmentedCommunities.AssignPropertiesTo(destination)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesTo() for conversion")
		}
	}

	// No error
	return nil
}

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

// AssignProperties_From_VirtualNetworkOperatorSpec populates our VirtualNetworkOperatorSpec from the provided source VirtualNetworkOperatorSpec
func (operator *VirtualNetworkOperatorSpec) AssignProperties_From_VirtualNetworkOperatorSpec(source *v20240301s.VirtualNetworkOperatorSpec) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(source.PropertyBag)

	// 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
	}

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

	// Invoke the augmentConversionForVirtualNetworkOperatorSpec interface (if implemented) to customize the conversion
	var operatorAsAny any = operator
	if augmentedOperator, ok := operatorAsAny.(augmentConversionForVirtualNetworkOperatorSpec); ok {
		err := augmentedOperator.AssignPropertiesFrom(source)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesFrom() for conversion")
		}
	}

	// No error
	return nil
}

// AssignProperties_To_VirtualNetworkOperatorSpec populates the provided destination VirtualNetworkOperatorSpec from our VirtualNetworkOperatorSpec
func (operator *VirtualNetworkOperatorSpec) AssignProperties_To_VirtualNetworkOperatorSpec(destination *v20240301s.VirtualNetworkOperatorSpec) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(operator.PropertyBag)

	// 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
	}

	// Invoke the augmentConversionForVirtualNetworkOperatorSpec interface (if implemented) to customize the conversion
	var operatorAsAny any = operator
	if augmentedOperator, ok := operatorAsAny.(augmentConversionForVirtualNetworkOperatorSpec); ok {
		err := augmentedOperator.AssignPropertiesTo(destination)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesTo() for conversion")
		}
	}

	// No error
	return nil
}

type augmentConversionForAddressSpace interface {
	AssignPropertiesFrom(src *v20240301s.AddressSpace) error
	AssignPropertiesTo(dst *v20240301s.AddressSpace) error
}

type augmentConversionForAddressSpace_STATUS interface {
	AssignPropertiesFrom(src *v20240301s.AddressSpace_STATUS) error
	AssignPropertiesTo(dst *v20240301s.AddressSpace_STATUS) error
}

type augmentConversionForDhcpOptions interface {
	AssignPropertiesFrom(src *v20240301s.DhcpOptions) error
	AssignPropertiesTo(dst *v20240301s.DhcpOptions) error
}

type augmentConversionForDhcpOptions_STATUS interface {
	AssignPropertiesFrom(src *v20240301s.DhcpOptions_STATUS) error
	AssignPropertiesTo(dst *v20240301s.DhcpOptions_STATUS) error
}

type augmentConversionForVirtualNetworkBgpCommunities interface {
	AssignPropertiesFrom(src *v20240301s.VirtualNetworkBgpCommunities) error
	AssignPropertiesTo(dst *v20240301s.VirtualNetworkBgpCommunities) error
}

type augmentConversionForVirtualNetworkBgpCommunities_STATUS interface {
	AssignPropertiesFrom(src *v20240301s.VirtualNetworkBgpCommunities_STATUS) error
	AssignPropertiesTo(dst *v20240301s.VirtualNetworkBgpCommunities_STATUS) error
}

type augmentConversionForVirtualNetworkOperatorSpec interface {
	AssignPropertiesFrom(src *v20240301s.VirtualNetworkOperatorSpec) error
	AssignPropertiesTo(dst *v20240301s.VirtualNetworkOperatorSpec) error
}

func init() {
	SchemeBuilder.Register(&VirtualNetwork{}, &VirtualNetworkList{})
}
