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

import (
	"fmt"
	arm "github.com/Azure/azure-service-operator/v2/api/network/v1api20220701/arm"
	storage "github.com/Azure/azure-service-operator/v2/api/network/v1api20220701/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: /dnsresolver/resource-manager/Microsoft.Network/DnsResolver/stable/2022-07-01/dnsresolver.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}
type DnsForwardingRuleSetsForwardingRule struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              DnsForwardingRuleSetsForwardingRule_Spec   `json:"spec,omitempty"`
	Status            DnsForwardingRuleSetsForwardingRule_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &DnsForwardingRuleSetsForwardingRule{}

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

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

var _ conversion.Convertible = &DnsForwardingRuleSetsForwardingRule{}

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

	return rule.AssignProperties_From_DnsForwardingRuleSetsForwardingRule(source)
}

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

	return rule.AssignProperties_To_DnsForwardingRuleSetsForwardingRule(destination)
}

var _ configmaps.Exporter = &DnsForwardingRuleSetsForwardingRule{}

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

var _ secrets.Exporter = &DnsForwardingRuleSetsForwardingRule{}

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

var _ genruntime.ImportableResource = &DnsForwardingRuleSetsForwardingRule{}

// InitializeSpec initializes the spec for this resource from the given status
func (rule *DnsForwardingRuleSetsForwardingRule) InitializeSpec(status genruntime.ConvertibleStatus) error {
	if s, ok := status.(*DnsForwardingRuleSetsForwardingRule_STATUS); ok {
		return rule.Spec.Initialize_From_DnsForwardingRuleSetsForwardingRule_STATUS(s)
	}

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

var _ genruntime.KubernetesResource = &DnsForwardingRuleSetsForwardingRule{}

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

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

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

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

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

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

// NewEmptyStatus returns a new empty (blank) status
func (rule *DnsForwardingRuleSetsForwardingRule) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &DnsForwardingRuleSetsForwardingRule_STATUS{}
}

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

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

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

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

	rule.Status = st
	return nil
}

// AssignProperties_From_DnsForwardingRuleSetsForwardingRule populates our DnsForwardingRuleSetsForwardingRule from the provided source DnsForwardingRuleSetsForwardingRule
func (rule *DnsForwardingRuleSetsForwardingRule) AssignProperties_From_DnsForwardingRuleSetsForwardingRule(source *storage.DnsForwardingRuleSetsForwardingRule) error {

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

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

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

	// No error
	return nil
}

// AssignProperties_To_DnsForwardingRuleSetsForwardingRule populates the provided destination DnsForwardingRuleSetsForwardingRule from our DnsForwardingRuleSetsForwardingRule
func (rule *DnsForwardingRuleSetsForwardingRule) AssignProperties_To_DnsForwardingRuleSetsForwardingRule(destination *storage.DnsForwardingRuleSetsForwardingRule) error {

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

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

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

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /dnsresolver/resource-manager/Microsoft.Network/DnsResolver/stable/2022-07-01/dnsresolver.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}
type DnsForwardingRuleSetsForwardingRuleList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []DnsForwardingRuleSetsForwardingRule `json:"items"`
}

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

	// +kubebuilder:validation:Required
	// DomainName: The domain name for the forwarding rule.
	DomainName *string `json:"domainName,omitempty"`

	// ForwardingRuleState: The state of forwarding rule.
	ForwardingRuleState *ForwardingRuleProperties_ForwardingRuleState `json:"forwardingRuleState,omitempty"`

	// Metadata: Metadata attached to the forwarding rule.
	Metadata map[string]string `json:"metadata,omitempty"`

	// OperatorSpec: The specification for configuring operator behavior. This field is interpreted by the operator and not
	// passed directly to Azure
	OperatorSpec *DnsForwardingRuleSetsForwardingRuleOperatorSpec `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 network.azure.com/DnsForwardingRuleset resource
	Owner *genruntime.KnownResourceReference `group:"network.azure.com" json:"owner,omitempty" kind:"DnsForwardingRuleset"`

	// +kubebuilder:validation:Required
	// TargetDnsServers: DNS servers to forward the DNS query to.
	TargetDnsServers []TargetDnsServer `json:"targetDnsServers,omitempty"`
}

var _ genruntime.ARMTransformer = &DnsForwardingRuleSetsForwardingRule_Spec{}

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

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

	// Set property "Properties":
	if rule.DomainName != nil ||
		rule.ForwardingRuleState != nil ||
		rule.Metadata != nil ||
		rule.TargetDnsServers != nil {
		result.Properties = &arm.ForwardingRuleProperties{}
	}
	if rule.DomainName != nil {
		domainName := *rule.DomainName
		result.Properties.DomainName = &domainName
	}
	if rule.ForwardingRuleState != nil {
		var temp string
		temp = string(*rule.ForwardingRuleState)
		forwardingRuleState := arm.ForwardingRuleProperties_ForwardingRuleState(temp)
		result.Properties.ForwardingRuleState = &forwardingRuleState
	}
	if rule.Metadata != nil {
		result.Properties.Metadata = make(map[string]string, len(rule.Metadata))
		for key, value := range rule.Metadata {
			result.Properties.Metadata[key] = value
		}
	}
	for _, item := range rule.TargetDnsServers {
		item_ARM, err := item.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		result.Properties.TargetDnsServers = append(result.Properties.TargetDnsServers, *item_ARM.(*arm.TargetDnsServer))
	}
	return result, nil
}

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

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

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

	// Set property "DomainName":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.DomainName != nil {
			domainName := *typedInput.Properties.DomainName
			rule.DomainName = &domainName
		}
	}

	// Set property "ForwardingRuleState":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ForwardingRuleState != nil {
			var temp string
			temp = string(*typedInput.Properties.ForwardingRuleState)
			forwardingRuleState := ForwardingRuleProperties_ForwardingRuleState(temp)
			rule.ForwardingRuleState = &forwardingRuleState
		}
	}

	// Set property "Metadata":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Metadata != nil {
			rule.Metadata = make(map[string]string, len(typedInput.Properties.Metadata))
			for key, value := range typedInput.Properties.Metadata {
				rule.Metadata[key] = value
			}
		}
	}

	// no assignment for property "OperatorSpec"

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

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

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &DnsForwardingRuleSetsForwardingRule_Spec{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.DnsForwardingRuleSetsForwardingRule_Spec{}
	err := rule.AssignProperties_To_DnsForwardingRuleSetsForwardingRule_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_DnsForwardingRuleSetsForwardingRule_Spec populates our DnsForwardingRuleSetsForwardingRule_Spec from the provided source DnsForwardingRuleSetsForwardingRule_Spec
func (rule *DnsForwardingRuleSetsForwardingRule_Spec) AssignProperties_From_DnsForwardingRuleSetsForwardingRule_Spec(source *storage.DnsForwardingRuleSetsForwardingRule_Spec) error {

	// AzureName
	rule.AzureName = source.AzureName

	// DomainName
	rule.DomainName = genruntime.ClonePointerToString(source.DomainName)

	// ForwardingRuleState
	if source.ForwardingRuleState != nil {
		forwardingRuleState := *source.ForwardingRuleState
		forwardingRuleStateTemp := genruntime.ToEnum(forwardingRuleState, forwardingRuleProperties_ForwardingRuleState_Values)
		rule.ForwardingRuleState = &forwardingRuleStateTemp
	} else {
		rule.ForwardingRuleState = nil
	}

	// Metadata
	rule.Metadata = genruntime.CloneMapOfStringToString(source.Metadata)

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

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

	// TargetDnsServers
	if source.TargetDnsServers != nil {
		targetDnsServerList := make([]TargetDnsServer, len(source.TargetDnsServers))
		for targetDnsServerIndex, targetDnsServerItem := range source.TargetDnsServers {
			var targetDnsServer TargetDnsServer
			err := targetDnsServer.AssignProperties_From_TargetDnsServer(&targetDnsServerItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_TargetDnsServer() to populate field TargetDnsServers")
			}
			targetDnsServerList[targetDnsServerIndex] = targetDnsServer
		}
		rule.TargetDnsServers = targetDnsServerList
	} else {
		rule.TargetDnsServers = nil
	}

	// No error
	return nil
}

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

	// AzureName
	destination.AzureName = rule.AzureName

	// DomainName
	destination.DomainName = genruntime.ClonePointerToString(rule.DomainName)

	// ForwardingRuleState
	if rule.ForwardingRuleState != nil {
		forwardingRuleState := string(*rule.ForwardingRuleState)
		destination.ForwardingRuleState = &forwardingRuleState
	} else {
		destination.ForwardingRuleState = nil
	}

	// Metadata
	destination.Metadata = genruntime.CloneMapOfStringToString(rule.Metadata)

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

	// OriginalVersion
	destination.OriginalVersion = rule.OriginalVersion()

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

	// TargetDnsServers
	if rule.TargetDnsServers != nil {
		targetDnsServerList := make([]storage.TargetDnsServer, len(rule.TargetDnsServers))
		for targetDnsServerIndex, targetDnsServerItem := range rule.TargetDnsServers {
			var targetDnsServer storage.TargetDnsServer
			err := targetDnsServerItem.AssignProperties_To_TargetDnsServer(&targetDnsServer)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_TargetDnsServer() to populate field TargetDnsServers")
			}
			targetDnsServerList[targetDnsServerIndex] = targetDnsServer
		}
		destination.TargetDnsServers = targetDnsServerList
	} else {
		destination.TargetDnsServers = nil
	}

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

	// No error
	return nil
}

// Initialize_From_DnsForwardingRuleSetsForwardingRule_STATUS populates our DnsForwardingRuleSetsForwardingRule_Spec from the provided source DnsForwardingRuleSetsForwardingRule_STATUS
func (rule *DnsForwardingRuleSetsForwardingRule_Spec) Initialize_From_DnsForwardingRuleSetsForwardingRule_STATUS(source *DnsForwardingRuleSetsForwardingRule_STATUS) error {

	// DomainName
	rule.DomainName = genruntime.ClonePointerToString(source.DomainName)

	// ForwardingRuleState
	if source.ForwardingRuleState != nil {
		forwardingRuleState := genruntime.ToEnum(string(*source.ForwardingRuleState), forwardingRuleProperties_ForwardingRuleState_Values)
		rule.ForwardingRuleState = &forwardingRuleState
	} else {
		rule.ForwardingRuleState = nil
	}

	// Metadata
	rule.Metadata = genruntime.CloneMapOfStringToString(source.Metadata)

	// TargetDnsServers
	if source.TargetDnsServers != nil {
		targetDnsServerList := make([]TargetDnsServer, len(source.TargetDnsServers))
		for targetDnsServerIndex, targetDnsServerItem := range source.TargetDnsServers {
			var targetDnsServer TargetDnsServer
			err := targetDnsServer.Initialize_From_TargetDnsServer_STATUS(&targetDnsServerItem)
			if err != nil {
				return eris.Wrap(err, "calling Initialize_From_TargetDnsServer_STATUS() to populate field TargetDnsServers")
			}
			targetDnsServerList[targetDnsServerIndex] = targetDnsServer
		}
		rule.TargetDnsServers = targetDnsServerList
	} else {
		rule.TargetDnsServers = nil
	}

	// No error
	return nil
}

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

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

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

	// DomainName: The domain name for the forwarding rule.
	DomainName *string `json:"domainName,omitempty"`

	// Etag: ETag of the forwarding rule.
	Etag *string `json:"etag,omitempty"`

	// ForwardingRuleState: The state of forwarding rule.
	ForwardingRuleState *ForwardingRuleProperties_ForwardingRuleState_STATUS `json:"forwardingRuleState,omitempty"`

	// Id: Fully qualified resource ID for the resource. Ex -
	// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
	Id *string `json:"id,omitempty"`

	// Metadata: Metadata attached to the forwarding rule.
	Metadata map[string]string `json:"metadata,omitempty"`

	// Name: The name of the resource
	Name *string `json:"name,omitempty"`

	// ProvisioningState: The current provisioning state of the forwarding rule. This is a read-only property and any attempt
	// to set this value will be ignored.
	ProvisioningState *DnsresolverProvisioningState_STATUS `json:"provisioningState,omitempty"`

	// SystemData: Metadata pertaining to creation and last modification of the resource.
	SystemData *SystemData_STATUS `json:"systemData,omitempty"`

	// TargetDnsServers: DNS servers to forward the DNS query to.
	TargetDnsServers []TargetDnsServer_STATUS `json:"targetDnsServers,omitempty"`

	// Type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
	Type *string `json:"type,omitempty"`
}

var _ genruntime.ConvertibleStatus = &DnsForwardingRuleSetsForwardingRule_STATUS{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.DnsForwardingRuleSetsForwardingRule_STATUS{}
	err := rule.AssignProperties_To_DnsForwardingRuleSetsForwardingRule_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 = &DnsForwardingRuleSetsForwardingRule_STATUS{}

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

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

	// no assignment for property "Conditions"

	// Set property "DomainName":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.DomainName != nil {
			domainName := *typedInput.Properties.DomainName
			rule.DomainName = &domainName
		}
	}

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

	// Set property "ForwardingRuleState":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ForwardingRuleState != nil {
			var temp string
			temp = string(*typedInput.Properties.ForwardingRuleState)
			forwardingRuleState := ForwardingRuleProperties_ForwardingRuleState_STATUS(temp)
			rule.ForwardingRuleState = &forwardingRuleState
		}
	}

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

	// Set property "Metadata":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Metadata != nil {
			rule.Metadata = make(map[string]string, len(typedInput.Properties.Metadata))
			for key, value := range typedInput.Properties.Metadata {
				rule.Metadata[key] = value
			}
		}
	}

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

	// Set property "SystemData":
	if typedInput.SystemData != nil {
		var systemData1 SystemData_STATUS
		err := systemData1.PopulateFromARM(owner, *typedInput.SystemData)
		if err != nil {
			return err
		}
		systemData := systemData1
		rule.SystemData = &systemData
	}

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

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

	// No error
	return nil
}

// AssignProperties_From_DnsForwardingRuleSetsForwardingRule_STATUS populates our DnsForwardingRuleSetsForwardingRule_STATUS from the provided source DnsForwardingRuleSetsForwardingRule_STATUS
func (rule *DnsForwardingRuleSetsForwardingRule_STATUS) AssignProperties_From_DnsForwardingRuleSetsForwardingRule_STATUS(source *storage.DnsForwardingRuleSetsForwardingRule_STATUS) error {

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

	// DomainName
	rule.DomainName = genruntime.ClonePointerToString(source.DomainName)

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

	// ForwardingRuleState
	if source.ForwardingRuleState != nil {
		forwardingRuleState := *source.ForwardingRuleState
		forwardingRuleStateTemp := genruntime.ToEnum(forwardingRuleState, forwardingRuleProperties_ForwardingRuleState_STATUS_Values)
		rule.ForwardingRuleState = &forwardingRuleStateTemp
	} else {
		rule.ForwardingRuleState = nil
	}

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

	// Metadata
	rule.Metadata = genruntime.CloneMapOfStringToString(source.Metadata)

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

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

	// SystemData
	if source.SystemData != nil {
		var systemDatum SystemData_STATUS
		err := systemDatum.AssignProperties_From_SystemData_STATUS(source.SystemData)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_SystemData_STATUS() to populate field SystemData")
		}
		rule.SystemData = &systemDatum
	} else {
		rule.SystemData = nil
	}

	// TargetDnsServers
	if source.TargetDnsServers != nil {
		targetDnsServerList := make([]TargetDnsServer_STATUS, len(source.TargetDnsServers))
		for targetDnsServerIndex, targetDnsServerItem := range source.TargetDnsServers {
			var targetDnsServer TargetDnsServer_STATUS
			err := targetDnsServer.AssignProperties_From_TargetDnsServer_STATUS(&targetDnsServerItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_TargetDnsServer_STATUS() to populate field TargetDnsServers")
			}
			targetDnsServerList[targetDnsServerIndex] = targetDnsServer
		}
		rule.TargetDnsServers = targetDnsServerList
	} else {
		rule.TargetDnsServers = nil
	}

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

	// No error
	return nil
}

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

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

	// DomainName
	destination.DomainName = genruntime.ClonePointerToString(rule.DomainName)

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

	// ForwardingRuleState
	if rule.ForwardingRuleState != nil {
		forwardingRuleState := string(*rule.ForwardingRuleState)
		destination.ForwardingRuleState = &forwardingRuleState
	} else {
		destination.ForwardingRuleState = nil
	}

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

	// Metadata
	destination.Metadata = genruntime.CloneMapOfStringToString(rule.Metadata)

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

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

	// SystemData
	if rule.SystemData != nil {
		var systemDatum storage.SystemData_STATUS
		err := rule.SystemData.AssignProperties_To_SystemData_STATUS(&systemDatum)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_SystemData_STATUS() to populate field SystemData")
		}
		destination.SystemData = &systemDatum
	} else {
		destination.SystemData = nil
	}

	// TargetDnsServers
	if rule.TargetDnsServers != nil {
		targetDnsServerList := make([]storage.TargetDnsServer_STATUS, len(rule.TargetDnsServers))
		for targetDnsServerIndex, targetDnsServerItem := range rule.TargetDnsServers {
			var targetDnsServer storage.TargetDnsServer_STATUS
			err := targetDnsServerItem.AssignProperties_To_TargetDnsServer_STATUS(&targetDnsServer)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_TargetDnsServer_STATUS() to populate field TargetDnsServers")
			}
			targetDnsServerList[targetDnsServerIndex] = targetDnsServer
		}
		destination.TargetDnsServers = targetDnsServerList
	} else {
		destination.TargetDnsServers = nil
	}

	// Type
	destination.Type = genruntime.ClonePointerToString(rule.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 DnsForwardingRuleSetsForwardingRuleOperatorSpec 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_DnsForwardingRuleSetsForwardingRuleOperatorSpec populates our DnsForwardingRuleSetsForwardingRuleOperatorSpec from the provided source DnsForwardingRuleSetsForwardingRuleOperatorSpec
func (operator *DnsForwardingRuleSetsForwardingRuleOperatorSpec) AssignProperties_From_DnsForwardingRuleSetsForwardingRuleOperatorSpec(source *storage.DnsForwardingRuleSetsForwardingRuleOperatorSpec) 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_DnsForwardingRuleSetsForwardingRuleOperatorSpec populates the provided destination DnsForwardingRuleSetsForwardingRuleOperatorSpec from our DnsForwardingRuleSetsForwardingRuleOperatorSpec
func (operator *DnsForwardingRuleSetsForwardingRuleOperatorSpec) AssignProperties_To_DnsForwardingRuleSetsForwardingRuleOperatorSpec(destination *storage.DnsForwardingRuleSetsForwardingRuleOperatorSpec) 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
}

// The current provisioning state of the resource.
type DnsresolverProvisioningState_STATUS string

const (
	DnsresolverProvisioningState_STATUS_Canceled  = DnsresolverProvisioningState_STATUS("Canceled")
	DnsresolverProvisioningState_STATUS_Creating  = DnsresolverProvisioningState_STATUS("Creating")
	DnsresolverProvisioningState_STATUS_Deleting  = DnsresolverProvisioningState_STATUS("Deleting")
	DnsresolverProvisioningState_STATUS_Failed    = DnsresolverProvisioningState_STATUS("Failed")
	DnsresolverProvisioningState_STATUS_Succeeded = DnsresolverProvisioningState_STATUS("Succeeded")
	DnsresolverProvisioningState_STATUS_Updating  = DnsresolverProvisioningState_STATUS("Updating")
)

// Mapping from string to DnsresolverProvisioningState_STATUS
var dnsresolverProvisioningState_STATUS_Values = map[string]DnsresolverProvisioningState_STATUS{
	"canceled":  DnsresolverProvisioningState_STATUS_Canceled,
	"creating":  DnsresolverProvisioningState_STATUS_Creating,
	"deleting":  DnsresolverProvisioningState_STATUS_Deleting,
	"failed":    DnsresolverProvisioningState_STATUS_Failed,
	"succeeded": DnsresolverProvisioningState_STATUS_Succeeded,
	"updating":  DnsresolverProvisioningState_STATUS_Updating,
}

// +kubebuilder:validation:Enum={"Disabled","Enabled"}
type ForwardingRuleProperties_ForwardingRuleState string

const (
	ForwardingRuleProperties_ForwardingRuleState_Disabled = ForwardingRuleProperties_ForwardingRuleState("Disabled")
	ForwardingRuleProperties_ForwardingRuleState_Enabled  = ForwardingRuleProperties_ForwardingRuleState("Enabled")
)

// Mapping from string to ForwardingRuleProperties_ForwardingRuleState
var forwardingRuleProperties_ForwardingRuleState_Values = map[string]ForwardingRuleProperties_ForwardingRuleState{
	"disabled": ForwardingRuleProperties_ForwardingRuleState_Disabled,
	"enabled":  ForwardingRuleProperties_ForwardingRuleState_Enabled,
}

type ForwardingRuleProperties_ForwardingRuleState_STATUS string

const (
	ForwardingRuleProperties_ForwardingRuleState_STATUS_Disabled = ForwardingRuleProperties_ForwardingRuleState_STATUS("Disabled")
	ForwardingRuleProperties_ForwardingRuleState_STATUS_Enabled  = ForwardingRuleProperties_ForwardingRuleState_STATUS("Enabled")
)

// Mapping from string to ForwardingRuleProperties_ForwardingRuleState_STATUS
var forwardingRuleProperties_ForwardingRuleState_STATUS_Values = map[string]ForwardingRuleProperties_ForwardingRuleState_STATUS{
	"disabled": ForwardingRuleProperties_ForwardingRuleState_STATUS_Disabled,
	"enabled":  ForwardingRuleProperties_ForwardingRuleState_STATUS_Enabled,
}

// Metadata pertaining to creation and last modification of the resource.
type SystemData_STATUS struct {
	// CreatedAt: The timestamp of resource creation (UTC).
	CreatedAt *string `json:"createdAt,omitempty"`

	// CreatedBy: The identity that created the resource.
	CreatedBy *string `json:"createdBy,omitempty"`

	// CreatedByType: The type of identity that created the resource.
	CreatedByType *SystemData_CreatedByType_STATUS `json:"createdByType,omitempty"`

	// LastModifiedAt: The timestamp of resource last modification (UTC)
	LastModifiedAt *string `json:"lastModifiedAt,omitempty"`

	// LastModifiedBy: The identity that last modified the resource.
	LastModifiedBy *string `json:"lastModifiedBy,omitempty"`

	// LastModifiedByType: The type of identity that last modified the resource.
	LastModifiedByType *SystemData_LastModifiedByType_STATUS `json:"lastModifiedByType,omitempty"`
}

var _ genruntime.FromARMConverter = &SystemData_STATUS{}

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

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

	// Set property "CreatedAt":
	if typedInput.CreatedAt != nil {
		createdAt := *typedInput.CreatedAt
		data.CreatedAt = &createdAt
	}

	// Set property "CreatedBy":
	if typedInput.CreatedBy != nil {
		createdBy := *typedInput.CreatedBy
		data.CreatedBy = &createdBy
	}

	// Set property "CreatedByType":
	if typedInput.CreatedByType != nil {
		var temp string
		temp = string(*typedInput.CreatedByType)
		createdByType := SystemData_CreatedByType_STATUS(temp)
		data.CreatedByType = &createdByType
	}

	// Set property "LastModifiedAt":
	if typedInput.LastModifiedAt != nil {
		lastModifiedAt := *typedInput.LastModifiedAt
		data.LastModifiedAt = &lastModifiedAt
	}

	// Set property "LastModifiedBy":
	if typedInput.LastModifiedBy != nil {
		lastModifiedBy := *typedInput.LastModifiedBy
		data.LastModifiedBy = &lastModifiedBy
	}

	// Set property "LastModifiedByType":
	if typedInput.LastModifiedByType != nil {
		var temp string
		temp = string(*typedInput.LastModifiedByType)
		lastModifiedByType := SystemData_LastModifiedByType_STATUS(temp)
		data.LastModifiedByType = &lastModifiedByType
	}

	// No error
	return nil
}

// AssignProperties_From_SystemData_STATUS populates our SystemData_STATUS from the provided source SystemData_STATUS
func (data *SystemData_STATUS) AssignProperties_From_SystemData_STATUS(source *storage.SystemData_STATUS) error {

	// CreatedAt
	data.CreatedAt = genruntime.ClonePointerToString(source.CreatedAt)

	// CreatedBy
	data.CreatedBy = genruntime.ClonePointerToString(source.CreatedBy)

	// CreatedByType
	if source.CreatedByType != nil {
		createdByType := *source.CreatedByType
		createdByTypeTemp := genruntime.ToEnum(createdByType, systemData_CreatedByType_STATUS_Values)
		data.CreatedByType = &createdByTypeTemp
	} else {
		data.CreatedByType = nil
	}

	// LastModifiedAt
	data.LastModifiedAt = genruntime.ClonePointerToString(source.LastModifiedAt)

	// LastModifiedBy
	data.LastModifiedBy = genruntime.ClonePointerToString(source.LastModifiedBy)

	// LastModifiedByType
	if source.LastModifiedByType != nil {
		lastModifiedByType := *source.LastModifiedByType
		lastModifiedByTypeTemp := genruntime.ToEnum(lastModifiedByType, systemData_LastModifiedByType_STATUS_Values)
		data.LastModifiedByType = &lastModifiedByTypeTemp
	} else {
		data.LastModifiedByType = nil
	}

	// No error
	return nil
}

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

	// CreatedAt
	destination.CreatedAt = genruntime.ClonePointerToString(data.CreatedAt)

	// CreatedBy
	destination.CreatedBy = genruntime.ClonePointerToString(data.CreatedBy)

	// CreatedByType
	if data.CreatedByType != nil {
		createdByType := string(*data.CreatedByType)
		destination.CreatedByType = &createdByType
	} else {
		destination.CreatedByType = nil
	}

	// LastModifiedAt
	destination.LastModifiedAt = genruntime.ClonePointerToString(data.LastModifiedAt)

	// LastModifiedBy
	destination.LastModifiedBy = genruntime.ClonePointerToString(data.LastModifiedBy)

	// LastModifiedByType
	if data.LastModifiedByType != nil {
		lastModifiedByType := string(*data.LastModifiedByType)
		destination.LastModifiedByType = &lastModifiedByType
	} else {
		destination.LastModifiedByType = nil
	}

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

	// No error
	return nil
}

// Describes a server to forward the DNS queries to.
type TargetDnsServer struct {
	// IpAddress: DNS server IP address.
	IpAddress *string `json:"ipAddress,omitempty" optionalConfigMapPair:"IpAddress"`

	// IpAddressFromConfig: DNS server IP address.
	IpAddressFromConfig *genruntime.ConfigMapReference `json:"ipAddressFromConfig,omitempty" optionalConfigMapPair:"IpAddress"`

	// Port: DNS server port.
	Port *int `json:"port,omitempty"`
}

var _ genruntime.ARMTransformer = &TargetDnsServer{}

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

	// Set property "IpAddress":
	if server.IpAddress != nil {
		ipAddress := *server.IpAddress
		result.IpAddress = &ipAddress
	}
	if server.IpAddressFromConfig != nil {
		ipAddressValue, err := resolved.ResolvedConfigMaps.Lookup(*server.IpAddressFromConfig)
		if err != nil {
			return nil, eris.Wrap(err, "looking up configmap for property IpAddress")
		}
		ipAddress := ipAddressValue
		result.IpAddress = &ipAddress
	}

	// Set property "Port":
	if server.Port != nil {
		port := *server.Port
		result.Port = &port
	}
	return result, nil
}

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

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

	// Set property "IpAddress":
	if typedInput.IpAddress != nil {
		ipAddress := *typedInput.IpAddress
		server.IpAddress = &ipAddress
	}

	// no assignment for property "IpAddressFromConfig"

	// Set property "Port":
	if typedInput.Port != nil {
		port := *typedInput.Port
		server.Port = &port
	}

	// No error
	return nil
}

// AssignProperties_From_TargetDnsServer populates our TargetDnsServer from the provided source TargetDnsServer
func (server *TargetDnsServer) AssignProperties_From_TargetDnsServer(source *storage.TargetDnsServer) error {

	// IpAddress
	server.IpAddress = genruntime.ClonePointerToString(source.IpAddress)

	// IpAddressFromConfig
	if source.IpAddressFromConfig != nil {
		ipAddressFromConfig := source.IpAddressFromConfig.Copy()
		server.IpAddressFromConfig = &ipAddressFromConfig
	} else {
		server.IpAddressFromConfig = nil
	}

	// Port
	server.Port = genruntime.ClonePointerToInt(source.Port)

	// No error
	return nil
}

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

	// IpAddress
	destination.IpAddress = genruntime.ClonePointerToString(server.IpAddress)

	// IpAddressFromConfig
	if server.IpAddressFromConfig != nil {
		ipAddressFromConfig := server.IpAddressFromConfig.Copy()
		destination.IpAddressFromConfig = &ipAddressFromConfig
	} else {
		destination.IpAddressFromConfig = nil
	}

	// Port
	destination.Port = genruntime.ClonePointerToInt(server.Port)

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

	// No error
	return nil
}

// Initialize_From_TargetDnsServer_STATUS populates our TargetDnsServer from the provided source TargetDnsServer_STATUS
func (server *TargetDnsServer) Initialize_From_TargetDnsServer_STATUS(source *TargetDnsServer_STATUS) error {

	// IpAddress
	server.IpAddress = genruntime.ClonePointerToString(source.IpAddress)

	// Port
	server.Port = genruntime.ClonePointerToInt(source.Port)

	// No error
	return nil
}

// Describes a server to forward the DNS queries to.
type TargetDnsServer_STATUS struct {
	// IpAddress: DNS server IP address.
	IpAddress *string `json:"ipAddress,omitempty"`

	// Port: DNS server port.
	Port *int `json:"port,omitempty"`
}

var _ genruntime.FromARMConverter = &TargetDnsServer_STATUS{}

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

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

	// Set property "IpAddress":
	if typedInput.IpAddress != nil {
		ipAddress := *typedInput.IpAddress
		server.IpAddress = &ipAddress
	}

	// Set property "Port":
	if typedInput.Port != nil {
		port := *typedInput.Port
		server.Port = &port
	}

	// No error
	return nil
}

// AssignProperties_From_TargetDnsServer_STATUS populates our TargetDnsServer_STATUS from the provided source TargetDnsServer_STATUS
func (server *TargetDnsServer_STATUS) AssignProperties_From_TargetDnsServer_STATUS(source *storage.TargetDnsServer_STATUS) error {

	// IpAddress
	server.IpAddress = genruntime.ClonePointerToString(source.IpAddress)

	// Port
	server.Port = genruntime.ClonePointerToInt(source.Port)

	// No error
	return nil
}

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

	// IpAddress
	destination.IpAddress = genruntime.ClonePointerToString(server.IpAddress)

	// Port
	destination.Port = genruntime.ClonePointerToInt(server.Port)

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

	// No error
	return nil
}

type SystemData_CreatedByType_STATUS string

const (
	SystemData_CreatedByType_STATUS_Application     = SystemData_CreatedByType_STATUS("Application")
	SystemData_CreatedByType_STATUS_Key             = SystemData_CreatedByType_STATUS("Key")
	SystemData_CreatedByType_STATUS_ManagedIdentity = SystemData_CreatedByType_STATUS("ManagedIdentity")
	SystemData_CreatedByType_STATUS_User            = SystemData_CreatedByType_STATUS("User")
)

// Mapping from string to SystemData_CreatedByType_STATUS
var systemData_CreatedByType_STATUS_Values = map[string]SystemData_CreatedByType_STATUS{
	"application":     SystemData_CreatedByType_STATUS_Application,
	"key":             SystemData_CreatedByType_STATUS_Key,
	"managedidentity": SystemData_CreatedByType_STATUS_ManagedIdentity,
	"user":            SystemData_CreatedByType_STATUS_User,
}

type SystemData_LastModifiedByType_STATUS string

const (
	SystemData_LastModifiedByType_STATUS_Application     = SystemData_LastModifiedByType_STATUS("Application")
	SystemData_LastModifiedByType_STATUS_Key             = SystemData_LastModifiedByType_STATUS("Key")
	SystemData_LastModifiedByType_STATUS_ManagedIdentity = SystemData_LastModifiedByType_STATUS("ManagedIdentity")
	SystemData_LastModifiedByType_STATUS_User            = SystemData_LastModifiedByType_STATUS("User")
)

// Mapping from string to SystemData_LastModifiedByType_STATUS
var systemData_LastModifiedByType_STATUS_Values = map[string]SystemData_LastModifiedByType_STATUS{
	"application":     SystemData_LastModifiedByType_STATUS_Application,
	"key":             SystemData_LastModifiedByType_STATUS_Key,
	"managedidentity": SystemData_LastModifiedByType_STATUS_ManagedIdentity,
	"user":            SystemData_LastModifiedByType_STATUS_User,
}

func init() {
	SchemeBuilder.Register(&DnsForwardingRuleSetsForwardingRule{}, &DnsForwardingRuleSetsForwardingRuleList{})
}
