// 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.VirtualNetworksVirtualNetworkPeering
// 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}/virtualNetworkPeerings/{virtualNetworkPeeringName}
type VirtualNetworksVirtualNetworkPeering struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              VirtualNetworksVirtualNetworkPeering_Spec   `json:"spec,omitempty"`
	Status            VirtualNetworksVirtualNetworkPeering_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &VirtualNetworksVirtualNetworkPeering{}

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

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

var _ conversion.Convertible = &VirtualNetworksVirtualNetworkPeering{}

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

	return peering.AssignProperties_From_VirtualNetworksVirtualNetworkPeering(source)
}

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

	return peering.AssignProperties_To_VirtualNetworksVirtualNetworkPeering(destination)
}

var _ configmaps.Exporter = &VirtualNetworksVirtualNetworkPeering{}

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

var _ secrets.Exporter = &VirtualNetworksVirtualNetworkPeering{}

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

var _ genruntime.KubernetesResource = &VirtualNetworksVirtualNetworkPeering{}

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

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

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

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

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

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

// NewEmptyStatus returns a new empty (blank) status
func (peering *VirtualNetworksVirtualNetworkPeering) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &VirtualNetworksVirtualNetworkPeering_STATUS{}
}

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

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

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

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

	peering.Status = st
	return nil
}

// AssignProperties_From_VirtualNetworksVirtualNetworkPeering populates our VirtualNetworksVirtualNetworkPeering from the provided source VirtualNetworksVirtualNetworkPeering
func (peering *VirtualNetworksVirtualNetworkPeering) AssignProperties_From_VirtualNetworksVirtualNetworkPeering(source *v20240301s.VirtualNetworksVirtualNetworkPeering) error {

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

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

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

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

	// No error
	return nil
}

// AssignProperties_To_VirtualNetworksVirtualNetworkPeering populates the provided destination VirtualNetworksVirtualNetworkPeering from our VirtualNetworksVirtualNetworkPeering
func (peering *VirtualNetworksVirtualNetworkPeering) AssignProperties_To_VirtualNetworksVirtualNetworkPeering(destination *v20240301s.VirtualNetworksVirtualNetworkPeering) error {

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

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

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

	// Invoke the augmentConversionForVirtualNetworksVirtualNetworkPeering interface (if implemented) to customize the conversion
	var peeringAsAny any = peering
	if augmentedPeering, ok := peeringAsAny.(augmentConversionForVirtualNetworksVirtualNetworkPeering); ok {
		err := augmentedPeering.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 (peering *VirtualNetworksVirtualNetworkPeering) OriginalGVK() *schema.GroupVersionKind {
	return &schema.GroupVersionKind{
		Group:   GroupVersion.Group,
		Version: peering.Spec.OriginalVersion,
		Kind:    "VirtualNetworksVirtualNetworkPeering",
	}
}

// +kubebuilder:object:root=true
// Storage version of v1api20201101.VirtualNetworksVirtualNetworkPeering
// 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}/virtualNetworkPeerings/{virtualNetworkPeeringName}
type VirtualNetworksVirtualNetworkPeeringList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []VirtualNetworksVirtualNetworkPeering `json:"items"`
}

type augmentConversionForVirtualNetworksVirtualNetworkPeering interface {
	AssignPropertiesFrom(src *v20240301s.VirtualNetworksVirtualNetworkPeering) error
	AssignPropertiesTo(dst *v20240301s.VirtualNetworksVirtualNetworkPeering) error
}

// Storage version of v1api20201101.VirtualNetworksVirtualNetworkPeering_Spec
type VirtualNetworksVirtualNetworkPeering_Spec struct {
	AllowForwardedTraffic     *bool `json:"allowForwardedTraffic,omitempty"`
	AllowGatewayTransit       *bool `json:"allowGatewayTransit,omitempty"`
	AllowVirtualNetworkAccess *bool `json:"allowVirtualNetworkAccess,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"`
	DoNotVerifyRemoteGateways *bool                                             `json:"doNotVerifyRemoteGateways,omitempty"`
	OperatorSpec              *VirtualNetworksVirtualNetworkPeeringOperatorSpec `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 network.azure.com/VirtualNetwork resource
	Owner                *genruntime.KnownResourceReference `group:"network.azure.com" json:"owner,omitempty" kind:"VirtualNetwork"`
	PeeringState         *string                            `json:"peeringState,omitempty"`
	PropertyBag          genruntime.PropertyBag             `json:"$propertyBag,omitempty"`
	RemoteAddressSpace   *AddressSpace                      `json:"remoteAddressSpace,omitempty"`
	RemoteBgpCommunities *VirtualNetworkBgpCommunities      `json:"remoteBgpCommunities,omitempty"`
	RemoteVirtualNetwork *SubResource                       `json:"remoteVirtualNetwork,omitempty"`
	UseRemoteGateways    *bool                              `json:"useRemoteGateways,omitempty"`
}

var _ genruntime.ConvertibleSpec = &VirtualNetworksVirtualNetworkPeering_Spec{}

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

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

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

	return nil
}

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

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

	// AllowForwardedTraffic
	if source.AllowForwardedTraffic != nil {
		allowForwardedTraffic := *source.AllowForwardedTraffic
		peering.AllowForwardedTraffic = &allowForwardedTraffic
	} else {
		peering.AllowForwardedTraffic = nil
	}

	// AllowGatewayTransit
	if source.AllowGatewayTransit != nil {
		allowGatewayTransit := *source.AllowGatewayTransit
		peering.AllowGatewayTransit = &allowGatewayTransit
	} else {
		peering.AllowGatewayTransit = nil
	}

	// AllowVirtualNetworkAccess
	if source.AllowVirtualNetworkAccess != nil {
		allowVirtualNetworkAccess := *source.AllowVirtualNetworkAccess
		peering.AllowVirtualNetworkAccess = &allowVirtualNetworkAccess
	} else {
		peering.AllowVirtualNetworkAccess = nil
	}

	// AzureName
	peering.AzureName = source.AzureName

	// DoNotVerifyRemoteGateways
	if source.DoNotVerifyRemoteGateways != nil {
		doNotVerifyRemoteGateway := *source.DoNotVerifyRemoteGateways
		peering.DoNotVerifyRemoteGateways = &doNotVerifyRemoteGateway
	} else {
		peering.DoNotVerifyRemoteGateways = nil
	}

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

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

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

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

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

	// OriginalVersion
	peering.OriginalVersion = source.OriginalVersion

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

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

	// PeeringState
	peering.PeeringState = genruntime.ClonePointerToString(source.PeeringState)

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

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

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

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

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

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

	// UseRemoteGateways
	if source.UseRemoteGateways != nil {
		useRemoteGateway := *source.UseRemoteGateways
		peering.UseRemoteGateways = &useRemoteGateway
	} else {
		peering.UseRemoteGateways = nil
	}

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

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

	// No error
	return nil
}

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

	// AllowForwardedTraffic
	if peering.AllowForwardedTraffic != nil {
		allowForwardedTraffic := *peering.AllowForwardedTraffic
		destination.AllowForwardedTraffic = &allowForwardedTraffic
	} else {
		destination.AllowForwardedTraffic = nil
	}

	// AllowGatewayTransit
	if peering.AllowGatewayTransit != nil {
		allowGatewayTransit := *peering.AllowGatewayTransit
		destination.AllowGatewayTransit = &allowGatewayTransit
	} else {
		destination.AllowGatewayTransit = nil
	}

	// AllowVirtualNetworkAccess
	if peering.AllowVirtualNetworkAccess != nil {
		allowVirtualNetworkAccess := *peering.AllowVirtualNetworkAccess
		destination.AllowVirtualNetworkAccess = &allowVirtualNetworkAccess
	} else {
		destination.AllowVirtualNetworkAccess = nil
	}

	// AzureName
	destination.AzureName = peering.AzureName

	// DoNotVerifyRemoteGateways
	if peering.DoNotVerifyRemoteGateways != nil {
		doNotVerifyRemoteGateway := *peering.DoNotVerifyRemoteGateways
		destination.DoNotVerifyRemoteGateways = &doNotVerifyRemoteGateway
	} else {
		destination.DoNotVerifyRemoteGateways = nil
	}

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

		destination.EnableOnlyIPv6Peering = &enableOnlyIPv6Peering
	} else {
		destination.EnableOnlyIPv6Peering = nil
	}

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

		destination.LocalAddressSpace = &localAddressSpace
	} else {
		destination.LocalAddressSpace = nil
	}

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

		destination.LocalSubnetNames = localSubnetName
	} else {
		destination.LocalSubnetNames = nil
	}

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

		destination.LocalVirtualNetworkAddressSpace = &localVirtualNetworkAddressSpace
	} else {
		destination.LocalVirtualNetworkAddressSpace = nil
	}

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

	// OriginalVersion
	destination.OriginalVersion = peering.OriginalVersion

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

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

		destination.PeerCompleteVnets = &peerCompleteVnet
	} else {
		destination.PeerCompleteVnets = nil
	}

	// PeeringState
	destination.PeeringState = genruntime.ClonePointerToString(peering.PeeringState)

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

		destination.PeeringSyncLevel = &peeringSyncLevel
	} else {
		destination.PeeringSyncLevel = nil
	}

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

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

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

		destination.RemoteSubnetNames = remoteSubnetName
	} else {
		destination.RemoteSubnetNames = nil
	}

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

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

		destination.RemoteVirtualNetworkAddressSpace = &remoteVirtualNetworkAddressSpace
	} else {
		destination.RemoteVirtualNetworkAddressSpace = nil
	}

	// UseRemoteGateways
	if peering.UseRemoteGateways != nil {
		useRemoteGateway := *peering.UseRemoteGateways
		destination.UseRemoteGateways = &useRemoteGateway
	} else {
		destination.UseRemoteGateways = nil
	}

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

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

	// No error
	return nil
}

// Storage version of v1api20201101.VirtualNetworksVirtualNetworkPeering_STATUS
type VirtualNetworksVirtualNetworkPeering_STATUS struct {
	AllowForwardedTraffic     *bool                                `json:"allowForwardedTraffic,omitempty"`
	AllowGatewayTransit       *bool                                `json:"allowGatewayTransit,omitempty"`
	AllowVirtualNetworkAccess *bool                                `json:"allowVirtualNetworkAccess,omitempty"`
	Conditions                []conditions.Condition               `json:"conditions,omitempty"`
	DoNotVerifyRemoteGateways *bool                                `json:"doNotVerifyRemoteGateways,omitempty"`
	Etag                      *string                              `json:"etag,omitempty"`
	Id                        *string                              `json:"id,omitempty"`
	Name                      *string                              `json:"name,omitempty"`
	PeeringState              *string                              `json:"peeringState,omitempty"`
	PropertyBag               genruntime.PropertyBag               `json:"$propertyBag,omitempty"`
	ProvisioningState         *string                              `json:"provisioningState,omitempty"`
	RemoteAddressSpace        *AddressSpace_STATUS                 `json:"remoteAddressSpace,omitempty"`
	RemoteBgpCommunities      *VirtualNetworkBgpCommunities_STATUS `json:"remoteBgpCommunities,omitempty"`
	RemoteVirtualNetwork      *SubResource_STATUS                  `json:"remoteVirtualNetwork,omitempty"`
	ResourceGuid              *string                              `json:"resourceGuid,omitempty"`
	Type                      *string                              `json:"type,omitempty"`
	UseRemoteGateways         *bool                                `json:"useRemoteGateways,omitempty"`
}

var _ genruntime.ConvertibleStatus = &VirtualNetworksVirtualNetworkPeering_STATUS{}

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

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

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

	return nil
}

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

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

	// AllowForwardedTraffic
	if source.AllowForwardedTraffic != nil {
		allowForwardedTraffic := *source.AllowForwardedTraffic
		peering.AllowForwardedTraffic = &allowForwardedTraffic
	} else {
		peering.AllowForwardedTraffic = nil
	}

	// AllowGatewayTransit
	if source.AllowGatewayTransit != nil {
		allowGatewayTransit := *source.AllowGatewayTransit
		peering.AllowGatewayTransit = &allowGatewayTransit
	} else {
		peering.AllowGatewayTransit = nil
	}

	// AllowVirtualNetworkAccess
	if source.AllowVirtualNetworkAccess != nil {
		allowVirtualNetworkAccess := *source.AllowVirtualNetworkAccess
		peering.AllowVirtualNetworkAccess = &allowVirtualNetworkAccess
	} else {
		peering.AllowVirtualNetworkAccess = nil
	}

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

	// DoNotVerifyRemoteGateways
	if source.DoNotVerifyRemoteGateways != nil {
		doNotVerifyRemoteGateway := *source.DoNotVerifyRemoteGateways
		peering.DoNotVerifyRemoteGateways = &doNotVerifyRemoteGateway
	} else {
		peering.DoNotVerifyRemoteGateways = nil
	}

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

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

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

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

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

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

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

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

	// PeeringState
	peering.PeeringState = genruntime.ClonePointerToString(source.PeeringState)

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

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

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

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

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

	// RemoteVirtualNetwork
	if source.RemoteVirtualNetwork != nil {
		var subResourceSTATUSStash v20240101s.SubResource_STATUS
		err := subResourceSTATUSStash.AssignProperties_From_SubResource_STATUS(source.RemoteVirtualNetwork)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_SubResource_STATUS() to populate field SubResource_STATUSStash from RemoteVirtualNetwork")
		}
		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 remoteVirtualNetwork SubResource_STATUS
		err = remoteVirtualNetwork.AssignProperties_From_SubResource_STATUS(&subResourceSTATUSStashLocal)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_SubResource_STATUS() to populate field RemoteVirtualNetwork from SubResource_STATUSStash")
		}
		peering.RemoteVirtualNetwork = &remoteVirtualNetwork
	} else {
		peering.RemoteVirtualNetwork = nil
	}

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

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

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

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

	// UseRemoteGateways
	if source.UseRemoteGateways != nil {
		useRemoteGateway := *source.UseRemoteGateways
		peering.UseRemoteGateways = &useRemoteGateway
	} else {
		peering.UseRemoteGateways = nil
	}

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

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

	// No error
	return nil
}

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

	// AllowForwardedTraffic
	if peering.AllowForwardedTraffic != nil {
		allowForwardedTraffic := *peering.AllowForwardedTraffic
		destination.AllowForwardedTraffic = &allowForwardedTraffic
	} else {
		destination.AllowForwardedTraffic = nil
	}

	// AllowGatewayTransit
	if peering.AllowGatewayTransit != nil {
		allowGatewayTransit := *peering.AllowGatewayTransit
		destination.AllowGatewayTransit = &allowGatewayTransit
	} else {
		destination.AllowGatewayTransit = nil
	}

	// AllowVirtualNetworkAccess
	if peering.AllowVirtualNetworkAccess != nil {
		allowVirtualNetworkAccess := *peering.AllowVirtualNetworkAccess
		destination.AllowVirtualNetworkAccess = &allowVirtualNetworkAccess
	} else {
		destination.AllowVirtualNetworkAccess = nil
	}

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

	// DoNotVerifyRemoteGateways
	if peering.DoNotVerifyRemoteGateways != nil {
		doNotVerifyRemoteGateway := *peering.DoNotVerifyRemoteGateways
		destination.DoNotVerifyRemoteGateways = &doNotVerifyRemoteGateway
	} else {
		destination.DoNotVerifyRemoteGateways = nil
	}

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

		destination.EnableOnlyIPv6Peering = &enableOnlyIPv6Peering
	} else {
		destination.EnableOnlyIPv6Peering = nil
	}

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

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

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

		destination.LocalAddressSpace = &localAddressSpace
	} else {
		destination.LocalAddressSpace = nil
	}

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

		destination.LocalSubnetNames = localSubnetName
	} else {
		destination.LocalSubnetNames = nil
	}

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

		destination.LocalVirtualNetworkAddressSpace = &localVirtualNetworkAddressSpace
	} else {
		destination.LocalVirtualNetworkAddressSpace = nil
	}

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

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

		destination.PeerCompleteVnets = &peerCompleteVnet
	} else {
		destination.PeerCompleteVnets = nil
	}

	// PeeringState
	destination.PeeringState = genruntime.ClonePointerToString(peering.PeeringState)

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

		destination.PeeringSyncLevel = &peeringSyncLevel
	} else {
		destination.PeeringSyncLevel = nil
	}

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

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

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

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

		destination.RemoteSubnetNames = remoteSubnetName
	} else {
		destination.RemoteSubnetNames = nil
	}

	// RemoteVirtualNetwork
	if peering.RemoteVirtualNetwork != nil {
		var subResourceSTATUSStash v20220701s.SubResource_STATUS
		err := peering.RemoteVirtualNetwork.AssignProperties_To_SubResource_STATUS(&subResourceSTATUSStash)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_SubResource_STATUS() to populate field SubResource_STATUSStash from RemoteVirtualNetwork")
		}
		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 remoteVirtualNetwork v20240301s.SubResource_STATUS
		err = subResourceSTATUSStashLocal.AssignProperties_To_SubResource_STATUS(&remoteVirtualNetwork)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_SubResource_STATUS() to populate field RemoteVirtualNetwork from SubResource_STATUSStash")
		}
		destination.RemoteVirtualNetwork = &remoteVirtualNetwork
	} else {
		destination.RemoteVirtualNetwork = nil
	}

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

		destination.RemoteVirtualNetworkAddressSpace = &remoteVirtualNetworkAddressSpace
	} else {
		destination.RemoteVirtualNetworkAddressSpace = nil
	}

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

		destination.RemoteVirtualNetworkEncryption = &remoteVirtualNetworkEncryption
	} else {
		destination.RemoteVirtualNetworkEncryption = nil
	}

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

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

	// UseRemoteGateways
	if peering.UseRemoteGateways != nil {
		useRemoteGateway := *peering.UseRemoteGateways
		destination.UseRemoteGateways = &useRemoteGateway
	} else {
		destination.UseRemoteGateways = nil
	}

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

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

	// No error
	return nil
}

type augmentConversionForVirtualNetworksVirtualNetworkPeering_Spec interface {
	AssignPropertiesFrom(src *v20240301s.VirtualNetworksVirtualNetworkPeering_Spec) error
	AssignPropertiesTo(dst *v20240301s.VirtualNetworksVirtualNetworkPeering_Spec) error
}

type augmentConversionForVirtualNetworksVirtualNetworkPeering_STATUS interface {
	AssignPropertiesFrom(src *v20240301s.VirtualNetworksVirtualNetworkPeering_STATUS) error
	AssignPropertiesTo(dst *v20240301s.VirtualNetworksVirtualNetworkPeering_STATUS) error
}

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

// AssignProperties_From_VirtualNetworksVirtualNetworkPeeringOperatorSpec populates our VirtualNetworksVirtualNetworkPeeringOperatorSpec from the provided source VirtualNetworksVirtualNetworkPeeringOperatorSpec
func (operator *VirtualNetworksVirtualNetworkPeeringOperatorSpec) AssignProperties_From_VirtualNetworksVirtualNetworkPeeringOperatorSpec(source *v20240301s.VirtualNetworksVirtualNetworkPeeringOperatorSpec) 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 augmentConversionForVirtualNetworksVirtualNetworkPeeringOperatorSpec interface (if implemented) to customize the conversion
	var operatorAsAny any = operator
	if augmentedOperator, ok := operatorAsAny.(augmentConversionForVirtualNetworksVirtualNetworkPeeringOperatorSpec); ok {
		err := augmentedOperator.AssignPropertiesFrom(source)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesFrom() for conversion")
		}
	}

	// No error
	return nil
}

// AssignProperties_To_VirtualNetworksVirtualNetworkPeeringOperatorSpec populates the provided destination VirtualNetworksVirtualNetworkPeeringOperatorSpec from our VirtualNetworksVirtualNetworkPeeringOperatorSpec
func (operator *VirtualNetworksVirtualNetworkPeeringOperatorSpec) AssignProperties_To_VirtualNetworksVirtualNetworkPeeringOperatorSpec(destination *v20240301s.VirtualNetworksVirtualNetworkPeeringOperatorSpec) 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 augmentConversionForVirtualNetworksVirtualNetworkPeeringOperatorSpec interface (if implemented) to customize the conversion
	var operatorAsAny any = operator
	if augmentedOperator, ok := operatorAsAny.(augmentConversionForVirtualNetworksVirtualNetworkPeeringOperatorSpec); ok {
		err := augmentedOperator.AssignPropertiesTo(destination)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesTo() for conversion")
		}
	}

	// No error
	return nil
}

type augmentConversionForVirtualNetworksVirtualNetworkPeeringOperatorSpec interface {
	AssignPropertiesFrom(src *v20240301s.VirtualNetworksVirtualNetworkPeeringOperatorSpec) error
	AssignPropertiesTo(dst *v20240301s.VirtualNetworksVirtualNetworkPeeringOperatorSpec) error
}

func init() {
	SchemeBuilder.Register(&VirtualNetworksVirtualNetworkPeering{}, &VirtualNetworksVirtualNetworkPeeringList{})
}
