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

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

// +kubebuilder:object:root=true
// +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/2022-07-01/natGateway.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/natGateways/{natGatewayName}
type NatGateway struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              NatGateway_Spec   `json:"spec,omitempty"`
	Status            NatGateway_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &NatGateway{}

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

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

var _ conversion.Convertible = &NatGateway{}

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

	return gateway.AssignProperties_From_NatGateway(source)
}

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

	return gateway.AssignProperties_To_NatGateway(destination)
}

// +kubebuilder:webhook:path=/mutate-network-azure-com-v1api20220701-natgateway,mutating=true,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=network.azure.com,resources=natgateways,verbs=create;update,versions=v1api20220701,name=default.v1api20220701.natgateways.network.azure.com,admissionReviewVersions=v1

var _ admission.Defaulter = &NatGateway{}

// Default applies defaults to the NatGateway resource
func (gateway *NatGateway) Default() {
	gateway.defaultImpl()
	var temp any = gateway
	if runtimeDefaulter, ok := temp.(genruntime.Defaulter); ok {
		runtimeDefaulter.CustomDefault()
	}
}

// defaultAzureName defaults the Azure name of the resource to the Kubernetes name
func (gateway *NatGateway) defaultAzureName() {
	if gateway.Spec.AzureName == "" {
		gateway.Spec.AzureName = gateway.Name
	}
}

// defaultImpl applies the code generated defaults to the NatGateway resource
func (gateway *NatGateway) defaultImpl() { gateway.defaultAzureName() }

var _ genruntime.ImportableResource = &NatGateway{}

// InitializeSpec initializes the spec for this resource from the given status
func (gateway *NatGateway) InitializeSpec(status genruntime.ConvertibleStatus) error {
	if s, ok := status.(*NatGateway_STATUS); ok {
		return gateway.Spec.Initialize_From_NatGateway_STATUS(s)
	}

	return fmt.Errorf("expected Status of type NatGateway_STATUS but received %T instead", status)
}

var _ genruntime.KubernetesResource = &NatGateway{}

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

// GetAPIVersion returns the ARM API version of the resource. This is always "2022-07-01"
func (gateway NatGateway) GetAPIVersion() string {
	return string(APIVersion_Value)
}

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

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

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

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

// NewEmptyStatus returns a new empty (blank) status
func (gateway *NatGateway) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &NatGateway_STATUS{}
}

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

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

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

	gateway.Status = st
	return nil
}

// +kubebuilder:webhook:path=/validate-network-azure-com-v1api20220701-natgateway,mutating=false,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=network.azure.com,resources=natgateways,verbs=create;update,versions=v1api20220701,name=validate.v1api20220701.natgateways.network.azure.com,admissionReviewVersions=v1

var _ admission.Validator = &NatGateway{}

// ValidateCreate validates the creation of the resource
func (gateway *NatGateway) ValidateCreate() (admission.Warnings, error) {
	validations := gateway.createValidations()
	var temp any = gateway
	if runtimeValidator, ok := temp.(genruntime.Validator); ok {
		validations = append(validations, runtimeValidator.CreateValidations()...)
	}
	return genruntime.ValidateCreate(validations)
}

// ValidateDelete validates the deletion of the resource
func (gateway *NatGateway) ValidateDelete() (admission.Warnings, error) {
	validations := gateway.deleteValidations()
	var temp any = gateway
	if runtimeValidator, ok := temp.(genruntime.Validator); ok {
		validations = append(validations, runtimeValidator.DeleteValidations()...)
	}
	return genruntime.ValidateDelete(validations)
}

// ValidateUpdate validates an update of the resource
func (gateway *NatGateway) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
	validations := gateway.updateValidations()
	var temp any = gateway
	if runtimeValidator, ok := temp.(genruntime.Validator); ok {
		validations = append(validations, runtimeValidator.UpdateValidations()...)
	}
	return genruntime.ValidateUpdate(old, validations)
}

// createValidations validates the creation of the resource
func (gateway *NatGateway) createValidations() []func() (admission.Warnings, error) {
	return []func() (admission.Warnings, error){gateway.validateResourceReferences, gateway.validateOwnerReference}
}

// deleteValidations validates the deletion of the resource
func (gateway *NatGateway) deleteValidations() []func() (admission.Warnings, error) {
	return nil
}

// updateValidations validates the update of the resource
func (gateway *NatGateway) updateValidations() []func(old runtime.Object) (admission.Warnings, error) {
	return []func(old runtime.Object) (admission.Warnings, error){
		func(old runtime.Object) (admission.Warnings, error) {
			return gateway.validateResourceReferences()
		},
		gateway.validateWriteOnceProperties,
		func(old runtime.Object) (admission.Warnings, error) {
			return gateway.validateOwnerReference()
		},
	}
}

// validateOwnerReference validates the owner field
func (gateway *NatGateway) validateOwnerReference() (admission.Warnings, error) {
	return genruntime.ValidateOwner(gateway)
}

// validateResourceReferences validates all resource references
func (gateway *NatGateway) validateResourceReferences() (admission.Warnings, error) {
	refs, err := reflecthelpers.FindResourceReferences(&gateway.Spec)
	if err != nil {
		return nil, err
	}
	return genruntime.ValidateResourceReferences(refs)
}

// validateWriteOnceProperties validates all WriteOnce properties
func (gateway *NatGateway) validateWriteOnceProperties(old runtime.Object) (admission.Warnings, error) {
	oldObj, ok := old.(*NatGateway)
	if !ok {
		return nil, nil
	}

	return genruntime.ValidateWriteOnceProperties(oldObj, gateway)
}

// AssignProperties_From_NatGateway populates our NatGateway from the provided source NatGateway
func (gateway *NatGateway) AssignProperties_From_NatGateway(source *v20220701s.NatGateway) error {

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

	// Spec
	var spec NatGateway_Spec
	err := spec.AssignProperties_From_NatGateway_Spec(&source.Spec)
	if err != nil {
		return errors.Wrap(err, "calling AssignProperties_From_NatGateway_Spec() to populate field Spec")
	}
	gateway.Spec = spec

	// Status
	var status NatGateway_STATUS
	err = status.AssignProperties_From_NatGateway_STATUS(&source.Status)
	if err != nil {
		return errors.Wrap(err, "calling AssignProperties_From_NatGateway_STATUS() to populate field Status")
	}
	gateway.Status = status

	// No error
	return nil
}

// AssignProperties_To_NatGateway populates the provided destination NatGateway from our NatGateway
func (gateway *NatGateway) AssignProperties_To_NatGateway(destination *v20220701s.NatGateway) error {

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

	// Spec
	var spec v20220701s.NatGateway_Spec
	err := gateway.Spec.AssignProperties_To_NatGateway_Spec(&spec)
	if err != nil {
		return errors.Wrap(err, "calling AssignProperties_To_NatGateway_Spec() to populate field Spec")
	}
	destination.Spec = spec

	// Status
	var status v20220701s.NatGateway_STATUS
	err = gateway.Status.AssignProperties_To_NatGateway_STATUS(&status)
	if err != nil {
		return errors.Wrap(err, "calling AssignProperties_To_NatGateway_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 (gateway *NatGateway) OriginalGVK() *schema.GroupVersionKind {
	return &schema.GroupVersionKind{
		Group:   GroupVersion.Group,
		Version: gateway.Spec.OriginalVersion(),
		Kind:    "NatGateway",
	}
}

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /network/resource-manager/Microsoft.Network/stable/2022-07-01/natGateway.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/natGateways/{natGatewayName}
type NatGatewayList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []NatGateway `json:"items"`
}

type NatGateway_Spec struct {
	// AzureName: The name of the resource in Azure. This is often the same as the name of the resource in Kubernetes but it
	// doesn't have to be.
	AzureName string `json:"azureName,omitempty"`

	// IdleTimeoutInMinutes: The idle timeout of the nat gateway.
	IdleTimeoutInMinutes *int `json:"idleTimeoutInMinutes,omitempty"`

	// Location: Resource location.
	Location *string `json:"location,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"`

	// PublicIpAddresses: An array of public ip addresses associated with the nat gateway resource.
	PublicIpAddresses []ApplicationGatewaySubResource `json:"publicIpAddresses,omitempty"`

	// PublicIpPrefixes: An array of public ip prefixes associated with the nat gateway resource.
	PublicIpPrefixes []ApplicationGatewaySubResource `json:"publicIpPrefixes,omitempty"`

	// Sku: The nat gateway SKU.
	Sku *NatGatewaySku `json:"sku,omitempty"`

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

	// Zones: A list of availability zones denoting the zone in which Nat Gateway should be deployed.
	Zones []string `json:"zones,omitempty"`
}

var _ genruntime.ARMTransformer = &NatGateway_Spec{}

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

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

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

	// Set property "Properties":
	if gateway.IdleTimeoutInMinutes != nil ||
		gateway.PublicIpAddresses != nil ||
		gateway.PublicIpPrefixes != nil {
		result.Properties = &NatGatewayPropertiesFormat_ARM{}
	}
	if gateway.IdleTimeoutInMinutes != nil {
		idleTimeoutInMinutes := *gateway.IdleTimeoutInMinutes
		result.Properties.IdleTimeoutInMinutes = &idleTimeoutInMinutes
	}
	for _, item := range gateway.PublicIpAddresses {
		item_ARM, err := item.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		result.Properties.PublicIpAddresses = append(result.Properties.PublicIpAddresses, *item_ARM.(*ApplicationGatewaySubResource_ARM))
	}
	for _, item := range gateway.PublicIpPrefixes {
		item_ARM, err := item.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		result.Properties.PublicIpPrefixes = append(result.Properties.PublicIpPrefixes, *item_ARM.(*ApplicationGatewaySubResource_ARM))
	}

	// Set property "Sku":
	if gateway.Sku != nil {
		sku_ARM, err := (*gateway.Sku).ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		sku := *sku_ARM.(*NatGatewaySku_ARM)
		result.Sku = &sku
	}

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

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

// NewEmptyARMValue returns an empty ARM value suitable for deserializing into
func (gateway *NatGateway_Spec) NewEmptyARMValue() genruntime.ARMResourceStatus {
	return &NatGateway_Spec_ARM{}
}

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

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

	// Set property "IdleTimeoutInMinutes":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.IdleTimeoutInMinutes != nil {
			idleTimeoutInMinutes := *typedInput.Properties.IdleTimeoutInMinutes
			gateway.IdleTimeoutInMinutes = &idleTimeoutInMinutes
		}
	}

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

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

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

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

	// Set property "Sku":
	if typedInput.Sku != nil {
		var sku1 NatGatewaySku
		err := sku1.PopulateFromARM(owner, *typedInput.Sku)
		if err != nil {
			return err
		}
		sku := sku1
		gateway.Sku = &sku
	}

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

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

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &NatGateway_Spec{}

// ConvertSpecFrom populates our NatGateway_Spec from the provided source
func (gateway *NatGateway_Spec) ConvertSpecFrom(source genruntime.ConvertibleSpec) error {
	src, ok := source.(*v20220701s.NatGateway_Spec)
	if ok {
		// Populate our instance from source
		return gateway.AssignProperties_From_NatGateway_Spec(src)
	}

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

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

	return nil
}

// ConvertSpecTo populates the provided destination from our NatGateway_Spec
func (gateway *NatGateway_Spec) ConvertSpecTo(destination genruntime.ConvertibleSpec) error {
	dst, ok := destination.(*v20220701s.NatGateway_Spec)
	if ok {
		// Populate destination from our instance
		return gateway.AssignProperties_To_NatGateway_Spec(dst)
	}

	// Convert to an intermediate form
	dst = &v20220701s.NatGateway_Spec{}
	err := gateway.AssignProperties_To_NatGateway_Spec(dst)
	if err != nil {
		return errors.Wrap(err, "initial step of conversion in ConvertSpecTo()")
	}

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

	return nil
}

// AssignProperties_From_NatGateway_Spec populates our NatGateway_Spec from the provided source NatGateway_Spec
func (gateway *NatGateway_Spec) AssignProperties_From_NatGateway_Spec(source *v20220701s.NatGateway_Spec) error {

	// AzureName
	gateway.AzureName = source.AzureName

	// IdleTimeoutInMinutes
	gateway.IdleTimeoutInMinutes = genruntime.ClonePointerToInt(source.IdleTimeoutInMinutes)

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

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

	// PublicIpAddresses
	if source.PublicIpAddresses != nil {
		publicIpAddressList := make([]ApplicationGatewaySubResource, len(source.PublicIpAddresses))
		for publicIpAddressIndex, publicIpAddressItem := range source.PublicIpAddresses {
			// Shadow the loop variable to avoid aliasing
			publicIpAddressItem := publicIpAddressItem
			var publicIpAddress ApplicationGatewaySubResource
			err := publicIpAddress.AssignProperties_From_ApplicationGatewaySubResource(&publicIpAddressItem)
			if err != nil {
				return errors.Wrap(err, "calling AssignProperties_From_ApplicationGatewaySubResource() to populate field PublicIpAddresses")
			}
			publicIpAddressList[publicIpAddressIndex] = publicIpAddress
		}
		gateway.PublicIpAddresses = publicIpAddressList
	} else {
		gateway.PublicIpAddresses = nil
	}

	// PublicIpPrefixes
	if source.PublicIpPrefixes != nil {
		publicIpPrefixList := make([]ApplicationGatewaySubResource, len(source.PublicIpPrefixes))
		for publicIpPrefixIndex, publicIpPrefixItem := range source.PublicIpPrefixes {
			// Shadow the loop variable to avoid aliasing
			publicIpPrefixItem := publicIpPrefixItem
			var publicIpPrefix ApplicationGatewaySubResource
			err := publicIpPrefix.AssignProperties_From_ApplicationGatewaySubResource(&publicIpPrefixItem)
			if err != nil {
				return errors.Wrap(err, "calling AssignProperties_From_ApplicationGatewaySubResource() to populate field PublicIpPrefixes")
			}
			publicIpPrefixList[publicIpPrefixIndex] = publicIpPrefix
		}
		gateway.PublicIpPrefixes = publicIpPrefixList
	} else {
		gateway.PublicIpPrefixes = nil
	}

	// Sku
	if source.Sku != nil {
		var sku NatGatewaySku
		err := sku.AssignProperties_From_NatGatewaySku(source.Sku)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_From_NatGatewaySku() to populate field Sku")
		}
		gateway.Sku = &sku
	} else {
		gateway.Sku = nil
	}

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

	// Zones
	gateway.Zones = genruntime.CloneSliceOfString(source.Zones)

	// No error
	return nil
}

// AssignProperties_To_NatGateway_Spec populates the provided destination NatGateway_Spec from our NatGateway_Spec
func (gateway *NatGateway_Spec) AssignProperties_To_NatGateway_Spec(destination *v20220701s.NatGateway_Spec) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// AzureName
	destination.AzureName = gateway.AzureName

	// IdleTimeoutInMinutes
	destination.IdleTimeoutInMinutes = genruntime.ClonePointerToInt(gateway.IdleTimeoutInMinutes)

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

	// OriginalVersion
	destination.OriginalVersion = gateway.OriginalVersion()

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

	// PublicIpAddresses
	if gateway.PublicIpAddresses != nil {
		publicIpAddressList := make([]v20220701s.ApplicationGatewaySubResource, len(gateway.PublicIpAddresses))
		for publicIpAddressIndex, publicIpAddressItem := range gateway.PublicIpAddresses {
			// Shadow the loop variable to avoid aliasing
			publicIpAddressItem := publicIpAddressItem
			var publicIpAddress v20220701s.ApplicationGatewaySubResource
			err := publicIpAddressItem.AssignProperties_To_ApplicationGatewaySubResource(&publicIpAddress)
			if err != nil {
				return errors.Wrap(err, "calling AssignProperties_To_ApplicationGatewaySubResource() to populate field PublicIpAddresses")
			}
			publicIpAddressList[publicIpAddressIndex] = publicIpAddress
		}
		destination.PublicIpAddresses = publicIpAddressList
	} else {
		destination.PublicIpAddresses = nil
	}

	// PublicIpPrefixes
	if gateway.PublicIpPrefixes != nil {
		publicIpPrefixList := make([]v20220701s.ApplicationGatewaySubResource, len(gateway.PublicIpPrefixes))
		for publicIpPrefixIndex, publicIpPrefixItem := range gateway.PublicIpPrefixes {
			// Shadow the loop variable to avoid aliasing
			publicIpPrefixItem := publicIpPrefixItem
			var publicIpPrefix v20220701s.ApplicationGatewaySubResource
			err := publicIpPrefixItem.AssignProperties_To_ApplicationGatewaySubResource(&publicIpPrefix)
			if err != nil {
				return errors.Wrap(err, "calling AssignProperties_To_ApplicationGatewaySubResource() to populate field PublicIpPrefixes")
			}
			publicIpPrefixList[publicIpPrefixIndex] = publicIpPrefix
		}
		destination.PublicIpPrefixes = publicIpPrefixList
	} else {
		destination.PublicIpPrefixes = nil
	}

	// Sku
	if gateway.Sku != nil {
		var sku v20220701s.NatGatewaySku
		err := gateway.Sku.AssignProperties_To_NatGatewaySku(&sku)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_To_NatGatewaySku() to populate field Sku")
		}
		destination.Sku = &sku
	} else {
		destination.Sku = nil
	}

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

	// Zones
	destination.Zones = genruntime.CloneSliceOfString(gateway.Zones)

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

	// No error
	return nil
}

// Initialize_From_NatGateway_STATUS populates our NatGateway_Spec from the provided source NatGateway_STATUS
func (gateway *NatGateway_Spec) Initialize_From_NatGateway_STATUS(source *NatGateway_STATUS) error {

	// IdleTimeoutInMinutes
	gateway.IdleTimeoutInMinutes = genruntime.ClonePointerToInt(source.IdleTimeoutInMinutes)

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

	// PublicIpAddresses
	if source.PublicIpAddresses != nil {
		publicIpAddressList := make([]ApplicationGatewaySubResource, len(source.PublicIpAddresses))
		for publicIpAddressIndex, publicIpAddressItem := range source.PublicIpAddresses {
			// Shadow the loop variable to avoid aliasing
			publicIpAddressItem := publicIpAddressItem
			var publicIpAddress ApplicationGatewaySubResource
			err := publicIpAddress.Initialize_From_ApplicationGatewaySubResource_STATUS(&publicIpAddressItem)
			if err != nil {
				return errors.Wrap(err, "calling Initialize_From_ApplicationGatewaySubResource_STATUS() to populate field PublicIpAddresses")
			}
			publicIpAddressList[publicIpAddressIndex] = publicIpAddress
		}
		gateway.PublicIpAddresses = publicIpAddressList
	} else {
		gateway.PublicIpAddresses = nil
	}

	// PublicIpPrefixes
	if source.PublicIpPrefixes != nil {
		publicIpPrefixList := make([]ApplicationGatewaySubResource, len(source.PublicIpPrefixes))
		for publicIpPrefixIndex, publicIpPrefixItem := range source.PublicIpPrefixes {
			// Shadow the loop variable to avoid aliasing
			publicIpPrefixItem := publicIpPrefixItem
			var publicIpPrefix ApplicationGatewaySubResource
			err := publicIpPrefix.Initialize_From_ApplicationGatewaySubResource_STATUS(&publicIpPrefixItem)
			if err != nil {
				return errors.Wrap(err, "calling Initialize_From_ApplicationGatewaySubResource_STATUS() to populate field PublicIpPrefixes")
			}
			publicIpPrefixList[publicIpPrefixIndex] = publicIpPrefix
		}
		gateway.PublicIpPrefixes = publicIpPrefixList
	} else {
		gateway.PublicIpPrefixes = nil
	}

	// Sku
	if source.Sku != nil {
		var sku NatGatewaySku
		err := sku.Initialize_From_NatGatewaySku_STATUS(source.Sku)
		if err != nil {
			return errors.Wrap(err, "calling Initialize_From_NatGatewaySku_STATUS() to populate field Sku")
		}
		gateway.Sku = &sku
	} else {
		gateway.Sku = nil
	}

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

	// Zones
	gateway.Zones = genruntime.CloneSliceOfString(source.Zones)

	// No error
	return nil
}

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

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

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

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

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

	// IdleTimeoutInMinutes: The idle timeout of the nat gateway.
	IdleTimeoutInMinutes *int `json:"idleTimeoutInMinutes,omitempty"`

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

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

	// ProvisioningState: The provisioning state of the NAT gateway resource.
	ProvisioningState *ApplicationGatewayProvisioningState_STATUS `json:"provisioningState,omitempty"`

	// PublicIpAddresses: An array of public ip addresses associated with the nat gateway resource.
	PublicIpAddresses []ApplicationGatewaySubResource_STATUS `json:"publicIpAddresses,omitempty"`

	// PublicIpPrefixes: An array of public ip prefixes associated with the nat gateway resource.
	PublicIpPrefixes []ApplicationGatewaySubResource_STATUS `json:"publicIpPrefixes,omitempty"`

	// ResourceGuid: The resource GUID property of the NAT gateway resource.
	ResourceGuid *string `json:"resourceGuid,omitempty"`

	// Sku: The nat gateway SKU.
	Sku *NatGatewaySku_STATUS `json:"sku,omitempty"`

	// Subnets: An array of references to the subnets using this nat gateway resource.
	Subnets []ApplicationGatewaySubResource_STATUS `json:"subnets,omitempty"`

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

	// Type: Resource type.
	Type *string `json:"type,omitempty"`

	// Zones: A list of availability zones denoting the zone in which Nat Gateway should be deployed.
	Zones []string `json:"zones,omitempty"`
}

var _ genruntime.ConvertibleStatus = &NatGateway_STATUS{}

// ConvertStatusFrom populates our NatGateway_STATUS from the provided source
func (gateway *NatGateway_STATUS) ConvertStatusFrom(source genruntime.ConvertibleStatus) error {
	src, ok := source.(*v20220701s.NatGateway_STATUS)
	if ok {
		// Populate our instance from source
		return gateway.AssignProperties_From_NatGateway_STATUS(src)
	}

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

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

	return nil
}

// ConvertStatusTo populates the provided destination from our NatGateway_STATUS
func (gateway *NatGateway_STATUS) ConvertStatusTo(destination genruntime.ConvertibleStatus) error {
	dst, ok := destination.(*v20220701s.NatGateway_STATUS)
	if ok {
		// Populate destination from our instance
		return gateway.AssignProperties_To_NatGateway_STATUS(dst)
	}

	// Convert to an intermediate form
	dst = &v20220701s.NatGateway_STATUS{}
	err := gateway.AssignProperties_To_NatGateway_STATUS(dst)
	if err != nil {
		return errors.Wrap(err, "initial step of conversion in ConvertStatusTo()")
	}

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

	return nil
}

var _ genruntime.FromARMConverter = &NatGateway_STATUS{}

// NewEmptyARMValue returns an empty ARM value suitable for deserializing into
func (gateway *NatGateway_STATUS) NewEmptyARMValue() genruntime.ARMResourceStatus {
	return &NatGateway_STATUS_ARM{}
}

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

	// no assignment for property "Conditions"

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

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

	// Set property "IdleTimeoutInMinutes":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.IdleTimeoutInMinutes != nil {
			idleTimeoutInMinutes := *typedInput.Properties.IdleTimeoutInMinutes
			gateway.IdleTimeoutInMinutes = &idleTimeoutInMinutes
		}
	}

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

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

	// Set property "ProvisioningState":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ProvisioningState != nil {
			provisioningState := *typedInput.Properties.ProvisioningState
			gateway.ProvisioningState = &provisioningState
		}
	}

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

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

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

	// Set property "Sku":
	if typedInput.Sku != nil {
		var sku1 NatGatewaySku_STATUS
		err := sku1.PopulateFromARM(owner, *typedInput.Sku)
		if err != nil {
			return err
		}
		sku := sku1
		gateway.Sku = &sku
	}

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

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

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

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

	// No error
	return nil
}

// AssignProperties_From_NatGateway_STATUS populates our NatGateway_STATUS from the provided source NatGateway_STATUS
func (gateway *NatGateway_STATUS) AssignProperties_From_NatGateway_STATUS(source *v20220701s.NatGateway_STATUS) error {

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

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

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

	// IdleTimeoutInMinutes
	gateway.IdleTimeoutInMinutes = genruntime.ClonePointerToInt(source.IdleTimeoutInMinutes)

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

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

	// ProvisioningState
	if source.ProvisioningState != nil {
		provisioningState := ApplicationGatewayProvisioningState_STATUS(*source.ProvisioningState)
		gateway.ProvisioningState = &provisioningState
	} else {
		gateway.ProvisioningState = nil
	}

	// PublicIpAddresses
	if source.PublicIpAddresses != nil {
		publicIpAddressList := make([]ApplicationGatewaySubResource_STATUS, len(source.PublicIpAddresses))
		for publicIpAddressIndex, publicIpAddressItem := range source.PublicIpAddresses {
			// Shadow the loop variable to avoid aliasing
			publicIpAddressItem := publicIpAddressItem
			var publicIpAddress ApplicationGatewaySubResource_STATUS
			err := publicIpAddress.AssignProperties_From_ApplicationGatewaySubResource_STATUS(&publicIpAddressItem)
			if err != nil {
				return errors.Wrap(err, "calling AssignProperties_From_ApplicationGatewaySubResource_STATUS() to populate field PublicIpAddresses")
			}
			publicIpAddressList[publicIpAddressIndex] = publicIpAddress
		}
		gateway.PublicIpAddresses = publicIpAddressList
	} else {
		gateway.PublicIpAddresses = nil
	}

	// PublicIpPrefixes
	if source.PublicIpPrefixes != nil {
		publicIpPrefixList := make([]ApplicationGatewaySubResource_STATUS, len(source.PublicIpPrefixes))
		for publicIpPrefixIndex, publicIpPrefixItem := range source.PublicIpPrefixes {
			// Shadow the loop variable to avoid aliasing
			publicIpPrefixItem := publicIpPrefixItem
			var publicIpPrefix ApplicationGatewaySubResource_STATUS
			err := publicIpPrefix.AssignProperties_From_ApplicationGatewaySubResource_STATUS(&publicIpPrefixItem)
			if err != nil {
				return errors.Wrap(err, "calling AssignProperties_From_ApplicationGatewaySubResource_STATUS() to populate field PublicIpPrefixes")
			}
			publicIpPrefixList[publicIpPrefixIndex] = publicIpPrefix
		}
		gateway.PublicIpPrefixes = publicIpPrefixList
	} else {
		gateway.PublicIpPrefixes = nil
	}

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

	// Sku
	if source.Sku != nil {
		var sku NatGatewaySku_STATUS
		err := sku.AssignProperties_From_NatGatewaySku_STATUS(source.Sku)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_From_NatGatewaySku_STATUS() to populate field Sku")
		}
		gateway.Sku = &sku
	} else {
		gateway.Sku = nil
	}

	// Subnets
	if source.Subnets != nil {
		subnetList := make([]ApplicationGatewaySubResource_STATUS, len(source.Subnets))
		for subnetIndex, subnetItem := range source.Subnets {
			// Shadow the loop variable to avoid aliasing
			subnetItem := subnetItem
			var subnet ApplicationGatewaySubResource_STATUS
			err := subnet.AssignProperties_From_ApplicationGatewaySubResource_STATUS(&subnetItem)
			if err != nil {
				return errors.Wrap(err, "calling AssignProperties_From_ApplicationGatewaySubResource_STATUS() to populate field Subnets")
			}
			subnetList[subnetIndex] = subnet
		}
		gateway.Subnets = subnetList
	} else {
		gateway.Subnets = nil
	}

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

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

	// Zones
	gateway.Zones = genruntime.CloneSliceOfString(source.Zones)

	// No error
	return nil
}

// AssignProperties_To_NatGateway_STATUS populates the provided destination NatGateway_STATUS from our NatGateway_STATUS
func (gateway *NatGateway_STATUS) AssignProperties_To_NatGateway_STATUS(destination *v20220701s.NatGateway_STATUS) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

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

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

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

	// IdleTimeoutInMinutes
	destination.IdleTimeoutInMinutes = genruntime.ClonePointerToInt(gateway.IdleTimeoutInMinutes)

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

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

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

	// PublicIpAddresses
	if gateway.PublicIpAddresses != nil {
		publicIpAddressList := make([]v20220701s.ApplicationGatewaySubResource_STATUS, len(gateway.PublicIpAddresses))
		for publicIpAddressIndex, publicIpAddressItem := range gateway.PublicIpAddresses {
			// Shadow the loop variable to avoid aliasing
			publicIpAddressItem := publicIpAddressItem
			var publicIpAddress v20220701s.ApplicationGatewaySubResource_STATUS
			err := publicIpAddressItem.AssignProperties_To_ApplicationGatewaySubResource_STATUS(&publicIpAddress)
			if err != nil {
				return errors.Wrap(err, "calling AssignProperties_To_ApplicationGatewaySubResource_STATUS() to populate field PublicIpAddresses")
			}
			publicIpAddressList[publicIpAddressIndex] = publicIpAddress
		}
		destination.PublicIpAddresses = publicIpAddressList
	} else {
		destination.PublicIpAddresses = nil
	}

	// PublicIpPrefixes
	if gateway.PublicIpPrefixes != nil {
		publicIpPrefixList := make([]v20220701s.ApplicationGatewaySubResource_STATUS, len(gateway.PublicIpPrefixes))
		for publicIpPrefixIndex, publicIpPrefixItem := range gateway.PublicIpPrefixes {
			// Shadow the loop variable to avoid aliasing
			publicIpPrefixItem := publicIpPrefixItem
			var publicIpPrefix v20220701s.ApplicationGatewaySubResource_STATUS
			err := publicIpPrefixItem.AssignProperties_To_ApplicationGatewaySubResource_STATUS(&publicIpPrefix)
			if err != nil {
				return errors.Wrap(err, "calling AssignProperties_To_ApplicationGatewaySubResource_STATUS() to populate field PublicIpPrefixes")
			}
			publicIpPrefixList[publicIpPrefixIndex] = publicIpPrefix
		}
		destination.PublicIpPrefixes = publicIpPrefixList
	} else {
		destination.PublicIpPrefixes = nil
	}

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

	// Sku
	if gateway.Sku != nil {
		var sku v20220701s.NatGatewaySku_STATUS
		err := gateway.Sku.AssignProperties_To_NatGatewaySku_STATUS(&sku)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_To_NatGatewaySku_STATUS() to populate field Sku")
		}
		destination.Sku = &sku
	} else {
		destination.Sku = nil
	}

	// Subnets
	if gateway.Subnets != nil {
		subnetList := make([]v20220701s.ApplicationGatewaySubResource_STATUS, len(gateway.Subnets))
		for subnetIndex, subnetItem := range gateway.Subnets {
			// Shadow the loop variable to avoid aliasing
			subnetItem := subnetItem
			var subnet v20220701s.ApplicationGatewaySubResource_STATUS
			err := subnetItem.AssignProperties_To_ApplicationGatewaySubResource_STATUS(&subnet)
			if err != nil {
				return errors.Wrap(err, "calling AssignProperties_To_ApplicationGatewaySubResource_STATUS() to populate field Subnets")
			}
			subnetList[subnetIndex] = subnet
		}
		destination.Subnets = subnetList
	} else {
		destination.Subnets = nil
	}

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

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

	// Zones
	destination.Zones = genruntime.CloneSliceOfString(gateway.Zones)

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

	// No error
	return nil
}

// SKU of nat gateway.
type NatGatewaySku struct {
	// Name: Name of Nat Gateway SKU.
	Name *NatGatewaySku_Name `json:"name,omitempty"`
}

var _ genruntime.ARMTransformer = &NatGatewaySku{}

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

	// Set property "Name":
	if gatewaySku.Name != nil {
		name := *gatewaySku.Name
		result.Name = &name
	}
	return result, nil
}

// NewEmptyARMValue returns an empty ARM value suitable for deserializing into
func (gatewaySku *NatGatewaySku) NewEmptyARMValue() genruntime.ARMResourceStatus {
	return &NatGatewaySku_ARM{}
}

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

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

	// No error
	return nil
}

// AssignProperties_From_NatGatewaySku populates our NatGatewaySku from the provided source NatGatewaySku
func (gatewaySku *NatGatewaySku) AssignProperties_From_NatGatewaySku(source *v20220701s.NatGatewaySku) error {

	// Name
	if source.Name != nil {
		name := NatGatewaySku_Name(*source.Name)
		gatewaySku.Name = &name
	} else {
		gatewaySku.Name = nil
	}

	// No error
	return nil
}

// AssignProperties_To_NatGatewaySku populates the provided destination NatGatewaySku from our NatGatewaySku
func (gatewaySku *NatGatewaySku) AssignProperties_To_NatGatewaySku(destination *v20220701s.NatGatewaySku) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// Name
	if gatewaySku.Name != nil {
		name := string(*gatewaySku.Name)
		destination.Name = &name
	} else {
		destination.Name = nil
	}

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

	// No error
	return nil
}

// Initialize_From_NatGatewaySku_STATUS populates our NatGatewaySku from the provided source NatGatewaySku_STATUS
func (gatewaySku *NatGatewaySku) Initialize_From_NatGatewaySku_STATUS(source *NatGatewaySku_STATUS) error {

	// Name
	if source.Name != nil {
		name := NatGatewaySku_Name(*source.Name)
		gatewaySku.Name = &name
	} else {
		gatewaySku.Name = nil
	}

	// No error
	return nil
}

// SKU of nat gateway.
type NatGatewaySku_STATUS struct {
	// Name: Name of Nat Gateway SKU.
	Name *NatGatewaySku_Name_STATUS `json:"name,omitempty"`
}

var _ genruntime.FromARMConverter = &NatGatewaySku_STATUS{}

// NewEmptyARMValue returns an empty ARM value suitable for deserializing into
func (gatewaySku *NatGatewaySku_STATUS) NewEmptyARMValue() genruntime.ARMResourceStatus {
	return &NatGatewaySku_STATUS_ARM{}
}

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

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

	// No error
	return nil
}

// AssignProperties_From_NatGatewaySku_STATUS populates our NatGatewaySku_STATUS from the provided source NatGatewaySku_STATUS
func (gatewaySku *NatGatewaySku_STATUS) AssignProperties_From_NatGatewaySku_STATUS(source *v20220701s.NatGatewaySku_STATUS) error {

	// Name
	if source.Name != nil {
		name := NatGatewaySku_Name_STATUS(*source.Name)
		gatewaySku.Name = &name
	} else {
		gatewaySku.Name = nil
	}

	// No error
	return nil
}

// AssignProperties_To_NatGatewaySku_STATUS populates the provided destination NatGatewaySku_STATUS from our NatGatewaySku_STATUS
func (gatewaySku *NatGatewaySku_STATUS) AssignProperties_To_NatGatewaySku_STATUS(destination *v20220701s.NatGatewaySku_STATUS) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// Name
	if gatewaySku.Name != nil {
		name := string(*gatewaySku.Name)
		destination.Name = &name
	} else {
		destination.Name = nil
	}

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

	// No error
	return nil
}

func init() {
	SchemeBuilder.Register(&NatGateway{}, &NatGatewayList{})
}
