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

import (
	"fmt"
	arm "github.com/Azure/azure-service-operator/v2/api/network/v1api20201101/arm"
	storage "github.com/Azure/azure-service-operator/v2/api/network/v1api20201101/storage"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime/conditions"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime/configmaps"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime/core"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime/secrets"
	"github.com/rotisserie/eris"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/runtime/schema"
	"sigs.k8s.io/controller-runtime/pkg/conversion"
)

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,network}
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
// +kubebuilder:printcolumn:name="Severity",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].severity"
// +kubebuilder:printcolumn:name="Reason",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].reason"
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].message"
// Generator information:
// - Generated from: /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 {
	// intermediate variable for conversion
	var source storage.VirtualNetwork

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

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

	return nil
}

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

	return nil
}

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 *storage.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

	// No error
	return nil
}

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

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

	// Spec
	var spec storage.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 storage.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

	// 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
// 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 VirtualNetwork_Spec struct {
	// AddressSpace: The AddressSpace that contains an array of IP address ranges that can be used by subnets.
	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: Bgp Communities sent over ExpressRoute with each route corresponding to a prefix in this VNET.
	BgpCommunities *VirtualNetworkBgpCommunities `json:"bgpCommunities,omitempty"`

	// DdosProtectionPlan: The DDoS protection plan associated with the virtual network.
	DdosProtectionPlan *SubResource `json:"ddosProtectionPlan,omitempty"`

	// DhcpOptions: The dhcpOptions that contains an array of DNS servers available to VMs deployed in the virtual network.
	DhcpOptions *DhcpOptions `json:"dhcpOptions,omitempty"`

	// EnableDdosProtection: Indicates if DDoS protection is enabled for all the protected resources in the virtual network. It
	// requires a DDoS protection plan associated with the resource.
	EnableDdosProtection *bool `json:"enableDdosProtection,omitempty"`

	// EnableVmProtection: Indicates if VM protection is enabled for all the subnets in the virtual network.
	EnableVmProtection *bool `json:"enableVmProtection,omitempty"`

	// ExtendedLocation: The extended location of the virtual network.
	ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"`

	// IpAllocations: Array of IpAllocation which reference this VNET.
	IpAllocations []SubResource `json:"ipAllocations,omitempty"`

	// Location: Resource location.
	Location *string `json:"location,omitempty"`

	// OperatorSpec: The specification for configuring operator behavior. This field is interpreted by the operator and not
	// passed directly to Azure
	OperatorSpec *VirtualNetworkOperatorSpec `json:"operatorSpec,omitempty"`

	// +kubebuilder:validation:Required
	// Owner: The owner of the resource. The owner controls where the resource goes when it is deployed. The owner also
	// controls the resources lifecycle. When the owner is deleted the resource will also be deleted. Owner is expected to be a
	// reference to a resources.azure.com/ResourceGroup resource
	Owner *genruntime.KnownResourceReference `group:"resources.azure.com" json:"owner,omitempty" kind:"ResourceGroup"`

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

var _ genruntime.ARMTransformer = &VirtualNetwork_Spec{}

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

	// Set property "ExtendedLocation":
	if network.ExtendedLocation != nil {
		extendedLocation_ARM, err := network.ExtendedLocation.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		extendedLocation := *extendedLocation_ARM.(*arm.ExtendedLocation)
		result.ExtendedLocation = &extendedLocation
	}

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

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

	// Set property "Properties":
	if network.AddressSpace != nil ||
		network.BgpCommunities != nil ||
		network.DdosProtectionPlan != nil ||
		network.DhcpOptions != nil ||
		network.EnableDdosProtection != nil ||
		network.EnableVmProtection != nil ||
		network.IpAllocations != nil {
		result.Properties = &arm.VirtualNetworkPropertiesFormat{}
	}
	if network.AddressSpace != nil {
		addressSpace_ARM, err := network.AddressSpace.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		addressSpace := *addressSpace_ARM.(*arm.AddressSpace)
		result.Properties.AddressSpace = &addressSpace
	}
	if network.BgpCommunities != nil {
		bgpCommunities_ARM, err := network.BgpCommunities.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		bgpCommunities := *bgpCommunities_ARM.(*arm.VirtualNetworkBgpCommunities)
		result.Properties.BgpCommunities = &bgpCommunities
	}
	if network.DdosProtectionPlan != nil {
		ddosProtectionPlan_ARM, err := network.DdosProtectionPlan.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		ddosProtectionPlan := *ddosProtectionPlan_ARM.(*arm.SubResource)
		result.Properties.DdosProtectionPlan = &ddosProtectionPlan
	}
	if network.DhcpOptions != nil {
		dhcpOptions_ARM, err := network.DhcpOptions.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		dhcpOptions := *dhcpOptions_ARM.(*arm.DhcpOptions)
		result.Properties.DhcpOptions = &dhcpOptions
	}
	if network.EnableDdosProtection != nil {
		enableDdosProtection := *network.EnableDdosProtection
		result.Properties.EnableDdosProtection = &enableDdosProtection
	}
	if network.EnableVmProtection != nil {
		enableVmProtection := *network.EnableVmProtection
		result.Properties.EnableVmProtection = &enableVmProtection
	}
	for _, item := range network.IpAllocations {
		item_ARM, err := item.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		result.Properties.IpAllocations = append(result.Properties.IpAllocations, *item_ARM.(*arm.SubResource))
	}

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

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

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

	// Set property "AddressSpace":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.AddressSpace != nil {
			var addressSpace1 AddressSpace
			err := addressSpace1.PopulateFromARM(owner, *typedInput.Properties.AddressSpace)
			if err != nil {
				return err
			}
			addressSpace := addressSpace1
			network.AddressSpace = &addressSpace
		}
	}

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

	// Set property "BgpCommunities":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.BgpCommunities != nil {
			var bgpCommunities1 VirtualNetworkBgpCommunities
			err := bgpCommunities1.PopulateFromARM(owner, *typedInput.Properties.BgpCommunities)
			if err != nil {
				return err
			}
			bgpCommunities := bgpCommunities1
			network.BgpCommunities = &bgpCommunities
		}
	}

	// Set property "DdosProtectionPlan":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.DdosProtectionPlan != nil {
			var ddosProtectionPlan1 SubResource
			err := ddosProtectionPlan1.PopulateFromARM(owner, *typedInput.Properties.DdosProtectionPlan)
			if err != nil {
				return err
			}
			ddosProtectionPlan := ddosProtectionPlan1
			network.DdosProtectionPlan = &ddosProtectionPlan
		}
	}

	// Set property "DhcpOptions":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.DhcpOptions != nil {
			var dhcpOptions1 DhcpOptions
			err := dhcpOptions1.PopulateFromARM(owner, *typedInput.Properties.DhcpOptions)
			if err != nil {
				return err
			}
			dhcpOptions := dhcpOptions1
			network.DhcpOptions = &dhcpOptions
		}
	}

	// Set property "EnableDdosProtection":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.EnableDdosProtection != nil {
			enableDdosProtection := *typedInput.Properties.EnableDdosProtection
			network.EnableDdosProtection = &enableDdosProtection
		}
	}

	// Set property "EnableVmProtection":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.EnableVmProtection != nil {
			enableVmProtection := *typedInput.Properties.EnableVmProtection
			network.EnableVmProtection = &enableVmProtection
		}
	}

	// Set property "ExtendedLocation":
	if typedInput.ExtendedLocation != nil {
		var extendedLocation1 ExtendedLocation
		err := extendedLocation1.PopulateFromARM(owner, *typedInput.ExtendedLocation)
		if err != nil {
			return err
		}
		extendedLocation := extendedLocation1
		network.ExtendedLocation = &extendedLocation
	}

	// Set property "IpAllocations":
	// copying flattened property:
	if typedInput.Properties != nil {
		for _, item := range typedInput.Properties.IpAllocations {
			var item1 SubResource
			err := item1.PopulateFromARM(owner, item)
			if err != nil {
				return err
			}
			network.IpAllocations = append(network.IpAllocations, item1)
		}
	}

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

	// no assignment for property "OperatorSpec"

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

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

	// No error
	return nil
}

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.(*storage.VirtualNetwork_Spec)
	if ok {
		// Populate our instance from source
		return network.AssignProperties_From_VirtualNetwork_Spec(src)
	}

	// Convert to an intermediate form
	src = &storage.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.(*storage.VirtualNetwork_Spec)
	if ok {
		// Populate destination from our instance
		return network.AssignProperties_To_VirtualNetwork_Spec(dst)
	}

	// Convert to an intermediate form
	dst = &storage.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 *storage.VirtualNetwork_Spec) error {

	// 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 ddosProtectionPlan SubResource
		err := ddosProtectionPlan.AssignProperties_From_SubResource(source.DdosProtectionPlan)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_SubResource() to populate field DdosProtectionPlan")
		}
		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
	}

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

	// IpAllocations
	if source.IpAllocations != nil {
		ipAllocationList := make([]SubResource, len(source.IpAllocations))
		for ipAllocationIndex, ipAllocationItem := range source.IpAllocations {
			var ipAllocation SubResource
			err := ipAllocation.AssignProperties_From_SubResource(&ipAllocationItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_SubResource() to populate field IpAllocations")
			}
			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
	}

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

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

	// 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 *storage.VirtualNetwork_Spec) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// AddressSpace
	if network.AddressSpace != nil {
		var addressSpace storage.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 storage.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 ddosProtectionPlan storage.SubResource
		err := network.DdosProtectionPlan.AssignProperties_To_SubResource(&ddosProtectionPlan)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_SubResource() to populate field DdosProtectionPlan")
		}
		destination.DdosProtectionPlan = &ddosProtectionPlan
	} else {
		destination.DdosProtectionPlan = nil
	}

	// DhcpOptions
	if network.DhcpOptions != nil {
		var dhcpOption storage.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
	}

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

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

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

	// OperatorSpec
	if network.OperatorSpec != nil {
		var operatorSpec storage.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
	}

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

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

	// No error
	return nil
}

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

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

// Virtual Network resource.
type VirtualNetwork_STATUS struct {
	// AddressSpace: The AddressSpace that contains an array of IP address ranges that can be used by subnets.
	AddressSpace *AddressSpace_STATUS `json:"addressSpace,omitempty"`

	// BgpCommunities: Bgp Communities sent over ExpressRoute with each route corresponding to a prefix in this VNET.
	BgpCommunities *VirtualNetworkBgpCommunities_STATUS `json:"bgpCommunities,omitempty"`

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

	// DdosProtectionPlan: The DDoS protection plan associated with the virtual network.
	DdosProtectionPlan *SubResource_STATUS `json:"ddosProtectionPlan,omitempty"`

	// DhcpOptions: The dhcpOptions that contains an array of DNS servers available to VMs deployed in the virtual network.
	DhcpOptions *DhcpOptions_STATUS `json:"dhcpOptions,omitempty"`

	// EnableDdosProtection: Indicates if DDoS protection is enabled for all the protected resources in the virtual network. It
	// requires a DDoS protection plan associated with the resource.
	EnableDdosProtection *bool `json:"enableDdosProtection,omitempty"`

	// EnableVmProtection: Indicates if VM protection is enabled for all the subnets in the virtual network.
	EnableVmProtection *bool `json:"enableVmProtection,omitempty"`

	// Etag: A unique read-only string that changes whenever the resource is updated.
	Etag *string `json:"etag,omitempty"`

	// ExtendedLocation: The extended location of the virtual network.
	ExtendedLocation *ExtendedLocation_STATUS `json:"extendedLocation,omitempty"`

	// Id: Resource ID.
	Id *string `json:"id,omitempty"`

	// IpAllocations: Array of IpAllocation which reference this VNET.
	IpAllocations []SubResource_STATUS `json:"ipAllocations,omitempty"`

	// Location: Resource location.
	Location *string `json:"location,omitempty"`

	// Name: Resource name.
	Name *string `json:"name,omitempty"`

	// ProvisioningState: The provisioning state of the virtual network resource.
	ProvisioningState *ProvisioningState_STATUS `json:"provisioningState,omitempty"`

	// ResourceGuid: The resourceGuid property of the Virtual Network resource.
	ResourceGuid *string `json:"resourceGuid,omitempty"`

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

	// Type: Resource type.
	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.(*storage.VirtualNetwork_STATUS)
	if ok {
		// Populate our instance from source
		return network.AssignProperties_From_VirtualNetwork_STATUS(src)
	}

	// Convert to an intermediate form
	src = &storage.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.(*storage.VirtualNetwork_STATUS)
	if ok {
		// Populate destination from our instance
		return network.AssignProperties_To_VirtualNetwork_STATUS(dst)
	}

	// Convert to an intermediate form
	dst = &storage.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
}

var _ genruntime.FromARMConverter = &VirtualNetwork_STATUS{}

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

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

	// Set property "AddressSpace":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.AddressSpace != nil {
			var addressSpace1 AddressSpace_STATUS
			err := addressSpace1.PopulateFromARM(owner, *typedInput.Properties.AddressSpace)
			if err != nil {
				return err
			}
			addressSpace := addressSpace1
			network.AddressSpace = &addressSpace
		}
	}

	// Set property "BgpCommunities":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.BgpCommunities != nil {
			var bgpCommunities1 VirtualNetworkBgpCommunities_STATUS
			err := bgpCommunities1.PopulateFromARM(owner, *typedInput.Properties.BgpCommunities)
			if err != nil {
				return err
			}
			bgpCommunities := bgpCommunities1
			network.BgpCommunities = &bgpCommunities
		}
	}

	// no assignment for property "Conditions"

	// Set property "DdosProtectionPlan":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.DdosProtectionPlan != nil {
			var ddosProtectionPlan1 SubResource_STATUS
			err := ddosProtectionPlan1.PopulateFromARM(owner, *typedInput.Properties.DdosProtectionPlan)
			if err != nil {
				return err
			}
			ddosProtectionPlan := ddosProtectionPlan1
			network.DdosProtectionPlan = &ddosProtectionPlan
		}
	}

	// Set property "DhcpOptions":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.DhcpOptions != nil {
			var dhcpOptions1 DhcpOptions_STATUS
			err := dhcpOptions1.PopulateFromARM(owner, *typedInput.Properties.DhcpOptions)
			if err != nil {
				return err
			}
			dhcpOptions := dhcpOptions1
			network.DhcpOptions = &dhcpOptions
		}
	}

	// Set property "EnableDdosProtection":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.EnableDdosProtection != nil {
			enableDdosProtection := *typedInput.Properties.EnableDdosProtection
			network.EnableDdosProtection = &enableDdosProtection
		}
	}

	// Set property "EnableVmProtection":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.EnableVmProtection != nil {
			enableVmProtection := *typedInput.Properties.EnableVmProtection
			network.EnableVmProtection = &enableVmProtection
		}
	}

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

	// Set property "ExtendedLocation":
	if typedInput.ExtendedLocation != nil {
		var extendedLocation1 ExtendedLocation_STATUS
		err := extendedLocation1.PopulateFromARM(owner, *typedInput.ExtendedLocation)
		if err != nil {
			return err
		}
		extendedLocation := extendedLocation1
		network.ExtendedLocation = &extendedLocation
	}

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

	// Set property "IpAllocations":
	// copying flattened property:
	if typedInput.Properties != nil {
		for _, item := range typedInput.Properties.IpAllocations {
			var item1 SubResource_STATUS
			err := item1.PopulateFromARM(owner, item)
			if err != nil {
				return err
			}
			network.IpAllocations = append(network.IpAllocations, item1)
		}
	}

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

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

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

	// Set property "ResourceGuid":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ResourceGuid != nil {
			resourceGuid := *typedInput.Properties.ResourceGuid
			network.ResourceGuid = &resourceGuid
		}
	}

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

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

	// No error
	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 *storage.VirtualNetwork_STATUS) error {

	// 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 ddosProtectionPlan SubResource_STATUS
		err := ddosProtectionPlan.AssignProperties_From_SubResource_STATUS(source.DdosProtectionPlan)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_SubResource_STATUS() to populate field DdosProtectionPlan")
		}
		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
	}

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

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

	// 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 ipAllocation SubResource_STATUS
			err := ipAllocation.AssignProperties_From_SubResource_STATUS(&ipAllocationItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_SubResource_STATUS() to populate field IpAllocations")
			}
			ipAllocationList[ipAllocationIndex] = ipAllocation
		}
		network.IpAllocations = ipAllocationList
	} else {
		network.IpAllocations = nil
	}

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

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

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

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

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

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

	// 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 *storage.VirtualNetwork_STATUS) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// AddressSpace
	if network.AddressSpace != nil {
		var addressSpace storage.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 storage.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 ddosProtectionPlan storage.SubResource_STATUS
		err := network.DdosProtectionPlan.AssignProperties_To_SubResource_STATUS(&ddosProtectionPlan)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_SubResource_STATUS() to populate field DdosProtectionPlan")
		}
		destination.DdosProtectionPlan = &ddosProtectionPlan
	} else {
		destination.DdosProtectionPlan = nil
	}

	// DhcpOptions
	if network.DhcpOptions != nil {
		var dhcpOption storage.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
	}

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

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

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

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

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

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

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

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

	// No error
	return nil
}

// AddressSpace contains an array of IP address ranges that can be used by subnets of the virtual network.
type AddressSpace struct {
	// AddressPrefixes: A list of address blocks reserved for this virtual network in CIDR notation.
	AddressPrefixes []string `json:"addressPrefixes,omitempty"`
}

var _ genruntime.ARMTransformer = &AddressSpace{}

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

	// Set property "AddressPrefixes":
	for _, item := range space.AddressPrefixes {
		result.AddressPrefixes = append(result.AddressPrefixes, item)
	}
	return result, nil
}

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

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

	// Set property "AddressPrefixes":
	for _, item := range typedInput.AddressPrefixes {
		space.AddressPrefixes = append(space.AddressPrefixes, item)
	}

	// No error
	return nil
}

// AssignProperties_From_AddressSpace populates our AddressSpace from the provided source AddressSpace
func (space *AddressSpace) AssignProperties_From_AddressSpace(source *storage.AddressSpace) error {

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

	// No error
	return nil
}

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

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

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

	// No error
	return nil
}

// AddressSpace contains an array of IP address ranges that can be used by subnets of the virtual network.
type AddressSpace_STATUS struct {
	// AddressPrefixes: A list of address blocks reserved for this virtual network in CIDR notation.
	AddressPrefixes []string `json:"addressPrefixes,omitempty"`
}

var _ genruntime.FromARMConverter = &AddressSpace_STATUS{}

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

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

	// Set property "AddressPrefixes":
	for _, item := range typedInput.AddressPrefixes {
		space.AddressPrefixes = append(space.AddressPrefixes, item)
	}

	// No error
	return nil
}

// AssignProperties_From_AddressSpace_STATUS populates our AddressSpace_STATUS from the provided source AddressSpace_STATUS
func (space *AddressSpace_STATUS) AssignProperties_From_AddressSpace_STATUS(source *storage.AddressSpace_STATUS) error {

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

	// 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 *storage.AddressSpace_STATUS) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

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

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

	// No error
	return nil
}

// 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: The list of DNS servers IP addresses.
	DnsServers []string `json:"dnsServers,omitempty"`
}

var _ genruntime.ARMTransformer = &DhcpOptions{}

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

	// Set property "DnsServers":
	for _, item := range options.DnsServers {
		result.DnsServers = append(result.DnsServers, item)
	}
	return result, nil
}

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

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

	// Set property "DnsServers":
	for _, item := range typedInput.DnsServers {
		options.DnsServers = append(options.DnsServers, item)
	}

	// No error
	return nil
}

// AssignProperties_From_DhcpOptions populates our DhcpOptions from the provided source DhcpOptions
func (options *DhcpOptions) AssignProperties_From_DhcpOptions(source *storage.DhcpOptions) error {

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

	// No error
	return nil
}

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

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

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

	// No error
	return nil
}

// 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: The list of DNS servers IP addresses.
	DnsServers []string `json:"dnsServers,omitempty"`
}

var _ genruntime.FromARMConverter = &DhcpOptions_STATUS{}

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

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

	// Set property "DnsServers":
	for _, item := range typedInput.DnsServers {
		options.DnsServers = append(options.DnsServers, item)
	}

	// No error
	return nil
}

// AssignProperties_From_DhcpOptions_STATUS populates our DhcpOptions_STATUS from the provided source DhcpOptions_STATUS
func (options *DhcpOptions_STATUS) AssignProperties_From_DhcpOptions_STATUS(source *storage.DhcpOptions_STATUS) error {

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

	// 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 *storage.DhcpOptions_STATUS) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

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

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

	// No error
	return nil
}

// Bgp Communities sent over ExpressRoute with each route corresponding to a prefix in this VNET.
type VirtualNetworkBgpCommunities struct {
	// +kubebuilder:validation:Required
	// VirtualNetworkCommunity: The BGP community associated with the virtual network.
	VirtualNetworkCommunity *string `json:"virtualNetworkCommunity,omitempty"`
}

var _ genruntime.ARMTransformer = &VirtualNetworkBgpCommunities{}

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

	// Set property "VirtualNetworkCommunity":
	if communities.VirtualNetworkCommunity != nil {
		virtualNetworkCommunity := *communities.VirtualNetworkCommunity
		result.VirtualNetworkCommunity = &virtualNetworkCommunity
	}
	return result, nil
}

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

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

	// Set property "VirtualNetworkCommunity":
	if typedInput.VirtualNetworkCommunity != nil {
		virtualNetworkCommunity := *typedInput.VirtualNetworkCommunity
		communities.VirtualNetworkCommunity = &virtualNetworkCommunity
	}

	// No error
	return nil
}

// AssignProperties_From_VirtualNetworkBgpCommunities populates our VirtualNetworkBgpCommunities from the provided source VirtualNetworkBgpCommunities
func (communities *VirtualNetworkBgpCommunities) AssignProperties_From_VirtualNetworkBgpCommunities(source *storage.VirtualNetworkBgpCommunities) error {

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

	// No error
	return nil
}

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

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

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

	// No error
	return nil
}

// Bgp Communities sent over ExpressRoute with each route corresponding to a prefix in this VNET.
type VirtualNetworkBgpCommunities_STATUS struct {
	// RegionalCommunity: The BGP community associated with the region of the virtual network.
	RegionalCommunity *string `json:"regionalCommunity,omitempty"`

	// VirtualNetworkCommunity: The BGP community associated with the virtual network.
	VirtualNetworkCommunity *string `json:"virtualNetworkCommunity,omitempty"`
}

var _ genruntime.FromARMConverter = &VirtualNetworkBgpCommunities_STATUS{}

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

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

	// Set property "RegionalCommunity":
	if typedInput.RegionalCommunity != nil {
		regionalCommunity := *typedInput.RegionalCommunity
		communities.RegionalCommunity = &regionalCommunity
	}

	// Set property "VirtualNetworkCommunity":
	if typedInput.VirtualNetworkCommunity != nil {
		virtualNetworkCommunity := *typedInput.VirtualNetworkCommunity
		communities.VirtualNetworkCommunity = &virtualNetworkCommunity
	}

	// No error
	return nil
}

// AssignProperties_From_VirtualNetworkBgpCommunities_STATUS populates our VirtualNetworkBgpCommunities_STATUS from the provided source VirtualNetworkBgpCommunities_STATUS
func (communities *VirtualNetworkBgpCommunities_STATUS) AssignProperties_From_VirtualNetworkBgpCommunities_STATUS(source *storage.VirtualNetworkBgpCommunities_STATUS) error {

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

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

	// 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 *storage.VirtualNetworkBgpCommunities_STATUS) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

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

	// No error
	return nil
}

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

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

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

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

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

	// No error
	return nil
}

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

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

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

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

	// No error
	return nil
}

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