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

import (
	"fmt"
	arm "github.com/Azure/azure-service-operator/v2/api/documentdb/v1api20231115/arm"
	storage "github.com/Azure/azure-service-operator/v2/api/documentdb/v1api20231115/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,documentdb}
// +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: /cosmos-db/resource-manager/Microsoft.DocumentDB/stable/2023-11-15/cosmos-db.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}
type MongodbDatabaseCollection struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              MongodbDatabaseCollection_Spec   `json:"spec,omitempty"`
	Status            MongodbDatabaseCollection_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &MongodbDatabaseCollection{}

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

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

var _ conversion.Convertible = &MongodbDatabaseCollection{}

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

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

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

	return nil
}

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

	return nil
}

var _ configmaps.Exporter = &MongodbDatabaseCollection{}

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

var _ secrets.Exporter = &MongodbDatabaseCollection{}

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

var _ genruntime.KubernetesResource = &MongodbDatabaseCollection{}

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

// GetAPIVersion returns the ARM API version of the resource. This is always "2023-11-15"
func (collection MongodbDatabaseCollection) GetAPIVersion() string {
	return "2023-11-15"
}

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.DocumentDB/databaseAccounts/mongodbDatabases/collections"
func (collection *MongodbDatabaseCollection) GetType() string {
	return "Microsoft.DocumentDB/databaseAccounts/mongodbDatabases/collections"
}

// NewEmptyStatus returns a new empty (blank) status
func (collection *MongodbDatabaseCollection) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &MongodbDatabaseCollection_STATUS{}
}

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

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

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

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

	collection.Status = st
	return nil
}

// AssignProperties_From_MongodbDatabaseCollection populates our MongodbDatabaseCollection from the provided source MongodbDatabaseCollection
func (collection *MongodbDatabaseCollection) AssignProperties_From_MongodbDatabaseCollection(source *storage.MongodbDatabaseCollection) error {

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

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

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

	// No error
	return nil
}

// AssignProperties_To_MongodbDatabaseCollection populates the provided destination MongodbDatabaseCollection from our MongodbDatabaseCollection
func (collection *MongodbDatabaseCollection) AssignProperties_To_MongodbDatabaseCollection(destination *storage.MongodbDatabaseCollection) error {

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

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

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

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /cosmos-db/resource-manager/Microsoft.DocumentDB/stable/2023-11-15/cosmos-db.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}
type MongodbDatabaseCollectionList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []MongodbDatabaseCollection `json:"items"`
}

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

	// Location: The location of the resource group to which the resource belongs.
	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 *MongodbDatabaseCollectionOperatorSpec `json:"operatorSpec,omitempty"`

	// Options: A key-value pair of options to be applied for the request. This corresponds to the headers sent with the
	// request.
	Options *CreateUpdateOptions `json:"options,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 documentdb.azure.com/MongodbDatabase resource
	Owner *genruntime.KnownResourceReference `group:"documentdb.azure.com" json:"owner,omitempty" kind:"MongodbDatabase"`

	// +kubebuilder:validation:Required
	// Resource: The standard JSON format of a MongoDB collection
	Resource *MongoDBCollectionResource `json:"resource,omitempty"`
	Tags     map[string]string          `json:"tags,omitempty"`
}

var _ genruntime.ARMTransformer = &MongodbDatabaseCollection_Spec{}

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

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

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

	// Set property "Properties":
	if collection.Options != nil || collection.Resource != nil {
		result.Properties = &arm.MongoDBCollectionCreateUpdateProperties{}
	}
	if collection.Options != nil {
		options_ARM, err := collection.Options.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		options := *options_ARM.(*arm.CreateUpdateOptions)
		result.Properties.Options = &options
	}
	if collection.Resource != nil {
		resource_ARM, err := collection.Resource.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		resource := *resource_ARM.(*arm.MongoDBCollectionResource)
		result.Properties.Resource = &resource
	}

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

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

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

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

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

	// no assignment for property "OperatorSpec"

	// Set property "Options":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Options != nil {
			var options1 CreateUpdateOptions
			err := options1.PopulateFromARM(owner, *typedInput.Properties.Options)
			if err != nil {
				return err
			}
			options := options1
			collection.Options = &options
		}
	}

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

	// Set property "Resource":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Resource != nil {
			var resource1 MongoDBCollectionResource
			err := resource1.PopulateFromARM(owner, *typedInput.Properties.Resource)
			if err != nil {
				return err
			}
			resource := resource1
			collection.Resource = &resource
		}
	}

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

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &MongodbDatabaseCollection_Spec{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.MongodbDatabaseCollection_Spec{}
	err := collection.AssignProperties_To_MongodbDatabaseCollection_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_MongodbDatabaseCollection_Spec populates our MongodbDatabaseCollection_Spec from the provided source MongodbDatabaseCollection_Spec
func (collection *MongodbDatabaseCollection_Spec) AssignProperties_From_MongodbDatabaseCollection_Spec(source *storage.MongodbDatabaseCollection_Spec) error {

	// AzureName
	collection.AzureName = source.AzureName

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

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

	// Options
	if source.Options != nil {
		var option CreateUpdateOptions
		err := option.AssignProperties_From_CreateUpdateOptions(source.Options)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_CreateUpdateOptions() to populate field Options")
		}
		collection.Options = &option
	} else {
		collection.Options = nil
	}

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

	// Resource
	if source.Resource != nil {
		var resource MongoDBCollectionResource
		err := resource.AssignProperties_From_MongoDBCollectionResource(source.Resource)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_MongoDBCollectionResource() to populate field Resource")
		}
		collection.Resource = &resource
	} else {
		collection.Resource = nil
	}

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

	// No error
	return nil
}

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

	// AzureName
	destination.AzureName = collection.AzureName

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

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

	// Options
	if collection.Options != nil {
		var option storage.CreateUpdateOptions
		err := collection.Options.AssignProperties_To_CreateUpdateOptions(&option)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_CreateUpdateOptions() to populate field Options")
		}
		destination.Options = &option
	} else {
		destination.Options = nil
	}

	// OriginalVersion
	destination.OriginalVersion = collection.OriginalVersion()

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

	// Resource
	if collection.Resource != nil {
		var resource storage.MongoDBCollectionResource
		err := collection.Resource.AssignProperties_To_MongoDBCollectionResource(&resource)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_MongoDBCollectionResource() to populate field Resource")
		}
		destination.Resource = &resource
	} else {
		destination.Resource = nil
	}

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

	// 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 (collection *MongodbDatabaseCollection_Spec) OriginalVersion() string {
	return GroupVersion.Version
}

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

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

	// Id: The unique resource identifier of the ARM resource.
	Id *string `json:"id,omitempty"`

	// Location: The location of the resource group to which the resource belongs.
	Location *string `json:"location,omitempty"`

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

	// Options: Cosmos DB options resource object
	Options  *OptionsResource_STATUS                         `json:"options,omitempty"`
	Resource *MongoDBCollectionGetProperties_Resource_STATUS `json:"resource,omitempty"`
	Tags     map[string]string                               `json:"tags,omitempty"`

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

var _ genruntime.ConvertibleStatus = &MongodbDatabaseCollection_STATUS{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.MongodbDatabaseCollection_STATUS{}
	err := collection.AssignProperties_To_MongodbDatabaseCollection_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 = &MongodbDatabaseCollection_STATUS{}

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

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

	// no assignment for property "Conditions"

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

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

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

	// Set property "Options":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Options != nil {
			var options1 OptionsResource_STATUS
			err := options1.PopulateFromARM(owner, *typedInput.Properties.Options)
			if err != nil {
				return err
			}
			options := options1
			collection.Options = &options
		}
	}

	// Set property "Resource":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Resource != nil {
			var resource1 MongoDBCollectionGetProperties_Resource_STATUS
			err := resource1.PopulateFromARM(owner, *typedInput.Properties.Resource)
			if err != nil {
				return err
			}
			resource := resource1
			collection.Resource = &resource
		}
	}

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

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

	// No error
	return nil
}

// AssignProperties_From_MongodbDatabaseCollection_STATUS populates our MongodbDatabaseCollection_STATUS from the provided source MongodbDatabaseCollection_STATUS
func (collection *MongodbDatabaseCollection_STATUS) AssignProperties_From_MongodbDatabaseCollection_STATUS(source *storage.MongodbDatabaseCollection_STATUS) error {

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

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

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

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

	// Options
	if source.Options != nil {
		var option OptionsResource_STATUS
		err := option.AssignProperties_From_OptionsResource_STATUS(source.Options)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_OptionsResource_STATUS() to populate field Options")
		}
		collection.Options = &option
	} else {
		collection.Options = nil
	}

	// Resource
	if source.Resource != nil {
		var resource MongoDBCollectionGetProperties_Resource_STATUS
		err := resource.AssignProperties_From_MongoDBCollectionGetProperties_Resource_STATUS(source.Resource)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_MongoDBCollectionGetProperties_Resource_STATUS() to populate field Resource")
		}
		collection.Resource = &resource
	} else {
		collection.Resource = nil
	}

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

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

	// No error
	return nil
}

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

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

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

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

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

	// Options
	if collection.Options != nil {
		var option storage.OptionsResource_STATUS
		err := collection.Options.AssignProperties_To_OptionsResource_STATUS(&option)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_OptionsResource_STATUS() to populate field Options")
		}
		destination.Options = &option
	} else {
		destination.Options = nil
	}

	// Resource
	if collection.Resource != nil {
		var resource storage.MongoDBCollectionGetProperties_Resource_STATUS
		err := collection.Resource.AssignProperties_To_MongoDBCollectionGetProperties_Resource_STATUS(&resource)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_MongoDBCollectionGetProperties_Resource_STATUS() to populate field Resource")
		}
		destination.Resource = &resource
	} else {
		destination.Resource = nil
	}

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

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

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

	// No error
	return nil
}

type MongoDBCollectionGetProperties_Resource_STATUS struct {
	// AnalyticalStorageTtl: Analytical TTL.
	AnalyticalStorageTtl *int `json:"analyticalStorageTtl,omitempty"`

	// CreateMode: Enum to indicate the mode of resource creation.
	CreateMode *CreateMode_STATUS `json:"createMode,omitempty"`

	// Etag: A system generated property representing the resource etag required for optimistic concurrency control.
	Etag *string `json:"_etag,omitempty"`

	// Id: Name of the Cosmos DB MongoDB collection
	Id *string `json:"id,omitempty"`

	// Indexes: List of index keys
	Indexes []MongoIndex_STATUS `json:"indexes,omitempty"`

	// RestoreParameters: Parameters to indicate the information about the restore
	RestoreParameters *RestoreParametersBase_STATUS `json:"restoreParameters,omitempty"`

	// Rid: A system generated property. A unique identifier.
	Rid *string `json:"_rid,omitempty"`

	// ShardKey: A key-value pair of shard keys to be applied for the request.
	ShardKey map[string]string `json:"shardKey,omitempty"`

	// Ts: A system generated property that denotes the last updated timestamp of the resource.
	Ts *float64 `json:"_ts,omitempty"`
}

var _ genruntime.FromARMConverter = &MongoDBCollectionGetProperties_Resource_STATUS{}

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

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

	// Set property "AnalyticalStorageTtl":
	if typedInput.AnalyticalStorageTtl != nil {
		analyticalStorageTtl := *typedInput.AnalyticalStorageTtl
		resource.AnalyticalStorageTtl = &analyticalStorageTtl
	}

	// Set property "CreateMode":
	if typedInput.CreateMode != nil {
		var temp string
		temp = string(*typedInput.CreateMode)
		createMode := CreateMode_STATUS(temp)
		resource.CreateMode = &createMode
	}

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

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

	// Set property "Indexes":
	for _, item := range typedInput.Indexes {
		var item1 MongoIndex_STATUS
		err := item1.PopulateFromARM(owner, item)
		if err != nil {
			return err
		}
		resource.Indexes = append(resource.Indexes, item1)
	}

	// Set property "RestoreParameters":
	if typedInput.RestoreParameters != nil {
		var restoreParameters1 RestoreParametersBase_STATUS
		err := restoreParameters1.PopulateFromARM(owner, *typedInput.RestoreParameters)
		if err != nil {
			return err
		}
		restoreParameters := restoreParameters1
		resource.RestoreParameters = &restoreParameters
	}

	// Set property "Rid":
	if typedInput.Rid != nil {
		rid := *typedInput.Rid
		resource.Rid = &rid
	}

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

	// Set property "Ts":
	if typedInput.Ts != nil {
		ts := *typedInput.Ts
		resource.Ts = &ts
	}

	// No error
	return nil
}

// AssignProperties_From_MongoDBCollectionGetProperties_Resource_STATUS populates our MongoDBCollectionGetProperties_Resource_STATUS from the provided source MongoDBCollectionGetProperties_Resource_STATUS
func (resource *MongoDBCollectionGetProperties_Resource_STATUS) AssignProperties_From_MongoDBCollectionGetProperties_Resource_STATUS(source *storage.MongoDBCollectionGetProperties_Resource_STATUS) error {

	// AnalyticalStorageTtl
	resource.AnalyticalStorageTtl = genruntime.ClonePointerToInt(source.AnalyticalStorageTtl)

	// CreateMode
	if source.CreateMode != nil {
		createMode := *source.CreateMode
		createModeTemp := genruntime.ToEnum(createMode, createMode_STATUS_Values)
		resource.CreateMode = &createModeTemp
	} else {
		resource.CreateMode = nil
	}

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

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

	// Indexes
	if source.Indexes != nil {
		indexList := make([]MongoIndex_STATUS, len(source.Indexes))
		for index, indexItem := range source.Indexes {
			var indexLocal MongoIndex_STATUS
			err := indexLocal.AssignProperties_From_MongoIndex_STATUS(&indexItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_MongoIndex_STATUS() to populate field Indexes")
			}
			indexList[index] = indexLocal
		}
		resource.Indexes = indexList
	} else {
		resource.Indexes = nil
	}

	// RestoreParameters
	if source.RestoreParameters != nil {
		var restoreParameter RestoreParametersBase_STATUS
		err := restoreParameter.AssignProperties_From_RestoreParametersBase_STATUS(source.RestoreParameters)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_RestoreParametersBase_STATUS() to populate field RestoreParameters")
		}
		resource.RestoreParameters = &restoreParameter
	} else {
		resource.RestoreParameters = nil
	}

	// Rid
	resource.Rid = genruntime.ClonePointerToString(source.Rid)

	// ShardKey
	resource.ShardKey = genruntime.CloneMapOfStringToString(source.ShardKey)

	// Ts
	if source.Ts != nil {
		t := *source.Ts
		resource.Ts = &t
	} else {
		resource.Ts = nil
	}

	// No error
	return nil
}

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

	// AnalyticalStorageTtl
	destination.AnalyticalStorageTtl = genruntime.ClonePointerToInt(resource.AnalyticalStorageTtl)

	// CreateMode
	if resource.CreateMode != nil {
		createMode := string(*resource.CreateMode)
		destination.CreateMode = &createMode
	} else {
		destination.CreateMode = nil
	}

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

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

	// Indexes
	if resource.Indexes != nil {
		indexList := make([]storage.MongoIndex_STATUS, len(resource.Indexes))
		for index, indexItem := range resource.Indexes {
			var indexLocal storage.MongoIndex_STATUS
			err := indexItem.AssignProperties_To_MongoIndex_STATUS(&indexLocal)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_MongoIndex_STATUS() to populate field Indexes")
			}
			indexList[index] = indexLocal
		}
		destination.Indexes = indexList
	} else {
		destination.Indexes = nil
	}

	// RestoreParameters
	if resource.RestoreParameters != nil {
		var restoreParameter storage.RestoreParametersBase_STATUS
		err := resource.RestoreParameters.AssignProperties_To_RestoreParametersBase_STATUS(&restoreParameter)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_RestoreParametersBase_STATUS() to populate field RestoreParameters")
		}
		destination.RestoreParameters = &restoreParameter
	} else {
		destination.RestoreParameters = nil
	}

	// Rid
	destination.Rid = genruntime.ClonePointerToString(resource.Rid)

	// ShardKey
	destination.ShardKey = genruntime.CloneMapOfStringToString(resource.ShardKey)

	// Ts
	if resource.Ts != nil {
		t := *resource.Ts
		destination.Ts = &t
	} else {
		destination.Ts = nil
	}

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

	// No error
	return nil
}

// Cosmos DB MongoDB collection resource object
type MongoDBCollectionResource struct {
	// AnalyticalStorageTtl: Analytical TTL.
	AnalyticalStorageTtl *int `json:"analyticalStorageTtl,omitempty"`

	// CreateMode: Enum to indicate the mode of resource creation.
	CreateMode *CreateMode `json:"createMode,omitempty"`

	// +kubebuilder:validation:Required
	// Id: Name of the Cosmos DB MongoDB collection
	Id *string `json:"id,omitempty"`

	// Indexes: List of index keys
	Indexes []MongoIndex `json:"indexes,omitempty"`

	// RestoreParameters: Parameters to indicate the information about the restore
	RestoreParameters *RestoreParametersBase `json:"restoreParameters,omitempty"`

	// ShardKey: A key-value pair of shard keys to be applied for the request.
	ShardKey map[string]string `json:"shardKey,omitempty"`
}

var _ genruntime.ARMTransformer = &MongoDBCollectionResource{}

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

	// Set property "AnalyticalStorageTtl":
	if resource.AnalyticalStorageTtl != nil {
		analyticalStorageTtl := *resource.AnalyticalStorageTtl
		result.AnalyticalStorageTtl = &analyticalStorageTtl
	}

	// Set property "CreateMode":
	if resource.CreateMode != nil {
		var temp string
		temp = string(*resource.CreateMode)
		createMode := arm.CreateMode(temp)
		result.CreateMode = &createMode
	}

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

	// Set property "Indexes":
	for _, item := range resource.Indexes {
		item_ARM, err := item.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		result.Indexes = append(result.Indexes, *item_ARM.(*arm.MongoIndex))
	}

	// Set property "RestoreParameters":
	if resource.RestoreParameters != nil {
		restoreParameters_ARM, err := resource.RestoreParameters.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		restoreParameters := *restoreParameters_ARM.(*arm.RestoreParametersBase)
		result.RestoreParameters = &restoreParameters
	}

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

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

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

	// Set property "AnalyticalStorageTtl":
	if typedInput.AnalyticalStorageTtl != nil {
		analyticalStorageTtl := *typedInput.AnalyticalStorageTtl
		resource.AnalyticalStorageTtl = &analyticalStorageTtl
	}

	// Set property "CreateMode":
	if typedInput.CreateMode != nil {
		var temp string
		temp = string(*typedInput.CreateMode)
		createMode := CreateMode(temp)
		resource.CreateMode = &createMode
	}

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

	// Set property "Indexes":
	for _, item := range typedInput.Indexes {
		var item1 MongoIndex
		err := item1.PopulateFromARM(owner, item)
		if err != nil {
			return err
		}
		resource.Indexes = append(resource.Indexes, item1)
	}

	// Set property "RestoreParameters":
	if typedInput.RestoreParameters != nil {
		var restoreParameters1 RestoreParametersBase
		err := restoreParameters1.PopulateFromARM(owner, *typedInput.RestoreParameters)
		if err != nil {
			return err
		}
		restoreParameters := restoreParameters1
		resource.RestoreParameters = &restoreParameters
	}

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

	// No error
	return nil
}

// AssignProperties_From_MongoDBCollectionResource populates our MongoDBCollectionResource from the provided source MongoDBCollectionResource
func (resource *MongoDBCollectionResource) AssignProperties_From_MongoDBCollectionResource(source *storage.MongoDBCollectionResource) error {

	// AnalyticalStorageTtl
	resource.AnalyticalStorageTtl = genruntime.ClonePointerToInt(source.AnalyticalStorageTtl)

	// CreateMode
	if source.CreateMode != nil {
		createMode := *source.CreateMode
		createModeTemp := genruntime.ToEnum(createMode, createMode_Values)
		resource.CreateMode = &createModeTemp
	} else {
		resource.CreateMode = nil
	}

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

	// Indexes
	if source.Indexes != nil {
		indexList := make([]MongoIndex, len(source.Indexes))
		for index, indexItem := range source.Indexes {
			var indexLocal MongoIndex
			err := indexLocal.AssignProperties_From_MongoIndex(&indexItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_MongoIndex() to populate field Indexes")
			}
			indexList[index] = indexLocal
		}
		resource.Indexes = indexList
	} else {
		resource.Indexes = nil
	}

	// RestoreParameters
	if source.RestoreParameters != nil {
		var restoreParameter RestoreParametersBase
		err := restoreParameter.AssignProperties_From_RestoreParametersBase(source.RestoreParameters)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_RestoreParametersBase() to populate field RestoreParameters")
		}
		resource.RestoreParameters = &restoreParameter
	} else {
		resource.RestoreParameters = nil
	}

	// ShardKey
	resource.ShardKey = genruntime.CloneMapOfStringToString(source.ShardKey)

	// No error
	return nil
}

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

	// AnalyticalStorageTtl
	destination.AnalyticalStorageTtl = genruntime.ClonePointerToInt(resource.AnalyticalStorageTtl)

	// CreateMode
	if resource.CreateMode != nil {
		createMode := string(*resource.CreateMode)
		destination.CreateMode = &createMode
	} else {
		destination.CreateMode = nil
	}

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

	// Indexes
	if resource.Indexes != nil {
		indexList := make([]storage.MongoIndex, len(resource.Indexes))
		for index, indexItem := range resource.Indexes {
			var indexLocal storage.MongoIndex
			err := indexItem.AssignProperties_To_MongoIndex(&indexLocal)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_MongoIndex() to populate field Indexes")
			}
			indexList[index] = indexLocal
		}
		destination.Indexes = indexList
	} else {
		destination.Indexes = nil
	}

	// RestoreParameters
	if resource.RestoreParameters != nil {
		var restoreParameter storage.RestoreParametersBase
		err := resource.RestoreParameters.AssignProperties_To_RestoreParametersBase(&restoreParameter)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_RestoreParametersBase() to populate field RestoreParameters")
		}
		destination.RestoreParameters = &restoreParameter
	} else {
		destination.RestoreParameters = nil
	}

	// ShardKey
	destination.ShardKey = genruntime.CloneMapOfStringToString(resource.ShardKey)

	// 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 MongodbDatabaseCollectionOperatorSpec 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_MongodbDatabaseCollectionOperatorSpec populates our MongodbDatabaseCollectionOperatorSpec from the provided source MongodbDatabaseCollectionOperatorSpec
func (operator *MongodbDatabaseCollectionOperatorSpec) AssignProperties_From_MongodbDatabaseCollectionOperatorSpec(source *storage.MongodbDatabaseCollectionOperatorSpec) 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_MongodbDatabaseCollectionOperatorSpec populates the provided destination MongodbDatabaseCollectionOperatorSpec from our MongodbDatabaseCollectionOperatorSpec
func (operator *MongodbDatabaseCollectionOperatorSpec) AssignProperties_To_MongodbDatabaseCollectionOperatorSpec(destination *storage.MongodbDatabaseCollectionOperatorSpec) 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
}

// Cosmos DB MongoDB collection index key
type MongoIndex struct {
	// Key: Cosmos DB MongoDB collection index keys
	Key *MongoIndexKeys `json:"key,omitempty"`

	// Options: Cosmos DB MongoDB collection index key options
	Options *MongoIndexOptions `json:"options,omitempty"`
}

var _ genruntime.ARMTransformer = &MongoIndex{}

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

	// Set property "Key":
	if index.Key != nil {
		key_ARM, err := index.Key.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		key := *key_ARM.(*arm.MongoIndexKeys)
		result.Key = &key
	}

	// Set property "Options":
	if index.Options != nil {
		options_ARM, err := index.Options.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		options := *options_ARM.(*arm.MongoIndexOptions)
		result.Options = &options
	}
	return result, nil
}

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

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

	// Set property "Key":
	if typedInput.Key != nil {
		var key1 MongoIndexKeys
		err := key1.PopulateFromARM(owner, *typedInput.Key)
		if err != nil {
			return err
		}
		key := key1
		index.Key = &key
	}

	// Set property "Options":
	if typedInput.Options != nil {
		var options1 MongoIndexOptions
		err := options1.PopulateFromARM(owner, *typedInput.Options)
		if err != nil {
			return err
		}
		options := options1
		index.Options = &options
	}

	// No error
	return nil
}

// AssignProperties_From_MongoIndex populates our MongoIndex from the provided source MongoIndex
func (index *MongoIndex) AssignProperties_From_MongoIndex(source *storage.MongoIndex) error {

	// Key
	if source.Key != nil {
		var key MongoIndexKeys
		err := key.AssignProperties_From_MongoIndexKeys(source.Key)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_MongoIndexKeys() to populate field Key")
		}
		index.Key = &key
	} else {
		index.Key = nil
	}

	// Options
	if source.Options != nil {
		var option MongoIndexOptions
		err := option.AssignProperties_From_MongoIndexOptions(source.Options)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_MongoIndexOptions() to populate field Options")
		}
		index.Options = &option
	} else {
		index.Options = nil
	}

	// No error
	return nil
}

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

	// Key
	if index.Key != nil {
		var key storage.MongoIndexKeys
		err := index.Key.AssignProperties_To_MongoIndexKeys(&key)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_MongoIndexKeys() to populate field Key")
		}
		destination.Key = &key
	} else {
		destination.Key = nil
	}

	// Options
	if index.Options != nil {
		var option storage.MongoIndexOptions
		err := index.Options.AssignProperties_To_MongoIndexOptions(&option)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_MongoIndexOptions() to populate field Options")
		}
		destination.Options = &option
	} else {
		destination.Options = nil
	}

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

	// No error
	return nil
}

// Cosmos DB MongoDB collection index key
type MongoIndex_STATUS struct {
	// Key: Cosmos DB MongoDB collection index keys
	Key *MongoIndexKeys_STATUS `json:"key,omitempty"`

	// Options: Cosmos DB MongoDB collection index key options
	Options *MongoIndexOptions_STATUS `json:"options,omitempty"`
}

var _ genruntime.FromARMConverter = &MongoIndex_STATUS{}

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

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

	// Set property "Key":
	if typedInput.Key != nil {
		var key1 MongoIndexKeys_STATUS
		err := key1.PopulateFromARM(owner, *typedInput.Key)
		if err != nil {
			return err
		}
		key := key1
		index.Key = &key
	}

	// Set property "Options":
	if typedInput.Options != nil {
		var options1 MongoIndexOptions_STATUS
		err := options1.PopulateFromARM(owner, *typedInput.Options)
		if err != nil {
			return err
		}
		options := options1
		index.Options = &options
	}

	// No error
	return nil
}

// AssignProperties_From_MongoIndex_STATUS populates our MongoIndex_STATUS from the provided source MongoIndex_STATUS
func (index *MongoIndex_STATUS) AssignProperties_From_MongoIndex_STATUS(source *storage.MongoIndex_STATUS) error {

	// Key
	if source.Key != nil {
		var key MongoIndexKeys_STATUS
		err := key.AssignProperties_From_MongoIndexKeys_STATUS(source.Key)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_MongoIndexKeys_STATUS() to populate field Key")
		}
		index.Key = &key
	} else {
		index.Key = nil
	}

	// Options
	if source.Options != nil {
		var option MongoIndexOptions_STATUS
		err := option.AssignProperties_From_MongoIndexOptions_STATUS(source.Options)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_MongoIndexOptions_STATUS() to populate field Options")
		}
		index.Options = &option
	} else {
		index.Options = nil
	}

	// No error
	return nil
}

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

	// Key
	if index.Key != nil {
		var key storage.MongoIndexKeys_STATUS
		err := index.Key.AssignProperties_To_MongoIndexKeys_STATUS(&key)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_MongoIndexKeys_STATUS() to populate field Key")
		}
		destination.Key = &key
	} else {
		destination.Key = nil
	}

	// Options
	if index.Options != nil {
		var option storage.MongoIndexOptions_STATUS
		err := index.Options.AssignProperties_To_MongoIndexOptions_STATUS(&option)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_MongoIndexOptions_STATUS() to populate field Options")
		}
		destination.Options = &option
	} else {
		destination.Options = nil
	}

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

	// No error
	return nil
}

// Cosmos DB MongoDB collection resource object
type MongoIndexKeys struct {
	// Keys: List of keys for each MongoDB collection in the Azure Cosmos DB service
	Keys []string `json:"keys,omitempty"`
}

var _ genruntime.ARMTransformer = &MongoIndexKeys{}

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

	// Set property "Keys":
	for _, item := range keys.Keys {
		result.Keys = append(result.Keys, item)
	}
	return result, nil
}

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

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

	// Set property "Keys":
	for _, item := range typedInput.Keys {
		keys.Keys = append(keys.Keys, item)
	}

	// No error
	return nil
}

// AssignProperties_From_MongoIndexKeys populates our MongoIndexKeys from the provided source MongoIndexKeys
func (keys *MongoIndexKeys) AssignProperties_From_MongoIndexKeys(source *storage.MongoIndexKeys) error {

	// Keys
	keys.Keys = genruntime.CloneSliceOfString(source.Keys)

	// No error
	return nil
}

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

	// Keys
	destination.Keys = genruntime.CloneSliceOfString(keys.Keys)

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

	// No error
	return nil
}

// Cosmos DB MongoDB collection resource object
type MongoIndexKeys_STATUS struct {
	// Keys: List of keys for each MongoDB collection in the Azure Cosmos DB service
	Keys []string `json:"keys,omitempty"`
}

var _ genruntime.FromARMConverter = &MongoIndexKeys_STATUS{}

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

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

	// Set property "Keys":
	for _, item := range typedInput.Keys {
		keys.Keys = append(keys.Keys, item)
	}

	// No error
	return nil
}

// AssignProperties_From_MongoIndexKeys_STATUS populates our MongoIndexKeys_STATUS from the provided source MongoIndexKeys_STATUS
func (keys *MongoIndexKeys_STATUS) AssignProperties_From_MongoIndexKeys_STATUS(source *storage.MongoIndexKeys_STATUS) error {

	// Keys
	keys.Keys = genruntime.CloneSliceOfString(source.Keys)

	// No error
	return nil
}

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

	// Keys
	destination.Keys = genruntime.CloneSliceOfString(keys.Keys)

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

	// No error
	return nil
}

// Cosmos DB MongoDB collection index options
type MongoIndexOptions struct {
	// ExpireAfterSeconds: Expire after seconds
	ExpireAfterSeconds *int `json:"expireAfterSeconds,omitempty"`

	// Unique: Is unique or not
	Unique *bool `json:"unique,omitempty"`
}

var _ genruntime.ARMTransformer = &MongoIndexOptions{}

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

	// Set property "ExpireAfterSeconds":
	if options.ExpireAfterSeconds != nil {
		expireAfterSeconds := *options.ExpireAfterSeconds
		result.ExpireAfterSeconds = &expireAfterSeconds
	}

	// Set property "Unique":
	if options.Unique != nil {
		unique := *options.Unique
		result.Unique = &unique
	}
	return result, nil
}

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

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

	// Set property "ExpireAfterSeconds":
	if typedInput.ExpireAfterSeconds != nil {
		expireAfterSeconds := *typedInput.ExpireAfterSeconds
		options.ExpireAfterSeconds = &expireAfterSeconds
	}

	// Set property "Unique":
	if typedInput.Unique != nil {
		unique := *typedInput.Unique
		options.Unique = &unique
	}

	// No error
	return nil
}

// AssignProperties_From_MongoIndexOptions populates our MongoIndexOptions from the provided source MongoIndexOptions
func (options *MongoIndexOptions) AssignProperties_From_MongoIndexOptions(source *storage.MongoIndexOptions) error {

	// ExpireAfterSeconds
	options.ExpireAfterSeconds = genruntime.ClonePointerToInt(source.ExpireAfterSeconds)

	// Unique
	if source.Unique != nil {
		unique := *source.Unique
		options.Unique = &unique
	} else {
		options.Unique = nil
	}

	// No error
	return nil
}

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

	// ExpireAfterSeconds
	destination.ExpireAfterSeconds = genruntime.ClonePointerToInt(options.ExpireAfterSeconds)

	// Unique
	if options.Unique != nil {
		unique := *options.Unique
		destination.Unique = &unique
	} else {
		destination.Unique = nil
	}

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

	// No error
	return nil
}

// Cosmos DB MongoDB collection index options
type MongoIndexOptions_STATUS struct {
	// ExpireAfterSeconds: Expire after seconds
	ExpireAfterSeconds *int `json:"expireAfterSeconds,omitempty"`

	// Unique: Is unique or not
	Unique *bool `json:"unique,omitempty"`
}

var _ genruntime.FromARMConverter = &MongoIndexOptions_STATUS{}

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

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

	// Set property "ExpireAfterSeconds":
	if typedInput.ExpireAfterSeconds != nil {
		expireAfterSeconds := *typedInput.ExpireAfterSeconds
		options.ExpireAfterSeconds = &expireAfterSeconds
	}

	// Set property "Unique":
	if typedInput.Unique != nil {
		unique := *typedInput.Unique
		options.Unique = &unique
	}

	// No error
	return nil
}

// AssignProperties_From_MongoIndexOptions_STATUS populates our MongoIndexOptions_STATUS from the provided source MongoIndexOptions_STATUS
func (options *MongoIndexOptions_STATUS) AssignProperties_From_MongoIndexOptions_STATUS(source *storage.MongoIndexOptions_STATUS) error {

	// ExpireAfterSeconds
	options.ExpireAfterSeconds = genruntime.ClonePointerToInt(source.ExpireAfterSeconds)

	// Unique
	if source.Unique != nil {
		unique := *source.Unique
		options.Unique = &unique
	} else {
		options.Unique = nil
	}

	// No error
	return nil
}

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

	// ExpireAfterSeconds
	destination.ExpireAfterSeconds = genruntime.ClonePointerToInt(options.ExpireAfterSeconds)

	// Unique
	if options.Unique != nil {
		unique := *options.Unique
		destination.Unique = &unique
	} else {
		destination.Unique = nil
	}

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

	// No error
	return nil
}

func init() {
	SchemeBuilder.Register(&MongodbDatabaseCollection{}, &MongodbDatabaseCollectionList{})
}
