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

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

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,network}
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
// +kubebuilder:printcolumn:name="Severity",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].severity"
// +kubebuilder:printcolumn:name="Reason",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].reason"
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].message"
// Generator information:
// - Generated from: /network/resource-manager/Microsoft.Network/stable/2024-03-01/networkSecurityGroup.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}/securityRules/{securityRuleName}
type NetworkSecurityGroupsSecurityRule struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              NetworkSecurityGroupsSecurityRule_Spec   `json:"spec,omitempty"`
	Status            NetworkSecurityGroupsSecurityRule_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &NetworkSecurityGroupsSecurityRule{}

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

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

var _ conversion.Convertible = &NetworkSecurityGroupsSecurityRule{}

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

	return rule.AssignProperties_From_NetworkSecurityGroupsSecurityRule(source)
}

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

	return rule.AssignProperties_To_NetworkSecurityGroupsSecurityRule(destination)
}

var _ configmaps.Exporter = &NetworkSecurityGroupsSecurityRule{}

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

var _ secrets.Exporter = &NetworkSecurityGroupsSecurityRule{}

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

var _ genruntime.ImportableResource = &NetworkSecurityGroupsSecurityRule{}

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

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

var _ genruntime.KubernetesResource = &NetworkSecurityGroupsSecurityRule{}

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

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

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

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

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

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

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

// Owner returns the ResourceReference of the owner
func (rule *NetworkSecurityGroupsSecurityRule) 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 *NetworkSecurityGroupsSecurityRule) SetStatus(status genruntime.ConvertibleStatus) error {
	// If we have exactly the right type of status, assign it
	if st, ok := status.(*NetworkSecurityGroupsSecurityRule_STATUS); ok {
		rule.Status = *st
		return nil
	}

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

	rule.Status = st
	return nil
}

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

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

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

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

	// No error
	return nil
}

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

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

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

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

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /network/resource-manager/Microsoft.Network/stable/2024-03-01/networkSecurityGroup.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}/securityRules/{securityRuleName}
type NetworkSecurityGroupsSecurityRuleList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []NetworkSecurityGroupsSecurityRule `json:"items"`
}

type NetworkSecurityGroupsSecurityRule_Spec struct {
	// +kubebuilder:validation:Required
	// Access: The network traffic is allowed or denied.
	Access *SecurityRuleAccess `json:"access,omitempty"`

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

	// Description: A description for this rule. Restricted to 140 chars.
	Description *string `json:"description,omitempty"`

	// DestinationAddressPrefix: The destination address prefix. CIDR or destination IP range. Asterisk '*' can also be used to
	// match all source IPs. Default tags such as 'VirtualNetwork', 'AzureLoadBalancer' and 'Internet' can also be used.
	DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"`

	// DestinationAddressPrefixes: The destination address prefixes. CIDR or destination IP ranges.
	DestinationAddressPrefixes []string `json:"destinationAddressPrefixes,omitempty"`

	// DestinationApplicationSecurityGroups: The application security group specified as destination.
	DestinationApplicationSecurityGroups []ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded `json:"destinationApplicationSecurityGroups,omitempty"`

	// DestinationPortRange: The destination port or range. Integer or range between 0 and 65535. Asterisk '*' can also be used
	// to match all ports.
	DestinationPortRange *string `json:"destinationPortRange,omitempty"`

	// DestinationPortRanges: The destination port ranges.
	DestinationPortRanges []string `json:"destinationPortRanges,omitempty"`

	// +kubebuilder:validation:Required
	// Direction: The direction of the rule. The direction specifies if rule will be evaluated on incoming or outgoing traffic.
	Direction *SecurityRuleDirection `json:"direction,omitempty"`

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

	// +kubebuilder:validation:Required
	// Priority: The priority of the rule. The value can be between 100 and 4096. The priority number must be unique for each
	// rule in the collection. The lower the priority number, the higher the priority of the rule.
	Priority *int `json:"priority,omitempty"`

	// +kubebuilder:validation:Required
	// Protocol: Network protocol this rule applies to.
	Protocol *SecurityRulePropertiesFormat_Protocol `json:"protocol,omitempty"`

	// SourceAddressPrefix: The CIDR or source IP range. Asterisk '*' can also be used to match all source IPs. Default tags
	// such as 'VirtualNetwork', 'AzureLoadBalancer' and 'Internet' can also be used. If this is an ingress rule, specifies
	// where network traffic originates from.
	SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"`

	// SourceAddressPrefixes: The CIDR or source IP ranges.
	SourceAddressPrefixes []string `json:"sourceAddressPrefixes,omitempty"`

	// SourceApplicationSecurityGroups: The application security group specified as source.
	SourceApplicationSecurityGroups []ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded `json:"sourceApplicationSecurityGroups,omitempty"`

	// SourcePortRange: The source port or range. Integer or range between 0 and 65535. Asterisk '*' can also be used to match
	// all ports.
	SourcePortRange *string `json:"sourcePortRange,omitempty"`

	// SourcePortRanges: The source port ranges.
	SourcePortRanges []string `json:"sourcePortRanges,omitempty"`
}

var _ genruntime.ARMTransformer = &NetworkSecurityGroupsSecurityRule_Spec{}

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

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

	// Set property "Properties":
	if rule.Access != nil ||
		rule.Description != nil ||
		rule.DestinationAddressPrefix != nil ||
		rule.DestinationAddressPrefixes != nil ||
		rule.DestinationApplicationSecurityGroups != nil ||
		rule.DestinationPortRange != nil ||
		rule.DestinationPortRanges != nil ||
		rule.Direction != nil ||
		rule.Priority != nil ||
		rule.Protocol != nil ||
		rule.SourceAddressPrefix != nil ||
		rule.SourceAddressPrefixes != nil ||
		rule.SourceApplicationSecurityGroups != nil ||
		rule.SourcePortRange != nil ||
		rule.SourcePortRanges != nil {
		result.Properties = &arm.SecurityRulePropertiesFormat_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded{}
	}
	if rule.Access != nil {
		var temp string
		temp = string(*rule.Access)
		access := arm.SecurityRuleAccess(temp)
		result.Properties.Access = &access
	}
	if rule.Description != nil {
		description := *rule.Description
		result.Properties.Description = &description
	}
	if rule.DestinationAddressPrefix != nil {
		destinationAddressPrefix := *rule.DestinationAddressPrefix
		result.Properties.DestinationAddressPrefix = &destinationAddressPrefix
	}
	for _, item := range rule.DestinationAddressPrefixes {
		result.Properties.DestinationAddressPrefixes = append(result.Properties.DestinationAddressPrefixes, item)
	}
	for _, item := range rule.DestinationApplicationSecurityGroups {
		item_ARM, err := item.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		result.Properties.DestinationApplicationSecurityGroups = append(result.Properties.DestinationApplicationSecurityGroups, *item_ARM.(*arm.ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded))
	}
	if rule.DestinationPortRange != nil {
		destinationPortRange := *rule.DestinationPortRange
		result.Properties.DestinationPortRange = &destinationPortRange
	}
	for _, item := range rule.DestinationPortRanges {
		result.Properties.DestinationPortRanges = append(result.Properties.DestinationPortRanges, item)
	}
	if rule.Direction != nil {
		var temp string
		temp = string(*rule.Direction)
		direction := arm.SecurityRuleDirection(temp)
		result.Properties.Direction = &direction
	}
	if rule.Priority != nil {
		priority := *rule.Priority
		result.Properties.Priority = &priority
	}
	if rule.Protocol != nil {
		var temp string
		temp = string(*rule.Protocol)
		protocol := arm.SecurityRulePropertiesFormat_Protocol(temp)
		result.Properties.Protocol = &protocol
	}
	if rule.SourceAddressPrefix != nil {
		sourceAddressPrefix := *rule.SourceAddressPrefix
		result.Properties.SourceAddressPrefix = &sourceAddressPrefix
	}
	for _, item := range rule.SourceAddressPrefixes {
		result.Properties.SourceAddressPrefixes = append(result.Properties.SourceAddressPrefixes, item)
	}
	for _, item := range rule.SourceApplicationSecurityGroups {
		item_ARM, err := item.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		result.Properties.SourceApplicationSecurityGroups = append(result.Properties.SourceApplicationSecurityGroups, *item_ARM.(*arm.ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded))
	}
	if rule.SourcePortRange != nil {
		sourcePortRange := *rule.SourcePortRange
		result.Properties.SourcePortRange = &sourcePortRange
	}
	for _, item := range rule.SourcePortRanges {
		result.Properties.SourcePortRanges = append(result.Properties.SourcePortRanges, item)
	}
	return result, nil
}

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

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

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

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

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

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

	// Set property "DestinationAddressPrefixes":
	// copying flattened property:
	if typedInput.Properties != nil {
		for _, item := range typedInput.Properties.DestinationAddressPrefixes {
			rule.DestinationAddressPrefixes = append(rule.DestinationAddressPrefixes, item)
		}
	}

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

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

	// Set property "DestinationPortRanges":
	// copying flattened property:
	if typedInput.Properties != nil {
		for _, item := range typedInput.Properties.DestinationPortRanges {
			rule.DestinationPortRanges = append(rule.DestinationPortRanges, item)
		}
	}

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

	// no assignment for property "OperatorSpec"

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

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

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

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

	// Set property "SourceAddressPrefixes":
	// copying flattened property:
	if typedInput.Properties != nil {
		for _, item := range typedInput.Properties.SourceAddressPrefixes {
			rule.SourceAddressPrefixes = append(rule.SourceAddressPrefixes, item)
		}
	}

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

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

	// Set property "SourcePortRanges":
	// copying flattened property:
	if typedInput.Properties != nil {
		for _, item := range typedInput.Properties.SourcePortRanges {
			rule.SourcePortRanges = append(rule.SourcePortRanges, item)
		}
	}

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &NetworkSecurityGroupsSecurityRule_Spec{}

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

	// Convert to an intermediate form
	src = &storage.NetworkSecurityGroupsSecurityRule_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_NetworkSecurityGroupsSecurityRule_Spec(src)
	if err != nil {
		return eris.Wrap(err, "final step of conversion in ConvertSpecFrom()")
	}

	return nil
}

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

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

	// Access
	if source.Access != nil {
		access := *source.Access
		accessTemp := genruntime.ToEnum(access, securityRuleAccess_Values)
		rule.Access = &accessTemp
	} else {
		rule.Access = nil
	}

	// AzureName
	rule.AzureName = source.AzureName

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

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

	// DestinationAddressPrefixes
	rule.DestinationAddressPrefixes = genruntime.CloneSliceOfString(source.DestinationAddressPrefixes)

	// DestinationApplicationSecurityGroups
	if source.DestinationApplicationSecurityGroups != nil {
		destinationApplicationSecurityGroupList := make([]ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded, len(source.DestinationApplicationSecurityGroups))
		for destinationApplicationSecurityGroupIndex, destinationApplicationSecurityGroupItem := range source.DestinationApplicationSecurityGroups {
			var destinationApplicationSecurityGroup ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded
			err := destinationApplicationSecurityGroup.AssignProperties_From_ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded(&destinationApplicationSecurityGroupItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded() to populate field DestinationApplicationSecurityGroups")
			}
			destinationApplicationSecurityGroupList[destinationApplicationSecurityGroupIndex] = destinationApplicationSecurityGroup
		}
		rule.DestinationApplicationSecurityGroups = destinationApplicationSecurityGroupList
	} else {
		rule.DestinationApplicationSecurityGroups = nil
	}

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

	// DestinationPortRanges
	rule.DestinationPortRanges = genruntime.CloneSliceOfString(source.DestinationPortRanges)

	// Direction
	if source.Direction != nil {
		direction := *source.Direction
		directionTemp := genruntime.ToEnum(direction, securityRuleDirection_Values)
		rule.Direction = &directionTemp
	} else {
		rule.Direction = nil
	}

	// OperatorSpec
	if source.OperatorSpec != nil {
		var operatorSpec NetworkSecurityGroupsSecurityRuleOperatorSpec
		err := operatorSpec.AssignProperties_From_NetworkSecurityGroupsSecurityRuleOperatorSpec(source.OperatorSpec)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_NetworkSecurityGroupsSecurityRuleOperatorSpec() 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
	}

	// Priority
	rule.Priority = genruntime.ClonePointerToInt(source.Priority)

	// Protocol
	if source.Protocol != nil {
		protocol := *source.Protocol
		protocolTemp := genruntime.ToEnum(protocol, securityRulePropertiesFormat_Protocol_Values)
		rule.Protocol = &protocolTemp
	} else {
		rule.Protocol = nil
	}

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

	// SourceAddressPrefixes
	rule.SourceAddressPrefixes = genruntime.CloneSliceOfString(source.SourceAddressPrefixes)

	// SourceApplicationSecurityGroups
	if source.SourceApplicationSecurityGroups != nil {
		sourceApplicationSecurityGroupList := make([]ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded, len(source.SourceApplicationSecurityGroups))
		for sourceApplicationSecurityGroupIndex, sourceApplicationSecurityGroupItem := range source.SourceApplicationSecurityGroups {
			var sourceApplicationSecurityGroup ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded
			err := sourceApplicationSecurityGroup.AssignProperties_From_ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded(&sourceApplicationSecurityGroupItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded() to populate field SourceApplicationSecurityGroups")
			}
			sourceApplicationSecurityGroupList[sourceApplicationSecurityGroupIndex] = sourceApplicationSecurityGroup
		}
		rule.SourceApplicationSecurityGroups = sourceApplicationSecurityGroupList
	} else {
		rule.SourceApplicationSecurityGroups = nil
	}

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

	// SourcePortRanges
	rule.SourcePortRanges = genruntime.CloneSliceOfString(source.SourcePortRanges)

	// No error
	return nil
}

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

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

	// AzureName
	destination.AzureName = rule.AzureName

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

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

	// DestinationAddressPrefixes
	destination.DestinationAddressPrefixes = genruntime.CloneSliceOfString(rule.DestinationAddressPrefixes)

	// DestinationApplicationSecurityGroups
	if rule.DestinationApplicationSecurityGroups != nil {
		destinationApplicationSecurityGroupList := make([]storage.ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded, len(rule.DestinationApplicationSecurityGroups))
		for destinationApplicationSecurityGroupIndex, destinationApplicationSecurityGroupItem := range rule.DestinationApplicationSecurityGroups {
			var destinationApplicationSecurityGroup storage.ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded
			err := destinationApplicationSecurityGroupItem.AssignProperties_To_ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded(&destinationApplicationSecurityGroup)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded() to populate field DestinationApplicationSecurityGroups")
			}
			destinationApplicationSecurityGroupList[destinationApplicationSecurityGroupIndex] = destinationApplicationSecurityGroup
		}
		destination.DestinationApplicationSecurityGroups = destinationApplicationSecurityGroupList
	} else {
		destination.DestinationApplicationSecurityGroups = nil
	}

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

	// DestinationPortRanges
	destination.DestinationPortRanges = genruntime.CloneSliceOfString(rule.DestinationPortRanges)

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

	// OperatorSpec
	if rule.OperatorSpec != nil {
		var operatorSpec storage.NetworkSecurityGroupsSecurityRuleOperatorSpec
		err := rule.OperatorSpec.AssignProperties_To_NetworkSecurityGroupsSecurityRuleOperatorSpec(&operatorSpec)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_NetworkSecurityGroupsSecurityRuleOperatorSpec() 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
	}

	// Priority
	destination.Priority = genruntime.ClonePointerToInt(rule.Priority)

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

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

	// SourceAddressPrefixes
	destination.SourceAddressPrefixes = genruntime.CloneSliceOfString(rule.SourceAddressPrefixes)

	// SourceApplicationSecurityGroups
	if rule.SourceApplicationSecurityGroups != nil {
		sourceApplicationSecurityGroupList := make([]storage.ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded, len(rule.SourceApplicationSecurityGroups))
		for sourceApplicationSecurityGroupIndex, sourceApplicationSecurityGroupItem := range rule.SourceApplicationSecurityGroups {
			var sourceApplicationSecurityGroup storage.ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded
			err := sourceApplicationSecurityGroupItem.AssignProperties_To_ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded(&sourceApplicationSecurityGroup)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded() to populate field SourceApplicationSecurityGroups")
			}
			sourceApplicationSecurityGroupList[sourceApplicationSecurityGroupIndex] = sourceApplicationSecurityGroup
		}
		destination.SourceApplicationSecurityGroups = sourceApplicationSecurityGroupList
	} else {
		destination.SourceApplicationSecurityGroups = nil
	}

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

	// SourcePortRanges
	destination.SourcePortRanges = genruntime.CloneSliceOfString(rule.SourcePortRanges)

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

	// No error
	return nil
}

// Initialize_From_NetworkSecurityGroupsSecurityRule_STATUS populates our NetworkSecurityGroupsSecurityRule_Spec from the provided source NetworkSecurityGroupsSecurityRule_STATUS
func (rule *NetworkSecurityGroupsSecurityRule_Spec) Initialize_From_NetworkSecurityGroupsSecurityRule_STATUS(source *NetworkSecurityGroupsSecurityRule_STATUS) error {

	// Access
	if source.Access != nil {
		access := genruntime.ToEnum(string(*source.Access), securityRuleAccess_Values)
		rule.Access = &access
	} else {
		rule.Access = nil
	}

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

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

	// DestinationAddressPrefixes
	rule.DestinationAddressPrefixes = genruntime.CloneSliceOfString(source.DestinationAddressPrefixes)

	// DestinationApplicationSecurityGroups
	if source.DestinationApplicationSecurityGroups != nil {
		destinationApplicationSecurityGroupList := make([]ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded, len(source.DestinationApplicationSecurityGroups))
		for destinationApplicationSecurityGroupIndex, destinationApplicationSecurityGroupItem := range source.DestinationApplicationSecurityGroups {
			var destinationApplicationSecurityGroup ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded
			err := destinationApplicationSecurityGroup.Initialize_From_ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded(&destinationApplicationSecurityGroupItem)
			if err != nil {
				return eris.Wrap(err, "calling Initialize_From_ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded() to populate field DestinationApplicationSecurityGroups")
			}
			destinationApplicationSecurityGroupList[destinationApplicationSecurityGroupIndex] = destinationApplicationSecurityGroup
		}
		rule.DestinationApplicationSecurityGroups = destinationApplicationSecurityGroupList
	} else {
		rule.DestinationApplicationSecurityGroups = nil
	}

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

	// DestinationPortRanges
	rule.DestinationPortRanges = genruntime.CloneSliceOfString(source.DestinationPortRanges)

	// Direction
	if source.Direction != nil {
		direction := genruntime.ToEnum(string(*source.Direction), securityRuleDirection_Values)
		rule.Direction = &direction
	} else {
		rule.Direction = nil
	}

	// Priority
	rule.Priority = genruntime.ClonePointerToInt(source.Priority)

	// Protocol
	if source.Protocol != nil {
		protocol := genruntime.ToEnum(string(*source.Protocol), securityRulePropertiesFormat_Protocol_Values)
		rule.Protocol = &protocol
	} else {
		rule.Protocol = nil
	}

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

	// SourceAddressPrefixes
	rule.SourceAddressPrefixes = genruntime.CloneSliceOfString(source.SourceAddressPrefixes)

	// SourceApplicationSecurityGroups
	if source.SourceApplicationSecurityGroups != nil {
		sourceApplicationSecurityGroupList := make([]ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded, len(source.SourceApplicationSecurityGroups))
		for sourceApplicationSecurityGroupIndex, sourceApplicationSecurityGroupItem := range source.SourceApplicationSecurityGroups {
			var sourceApplicationSecurityGroup ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded
			err := sourceApplicationSecurityGroup.Initialize_From_ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded(&sourceApplicationSecurityGroupItem)
			if err != nil {
				return eris.Wrap(err, "calling Initialize_From_ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded() to populate field SourceApplicationSecurityGroups")
			}
			sourceApplicationSecurityGroupList[sourceApplicationSecurityGroupIndex] = sourceApplicationSecurityGroup
		}
		rule.SourceApplicationSecurityGroups = sourceApplicationSecurityGroupList
	} else {
		rule.SourceApplicationSecurityGroups = nil
	}

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

	// SourcePortRanges
	rule.SourcePortRanges = genruntime.CloneSliceOfString(source.SourcePortRanges)

	// No error
	return nil
}

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

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

type NetworkSecurityGroupsSecurityRule_STATUS struct {
	// Access: The network traffic is allowed or denied.
	Access *SecurityRuleAccess_STATUS `json:"access,omitempty"`

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

	// Description: A description for this rule. Restricted to 140 chars.
	Description *string `json:"description,omitempty"`

	// DestinationAddressPrefix: The destination address prefix. CIDR or destination IP range. Asterisk '*' can also be used to
	// match all source IPs. Default tags such as 'VirtualNetwork', 'AzureLoadBalancer' and 'Internet' can also be used.
	DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"`

	// DestinationAddressPrefixes: The destination address prefixes. CIDR or destination IP ranges.
	DestinationAddressPrefixes []string `json:"destinationAddressPrefixes,omitempty"`

	// DestinationApplicationSecurityGroups: The application security group specified as destination.
	DestinationApplicationSecurityGroups []ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded `json:"destinationApplicationSecurityGroups,omitempty"`

	// DestinationPortRange: The destination port or range. Integer or range between 0 and 65535. Asterisk '*' can also be used
	// to match all ports.
	DestinationPortRange *string `json:"destinationPortRange,omitempty"`

	// DestinationPortRanges: The destination port ranges.
	DestinationPortRanges []string `json:"destinationPortRanges,omitempty"`

	// Direction: The direction of the rule. The direction specifies if rule will be evaluated on incoming or outgoing traffic.
	Direction *SecurityRuleDirection_STATUS `json:"direction,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"`

	// Name: The name of the resource that is unique within a resource group. This name can be used to access the resource.
	Name *string `json:"name,omitempty"`

	// Priority: The priority of the rule. The value can be between 100 and 4096. The priority number must be unique for each
	// rule in the collection. The lower the priority number, the higher the priority of the rule.
	Priority *int `json:"priority,omitempty"`

	// Protocol: Network protocol this rule applies to.
	Protocol *SecurityRulePropertiesFormat_Protocol_STATUS `json:"protocol,omitempty"`

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

	// SourceAddressPrefix: The CIDR or source IP range. Asterisk '*' can also be used to match all source IPs. Default tags
	// such as 'VirtualNetwork', 'AzureLoadBalancer' and 'Internet' can also be used. If this is an ingress rule, specifies
	// where network traffic originates from.
	SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"`

	// SourceAddressPrefixes: The CIDR or source IP ranges.
	SourceAddressPrefixes []string `json:"sourceAddressPrefixes,omitempty"`

	// SourceApplicationSecurityGroups: The application security group specified as source.
	SourceApplicationSecurityGroups []ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded `json:"sourceApplicationSecurityGroups,omitempty"`

	// SourcePortRange: The source port or range. Integer or range between 0 and 65535. Asterisk '*' can also be used to match
	// all ports.
	SourcePortRange *string `json:"sourcePortRange,omitempty"`

	// SourcePortRanges: The source port ranges.
	SourcePortRanges []string `json:"sourcePortRanges,omitempty"`

	// Type: The type of the resource.
	Type *string `json:"type,omitempty"`
}

var _ genruntime.ConvertibleStatus = &NetworkSecurityGroupsSecurityRule_STATUS{}

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

	// Convert to an intermediate form
	src = &storage.NetworkSecurityGroupsSecurityRule_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_NetworkSecurityGroupsSecurityRule_STATUS(src)
	if err != nil {
		return eris.Wrap(err, "final step of conversion in ConvertStatusFrom()")
	}

	return nil
}

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

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

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

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

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

	// no assignment for property "Conditions"

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

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

	// Set property "DestinationAddressPrefixes":
	// copying flattened property:
	if typedInput.Properties != nil {
		for _, item := range typedInput.Properties.DestinationAddressPrefixes {
			rule.DestinationAddressPrefixes = append(rule.DestinationAddressPrefixes, item)
		}
	}

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

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

	// Set property "DestinationPortRanges":
	// copying flattened property:
	if typedInput.Properties != nil {
		for _, item := range typedInput.Properties.DestinationPortRanges {
			rule.DestinationPortRanges = append(rule.DestinationPortRanges, item)
		}
	}

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

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

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

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

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

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

	// 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)
			rule.ProvisioningState = &provisioningState
		}
	}

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

	// Set property "SourceAddressPrefixes":
	// copying flattened property:
	if typedInput.Properties != nil {
		for _, item := range typedInput.Properties.SourceAddressPrefixes {
			rule.SourceAddressPrefixes = append(rule.SourceAddressPrefixes, item)
		}
	}

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

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

	// Set property "SourcePortRanges":
	// copying flattened property:
	if typedInput.Properties != nil {
		for _, item := range typedInput.Properties.SourcePortRanges {
			rule.SourcePortRanges = append(rule.SourcePortRanges, item)
		}
	}

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

	// No error
	return nil
}

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

	// Access
	if source.Access != nil {
		access := *source.Access
		accessTemp := genruntime.ToEnum(access, securityRuleAccess_STATUS_Values)
		rule.Access = &accessTemp
	} else {
		rule.Access = nil
	}

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

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

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

	// DestinationAddressPrefixes
	rule.DestinationAddressPrefixes = genruntime.CloneSliceOfString(source.DestinationAddressPrefixes)

	// DestinationApplicationSecurityGroups
	if source.DestinationApplicationSecurityGroups != nil {
		destinationApplicationSecurityGroupList := make([]ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded, len(source.DestinationApplicationSecurityGroups))
		for destinationApplicationSecurityGroupIndex, destinationApplicationSecurityGroupItem := range source.DestinationApplicationSecurityGroups {
			var destinationApplicationSecurityGroup ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded
			err := destinationApplicationSecurityGroup.AssignProperties_From_ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded(&destinationApplicationSecurityGroupItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded() to populate field DestinationApplicationSecurityGroups")
			}
			destinationApplicationSecurityGroupList[destinationApplicationSecurityGroupIndex] = destinationApplicationSecurityGroup
		}
		rule.DestinationApplicationSecurityGroups = destinationApplicationSecurityGroupList
	} else {
		rule.DestinationApplicationSecurityGroups = nil
	}

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

	// DestinationPortRanges
	rule.DestinationPortRanges = genruntime.CloneSliceOfString(source.DestinationPortRanges)

	// Direction
	if source.Direction != nil {
		direction := *source.Direction
		directionTemp := genruntime.ToEnum(direction, securityRuleDirection_STATUS_Values)
		rule.Direction = &directionTemp
	} else {
		rule.Direction = nil
	}

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

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

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

	// Priority
	rule.Priority = genruntime.ClonePointerToInt(source.Priority)

	// Protocol
	if source.Protocol != nil {
		protocol := *source.Protocol
		protocolTemp := genruntime.ToEnum(protocol, securityRulePropertiesFormat_Protocol_STATUS_Values)
		rule.Protocol = &protocolTemp
	} else {
		rule.Protocol = nil
	}

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

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

	// SourceAddressPrefixes
	rule.SourceAddressPrefixes = genruntime.CloneSliceOfString(source.SourceAddressPrefixes)

	// SourceApplicationSecurityGroups
	if source.SourceApplicationSecurityGroups != nil {
		sourceApplicationSecurityGroupList := make([]ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded, len(source.SourceApplicationSecurityGroups))
		for sourceApplicationSecurityGroupIndex, sourceApplicationSecurityGroupItem := range source.SourceApplicationSecurityGroups {
			var sourceApplicationSecurityGroup ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded
			err := sourceApplicationSecurityGroup.AssignProperties_From_ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded(&sourceApplicationSecurityGroupItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded() to populate field SourceApplicationSecurityGroups")
			}
			sourceApplicationSecurityGroupList[sourceApplicationSecurityGroupIndex] = sourceApplicationSecurityGroup
		}
		rule.SourceApplicationSecurityGroups = sourceApplicationSecurityGroupList
	} else {
		rule.SourceApplicationSecurityGroups = nil
	}

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

	// SourcePortRanges
	rule.SourcePortRanges = genruntime.CloneSliceOfString(source.SourcePortRanges)

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

	// No error
	return nil
}

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

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

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

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

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

	// DestinationAddressPrefixes
	destination.DestinationAddressPrefixes = genruntime.CloneSliceOfString(rule.DestinationAddressPrefixes)

	// DestinationApplicationSecurityGroups
	if rule.DestinationApplicationSecurityGroups != nil {
		destinationApplicationSecurityGroupList := make([]storage.ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded, len(rule.DestinationApplicationSecurityGroups))
		for destinationApplicationSecurityGroupIndex, destinationApplicationSecurityGroupItem := range rule.DestinationApplicationSecurityGroups {
			var destinationApplicationSecurityGroup storage.ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded
			err := destinationApplicationSecurityGroupItem.AssignProperties_To_ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded(&destinationApplicationSecurityGroup)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded() to populate field DestinationApplicationSecurityGroups")
			}
			destinationApplicationSecurityGroupList[destinationApplicationSecurityGroupIndex] = destinationApplicationSecurityGroup
		}
		destination.DestinationApplicationSecurityGroups = destinationApplicationSecurityGroupList
	} else {
		destination.DestinationApplicationSecurityGroups = nil
	}

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

	// DestinationPortRanges
	destination.DestinationPortRanges = genruntime.CloneSliceOfString(rule.DestinationPortRanges)

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

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

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

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

	// Priority
	destination.Priority = genruntime.ClonePointerToInt(rule.Priority)

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

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

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

	// SourceAddressPrefixes
	destination.SourceAddressPrefixes = genruntime.CloneSliceOfString(rule.SourceAddressPrefixes)

	// SourceApplicationSecurityGroups
	if rule.SourceApplicationSecurityGroups != nil {
		sourceApplicationSecurityGroupList := make([]storage.ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded, len(rule.SourceApplicationSecurityGroups))
		for sourceApplicationSecurityGroupIndex, sourceApplicationSecurityGroupItem := range rule.SourceApplicationSecurityGroups {
			var sourceApplicationSecurityGroup storage.ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded
			err := sourceApplicationSecurityGroupItem.AssignProperties_To_ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded(&sourceApplicationSecurityGroup)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded() to populate field SourceApplicationSecurityGroups")
			}
			sourceApplicationSecurityGroupList[sourceApplicationSecurityGroupIndex] = sourceApplicationSecurityGroup
		}
		destination.SourceApplicationSecurityGroups = sourceApplicationSecurityGroupList
	} else {
		destination.SourceApplicationSecurityGroups = nil
	}

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

	// SourcePortRanges
	destination.SourcePortRanges = genruntime.CloneSliceOfString(rule.SourcePortRanges)

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

// An application security group in a resource group.
type ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded struct {
	// Id: Resource ID.
	Id *string `json:"id,omitempty"`
}

var _ genruntime.FromARMConverter = &ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded{}

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

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

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

	// No error
	return nil
}

// AssignProperties_From_ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded populates our ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded from the provided source ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded
func (embedded *ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded) AssignProperties_From_ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded(source *storage.ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded) error {

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

	// No error
	return nil
}

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

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

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

	// No error
	return nil
}

// An application security group in a resource group.
type ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded struct {
	// Reference: Resource ID.
	Reference *genruntime.ResourceReference `armReference:"Id" json:"reference,omitempty"`
}

var _ genruntime.ARMTransformer = &ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded{}

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

	// Set property "Id":
	if embedded.Reference != nil {
		referenceARMID, err := resolved.ResolvedReferences.Lookup(*embedded.Reference)
		if err != nil {
			return nil, err
		}
		reference := referenceARMID
		result.Id = &reference
	}
	return result, nil
}

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

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

	// no assignment for property "Reference"

	// No error
	return nil
}

// AssignProperties_From_ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded populates our ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded from the provided source ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded
func (embedded *ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded) AssignProperties_From_ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded(source *storage.ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded) error {

	// Reference
	if source.Reference != nil {
		reference := source.Reference.Copy()
		embedded.Reference = &reference
	} else {
		embedded.Reference = nil
	}

	// No error
	return nil
}

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

	// Reference
	if embedded.Reference != nil {
		reference := embedded.Reference.Copy()
		destination.Reference = &reference
	} else {
		destination.Reference = nil
	}

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

	// No error
	return nil
}

// Initialize_From_ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded populates our ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded from the provided source ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded
func (embedded *ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded) Initialize_From_ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded(source *ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded) error {

	// Reference
	if source.Id != nil {
		reference := genruntime.CreateResourceReferenceFromARMID(*source.Id)
		embedded.Reference = &reference
	} else {
		embedded.Reference = 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 NetworkSecurityGroupsSecurityRuleOperatorSpec 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_NetworkSecurityGroupsSecurityRuleOperatorSpec populates our NetworkSecurityGroupsSecurityRuleOperatorSpec from the provided source NetworkSecurityGroupsSecurityRuleOperatorSpec
func (operator *NetworkSecurityGroupsSecurityRuleOperatorSpec) AssignProperties_From_NetworkSecurityGroupsSecurityRuleOperatorSpec(source *storage.NetworkSecurityGroupsSecurityRuleOperatorSpec) 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_NetworkSecurityGroupsSecurityRuleOperatorSpec populates the provided destination NetworkSecurityGroupsSecurityRuleOperatorSpec from our NetworkSecurityGroupsSecurityRuleOperatorSpec
func (operator *NetworkSecurityGroupsSecurityRuleOperatorSpec) AssignProperties_To_NetworkSecurityGroupsSecurityRuleOperatorSpec(destination *storage.NetworkSecurityGroupsSecurityRuleOperatorSpec) 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
}

// Whether network traffic is allowed or denied.
// +kubebuilder:validation:Enum={"Allow","Deny"}
type SecurityRuleAccess string

const (
	SecurityRuleAccess_Allow = SecurityRuleAccess("Allow")
	SecurityRuleAccess_Deny  = SecurityRuleAccess("Deny")
)

// Mapping from string to SecurityRuleAccess
var securityRuleAccess_Values = map[string]SecurityRuleAccess{
	"allow": SecurityRuleAccess_Allow,
	"deny":  SecurityRuleAccess_Deny,
}

// Whether network traffic is allowed or denied.
type SecurityRuleAccess_STATUS string

const (
	SecurityRuleAccess_STATUS_Allow = SecurityRuleAccess_STATUS("Allow")
	SecurityRuleAccess_STATUS_Deny  = SecurityRuleAccess_STATUS("Deny")
)

// Mapping from string to SecurityRuleAccess_STATUS
var securityRuleAccess_STATUS_Values = map[string]SecurityRuleAccess_STATUS{
	"allow": SecurityRuleAccess_STATUS_Allow,
	"deny":  SecurityRuleAccess_STATUS_Deny,
}

// The direction of the rule. The direction specifies if rule will be evaluated on incoming or outgoing traffic.
// +kubebuilder:validation:Enum={"Inbound","Outbound"}
type SecurityRuleDirection string

const (
	SecurityRuleDirection_Inbound  = SecurityRuleDirection("Inbound")
	SecurityRuleDirection_Outbound = SecurityRuleDirection("Outbound")
)

// Mapping from string to SecurityRuleDirection
var securityRuleDirection_Values = map[string]SecurityRuleDirection{
	"inbound":  SecurityRuleDirection_Inbound,
	"outbound": SecurityRuleDirection_Outbound,
}

// The direction of the rule. The direction specifies if rule will be evaluated on incoming or outgoing traffic.
type SecurityRuleDirection_STATUS string

const (
	SecurityRuleDirection_STATUS_Inbound  = SecurityRuleDirection_STATUS("Inbound")
	SecurityRuleDirection_STATUS_Outbound = SecurityRuleDirection_STATUS("Outbound")
)

// Mapping from string to SecurityRuleDirection_STATUS
var securityRuleDirection_STATUS_Values = map[string]SecurityRuleDirection_STATUS{
	"inbound":  SecurityRuleDirection_STATUS_Inbound,
	"outbound": SecurityRuleDirection_STATUS_Outbound,
}

// +kubebuilder:validation:Enum={"Ah","Esp","Icmp","*","Tcp","Udp"}
type SecurityRulePropertiesFormat_Protocol string

const (
	SecurityRulePropertiesFormat_Protocol_Ah   = SecurityRulePropertiesFormat_Protocol("Ah")
	SecurityRulePropertiesFormat_Protocol_Esp  = SecurityRulePropertiesFormat_Protocol("Esp")
	SecurityRulePropertiesFormat_Protocol_Icmp = SecurityRulePropertiesFormat_Protocol("Icmp")
	SecurityRulePropertiesFormat_Protocol_Star = SecurityRulePropertiesFormat_Protocol("*")
	SecurityRulePropertiesFormat_Protocol_Tcp  = SecurityRulePropertiesFormat_Protocol("Tcp")
	SecurityRulePropertiesFormat_Protocol_Udp  = SecurityRulePropertiesFormat_Protocol("Udp")
)

// Mapping from string to SecurityRulePropertiesFormat_Protocol
var securityRulePropertiesFormat_Protocol_Values = map[string]SecurityRulePropertiesFormat_Protocol{
	"ah":   SecurityRulePropertiesFormat_Protocol_Ah,
	"esp":  SecurityRulePropertiesFormat_Protocol_Esp,
	"icmp": SecurityRulePropertiesFormat_Protocol_Icmp,
	"*":    SecurityRulePropertiesFormat_Protocol_Star,
	"tcp":  SecurityRulePropertiesFormat_Protocol_Tcp,
	"udp":  SecurityRulePropertiesFormat_Protocol_Udp,
}

type SecurityRulePropertiesFormat_Protocol_STATUS string

const (
	SecurityRulePropertiesFormat_Protocol_STATUS_Ah   = SecurityRulePropertiesFormat_Protocol_STATUS("Ah")
	SecurityRulePropertiesFormat_Protocol_STATUS_Esp  = SecurityRulePropertiesFormat_Protocol_STATUS("Esp")
	SecurityRulePropertiesFormat_Protocol_STATUS_Icmp = SecurityRulePropertiesFormat_Protocol_STATUS("Icmp")
	SecurityRulePropertiesFormat_Protocol_STATUS_Star = SecurityRulePropertiesFormat_Protocol_STATUS("*")
	SecurityRulePropertiesFormat_Protocol_STATUS_Tcp  = SecurityRulePropertiesFormat_Protocol_STATUS("Tcp")
	SecurityRulePropertiesFormat_Protocol_STATUS_Udp  = SecurityRulePropertiesFormat_Protocol_STATUS("Udp")
)

// Mapping from string to SecurityRulePropertiesFormat_Protocol_STATUS
var securityRulePropertiesFormat_Protocol_STATUS_Values = map[string]SecurityRulePropertiesFormat_Protocol_STATUS{
	"ah":   SecurityRulePropertiesFormat_Protocol_STATUS_Ah,
	"esp":  SecurityRulePropertiesFormat_Protocol_STATUS_Esp,
	"icmp": SecurityRulePropertiesFormat_Protocol_STATUS_Icmp,
	"*":    SecurityRulePropertiesFormat_Protocol_STATUS_Star,
	"tcp":  SecurityRulePropertiesFormat_Protocol_STATUS_Tcp,
	"udp":  SecurityRulePropertiesFormat_Protocol_STATUS_Udp,
}

func init() {
	SchemeBuilder.Register(&NetworkSecurityGroupsSecurityRule{}, &NetworkSecurityGroupsSecurityRuleList{})
}
