// 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/routeTable.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}
type RouteTable struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              RouteTable_Spec   `json:"spec,omitempty"`
	Status            RouteTable_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &RouteTable{}

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

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

var _ conversion.Convertible = &RouteTable{}

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

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

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

	return nil
}

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

	return nil
}

var _ configmaps.Exporter = &RouteTable{}

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

var _ secrets.Exporter = &RouteTable{}

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

var _ genruntime.KubernetesResource = &RouteTable{}

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

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

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

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

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

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

// NewEmptyStatus returns a new empty (blank) status
func (table *RouteTable) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &RouteTable_STATUS{}
}

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

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

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

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

	table.Status = st
	return nil
}

// AssignProperties_From_RouteTable populates our RouteTable from the provided source RouteTable
func (table *RouteTable) AssignProperties_From_RouteTable(source *storage.RouteTable) error {

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

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

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

	// No error
	return nil
}

// AssignProperties_To_RouteTable populates the provided destination RouteTable from our RouteTable
func (table *RouteTable) AssignProperties_To_RouteTable(destination *storage.RouteTable) error {

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

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

	// Status
	var status storage.RouteTable_STATUS
	err = table.Status.AssignProperties_To_RouteTable_STATUS(&status)
	if err != nil {
		return eris.Wrap(err, "calling AssignProperties_To_RouteTable_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 (table *RouteTable) OriginalGVK() *schema.GroupVersionKind {
	return &schema.GroupVersionKind{
		Group:   GroupVersion.Group,
		Version: table.Spec.OriginalVersion(),
		Kind:    "RouteTable",
	}
}

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /network/resource-manager/Microsoft.Network/stable/2020-11-01/routeTable.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}
type RouteTableList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []RouteTable `json:"items"`
}

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

	// DisableBgpRoutePropagation: Whether to disable the routes learned by BGP on that route table. True means disable.
	DisableBgpRoutePropagation *bool `json:"disableBgpRoutePropagation,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 *RouteTableOperatorSpec `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 = &RouteTable_Spec{}

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

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

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

	// Set property "Properties":
	if table.DisableBgpRoutePropagation != nil {
		result.Properties = &arm.RouteTablePropertiesFormat{}
	}
	if table.DisableBgpRoutePropagation != nil {
		disableBgpRoutePropagation := *table.DisableBgpRoutePropagation
		result.Properties.DisableBgpRoutePropagation = &disableBgpRoutePropagation
	}

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

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

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

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

	// Set property "DisableBgpRoutePropagation":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.DisableBgpRoutePropagation != nil {
			disableBgpRoutePropagation := *typedInput.Properties.DisableBgpRoutePropagation
			table.DisableBgpRoutePropagation = &disableBgpRoutePropagation
		}
	}

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

	// no assignment for property "OperatorSpec"

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

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

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &RouteTable_Spec{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.RouteTable_Spec{}
	err := table.AssignProperties_To_RouteTable_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_RouteTable_Spec populates our RouteTable_Spec from the provided source RouteTable_Spec
func (table *RouteTable_Spec) AssignProperties_From_RouteTable_Spec(source *storage.RouteTable_Spec) error {

	// AzureName
	table.AzureName = source.AzureName

	// DisableBgpRoutePropagation
	if source.DisableBgpRoutePropagation != nil {
		disableBgpRoutePropagation := *source.DisableBgpRoutePropagation
		table.DisableBgpRoutePropagation = &disableBgpRoutePropagation
	} else {
		table.DisableBgpRoutePropagation = nil
	}

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

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

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

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

	// No error
	return nil
}

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

	// AzureName
	destination.AzureName = table.AzureName

	// DisableBgpRoutePropagation
	if table.DisableBgpRoutePropagation != nil {
		disableBgpRoutePropagation := *table.DisableBgpRoutePropagation
		destination.DisableBgpRoutePropagation = &disableBgpRoutePropagation
	} else {
		destination.DisableBgpRoutePropagation = nil
	}

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

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

	// OriginalVersion
	destination.OriginalVersion = table.OriginalVersion()

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

	// Tags
	destination.Tags = genruntime.CloneMapOfStringToString(table.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 (table *RouteTable_Spec) OriginalVersion() string {
	return GroupVersion.Version
}

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

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

	// DisableBgpRoutePropagation: Whether to disable the routes learned by BGP on that route table. True means disable.
	DisableBgpRoutePropagation *bool `json:"disableBgpRoutePropagation,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"`

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

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

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

	// ResourceGuid: The resource GUID property of the route table.
	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 = &RouteTable_STATUS{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.RouteTable_STATUS{}
	err := table.AssignProperties_To_RouteTable_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 = &RouteTable_STATUS{}

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

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

	// no assignment for property "Conditions"

	// Set property "DisableBgpRoutePropagation":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.DisableBgpRoutePropagation != nil {
			disableBgpRoutePropagation := *typedInput.Properties.DisableBgpRoutePropagation
			table.DisableBgpRoutePropagation = &disableBgpRoutePropagation
		}
	}

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

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

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

	// Set property "Name":
	if typedInput.Name != nil {
		name := *typedInput.Name
		table.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)
			table.ProvisioningState = &provisioningState
		}
	}

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

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

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

	// No error
	return nil
}

// AssignProperties_From_RouteTable_STATUS populates our RouteTable_STATUS from the provided source RouteTable_STATUS
func (table *RouteTable_STATUS) AssignProperties_From_RouteTable_STATUS(source *storage.RouteTable_STATUS) error {

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

	// DisableBgpRoutePropagation
	if source.DisableBgpRoutePropagation != nil {
		disableBgpRoutePropagation := *source.DisableBgpRoutePropagation
		table.DisableBgpRoutePropagation = &disableBgpRoutePropagation
	} else {
		table.DisableBgpRoutePropagation = nil
	}

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

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

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

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

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

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

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

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

	// No error
	return nil
}

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

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

	// DisableBgpRoutePropagation
	if table.DisableBgpRoutePropagation != nil {
		disableBgpRoutePropagation := *table.DisableBgpRoutePropagation
		destination.DisableBgpRoutePropagation = &disableBgpRoutePropagation
	} else {
		destination.DisableBgpRoutePropagation = nil
	}

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

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

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

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

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

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

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

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

	// 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 RouteTableOperatorSpec 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_RouteTableOperatorSpec populates our RouteTableOperatorSpec from the provided source RouteTableOperatorSpec
func (operator *RouteTableOperatorSpec) AssignProperties_From_RouteTableOperatorSpec(source *storage.RouteTableOperatorSpec) 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_RouteTableOperatorSpec populates the provided destination RouteTableOperatorSpec from our RouteTableOperatorSpec
func (operator *RouteTableOperatorSpec) AssignProperties_To_RouteTableOperatorSpec(destination *storage.RouteTableOperatorSpec) 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(&RouteTable{}, &RouteTableList{})
}
