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

import (
	"fmt"
	arm "github.com/Azure/azure-service-operator/v2/api/servicebus/v1api20210101preview/arm"
	storage "github.com/Azure/azure-service-operator/v2/api/servicebus/v1api20210101preview/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,servicebus}
// +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: /servicebus/resource-manager/Microsoft.ServiceBus/ServiceBus/preview/2021-01-01-preview/topics.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}
type NamespacesTopic struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              NamespacesTopic_Spec   `json:"spec,omitempty"`
	Status            NamespacesTopic_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &NamespacesTopic{}

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

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

var _ conversion.Convertible = &NamespacesTopic{}

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

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

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

	return nil
}

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

	return nil
}

var _ configmaps.Exporter = &NamespacesTopic{}

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

var _ secrets.Exporter = &NamespacesTopic{}

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

var _ genruntime.KubernetesResource = &NamespacesTopic{}

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

// GetAPIVersion returns the ARM API version of the resource. This is always "2021-01-01-preview"
func (topic NamespacesTopic) GetAPIVersion() string {
	return "2021-01-01-preview"
}

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

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

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

// GetSupportedOperations returns the operations supported by the resource
func (topic *NamespacesTopic) GetSupportedOperations() []genruntime.ResourceOperation {
	return []genruntime.ResourceOperation{
		genruntime.ResourceOperationDelete,
		genruntime.ResourceOperationGet,
		genruntime.ResourceOperationPut,
	}
}

// GetType returns the ARM Type of the resource. This is always "Microsoft.ServiceBus/namespaces/topics"
func (topic *NamespacesTopic) GetType() string {
	return "Microsoft.ServiceBus/namespaces/topics"
}

// NewEmptyStatus returns a new empty (blank) status
func (topic *NamespacesTopic) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &NamespacesTopic_STATUS{}
}

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

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

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

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

	topic.Status = st
	return nil
}

// AssignProperties_From_NamespacesTopic populates our NamespacesTopic from the provided source NamespacesTopic
func (topic *NamespacesTopic) AssignProperties_From_NamespacesTopic(source *storage.NamespacesTopic) error {

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

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

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

	// No error
	return nil
}

// AssignProperties_To_NamespacesTopic populates the provided destination NamespacesTopic from our NamespacesTopic
func (topic *NamespacesTopic) AssignProperties_To_NamespacesTopic(destination *storage.NamespacesTopic) error {

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

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

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

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /servicebus/resource-manager/Microsoft.ServiceBus/ServiceBus/preview/2021-01-01-preview/topics.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}
type NamespacesTopicList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []NamespacesTopic `json:"items"`
}

type NamespacesTopic_Spec struct {
	// AutoDeleteOnIdle: ISO 8601 timespan idle interval after which the topic is automatically deleted. The minimum duration
	// is 5 minutes.
	AutoDeleteOnIdle *string `json:"autoDeleteOnIdle,omitempty"`

	// +kubebuilder:validation:MinLength=1
	// 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"`

	// DefaultMessageTimeToLive: ISO 8601 Default message timespan to live value. This is the duration after which the message
	// expires, starting from when the message is sent to Service Bus. This is the default value used when TimeToLive is not
	// set on a message itself.
	DefaultMessageTimeToLive *string `json:"defaultMessageTimeToLive,omitempty"`

	// DuplicateDetectionHistoryTimeWindow: ISO8601 timespan structure that defines the duration of the duplicate detection
	// history. The default value is 10 minutes.
	DuplicateDetectionHistoryTimeWindow *string `json:"duplicateDetectionHistoryTimeWindow,omitempty"`

	// EnableBatchedOperations: Value that indicates whether server-side batched operations are enabled.
	EnableBatchedOperations *bool `json:"enableBatchedOperations,omitempty"`

	// EnableExpress: Value that indicates whether Express Entities are enabled. An express topic holds a message in memory
	// temporarily before writing it to persistent storage.
	EnableExpress *bool `json:"enableExpress,omitempty"`

	// EnablePartitioning: Value that indicates whether the topic to be partitioned across multiple message brokers is enabled.
	EnablePartitioning *bool `json:"enablePartitioning,omitempty"`

	// MaxSizeInMegabytes: Maximum size of the topic in megabytes, which is the size of the memory allocated for the topic.
	// Default is 1024.
	MaxSizeInMegabytes *int `json:"maxSizeInMegabytes,omitempty"`

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

	// RequiresDuplicateDetection: Value indicating if this topic requires duplicate detection.
	RequiresDuplicateDetection *bool `json:"requiresDuplicateDetection,omitempty"`

	// SupportOrdering: Value that indicates whether the topic supports ordering.
	SupportOrdering *bool `json:"supportOrdering,omitempty"`
}

var _ genruntime.ARMTransformer = &NamespacesTopic_Spec{}

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

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

	// Set property "Properties":
	if topic.AutoDeleteOnIdle != nil ||
		topic.DefaultMessageTimeToLive != nil ||
		topic.DuplicateDetectionHistoryTimeWindow != nil ||
		topic.EnableBatchedOperations != nil ||
		topic.EnableExpress != nil ||
		topic.EnablePartitioning != nil ||
		topic.MaxSizeInMegabytes != nil ||
		topic.RequiresDuplicateDetection != nil ||
		topic.SupportOrdering != nil {
		result.Properties = &arm.SBTopicProperties{}
	}
	if topic.AutoDeleteOnIdle != nil {
		autoDeleteOnIdle := *topic.AutoDeleteOnIdle
		result.Properties.AutoDeleteOnIdle = &autoDeleteOnIdle
	}
	if topic.DefaultMessageTimeToLive != nil {
		defaultMessageTimeToLive := *topic.DefaultMessageTimeToLive
		result.Properties.DefaultMessageTimeToLive = &defaultMessageTimeToLive
	}
	if topic.DuplicateDetectionHistoryTimeWindow != nil {
		duplicateDetectionHistoryTimeWindow := *topic.DuplicateDetectionHistoryTimeWindow
		result.Properties.DuplicateDetectionHistoryTimeWindow = &duplicateDetectionHistoryTimeWindow
	}
	if topic.EnableBatchedOperations != nil {
		enableBatchedOperations := *topic.EnableBatchedOperations
		result.Properties.EnableBatchedOperations = &enableBatchedOperations
	}
	if topic.EnableExpress != nil {
		enableExpress := *topic.EnableExpress
		result.Properties.EnableExpress = &enableExpress
	}
	if topic.EnablePartitioning != nil {
		enablePartitioning := *topic.EnablePartitioning
		result.Properties.EnablePartitioning = &enablePartitioning
	}
	if topic.MaxSizeInMegabytes != nil {
		maxSizeInMegabytes := *topic.MaxSizeInMegabytes
		result.Properties.MaxSizeInMegabytes = &maxSizeInMegabytes
	}
	if topic.RequiresDuplicateDetection != nil {
		requiresDuplicateDetection := *topic.RequiresDuplicateDetection
		result.Properties.RequiresDuplicateDetection = &requiresDuplicateDetection
	}
	if topic.SupportOrdering != nil {
		supportOrdering := *topic.SupportOrdering
		result.Properties.SupportOrdering = &supportOrdering
	}
	return result, nil
}

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

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

	// Set property "AutoDeleteOnIdle":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.AutoDeleteOnIdle != nil {
			autoDeleteOnIdle := *typedInput.Properties.AutoDeleteOnIdle
			topic.AutoDeleteOnIdle = &autoDeleteOnIdle
		}
	}

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

	// Set property "DefaultMessageTimeToLive":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.DefaultMessageTimeToLive != nil {
			defaultMessageTimeToLive := *typedInput.Properties.DefaultMessageTimeToLive
			topic.DefaultMessageTimeToLive = &defaultMessageTimeToLive
		}
	}

	// Set property "DuplicateDetectionHistoryTimeWindow":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.DuplicateDetectionHistoryTimeWindow != nil {
			duplicateDetectionHistoryTimeWindow := *typedInput.Properties.DuplicateDetectionHistoryTimeWindow
			topic.DuplicateDetectionHistoryTimeWindow = &duplicateDetectionHistoryTimeWindow
		}
	}

	// Set property "EnableBatchedOperations":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.EnableBatchedOperations != nil {
			enableBatchedOperations := *typedInput.Properties.EnableBatchedOperations
			topic.EnableBatchedOperations = &enableBatchedOperations
		}
	}

	// Set property "EnableExpress":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.EnableExpress != nil {
			enableExpress := *typedInput.Properties.EnableExpress
			topic.EnableExpress = &enableExpress
		}
	}

	// Set property "EnablePartitioning":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.EnablePartitioning != nil {
			enablePartitioning := *typedInput.Properties.EnablePartitioning
			topic.EnablePartitioning = &enablePartitioning
		}
	}

	// Set property "MaxSizeInMegabytes":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.MaxSizeInMegabytes != nil {
			maxSizeInMegabytes := *typedInput.Properties.MaxSizeInMegabytes
			topic.MaxSizeInMegabytes = &maxSizeInMegabytes
		}
	}

	// no assignment for property "OperatorSpec"

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

	// Set property "RequiresDuplicateDetection":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.RequiresDuplicateDetection != nil {
			requiresDuplicateDetection := *typedInput.Properties.RequiresDuplicateDetection
			topic.RequiresDuplicateDetection = &requiresDuplicateDetection
		}
	}

	// Set property "SupportOrdering":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.SupportOrdering != nil {
			supportOrdering := *typedInput.Properties.SupportOrdering
			topic.SupportOrdering = &supportOrdering
		}
	}

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &NamespacesTopic_Spec{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.NamespacesTopic_Spec{}
	err := topic.AssignProperties_To_NamespacesTopic_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_NamespacesTopic_Spec populates our NamespacesTopic_Spec from the provided source NamespacesTopic_Spec
func (topic *NamespacesTopic_Spec) AssignProperties_From_NamespacesTopic_Spec(source *storage.NamespacesTopic_Spec) error {

	// AutoDeleteOnIdle
	topic.AutoDeleteOnIdle = genruntime.ClonePointerToString(source.AutoDeleteOnIdle)

	// AzureName
	topic.AzureName = source.AzureName

	// DefaultMessageTimeToLive
	topic.DefaultMessageTimeToLive = genruntime.ClonePointerToString(source.DefaultMessageTimeToLive)

	// DuplicateDetectionHistoryTimeWindow
	topic.DuplicateDetectionHistoryTimeWindow = genruntime.ClonePointerToString(source.DuplicateDetectionHistoryTimeWindow)

	// EnableBatchedOperations
	if source.EnableBatchedOperations != nil {
		enableBatchedOperation := *source.EnableBatchedOperations
		topic.EnableBatchedOperations = &enableBatchedOperation
	} else {
		topic.EnableBatchedOperations = nil
	}

	// EnableExpress
	if source.EnableExpress != nil {
		enableExpress := *source.EnableExpress
		topic.EnableExpress = &enableExpress
	} else {
		topic.EnableExpress = nil
	}

	// EnablePartitioning
	if source.EnablePartitioning != nil {
		enablePartitioning := *source.EnablePartitioning
		topic.EnablePartitioning = &enablePartitioning
	} else {
		topic.EnablePartitioning = nil
	}

	// MaxSizeInMegabytes
	topic.MaxSizeInMegabytes = genruntime.ClonePointerToInt(source.MaxSizeInMegabytes)

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

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

	// RequiresDuplicateDetection
	if source.RequiresDuplicateDetection != nil {
		requiresDuplicateDetection := *source.RequiresDuplicateDetection
		topic.RequiresDuplicateDetection = &requiresDuplicateDetection
	} else {
		topic.RequiresDuplicateDetection = nil
	}

	// SupportOrdering
	if source.SupportOrdering != nil {
		supportOrdering := *source.SupportOrdering
		topic.SupportOrdering = &supportOrdering
	} else {
		topic.SupportOrdering = nil
	}

	// No error
	return nil
}

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

	// AutoDeleteOnIdle
	destination.AutoDeleteOnIdle = genruntime.ClonePointerToString(topic.AutoDeleteOnIdle)

	// AzureName
	destination.AzureName = topic.AzureName

	// DefaultMessageTimeToLive
	destination.DefaultMessageTimeToLive = genruntime.ClonePointerToString(topic.DefaultMessageTimeToLive)

	// DuplicateDetectionHistoryTimeWindow
	destination.DuplicateDetectionHistoryTimeWindow = genruntime.ClonePointerToString(topic.DuplicateDetectionHistoryTimeWindow)

	// EnableBatchedOperations
	if topic.EnableBatchedOperations != nil {
		enableBatchedOperation := *topic.EnableBatchedOperations
		destination.EnableBatchedOperations = &enableBatchedOperation
	} else {
		destination.EnableBatchedOperations = nil
	}

	// EnableExpress
	if topic.EnableExpress != nil {
		enableExpress := *topic.EnableExpress
		destination.EnableExpress = &enableExpress
	} else {
		destination.EnableExpress = nil
	}

	// EnablePartitioning
	if topic.EnablePartitioning != nil {
		enablePartitioning := *topic.EnablePartitioning
		destination.EnablePartitioning = &enablePartitioning
	} else {
		destination.EnablePartitioning = nil
	}

	// MaxSizeInMegabytes
	destination.MaxSizeInMegabytes = genruntime.ClonePointerToInt(topic.MaxSizeInMegabytes)

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

	// OriginalVersion
	destination.OriginalVersion = topic.OriginalVersion()

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

	// RequiresDuplicateDetection
	if topic.RequiresDuplicateDetection != nil {
		requiresDuplicateDetection := *topic.RequiresDuplicateDetection
		destination.RequiresDuplicateDetection = &requiresDuplicateDetection
	} else {
		destination.RequiresDuplicateDetection = nil
	}

	// SupportOrdering
	if topic.SupportOrdering != nil {
		supportOrdering := *topic.SupportOrdering
		destination.SupportOrdering = &supportOrdering
	} else {
		destination.SupportOrdering = nil
	}

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

	// No error
	return nil
}

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

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

type NamespacesTopic_STATUS struct {
	// AccessedAt: Last time the message was sent, or a request was received, for this topic.
	AccessedAt *string `json:"accessedAt,omitempty"`

	// AutoDeleteOnIdle: ISO 8601 timespan idle interval after which the topic is automatically deleted. The minimum duration
	// is 5 minutes.
	AutoDeleteOnIdle *string `json:"autoDeleteOnIdle,omitempty"`

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

	// CountDetails: Message count details
	CountDetails *MessageCountDetails_STATUS `json:"countDetails,omitempty"`

	// CreatedAt: Exact time the message was created.
	CreatedAt *string `json:"createdAt,omitempty"`

	// DefaultMessageTimeToLive: ISO 8601 Default message timespan to live value. This is the duration after which the message
	// expires, starting from when the message is sent to Service Bus. This is the default value used when TimeToLive is not
	// set on a message itself.
	DefaultMessageTimeToLive *string `json:"defaultMessageTimeToLive,omitempty"`

	// DuplicateDetectionHistoryTimeWindow: ISO8601 timespan structure that defines the duration of the duplicate detection
	// history. The default value is 10 minutes.
	DuplicateDetectionHistoryTimeWindow *string `json:"duplicateDetectionHistoryTimeWindow,omitempty"`

	// EnableBatchedOperations: Value that indicates whether server-side batched operations are enabled.
	EnableBatchedOperations *bool `json:"enableBatchedOperations,omitempty"`

	// EnableExpress: Value that indicates whether Express Entities are enabled. An express topic holds a message in memory
	// temporarily before writing it to persistent storage.
	EnableExpress *bool `json:"enableExpress,omitempty"`

	// EnablePartitioning: Value that indicates whether the topic to be partitioned across multiple message brokers is enabled.
	EnablePartitioning *bool `json:"enablePartitioning,omitempty"`

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

	// MaxSizeInMegabytes: Maximum size of the topic in megabytes, which is the size of the memory allocated for the topic.
	// Default is 1024.
	MaxSizeInMegabytes *int `json:"maxSizeInMegabytes,omitempty"`

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

	// RequiresDuplicateDetection: Value indicating if this topic requires duplicate detection.
	RequiresDuplicateDetection *bool `json:"requiresDuplicateDetection,omitempty"`

	// SizeInBytes: Size of the topic, in bytes.
	SizeInBytes *int `json:"sizeInBytes,omitempty"`

	// Status: Enumerates the possible values for the status of a messaging entity.
	Status *EntityStatus_STATUS `json:"status,omitempty"`

	// SubscriptionCount: Number of subscriptions.
	SubscriptionCount *int `json:"subscriptionCount,omitempty"`

	// SupportOrdering: Value that indicates whether the topic supports ordering.
	SupportOrdering *bool `json:"supportOrdering,omitempty"`

	// SystemData: The system meta data relating to this resource.
	SystemData *SystemData_STATUS `json:"systemData,omitempty"`

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

	// UpdatedAt: The exact time the message was updated.
	UpdatedAt *string `json:"updatedAt,omitempty"`
}

var _ genruntime.ConvertibleStatus = &NamespacesTopic_STATUS{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.NamespacesTopic_STATUS{}
	err := topic.AssignProperties_To_NamespacesTopic_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 = &NamespacesTopic_STATUS{}

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

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

	// Set property "AccessedAt":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.AccessedAt != nil {
			accessedAt := *typedInput.Properties.AccessedAt
			topic.AccessedAt = &accessedAt
		}
	}

	// Set property "AutoDeleteOnIdle":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.AutoDeleteOnIdle != nil {
			autoDeleteOnIdle := *typedInput.Properties.AutoDeleteOnIdle
			topic.AutoDeleteOnIdle = &autoDeleteOnIdle
		}
	}

	// no assignment for property "Conditions"

	// Set property "CountDetails":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.CountDetails != nil {
			var countDetails1 MessageCountDetails_STATUS
			err := countDetails1.PopulateFromARM(owner, *typedInput.Properties.CountDetails)
			if err != nil {
				return err
			}
			countDetails := countDetails1
			topic.CountDetails = &countDetails
		}
	}

	// Set property "CreatedAt":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.CreatedAt != nil {
			createdAt := *typedInput.Properties.CreatedAt
			topic.CreatedAt = &createdAt
		}
	}

	// Set property "DefaultMessageTimeToLive":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.DefaultMessageTimeToLive != nil {
			defaultMessageTimeToLive := *typedInput.Properties.DefaultMessageTimeToLive
			topic.DefaultMessageTimeToLive = &defaultMessageTimeToLive
		}
	}

	// Set property "DuplicateDetectionHistoryTimeWindow":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.DuplicateDetectionHistoryTimeWindow != nil {
			duplicateDetectionHistoryTimeWindow := *typedInput.Properties.DuplicateDetectionHistoryTimeWindow
			topic.DuplicateDetectionHistoryTimeWindow = &duplicateDetectionHistoryTimeWindow
		}
	}

	// Set property "EnableBatchedOperations":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.EnableBatchedOperations != nil {
			enableBatchedOperations := *typedInput.Properties.EnableBatchedOperations
			topic.EnableBatchedOperations = &enableBatchedOperations
		}
	}

	// Set property "EnableExpress":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.EnableExpress != nil {
			enableExpress := *typedInput.Properties.EnableExpress
			topic.EnableExpress = &enableExpress
		}
	}

	// Set property "EnablePartitioning":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.EnablePartitioning != nil {
			enablePartitioning := *typedInput.Properties.EnablePartitioning
			topic.EnablePartitioning = &enablePartitioning
		}
	}

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

	// Set property "MaxSizeInMegabytes":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.MaxSizeInMegabytes != nil {
			maxSizeInMegabytes := *typedInput.Properties.MaxSizeInMegabytes
			topic.MaxSizeInMegabytes = &maxSizeInMegabytes
		}
	}

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

	// Set property "RequiresDuplicateDetection":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.RequiresDuplicateDetection != nil {
			requiresDuplicateDetection := *typedInput.Properties.RequiresDuplicateDetection
			topic.RequiresDuplicateDetection = &requiresDuplicateDetection
		}
	}

	// Set property "SizeInBytes":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.SizeInBytes != nil {
			sizeInBytes := *typedInput.Properties.SizeInBytes
			topic.SizeInBytes = &sizeInBytes
		}
	}

	// Set property "Status":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Status != nil {
			var temp string
			temp = string(*typedInput.Properties.Status)
			status := EntityStatus_STATUS(temp)
			topic.Status = &status
		}
	}

	// Set property "SubscriptionCount":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.SubscriptionCount != nil {
			subscriptionCount := *typedInput.Properties.SubscriptionCount
			topic.SubscriptionCount = &subscriptionCount
		}
	}

	// Set property "SupportOrdering":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.SupportOrdering != nil {
			supportOrdering := *typedInput.Properties.SupportOrdering
			topic.SupportOrdering = &supportOrdering
		}
	}

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

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

	// Set property "UpdatedAt":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.UpdatedAt != nil {
			updatedAt := *typedInput.Properties.UpdatedAt
			topic.UpdatedAt = &updatedAt
		}
	}

	// No error
	return nil
}

// AssignProperties_From_NamespacesTopic_STATUS populates our NamespacesTopic_STATUS from the provided source NamespacesTopic_STATUS
func (topic *NamespacesTopic_STATUS) AssignProperties_From_NamespacesTopic_STATUS(source *storage.NamespacesTopic_STATUS) error {

	// AccessedAt
	topic.AccessedAt = genruntime.ClonePointerToString(source.AccessedAt)

	// AutoDeleteOnIdle
	topic.AutoDeleteOnIdle = genruntime.ClonePointerToString(source.AutoDeleteOnIdle)

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

	// CountDetails
	if source.CountDetails != nil {
		var countDetail MessageCountDetails_STATUS
		err := countDetail.AssignProperties_From_MessageCountDetails_STATUS(source.CountDetails)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_MessageCountDetails_STATUS() to populate field CountDetails")
		}
		topic.CountDetails = &countDetail
	} else {
		topic.CountDetails = nil
	}

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

	// DefaultMessageTimeToLive
	topic.DefaultMessageTimeToLive = genruntime.ClonePointerToString(source.DefaultMessageTimeToLive)

	// DuplicateDetectionHistoryTimeWindow
	topic.DuplicateDetectionHistoryTimeWindow = genruntime.ClonePointerToString(source.DuplicateDetectionHistoryTimeWindow)

	// EnableBatchedOperations
	if source.EnableBatchedOperations != nil {
		enableBatchedOperation := *source.EnableBatchedOperations
		topic.EnableBatchedOperations = &enableBatchedOperation
	} else {
		topic.EnableBatchedOperations = nil
	}

	// EnableExpress
	if source.EnableExpress != nil {
		enableExpress := *source.EnableExpress
		topic.EnableExpress = &enableExpress
	} else {
		topic.EnableExpress = nil
	}

	// EnablePartitioning
	if source.EnablePartitioning != nil {
		enablePartitioning := *source.EnablePartitioning
		topic.EnablePartitioning = &enablePartitioning
	} else {
		topic.EnablePartitioning = nil
	}

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

	// MaxSizeInMegabytes
	topic.MaxSizeInMegabytes = genruntime.ClonePointerToInt(source.MaxSizeInMegabytes)

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

	// RequiresDuplicateDetection
	if source.RequiresDuplicateDetection != nil {
		requiresDuplicateDetection := *source.RequiresDuplicateDetection
		topic.RequiresDuplicateDetection = &requiresDuplicateDetection
	} else {
		topic.RequiresDuplicateDetection = nil
	}

	// SizeInBytes
	topic.SizeInBytes = genruntime.ClonePointerToInt(source.SizeInBytes)

	// Status
	if source.Status != nil {
		status := *source.Status
		statusTemp := genruntime.ToEnum(status, entityStatus_STATUS_Values)
		topic.Status = &statusTemp
	} else {
		topic.Status = nil
	}

	// SubscriptionCount
	topic.SubscriptionCount = genruntime.ClonePointerToInt(source.SubscriptionCount)

	// SupportOrdering
	if source.SupportOrdering != nil {
		supportOrdering := *source.SupportOrdering
		topic.SupportOrdering = &supportOrdering
	} else {
		topic.SupportOrdering = nil
	}

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

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

	// UpdatedAt
	topic.UpdatedAt = genruntime.ClonePointerToString(source.UpdatedAt)

	// No error
	return nil
}

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

	// AccessedAt
	destination.AccessedAt = genruntime.ClonePointerToString(topic.AccessedAt)

	// AutoDeleteOnIdle
	destination.AutoDeleteOnIdle = genruntime.ClonePointerToString(topic.AutoDeleteOnIdle)

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

	// CountDetails
	if topic.CountDetails != nil {
		var countDetail storage.MessageCountDetails_STATUS
		err := topic.CountDetails.AssignProperties_To_MessageCountDetails_STATUS(&countDetail)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_MessageCountDetails_STATUS() to populate field CountDetails")
		}
		destination.CountDetails = &countDetail
	} else {
		destination.CountDetails = nil
	}

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

	// DefaultMessageTimeToLive
	destination.DefaultMessageTimeToLive = genruntime.ClonePointerToString(topic.DefaultMessageTimeToLive)

	// DuplicateDetectionHistoryTimeWindow
	destination.DuplicateDetectionHistoryTimeWindow = genruntime.ClonePointerToString(topic.DuplicateDetectionHistoryTimeWindow)

	// EnableBatchedOperations
	if topic.EnableBatchedOperations != nil {
		enableBatchedOperation := *topic.EnableBatchedOperations
		destination.EnableBatchedOperations = &enableBatchedOperation
	} else {
		destination.EnableBatchedOperations = nil
	}

	// EnableExpress
	if topic.EnableExpress != nil {
		enableExpress := *topic.EnableExpress
		destination.EnableExpress = &enableExpress
	} else {
		destination.EnableExpress = nil
	}

	// EnablePartitioning
	if topic.EnablePartitioning != nil {
		enablePartitioning := *topic.EnablePartitioning
		destination.EnablePartitioning = &enablePartitioning
	} else {
		destination.EnablePartitioning = nil
	}

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

	// MaxSizeInMegabytes
	destination.MaxSizeInMegabytes = genruntime.ClonePointerToInt(topic.MaxSizeInMegabytes)

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

	// RequiresDuplicateDetection
	if topic.RequiresDuplicateDetection != nil {
		requiresDuplicateDetection := *topic.RequiresDuplicateDetection
		destination.RequiresDuplicateDetection = &requiresDuplicateDetection
	} else {
		destination.RequiresDuplicateDetection = nil
	}

	// SizeInBytes
	destination.SizeInBytes = genruntime.ClonePointerToInt(topic.SizeInBytes)

	// Status
	if topic.Status != nil {
		status := string(*topic.Status)
		destination.Status = &status
	} else {
		destination.Status = nil
	}

	// SubscriptionCount
	destination.SubscriptionCount = genruntime.ClonePointerToInt(topic.SubscriptionCount)

	// SupportOrdering
	if topic.SupportOrdering != nil {
		supportOrdering := *topic.SupportOrdering
		destination.SupportOrdering = &supportOrdering
	} else {
		destination.SupportOrdering = nil
	}

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

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

	// UpdatedAt
	destination.UpdatedAt = genruntime.ClonePointerToString(topic.UpdatedAt)

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

	// No error
	return nil
}

// Details for configuring operator behavior. Fields in this struct are interpreted by the operator directly rather than being passed to Azure
type NamespacesTopicOperatorSpec 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_NamespacesTopicOperatorSpec populates our NamespacesTopicOperatorSpec from the provided source NamespacesTopicOperatorSpec
func (operator *NamespacesTopicOperatorSpec) AssignProperties_From_NamespacesTopicOperatorSpec(source *storage.NamespacesTopicOperatorSpec) 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_NamespacesTopicOperatorSpec populates the provided destination NamespacesTopicOperatorSpec from our NamespacesTopicOperatorSpec
func (operator *NamespacesTopicOperatorSpec) AssignProperties_To_NamespacesTopicOperatorSpec(destination *storage.NamespacesTopicOperatorSpec) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// ConfigMapExpressions
	if operator.ConfigMapExpressions != nil {
		configMapExpressionList := make([]*core.DestinationExpression, len(operator.ConfigMapExpressions))
		for configMapExpressionIndex, configMapExpressionItem := range operator.ConfigMapExpressions {
			if configMapExpressionItem != nil {
				configMapExpression := *configMapExpressionItem.DeepCopy()
				configMapExpressionList[configMapExpressionIndex] = &configMapExpression
			} else {
				configMapExpressionList[configMapExpressionIndex] = nil
			}
		}
		destination.ConfigMapExpressions = configMapExpressionList
	} else {
		destination.ConfigMapExpressions = nil
	}

	// SecretExpressions
	if operator.SecretExpressions != nil {
		secretExpressionList := make([]*core.DestinationExpression, len(operator.SecretExpressions))
		for secretExpressionIndex, secretExpressionItem := range operator.SecretExpressions {
			if secretExpressionItem != nil {
				secretExpression := *secretExpressionItem.DeepCopy()
				secretExpressionList[secretExpressionIndex] = &secretExpression
			} else {
				secretExpressionList[secretExpressionIndex] = nil
			}
		}
		destination.SecretExpressions = secretExpressionList
	} else {
		destination.SecretExpressions = nil
	}

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

	// No error
	return nil
}

func init() {
	SchemeBuilder.Register(&NamespacesTopic{}, &NamespacesTopicList{})
}
