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

import (
	"fmt"
	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"
// Storage version of v1api20201101.NetworkSecurityGroupsSecurityRule
// Generator information:
// - Generated from: /network/resource-manager/Microsoft.Network/stable/2020-11-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.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 "2020-11-01"
func (rule NetworkSecurityGroupsSecurityRule) GetAPIVersion() string {
	return "2020-11-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

	// Invoke the augmentConversionForNetworkSecurityGroupsSecurityRule interface (if implemented) to customize the conversion
	var ruleAsAny any = rule
	if augmentedRule, ok := ruleAsAny.(augmentConversionForNetworkSecurityGroupsSecurityRule); ok {
		err := augmentedRule.AssignPropertiesFrom(source)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesFrom() for conversion")
		}
	}

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

	// Invoke the augmentConversionForNetworkSecurityGroupsSecurityRule interface (if implemented) to customize the conversion
	var ruleAsAny any = rule
	if augmentedRule, ok := ruleAsAny.(augmentConversionForNetworkSecurityGroupsSecurityRule); ok {
		err := augmentedRule.AssignPropertiesTo(destination)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesTo() for conversion")
		}
	}

	// 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
// Storage version of v1api20201101.NetworkSecurityGroupsSecurityRule
// Generator information:
// - Generated from: /network/resource-manager/Microsoft.Network/stable/2020-11-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 augmentConversionForNetworkSecurityGroupsSecurityRule interface {
	AssignPropertiesFrom(src *storage.NetworkSecurityGroupsSecurityRule) error
	AssignPropertiesTo(dst *storage.NetworkSecurityGroupsSecurityRule) error
}

// Storage version of v1api20201101.NetworkSecurityGroupsSecurityRule_Spec
type NetworkSecurityGroupsSecurityRule_Spec struct {
	Access *string `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                          *string                                                                               `json:"description,omitempty"`
	DestinationAddressPrefix             *string                                                                               `json:"destinationAddressPrefix,omitempty"`
	DestinationAddressPrefixes           []string                                                                              `json:"destinationAddressPrefixes,omitempty"`
	DestinationApplicationSecurityGroups []ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded `json:"destinationApplicationSecurityGroups,omitempty"`
	DestinationPortRange                 *string                                                                               `json:"destinationPortRange,omitempty"`
	DestinationPortRanges                []string                                                                              `json:"destinationPortRanges,omitempty"`
	Direction                            *string                                                                               `json:"direction,omitempty"`
	OperatorSpec                         *NetworkSecurityGroupsSecurityRuleOperatorSpec                                        `json:"operatorSpec,omitempty"`
	OriginalVersion                      string                                                                                `json:"originalVersion,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"`
	Priority                        *int                                                                                  `json:"priority,omitempty"`
	PropertyBag                     genruntime.PropertyBag                                                                `json:"$propertyBag,omitempty"`
	Protocol                        *string                                                                               `json:"protocol,omitempty"`
	SourceAddressPrefix             *string                                                                               `json:"sourceAddressPrefix,omitempty"`
	SourceAddressPrefixes           []string                                                                              `json:"sourceAddressPrefixes,omitempty"`
	SourceApplicationSecurityGroups []ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded `json:"sourceApplicationSecurityGroups,omitempty"`
	SourcePortRange                 *string                                                                               `json:"sourcePortRange,omitempty"`
	SourcePortRanges                []string                                                                              `json:"sourcePortRanges,omitempty"`
}

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 {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(source.PropertyBag)

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

	// 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
	rule.Direction = genruntime.ClonePointerToString(source.Direction)

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

	// OriginalVersion
	rule.OriginalVersion = source.OriginalVersion

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

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

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

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

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

	// Invoke the augmentConversionForNetworkSecurityGroupsSecurityRule_Spec interface (if implemented) to customize the conversion
	var ruleAsAny any = rule
	if augmentedRule, ok := ruleAsAny.(augmentConversionForNetworkSecurityGroupsSecurityRule_Spec); ok {
		err := augmentedRule.AssignPropertiesFrom(source)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesFrom() for conversion")
		}
	}

	// 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 {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(rule.PropertyBag)

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

	// 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
	destination.Direction = genruntime.ClonePointerToString(rule.Direction)

	// 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
	destination.Protocol = genruntime.ClonePointerToString(rule.Protocol)

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

	// Invoke the augmentConversionForNetworkSecurityGroupsSecurityRule_Spec interface (if implemented) to customize the conversion
	var ruleAsAny any = rule
	if augmentedRule, ok := ruleAsAny.(augmentConversionForNetworkSecurityGroupsSecurityRule_Spec); ok {
		err := augmentedRule.AssignPropertiesTo(destination)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesTo() for conversion")
		}
	}

	// No error
	return nil
}

// Storage version of v1api20201101.NetworkSecurityGroupsSecurityRule_STATUS
type NetworkSecurityGroupsSecurityRule_STATUS struct {
	Access                               *string                                                                                  `json:"access,omitempty"`
	Conditions                           []conditions.Condition                                                                   `json:"conditions,omitempty"`
	Description                          *string                                                                                  `json:"description,omitempty"`
	DestinationAddressPrefix             *string                                                                                  `json:"destinationAddressPrefix,omitempty"`
	DestinationAddressPrefixes           []string                                                                                 `json:"destinationAddressPrefixes,omitempty"`
	DestinationApplicationSecurityGroups []ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded `json:"destinationApplicationSecurityGroups,omitempty"`
	DestinationPortRange                 *string                                                                                  `json:"destinationPortRange,omitempty"`
	DestinationPortRanges                []string                                                                                 `json:"destinationPortRanges,omitempty"`
	Direction                            *string                                                                                  `json:"direction,omitempty"`
	Etag                                 *string                                                                                  `json:"etag,omitempty"`
	Id                                   *string                                                                                  `json:"id,omitempty"`
	Name                                 *string                                                                                  `json:"name,omitempty"`
	Priority                             *int                                                                                     `json:"priority,omitempty"`
	PropertyBag                          genruntime.PropertyBag                                                                   `json:"$propertyBag,omitempty"`
	Protocol                             *string                                                                                  `json:"protocol,omitempty"`
	ProvisioningState                    *string                                                                                  `json:"provisioningState,omitempty"`
	SourceAddressPrefix                  *string                                                                                  `json:"sourceAddressPrefix,omitempty"`
	SourceAddressPrefixes                []string                                                                                 `json:"sourceAddressPrefixes,omitempty"`
	SourceApplicationSecurityGroups      []ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded `json:"sourceApplicationSecurityGroups,omitempty"`
	SourcePortRange                      *string                                                                                  `json:"sourcePortRange,omitempty"`
	SourcePortRanges                     []string                                                                                 `json:"sourcePortRanges,omitempty"`
	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
}

// 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 {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(source.PropertyBag)

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

	// 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
	rule.Direction = genruntime.ClonePointerToString(source.Direction)

	// 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
	rule.Protocol = genruntime.ClonePointerToString(source.Protocol)

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

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

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

	// Invoke the augmentConversionForNetworkSecurityGroupsSecurityRule_STATUS interface (if implemented) to customize the conversion
	var ruleAsAny any = rule
	if augmentedRule, ok := ruleAsAny.(augmentConversionForNetworkSecurityGroupsSecurityRule_STATUS); ok {
		err := augmentedRule.AssignPropertiesFrom(source)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesFrom() for conversion")
		}
	}

	// 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 {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(rule.PropertyBag)

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

	// 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
	destination.Direction = genruntime.ClonePointerToString(rule.Direction)

	// 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
	destination.Protocol = genruntime.ClonePointerToString(rule.Protocol)

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

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

	// Invoke the augmentConversionForNetworkSecurityGroupsSecurityRule_STATUS interface (if implemented) to customize the conversion
	var ruleAsAny any = rule
	if augmentedRule, ok := ruleAsAny.(augmentConversionForNetworkSecurityGroupsSecurityRule_STATUS); ok {
		err := augmentedRule.AssignPropertiesTo(destination)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesTo() for conversion")
		}
	}

	// No error
	return nil
}

// Storage version of v1api20201101.ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded
// An application security group in a resource group.
type ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded struct {
	Id          *string                `json:"id,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// 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 {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(source.PropertyBag)

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

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

	// Invoke the augmentConversionForApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded interface (if implemented) to customize the conversion
	var embeddedAsAny any = embedded
	if augmentedEmbedded, ok := embeddedAsAny.(augmentConversionForApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded); ok {
		err := augmentedEmbedded.AssignPropertiesFrom(source)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesFrom() for conversion")
		}
	}

	// 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 {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(embedded.PropertyBag)

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

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

	// Invoke the augmentConversionForApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded interface (if implemented) to customize the conversion
	var embeddedAsAny any = embedded
	if augmentedEmbedded, ok := embeddedAsAny.(augmentConversionForApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded); ok {
		err := augmentedEmbedded.AssignPropertiesTo(destination)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesTo() for conversion")
		}
	}

	// No error
	return nil
}

// Storage version of v1api20201101.ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded
// An application security group in a resource group.
type ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded struct {
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`

	// Reference: Resource ID.
	Reference *genruntime.ResourceReference `armReference:"Id" json:"reference,omitempty"`
}

// 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 {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(source.PropertyBag)

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

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

	// Invoke the augmentConversionForApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded interface (if implemented) to customize the conversion
	var embeddedAsAny any = embedded
	if augmentedEmbedded, ok := embeddedAsAny.(augmentConversionForApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded); ok {
		err := augmentedEmbedded.AssignPropertiesFrom(source)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesFrom() for conversion")
		}
	}

	// 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 {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(embedded.PropertyBag)

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

	// Invoke the augmentConversionForApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded interface (if implemented) to customize the conversion
	var embeddedAsAny any = embedded
	if augmentedEmbedded, ok := embeddedAsAny.(augmentConversionForApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded); ok {
		err := augmentedEmbedded.AssignPropertiesTo(destination)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesTo() for conversion")
		}
	}

	// No error
	return nil
}

type augmentConversionForNetworkSecurityGroupsSecurityRule_Spec interface {
	AssignPropertiesFrom(src *storage.NetworkSecurityGroupsSecurityRule_Spec) error
	AssignPropertiesTo(dst *storage.NetworkSecurityGroupsSecurityRule_Spec) error
}

type augmentConversionForNetworkSecurityGroupsSecurityRule_STATUS interface {
	AssignPropertiesFrom(src *storage.NetworkSecurityGroupsSecurityRule_STATUS) error
	AssignPropertiesTo(dst *storage.NetworkSecurityGroupsSecurityRule_STATUS) error
}

// Storage version of v1api20201101.NetworkSecurityGroupsSecurityRuleOperatorSpec
// 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 []*core.DestinationExpression `json:"configMapExpressions,omitempty"`
	PropertyBag          genruntime.PropertyBag        `json:"$propertyBag,omitempty"`
	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 {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(source.PropertyBag)

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

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

	// Invoke the augmentConversionForNetworkSecurityGroupsSecurityRuleOperatorSpec interface (if implemented) to customize the conversion
	var operatorAsAny any = operator
	if augmentedOperator, ok := operatorAsAny.(augmentConversionForNetworkSecurityGroupsSecurityRuleOperatorSpec); ok {
		err := augmentedOperator.AssignPropertiesFrom(source)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesFrom() for conversion")
		}
	}

	// 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 {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(operator.PropertyBag)

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

	// Invoke the augmentConversionForNetworkSecurityGroupsSecurityRuleOperatorSpec interface (if implemented) to customize the conversion
	var operatorAsAny any = operator
	if augmentedOperator, ok := operatorAsAny.(augmentConversionForNetworkSecurityGroupsSecurityRuleOperatorSpec); ok {
		err := augmentedOperator.AssignPropertiesTo(destination)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesTo() for conversion")
		}
	}

	// No error
	return nil
}

type augmentConversionForApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded interface {
	AssignPropertiesFrom(src *storage.ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded) error
	AssignPropertiesTo(dst *storage.ApplicationSecurityGroup_STATUS_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded) error
}

type augmentConversionForApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded interface {
	AssignPropertiesFrom(src *storage.ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded) error
	AssignPropertiesTo(dst *storage.ApplicationSecurityGroupSpec_NetworkSecurityGroups_SecurityRule_SubResourceEmbedded) error
}

type augmentConversionForNetworkSecurityGroupsSecurityRuleOperatorSpec interface {
	AssignPropertiesFrom(src *storage.NetworkSecurityGroupsSecurityRuleOperatorSpec) error
	AssignPropertiesTo(dst *storage.NetworkSecurityGroupsSecurityRuleOperatorSpec) error
}

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