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

import (
	"context"
	"fmt"
	arm "github.com/Azure/azure-service-operator/v2/api/eventgrid/v1api20200601/arm"
	storage "github.com/Azure/azure-service-operator/v2/api/eventgrid/v1api20200601/storage"
	"github.com/Azure/azure-service-operator/v2/internal/genericarmclient"
	"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/go-logr/logr"
	"github.com/rotisserie/eris"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/runtime/schema"
	"sigs.k8s.io/controller-runtime/pkg/client"
	"sigs.k8s.io/controller-runtime/pkg/conversion"
)

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,eventgrid}
// +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: /eventgrid/resource-manager/Microsoft.EventGrid/stable/2020-06-01/EventGrid.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}
type Topic struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              Topic_Spec   `json:"spec,omitempty"`
	Status            Topic_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &Topic{}

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

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

var _ conversion.Convertible = &Topic{}

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

	return topic.AssignProperties_From_Topic(source)
}

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

	return topic.AssignProperties_To_Topic(destination)
}

var _ configmaps.Exporter = &Topic{}

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

var _ secrets.Exporter = &Topic{}

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

var _ genruntime.ImportableResource = &Topic{}

// InitializeSpec initializes the spec for this resource from the given status
func (topic *Topic) InitializeSpec(status genruntime.ConvertibleStatus) error {
	if s, ok := status.(*Topic_STATUS); ok {
		return topic.Spec.Initialize_From_Topic_STATUS(s)
	}

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

var _ genruntime.KubernetesConfigExporter = &Topic{}

// ExportKubernetesConfigMaps defines a resource which can create ConfigMaps in Kubernetes.
func (topic *Topic) ExportKubernetesConfigMaps(_ context.Context, _ genruntime.MetaObject, _ *genericarmclient.GenericClient, _ logr.Logger) ([]client.Object, error) {
	collector := configmaps.NewCollector(topic.Namespace)
	if topic.Spec.OperatorSpec != nil && topic.Spec.OperatorSpec.ConfigMaps != nil {
		if topic.Status.Endpoint != nil {
			collector.AddValue(topic.Spec.OperatorSpec.ConfigMaps.Endpoint, *topic.Status.Endpoint)
		}
	}
	result, err := collector.Values()
	if err != nil {
		return nil, err
	}
	return configmaps.SliceToClientObjectSlice(result), nil
}

var _ genruntime.KubernetesResource = &Topic{}

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

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

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

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

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

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

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

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

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

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

	topic.Status = st
	return nil
}

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

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

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

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

	// No error
	return nil
}

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

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

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

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

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /eventgrid/resource-manager/Microsoft.EventGrid/stable/2020-06-01/EventGrid.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}
type TopicList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []Topic `json:"items"`
}

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

	// InboundIpRules: This can be used to restrict traffic from specific IPs instead of all IPs. Note: These are considered
	// only if PublicNetworkAccess is enabled.
	InboundIpRules []InboundIpRule `json:"inboundIpRules,omitempty"`

	// InputSchema: This determines the format that Event Grid should expect for incoming events published to the topic.
	InputSchema *TopicProperties_InputSchema `json:"inputSchema,omitempty"`

	// InputSchemaMapping: This enables publishing using custom event schemas. An InputSchemaMapping can be specified to map
	// various properties of a source schema to various required properties of the EventGridEvent schema.
	InputSchemaMapping *InputSchemaMapping `json:"inputSchemaMapping,omitempty"`

	// +kubebuilder:validation:Required
	// Location: Location of the resource.
	Location *string `json:"location,omitempty"`

	// OperatorSpec: The specification for configuring operator behavior. This field is interpreted by the operator and not
	// passed directly to Azure
	OperatorSpec *TopicOperatorSpec `json:"operatorSpec,omitempty"`

	// +kubebuilder:validation:Required
	// Owner: The owner of the resource. The owner controls where the resource goes when it is deployed. The owner also
	// controls the resources lifecycle. When the owner is deleted the resource will also be deleted. Owner is expected to be a
	// reference to a resources.azure.com/ResourceGroup resource
	Owner *genruntime.KnownResourceReference `group:"resources.azure.com" json:"owner,omitempty" kind:"ResourceGroup"`

	// PublicNetworkAccess: This determines if traffic is allowed over public network. By default it is enabled.
	// You can further restrict to specific IPs by configuring <seealso
	// cref="P:Microsoft.Azure.Events.ResourceProvider.Common.Contracts.TopicProperties.InboundIpRules" />
	PublicNetworkAccess *TopicProperties_PublicNetworkAccess `json:"publicNetworkAccess,omitempty"`

	// Tags: Tags of the resource.
	Tags map[string]string `json:"tags,omitempty"`
}

var _ genruntime.ARMTransformer = &Topic_Spec{}

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

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

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

	// Set property "Properties":
	if topic.InboundIpRules != nil ||
		topic.InputSchema != nil ||
		topic.InputSchemaMapping != nil ||
		topic.PublicNetworkAccess != nil {
		result.Properties = &arm.TopicProperties{}
	}
	for _, item := range topic.InboundIpRules {
		item_ARM, err := item.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		result.Properties.InboundIpRules = append(result.Properties.InboundIpRules, *item_ARM.(*arm.InboundIpRule))
	}
	if topic.InputSchema != nil {
		var temp string
		temp = string(*topic.InputSchema)
		inputSchema := arm.TopicProperties_InputSchema(temp)
		result.Properties.InputSchema = &inputSchema
	}
	if topic.InputSchemaMapping != nil {
		inputSchemaMapping_ARM, err := topic.InputSchemaMapping.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		inputSchemaMapping := *inputSchemaMapping_ARM.(*arm.InputSchemaMapping)
		result.Properties.InputSchemaMapping = &inputSchemaMapping
	}
	if topic.PublicNetworkAccess != nil {
		var temp string
		temp = string(*topic.PublicNetworkAccess)
		publicNetworkAccess := arm.TopicProperties_PublicNetworkAccess(temp)
		result.Properties.PublicNetworkAccess = &publicNetworkAccess
	}

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

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

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

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

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

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

	// Set property "InputSchemaMapping":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.InputSchemaMapping != nil {
			var inputSchemaMapping1 InputSchemaMapping
			err := inputSchemaMapping1.PopulateFromARM(owner, *typedInput.Properties.InputSchemaMapping)
			if err != nil {
				return err
			}
			inputSchemaMapping := inputSchemaMapping1
			topic.InputSchemaMapping = &inputSchemaMapping
		}
	}

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

	// no assignment for property "OperatorSpec"

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

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

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

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &Topic_Spec{}

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

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

	return nil
}

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

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

	// AzureName
	topic.AzureName = source.AzureName

	// InboundIpRules
	if source.InboundIpRules != nil {
		inboundIpRuleList := make([]InboundIpRule, len(source.InboundIpRules))
		for inboundIpRuleIndex, inboundIpRuleItem := range source.InboundIpRules {
			var inboundIpRule InboundIpRule
			err := inboundIpRule.AssignProperties_From_InboundIpRule(&inboundIpRuleItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_InboundIpRule() to populate field InboundIpRules")
			}
			inboundIpRuleList[inboundIpRuleIndex] = inboundIpRule
		}
		topic.InboundIpRules = inboundIpRuleList
	} else {
		topic.InboundIpRules = nil
	}

	// InputSchema
	if source.InputSchema != nil {
		inputSchema := *source.InputSchema
		inputSchemaTemp := genruntime.ToEnum(inputSchema, topicProperties_InputSchema_Values)
		topic.InputSchema = &inputSchemaTemp
	} else {
		topic.InputSchema = nil
	}

	// InputSchemaMapping
	if source.InputSchemaMapping != nil {
		var inputSchemaMapping InputSchemaMapping
		err := inputSchemaMapping.AssignProperties_From_InputSchemaMapping(source.InputSchemaMapping)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_InputSchemaMapping() to populate field InputSchemaMapping")
		}
		topic.InputSchemaMapping = &inputSchemaMapping
	} else {
		topic.InputSchemaMapping = nil
	}

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

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

	// PublicNetworkAccess
	if source.PublicNetworkAccess != nil {
		publicNetworkAccess := *source.PublicNetworkAccess
		publicNetworkAccessTemp := genruntime.ToEnum(publicNetworkAccess, topicProperties_PublicNetworkAccess_Values)
		topic.PublicNetworkAccess = &publicNetworkAccessTemp
	} else {
		topic.PublicNetworkAccess = nil
	}

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

	// No error
	return nil
}

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

	// AzureName
	destination.AzureName = topic.AzureName

	// InboundIpRules
	if topic.InboundIpRules != nil {
		inboundIpRuleList := make([]storage.InboundIpRule, len(topic.InboundIpRules))
		for inboundIpRuleIndex, inboundIpRuleItem := range topic.InboundIpRules {
			var inboundIpRule storage.InboundIpRule
			err := inboundIpRuleItem.AssignProperties_To_InboundIpRule(&inboundIpRule)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_InboundIpRule() to populate field InboundIpRules")
			}
			inboundIpRuleList[inboundIpRuleIndex] = inboundIpRule
		}
		destination.InboundIpRules = inboundIpRuleList
	} else {
		destination.InboundIpRules = nil
	}

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

	// InputSchemaMapping
	if topic.InputSchemaMapping != nil {
		var inputSchemaMapping storage.InputSchemaMapping
		err := topic.InputSchemaMapping.AssignProperties_To_InputSchemaMapping(&inputSchemaMapping)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_InputSchemaMapping() to populate field InputSchemaMapping")
		}
		destination.InputSchemaMapping = &inputSchemaMapping
	} else {
		destination.InputSchemaMapping = nil
	}

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

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

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

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

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

	// No error
	return nil
}

// Initialize_From_Topic_STATUS populates our Topic_Spec from the provided source Topic_STATUS
func (topic *Topic_Spec) Initialize_From_Topic_STATUS(source *Topic_STATUS) error {

	// InboundIpRules
	if source.InboundIpRules != nil {
		inboundIpRuleList := make([]InboundIpRule, len(source.InboundIpRules))
		for inboundIpRuleIndex, inboundIpRuleItem := range source.InboundIpRules {
			var inboundIpRule InboundIpRule
			err := inboundIpRule.Initialize_From_InboundIpRule_STATUS(&inboundIpRuleItem)
			if err != nil {
				return eris.Wrap(err, "calling Initialize_From_InboundIpRule_STATUS() to populate field InboundIpRules")
			}
			inboundIpRuleList[inboundIpRuleIndex] = inboundIpRule
		}
		topic.InboundIpRules = inboundIpRuleList
	} else {
		topic.InboundIpRules = nil
	}

	// InputSchema
	if source.InputSchema != nil {
		inputSchema := genruntime.ToEnum(string(*source.InputSchema), topicProperties_InputSchema_Values)
		topic.InputSchema = &inputSchema
	} else {
		topic.InputSchema = nil
	}

	// InputSchemaMapping
	if source.InputSchemaMapping != nil {
		var inputSchemaMapping InputSchemaMapping
		err := inputSchemaMapping.Initialize_From_InputSchemaMapping_STATUS(source.InputSchemaMapping)
		if err != nil {
			return eris.Wrap(err, "calling Initialize_From_InputSchemaMapping_STATUS() to populate field InputSchemaMapping")
		}
		topic.InputSchemaMapping = &inputSchemaMapping
	} else {
		topic.InputSchemaMapping = nil
	}

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

	// PublicNetworkAccess
	if source.PublicNetworkAccess != nil {
		publicNetworkAccess := genruntime.ToEnum(string(*source.PublicNetworkAccess), topicProperties_PublicNetworkAccess_Values)
		topic.PublicNetworkAccess = &publicNetworkAccess
	} else {
		topic.PublicNetworkAccess = nil
	}

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

	// No error
	return nil
}

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

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

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

	// Endpoint: Endpoint for the topic.
	Endpoint *string `json:"endpoint,omitempty"`

	// Id: Fully qualified identifier of the resource.
	Id *string `json:"id,omitempty"`

	// InboundIpRules: This can be used to restrict traffic from specific IPs instead of all IPs. Note: These are considered
	// only if PublicNetworkAccess is enabled.
	InboundIpRules []InboundIpRule_STATUS `json:"inboundIpRules,omitempty"`

	// InputSchema: This determines the format that Event Grid should expect for incoming events published to the topic.
	InputSchema *TopicProperties_InputSchema_STATUS `json:"inputSchema,omitempty"`

	// InputSchemaMapping: This enables publishing using custom event schemas. An InputSchemaMapping can be specified to map
	// various properties of a source schema to various required properties of the EventGridEvent schema.
	InputSchemaMapping *InputSchemaMapping_STATUS `json:"inputSchemaMapping,omitempty"`

	// Location: Location of the resource.
	Location *string `json:"location,omitempty"`

	// MetricResourceId: Metric resource id for the topic.
	MetricResourceId *string `json:"metricResourceId,omitempty"`

	// Name: Name of the resource.
	Name                       *string                                                      `json:"name,omitempty"`
	PrivateEndpointConnections []PrivateEndpointConnection_STATUS_Topic_SubResourceEmbedded `json:"privateEndpointConnections,omitempty"`

	// ProvisioningState: Provisioning state of the topic.
	ProvisioningState *TopicProperties_ProvisioningState_STATUS `json:"provisioningState,omitempty"`

	// PublicNetworkAccess: This determines if traffic is allowed over public network. By default it is enabled.
	// You can further restrict to specific IPs by configuring <seealso
	// cref="P:Microsoft.Azure.Events.ResourceProvider.Common.Contracts.TopicProperties.InboundIpRules" />
	PublicNetworkAccess *TopicProperties_PublicNetworkAccess_STATUS `json:"publicNetworkAccess,omitempty"`

	// SystemData: The system metadata relating to Topic resource.
	SystemData *SystemData_STATUS `json:"systemData,omitempty"`

	// Tags: Tags of the resource.
	Tags map[string]string `json:"tags,omitempty"`

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

var _ genruntime.ConvertibleStatus = &Topic_STATUS{}

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

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

	return nil
}

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

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

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

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

	// no assignment for property "Conditions"

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

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

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

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

	// Set property "InputSchemaMapping":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.InputSchemaMapping != nil {
			var inputSchemaMapping1 InputSchemaMapping_STATUS
			err := inputSchemaMapping1.PopulateFromARM(owner, *typedInput.Properties.InputSchemaMapping)
			if err != nil {
				return err
			}
			inputSchemaMapping := inputSchemaMapping1
			topic.InputSchemaMapping = &inputSchemaMapping
		}
	}

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

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

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

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

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

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

	// 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 "Tags":
	if typedInput.Tags != nil {
		topic.Tags = make(map[string]string, len(typedInput.Tags))
		for key, value := range typedInput.Tags {
			topic.Tags[key] = value
		}
	}

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

	// No error
	return nil
}

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

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

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

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

	// InboundIpRules
	if source.InboundIpRules != nil {
		inboundIpRuleList := make([]InboundIpRule_STATUS, len(source.InboundIpRules))
		for inboundIpRuleIndex, inboundIpRuleItem := range source.InboundIpRules {
			var inboundIpRule InboundIpRule_STATUS
			err := inboundIpRule.AssignProperties_From_InboundIpRule_STATUS(&inboundIpRuleItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_InboundIpRule_STATUS() to populate field InboundIpRules")
			}
			inboundIpRuleList[inboundIpRuleIndex] = inboundIpRule
		}
		topic.InboundIpRules = inboundIpRuleList
	} else {
		topic.InboundIpRules = nil
	}

	// InputSchema
	if source.InputSchema != nil {
		inputSchema := *source.InputSchema
		inputSchemaTemp := genruntime.ToEnum(inputSchema, topicProperties_InputSchema_STATUS_Values)
		topic.InputSchema = &inputSchemaTemp
	} else {
		topic.InputSchema = nil
	}

	// InputSchemaMapping
	if source.InputSchemaMapping != nil {
		var inputSchemaMapping InputSchemaMapping_STATUS
		err := inputSchemaMapping.AssignProperties_From_InputSchemaMapping_STATUS(source.InputSchemaMapping)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_InputSchemaMapping_STATUS() to populate field InputSchemaMapping")
		}
		topic.InputSchemaMapping = &inputSchemaMapping
	} else {
		topic.InputSchemaMapping = nil
	}

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

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

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

	// PrivateEndpointConnections
	if source.PrivateEndpointConnections != nil {
		privateEndpointConnectionList := make([]PrivateEndpointConnection_STATUS_Topic_SubResourceEmbedded, len(source.PrivateEndpointConnections))
		for privateEndpointConnectionIndex, privateEndpointConnectionItem := range source.PrivateEndpointConnections {
			var privateEndpointConnection PrivateEndpointConnection_STATUS_Topic_SubResourceEmbedded
			err := privateEndpointConnection.AssignProperties_From_PrivateEndpointConnection_STATUS_Topic_SubResourceEmbedded(&privateEndpointConnectionItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_PrivateEndpointConnection_STATUS_Topic_SubResourceEmbedded() to populate field PrivateEndpointConnections")
			}
			privateEndpointConnectionList[privateEndpointConnectionIndex] = privateEndpointConnection
		}
		topic.PrivateEndpointConnections = privateEndpointConnectionList
	} else {
		topic.PrivateEndpointConnections = nil
	}

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

	// PublicNetworkAccess
	if source.PublicNetworkAccess != nil {
		publicNetworkAccess := *source.PublicNetworkAccess
		publicNetworkAccessTemp := genruntime.ToEnum(publicNetworkAccess, topicProperties_PublicNetworkAccess_STATUS_Values)
		topic.PublicNetworkAccess = &publicNetworkAccessTemp
	} else {
		topic.PublicNetworkAccess = 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
	}

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

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

	// No error
	return nil
}

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

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

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

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

	// InboundIpRules
	if topic.InboundIpRules != nil {
		inboundIpRuleList := make([]storage.InboundIpRule_STATUS, len(topic.InboundIpRules))
		for inboundIpRuleIndex, inboundIpRuleItem := range topic.InboundIpRules {
			var inboundIpRule storage.InboundIpRule_STATUS
			err := inboundIpRuleItem.AssignProperties_To_InboundIpRule_STATUS(&inboundIpRule)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_InboundIpRule_STATUS() to populate field InboundIpRules")
			}
			inboundIpRuleList[inboundIpRuleIndex] = inboundIpRule
		}
		destination.InboundIpRules = inboundIpRuleList
	} else {
		destination.InboundIpRules = nil
	}

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

	// InputSchemaMapping
	if topic.InputSchemaMapping != nil {
		var inputSchemaMapping storage.InputSchemaMapping_STATUS
		err := topic.InputSchemaMapping.AssignProperties_To_InputSchemaMapping_STATUS(&inputSchemaMapping)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_InputSchemaMapping_STATUS() to populate field InputSchemaMapping")
		}
		destination.InputSchemaMapping = &inputSchemaMapping
	} else {
		destination.InputSchemaMapping = nil
	}

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

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

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

	// PrivateEndpointConnections
	if topic.PrivateEndpointConnections != nil {
		privateEndpointConnectionList := make([]storage.PrivateEndpointConnection_STATUS_Topic_SubResourceEmbedded, len(topic.PrivateEndpointConnections))
		for privateEndpointConnectionIndex, privateEndpointConnectionItem := range topic.PrivateEndpointConnections {
			var privateEndpointConnection storage.PrivateEndpointConnection_STATUS_Topic_SubResourceEmbedded
			err := privateEndpointConnectionItem.AssignProperties_To_PrivateEndpointConnection_STATUS_Topic_SubResourceEmbedded(&privateEndpointConnection)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_PrivateEndpointConnection_STATUS_Topic_SubResourceEmbedded() to populate field PrivateEndpointConnections")
			}
			privateEndpointConnectionList[privateEndpointConnectionIndex] = privateEndpointConnection
		}
		destination.PrivateEndpointConnections = privateEndpointConnectionList
	} else {
		destination.PrivateEndpointConnections = nil
	}

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

	// PublicNetworkAccess
	if topic.PublicNetworkAccess != nil {
		publicNetworkAccess := string(*topic.PublicNetworkAccess)
		destination.PublicNetworkAccess = &publicNetworkAccess
	} else {
		destination.PublicNetworkAccess = 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
	}

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

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

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

	// No error
	return nil
}

type PrivateEndpointConnection_STATUS_Topic_SubResourceEmbedded struct {
	// Id: Fully qualified identifier of the resource.
	Id *string `json:"id,omitempty"`
}

var _ genruntime.FromARMConverter = &PrivateEndpointConnection_STATUS_Topic_SubResourceEmbedded{}

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

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

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

	// No error
	return nil
}

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

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

	// No error
	return nil
}

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

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

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

	// No error
	return nil
}

// Details for configuring operator behavior. Fields in this struct are interpreted by the operator directly rather than being passed to Azure
type TopicOperatorSpec struct {
	// ConfigMapExpressions: configures where to place operator written dynamic ConfigMaps (created with CEL expressions).
	ConfigMapExpressions []*core.DestinationExpression `json:"configMapExpressions,omitempty"`

	// ConfigMaps: configures where to place operator written ConfigMaps.
	ConfigMaps *TopicOperatorConfigMaps `json:"configMaps,omitempty"`

	// SecretExpressions: configures where to place operator written dynamic secrets (created with CEL expressions).
	SecretExpressions []*core.DestinationExpression `json:"secretExpressions,omitempty"`

	// Secrets: configures where to place Azure generated secrets.
	Secrets *TopicOperatorSecrets `json:"secrets,omitempty"`
}

// AssignProperties_From_TopicOperatorSpec populates our TopicOperatorSpec from the provided source TopicOperatorSpec
func (operator *TopicOperatorSpec) AssignProperties_From_TopicOperatorSpec(source *storage.TopicOperatorSpec) 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
	}

	// ConfigMaps
	if source.ConfigMaps != nil {
		var configMap TopicOperatorConfigMaps
		err := configMap.AssignProperties_From_TopicOperatorConfigMaps(source.ConfigMaps)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_TopicOperatorConfigMaps() to populate field ConfigMaps")
		}
		operator.ConfigMaps = &configMap
	} else {
		operator.ConfigMaps = 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
	}

	// Secrets
	if source.Secrets != nil {
		var secret TopicOperatorSecrets
		err := secret.AssignProperties_From_TopicOperatorSecrets(source.Secrets)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_TopicOperatorSecrets() to populate field Secrets")
		}
		operator.Secrets = &secret
	} else {
		operator.Secrets = nil
	}

	// No error
	return nil
}

// AssignProperties_To_TopicOperatorSpec populates the provided destination TopicOperatorSpec from our TopicOperatorSpec
func (operator *TopicOperatorSpec) AssignProperties_To_TopicOperatorSpec(destination *storage.TopicOperatorSpec) 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
	}

	// ConfigMaps
	if operator.ConfigMaps != nil {
		var configMap storage.TopicOperatorConfigMaps
		err := operator.ConfigMaps.AssignProperties_To_TopicOperatorConfigMaps(&configMap)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_TopicOperatorConfigMaps() to populate field ConfigMaps")
		}
		destination.ConfigMaps = &configMap
	} else {
		destination.ConfigMaps = 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
	}

	// Secrets
	if operator.Secrets != nil {
		var secret storage.TopicOperatorSecrets
		err := operator.Secrets.AssignProperties_To_TopicOperatorSecrets(&secret)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_TopicOperatorSecrets() to populate field Secrets")
		}
		destination.Secrets = &secret
	} else {
		destination.Secrets = nil
	}

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

	// No error
	return nil
}

// +kubebuilder:validation:Enum={"CloudEventSchemaV1_0","CustomEventSchema","EventGridSchema"}
type TopicProperties_InputSchema string

const (
	TopicProperties_InputSchema_CloudEventSchemaV1_0 = TopicProperties_InputSchema("CloudEventSchemaV1_0")
	TopicProperties_InputSchema_CustomEventSchema    = TopicProperties_InputSchema("CustomEventSchema")
	TopicProperties_InputSchema_EventGridSchema      = TopicProperties_InputSchema("EventGridSchema")
)

// Mapping from string to TopicProperties_InputSchema
var topicProperties_InputSchema_Values = map[string]TopicProperties_InputSchema{
	"cloudeventschemav1_0": TopicProperties_InputSchema_CloudEventSchemaV1_0,
	"customeventschema":    TopicProperties_InputSchema_CustomEventSchema,
	"eventgridschema":      TopicProperties_InputSchema_EventGridSchema,
}

type TopicProperties_InputSchema_STATUS string

const (
	TopicProperties_InputSchema_STATUS_CloudEventSchemaV1_0 = TopicProperties_InputSchema_STATUS("CloudEventSchemaV1_0")
	TopicProperties_InputSchema_STATUS_CustomEventSchema    = TopicProperties_InputSchema_STATUS("CustomEventSchema")
	TopicProperties_InputSchema_STATUS_EventGridSchema      = TopicProperties_InputSchema_STATUS("EventGridSchema")
)

// Mapping from string to TopicProperties_InputSchema_STATUS
var topicProperties_InputSchema_STATUS_Values = map[string]TopicProperties_InputSchema_STATUS{
	"cloudeventschemav1_0": TopicProperties_InputSchema_STATUS_CloudEventSchemaV1_0,
	"customeventschema":    TopicProperties_InputSchema_STATUS_CustomEventSchema,
	"eventgridschema":      TopicProperties_InputSchema_STATUS_EventGridSchema,
}

type TopicProperties_ProvisioningState_STATUS string

const (
	TopicProperties_ProvisioningState_STATUS_Canceled  = TopicProperties_ProvisioningState_STATUS("Canceled")
	TopicProperties_ProvisioningState_STATUS_Creating  = TopicProperties_ProvisioningState_STATUS("Creating")
	TopicProperties_ProvisioningState_STATUS_Deleting  = TopicProperties_ProvisioningState_STATUS("Deleting")
	TopicProperties_ProvisioningState_STATUS_Failed    = TopicProperties_ProvisioningState_STATUS("Failed")
	TopicProperties_ProvisioningState_STATUS_Succeeded = TopicProperties_ProvisioningState_STATUS("Succeeded")
	TopicProperties_ProvisioningState_STATUS_Updating  = TopicProperties_ProvisioningState_STATUS("Updating")
)

// Mapping from string to TopicProperties_ProvisioningState_STATUS
var topicProperties_ProvisioningState_STATUS_Values = map[string]TopicProperties_ProvisioningState_STATUS{
	"canceled":  TopicProperties_ProvisioningState_STATUS_Canceled,
	"creating":  TopicProperties_ProvisioningState_STATUS_Creating,
	"deleting":  TopicProperties_ProvisioningState_STATUS_Deleting,
	"failed":    TopicProperties_ProvisioningState_STATUS_Failed,
	"succeeded": TopicProperties_ProvisioningState_STATUS_Succeeded,
	"updating":  TopicProperties_ProvisioningState_STATUS_Updating,
}

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

const (
	TopicProperties_PublicNetworkAccess_Disabled = TopicProperties_PublicNetworkAccess("Disabled")
	TopicProperties_PublicNetworkAccess_Enabled  = TopicProperties_PublicNetworkAccess("Enabled")
)

// Mapping from string to TopicProperties_PublicNetworkAccess
var topicProperties_PublicNetworkAccess_Values = map[string]TopicProperties_PublicNetworkAccess{
	"disabled": TopicProperties_PublicNetworkAccess_Disabled,
	"enabled":  TopicProperties_PublicNetworkAccess_Enabled,
}

type TopicProperties_PublicNetworkAccess_STATUS string

const (
	TopicProperties_PublicNetworkAccess_STATUS_Disabled = TopicProperties_PublicNetworkAccess_STATUS("Disabled")
	TopicProperties_PublicNetworkAccess_STATUS_Enabled  = TopicProperties_PublicNetworkAccess_STATUS("Enabled")
)

// Mapping from string to TopicProperties_PublicNetworkAccess_STATUS
var topicProperties_PublicNetworkAccess_STATUS_Values = map[string]TopicProperties_PublicNetworkAccess_STATUS{
	"disabled": TopicProperties_PublicNetworkAccess_STATUS_Disabled,
	"enabled":  TopicProperties_PublicNetworkAccess_STATUS_Enabled,
}

type TopicOperatorConfigMaps struct {
	// Endpoint: indicates where the Endpoint config map should be placed. If omitted, no config map will be created.
	Endpoint *genruntime.ConfigMapDestination `json:"endpoint,omitempty"`
}

// AssignProperties_From_TopicOperatorConfigMaps populates our TopicOperatorConfigMaps from the provided source TopicOperatorConfigMaps
func (maps *TopicOperatorConfigMaps) AssignProperties_From_TopicOperatorConfigMaps(source *storage.TopicOperatorConfigMaps) error {

	// Endpoint
	if source.Endpoint != nil {
		endpoint := source.Endpoint.Copy()
		maps.Endpoint = &endpoint
	} else {
		maps.Endpoint = nil
	}

	// No error
	return nil
}

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

	// Endpoint
	if maps.Endpoint != nil {
		endpoint := maps.Endpoint.Copy()
		destination.Endpoint = &endpoint
	} else {
		destination.Endpoint = nil
	}

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

	// No error
	return nil
}

type TopicOperatorSecrets struct {
	// Key1: indicates where the Key1 secret should be placed. If omitted, the secret will not be retrieved from Azure.
	Key1 *genruntime.SecretDestination `json:"key1,omitempty"`

	// Key2: indicates where the Key2 secret should be placed. If omitted, the secret will not be retrieved from Azure.
	Key2 *genruntime.SecretDestination `json:"key2,omitempty"`
}

// AssignProperties_From_TopicOperatorSecrets populates our TopicOperatorSecrets from the provided source TopicOperatorSecrets
func (secrets *TopicOperatorSecrets) AssignProperties_From_TopicOperatorSecrets(source *storage.TopicOperatorSecrets) error {

	// Key1
	if source.Key1 != nil {
		key1 := source.Key1.Copy()
		secrets.Key1 = &key1
	} else {
		secrets.Key1 = nil
	}

	// Key2
	if source.Key2 != nil {
		key2 := source.Key2.Copy()
		secrets.Key2 = &key2
	} else {
		secrets.Key2 = nil
	}

	// No error
	return nil
}

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

	// Key1
	if secrets.Key1 != nil {
		key1 := secrets.Key1.Copy()
		destination.Key1 = &key1
	} else {
		destination.Key1 = nil
	}

	// Key2
	if secrets.Key2 != nil {
		key2 := secrets.Key2.Copy()
		destination.Key2 = &key2
	} else {
		destination.Key2 = nil
	}

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

	// No error
	return nil
}

func init() {
	SchemeBuilder.Register(&Topic{}, &TopicList{})
}
