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

import (
	"fmt"
	arm "github.com/Azure/azure-service-operator/v2/api/documentdb/v1api20240815/arm"
	storage "github.com/Azure/azure-service-operator/v2/api/documentdb/v1api20240815/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/2024-08-15/cosmos-db.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}
type MongodbDatabase struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              MongodbDatabase_Spec   `json:"spec,omitempty"`
	Status            MongodbDatabase_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &MongodbDatabase{}

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

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

var _ conversion.Convertible = &MongodbDatabase{}

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

	return database.AssignProperties_From_MongodbDatabase(source)
}

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

	return database.AssignProperties_To_MongodbDatabase(destination)
}

var _ configmaps.Exporter = &MongodbDatabase{}

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

var _ secrets.Exporter = &MongodbDatabase{}

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

var _ genruntime.ImportableResource = &MongodbDatabase{}

// InitializeSpec initializes the spec for this resource from the given status
func (database *MongodbDatabase) InitializeSpec(status genruntime.ConvertibleStatus) error {
	if s, ok := status.(*MongodbDatabase_STATUS); ok {
		return database.Spec.Initialize_From_MongodbDatabase_STATUS(s)
	}

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

var _ genruntime.KubernetesResource = &MongodbDatabase{}

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

// GetAPIVersion returns the ARM API version of the resource. This is always "2024-08-15"
func (database MongodbDatabase) GetAPIVersion() string {
	return "2024-08-15"
}

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

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

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

// GetSupportedOperations returns the operations supported by the resource
func (database *MongodbDatabase) 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"
func (database *MongodbDatabase) GetType() string {
	return "Microsoft.DocumentDB/databaseAccounts/mongodbDatabases"
}

// NewEmptyStatus returns a new empty (blank) status
func (database *MongodbDatabase) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &MongodbDatabase_STATUS{}
}

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

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

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

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

	database.Status = st
	return nil
}

// AssignProperties_From_MongodbDatabase populates our MongodbDatabase from the provided source MongodbDatabase
func (database *MongodbDatabase) AssignProperties_From_MongodbDatabase(source *storage.MongodbDatabase) error {

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

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

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

	// No error
	return nil
}

// AssignProperties_To_MongodbDatabase populates the provided destination MongodbDatabase from our MongodbDatabase
func (database *MongodbDatabase) AssignProperties_To_MongodbDatabase(destination *storage.MongodbDatabase) error {

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

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

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

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

type MongodbDatabase_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 *MongodbDatabaseOperatorSpec `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/DatabaseAccount resource
	Owner *genruntime.KnownResourceReference `group:"documentdb.azure.com" json:"owner,omitempty" kind:"DatabaseAccount"`

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

var _ genruntime.ARMTransformer = &MongodbDatabase_Spec{}

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

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

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

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

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

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

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

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

	// Set property "Location":
	if typedInput.Location != nil {
		location := *typedInput.Location
		database.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
			database.Options = &options
		}
	}

	// Set property "Owner":
	database.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 MongoDBDatabaseResource
			err := resource1.PopulateFromARM(owner, *typedInput.Properties.Resource)
			if err != nil {
				return err
			}
			resource := resource1
			database.Resource = &resource
		}
	}

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

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &MongodbDatabase_Spec{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.MongodbDatabase_Spec{}
	err := database.AssignProperties_To_MongodbDatabase_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_MongodbDatabase_Spec populates our MongodbDatabase_Spec from the provided source MongodbDatabase_Spec
func (database *MongodbDatabase_Spec) AssignProperties_From_MongodbDatabase_Spec(source *storage.MongodbDatabase_Spec) error {

	// AzureName
	database.AzureName = source.AzureName

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

	// OperatorSpec
	if source.OperatorSpec != nil {
		var operatorSpec MongodbDatabaseOperatorSpec
		err := operatorSpec.AssignProperties_From_MongodbDatabaseOperatorSpec(source.OperatorSpec)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_MongodbDatabaseOperatorSpec() to populate field OperatorSpec")
		}
		database.OperatorSpec = &operatorSpec
	} else {
		database.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")
		}
		database.Options = &option
	} else {
		database.Options = nil
	}

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

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

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

	// No error
	return nil
}

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

	// AzureName
	destination.AzureName = database.AzureName

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

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

	// Options
	if database.Options != nil {
		var option storage.CreateUpdateOptions
		err := database.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 = database.OriginalVersion()

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

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

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

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

	// No error
	return nil
}

// Initialize_From_MongodbDatabase_STATUS populates our MongodbDatabase_Spec from the provided source MongodbDatabase_STATUS
func (database *MongodbDatabase_Spec) Initialize_From_MongodbDatabase_STATUS(source *MongodbDatabase_STATUS) error {

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

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

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

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

	// No error
	return nil
}

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

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

type MongodbDatabase_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 *MongoDBDatabaseGetProperties_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 = &MongodbDatabase_STATUS{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.MongodbDatabase_STATUS{}
	err := database.AssignProperties_To_MongodbDatabase_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 = &MongodbDatabase_STATUS{}

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

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

	// no assignment for property "Conditions"

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

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

	// Set property "Name":
	if typedInput.Name != nil {
		name := *typedInput.Name
		database.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
			database.Options = &options
		}
	}

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

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

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

	// No error
	return nil
}

// AssignProperties_From_MongodbDatabase_STATUS populates our MongodbDatabase_STATUS from the provided source MongodbDatabase_STATUS
func (database *MongodbDatabase_STATUS) AssignProperties_From_MongodbDatabase_STATUS(source *storage.MongodbDatabase_STATUS) error {

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

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

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

	// Name
	database.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")
		}
		database.Options = &option
	} else {
		database.Options = nil
	}

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

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

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

	// No error
	return nil
}

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

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

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

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

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

	// Options
	if database.Options != nil {
		var option storage.OptionsResource_STATUS
		err := database.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 database.Resource != nil {
		var resource storage.MongoDBDatabaseGetProperties_Resource_STATUS
		err := database.Resource.AssignProperties_To_MongoDBDatabaseGetProperties_Resource_STATUS(&resource)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_MongoDBDatabaseGetProperties_Resource_STATUS() to populate field Resource")
		}
		destination.Resource = &resource
	} else {
		destination.Resource = nil
	}

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

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

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

	// No error
	return nil
}

// CreateUpdateOptions are a list of key-value pairs that describe the resource. Supported keys are "If-Match",
// "If-None-Match", "Session-Token" and "Throughput"
type CreateUpdateOptions struct {
	// AutoscaleSettings: Specifies the Autoscale settings. Note: Either throughput or autoscaleSettings is required, but not
	// both.
	AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"`

	// Throughput: Request Units per second. For example, "throughput": 10000.
	Throughput *int `json:"throughput,omitempty"`
}

var _ genruntime.ARMTransformer = &CreateUpdateOptions{}

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

	// Set property "AutoscaleSettings":
	if options.AutoscaleSettings != nil {
		autoscaleSettings_ARM, err := options.AutoscaleSettings.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		autoscaleSettings := *autoscaleSettings_ARM.(*arm.AutoscaleSettings)
		result.AutoscaleSettings = &autoscaleSettings
	}

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

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

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

	// Set property "AutoscaleSettings":
	if typedInput.AutoscaleSettings != nil {
		var autoscaleSettings1 AutoscaleSettings
		err := autoscaleSettings1.PopulateFromARM(owner, *typedInput.AutoscaleSettings)
		if err != nil {
			return err
		}
		autoscaleSettings := autoscaleSettings1
		options.AutoscaleSettings = &autoscaleSettings
	}

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

	// No error
	return nil
}

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

	// AutoscaleSettings
	if source.AutoscaleSettings != nil {
		var autoscaleSetting AutoscaleSettings
		err := autoscaleSetting.AssignProperties_From_AutoscaleSettings(source.AutoscaleSettings)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_AutoscaleSettings() to populate field AutoscaleSettings")
		}
		options.AutoscaleSettings = &autoscaleSetting
	} else {
		options.AutoscaleSettings = nil
	}

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

	// No error
	return nil
}

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

	// AutoscaleSettings
	if options.AutoscaleSettings != nil {
		var autoscaleSetting storage.AutoscaleSettings
		err := options.AutoscaleSettings.AssignProperties_To_AutoscaleSettings(&autoscaleSetting)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_AutoscaleSettings() to populate field AutoscaleSettings")
		}
		destination.AutoscaleSettings = &autoscaleSetting
	} else {
		destination.AutoscaleSettings = nil
	}

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

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

	// No error
	return nil
}

// Initialize_From_OptionsResource_STATUS populates our CreateUpdateOptions from the provided source OptionsResource_STATUS
func (options *CreateUpdateOptions) Initialize_From_OptionsResource_STATUS(source *OptionsResource_STATUS) error {

	// AutoscaleSettings
	if source.AutoscaleSettings != nil {
		var autoscaleSetting AutoscaleSettings
		err := autoscaleSetting.Initialize_From_AutoscaleSettings_STATUS(source.AutoscaleSettings)
		if err != nil {
			return eris.Wrap(err, "calling Initialize_From_AutoscaleSettings_STATUS() to populate field AutoscaleSettings")
		}
		options.AutoscaleSettings = &autoscaleSetting
	} else {
		options.AutoscaleSettings = nil
	}

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

	// No error
	return nil
}

type MongoDBDatabaseGetProperties_Resource_STATUS struct {
	// 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 database
	Id *string `json:"id,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"`

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

var _ genruntime.FromARMConverter = &MongoDBDatabaseGetProperties_Resource_STATUS{}

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

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

	// 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 "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 "Ts":
	if typedInput.Ts != nil {
		ts := *typedInput.Ts
		resource.Ts = &ts
	}

	// No error
	return nil
}

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

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

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

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

	// No error
	return nil
}

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

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

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

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

// Details for configuring operator behavior. Fields in this struct are interpreted by the operator directly rather than being passed to Azure
type MongodbDatabaseOperatorSpec 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_MongodbDatabaseOperatorSpec populates our MongodbDatabaseOperatorSpec from the provided source MongodbDatabaseOperatorSpec
func (operator *MongodbDatabaseOperatorSpec) AssignProperties_From_MongodbDatabaseOperatorSpec(source *storage.MongodbDatabaseOperatorSpec) 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_MongodbDatabaseOperatorSpec populates the provided destination MongodbDatabaseOperatorSpec from our MongodbDatabaseOperatorSpec
func (operator *MongodbDatabaseOperatorSpec) AssignProperties_To_MongodbDatabaseOperatorSpec(destination *storage.MongodbDatabaseOperatorSpec) 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 database resource object
type MongoDBDatabaseResource struct {
	// CreateMode: Enum to indicate the mode of resource creation.
	CreateMode *CreateMode `json:"createMode,omitempty"`

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

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

var _ genruntime.ARMTransformer = &MongoDBDatabaseResource{}

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

	// 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 "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
	}
	return result, nil
}

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

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

	// 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 "RestoreParameters":
	if typedInput.RestoreParameters != nil {
		var restoreParameters1 RestoreParametersBase
		err := restoreParameters1.PopulateFromARM(owner, *typedInput.RestoreParameters)
		if err != nil {
			return err
		}
		restoreParameters := restoreParameters1
		resource.RestoreParameters = &restoreParameters
	}

	// No error
	return nil
}

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

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

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

	// No error
	return nil
}

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

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

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

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

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

	// No error
	return nil
}

// Initialize_From_MongoDBDatabaseGetProperties_Resource_STATUS populates our MongoDBDatabaseResource from the provided source MongoDBDatabaseGetProperties_Resource_STATUS
func (resource *MongoDBDatabaseResource) Initialize_From_MongoDBDatabaseGetProperties_Resource_STATUS(source *MongoDBDatabaseGetProperties_Resource_STATUS) error {

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

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

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

	// No error
	return nil
}

// Cosmos DB options resource object
type OptionsResource_STATUS struct {
	// AutoscaleSettings: Specifies the Autoscale settings.
	AutoscaleSettings *AutoscaleSettings_STATUS `json:"autoscaleSettings,omitempty"`

	// Throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when
	// retrieving offer details.
	Throughput *int `json:"throughput,omitempty"`
}

var _ genruntime.FromARMConverter = &OptionsResource_STATUS{}

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

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

	// Set property "AutoscaleSettings":
	if typedInput.AutoscaleSettings != nil {
		var autoscaleSettings1 AutoscaleSettings_STATUS
		err := autoscaleSettings1.PopulateFromARM(owner, *typedInput.AutoscaleSettings)
		if err != nil {
			return err
		}
		autoscaleSettings := autoscaleSettings1
		resource.AutoscaleSettings = &autoscaleSettings
	}

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

	// No error
	return nil
}

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

	// AutoscaleSettings
	if source.AutoscaleSettings != nil {
		var autoscaleSetting AutoscaleSettings_STATUS
		err := autoscaleSetting.AssignProperties_From_AutoscaleSettings_STATUS(source.AutoscaleSettings)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_AutoscaleSettings_STATUS() to populate field AutoscaleSettings")
		}
		resource.AutoscaleSettings = &autoscaleSetting
	} else {
		resource.AutoscaleSettings = nil
	}

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

	// No error
	return nil
}

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

	// AutoscaleSettings
	if resource.AutoscaleSettings != nil {
		var autoscaleSetting storage.AutoscaleSettings_STATUS
		err := resource.AutoscaleSettings.AssignProperties_To_AutoscaleSettings_STATUS(&autoscaleSetting)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_AutoscaleSettings_STATUS() to populate field AutoscaleSettings")
		}
		destination.AutoscaleSettings = &autoscaleSetting
	} else {
		destination.AutoscaleSettings = nil
	}

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

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

	// No error
	return nil
}

type AutoscaleSettings struct {
	// MaxThroughput: Represents maximum throughput, the resource can scale up to.
	MaxThroughput *int `json:"maxThroughput,omitempty"`
}

var _ genruntime.ARMTransformer = &AutoscaleSettings{}

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

	// Set property "MaxThroughput":
	if settings.MaxThroughput != nil {
		maxThroughput := *settings.MaxThroughput
		result.MaxThroughput = &maxThroughput
	}
	return result, nil
}

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

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

	// Set property "MaxThroughput":
	if typedInput.MaxThroughput != nil {
		maxThroughput := *typedInput.MaxThroughput
		settings.MaxThroughput = &maxThroughput
	}

	// No error
	return nil
}

// AssignProperties_From_AutoscaleSettings populates our AutoscaleSettings from the provided source AutoscaleSettings
func (settings *AutoscaleSettings) AssignProperties_From_AutoscaleSettings(source *storage.AutoscaleSettings) error {

	// MaxThroughput
	settings.MaxThroughput = genruntime.ClonePointerToInt(source.MaxThroughput)

	// No error
	return nil
}

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

	// MaxThroughput
	destination.MaxThroughput = genruntime.ClonePointerToInt(settings.MaxThroughput)

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

	// No error
	return nil
}

// Initialize_From_AutoscaleSettings_STATUS populates our AutoscaleSettings from the provided source AutoscaleSettings_STATUS
func (settings *AutoscaleSettings) Initialize_From_AutoscaleSettings_STATUS(source *AutoscaleSettings_STATUS) error {

	// MaxThroughput
	settings.MaxThroughput = genruntime.ClonePointerToInt(source.MaxThroughput)

	// No error
	return nil
}

type AutoscaleSettings_STATUS struct {
	// MaxThroughput: Represents maximum throughput, the resource can scale up to.
	MaxThroughput *int `json:"maxThroughput,omitempty"`
}

var _ genruntime.FromARMConverter = &AutoscaleSettings_STATUS{}

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

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

	// Set property "MaxThroughput":
	if typedInput.MaxThroughput != nil {
		maxThroughput := *typedInput.MaxThroughput
		settings.MaxThroughput = &maxThroughput
	}

	// No error
	return nil
}

// AssignProperties_From_AutoscaleSettings_STATUS populates our AutoscaleSettings_STATUS from the provided source AutoscaleSettings_STATUS
func (settings *AutoscaleSettings_STATUS) AssignProperties_From_AutoscaleSettings_STATUS(source *storage.AutoscaleSettings_STATUS) error {

	// MaxThroughput
	settings.MaxThroughput = genruntime.ClonePointerToInt(source.MaxThroughput)

	// No error
	return nil
}

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

	// MaxThroughput
	destination.MaxThroughput = genruntime.ClonePointerToInt(settings.MaxThroughput)

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

	// No error
	return nil
}

// Parameters to indicate the information about the restore.
type RestoreParametersBase struct {
	// RestoreSource: The id of the restorable database account from which the restore has to be initiated. For example:
	// /subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{restorableDatabaseAccountName}
	RestoreSource *string `json:"restoreSource,omitempty"`

	// RestoreTimestampInUtc: Time to which the account has to be restored (ISO-8601 format).
	RestoreTimestampInUtc *string `json:"restoreTimestampInUtc,omitempty"`

	// RestoreWithTtlDisabled: Specifies whether the restored account will have Time-To-Live disabled upon the successful
	// restore.
	RestoreWithTtlDisabled *bool `json:"restoreWithTtlDisabled,omitempty"`
}

var _ genruntime.ARMTransformer = &RestoreParametersBase{}

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

	// Set property "RestoreSource":
	if base.RestoreSource != nil {
		restoreSource := *base.RestoreSource
		result.RestoreSource = &restoreSource
	}

	// Set property "RestoreTimestampInUtc":
	if base.RestoreTimestampInUtc != nil {
		restoreTimestampInUtc := *base.RestoreTimestampInUtc
		result.RestoreTimestampInUtc = &restoreTimestampInUtc
	}

	// Set property "RestoreWithTtlDisabled":
	if base.RestoreWithTtlDisabled != nil {
		restoreWithTtlDisabled := *base.RestoreWithTtlDisabled
		result.RestoreWithTtlDisabled = &restoreWithTtlDisabled
	}
	return result, nil
}

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

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

	// Set property "RestoreSource":
	if typedInput.RestoreSource != nil {
		restoreSource := *typedInput.RestoreSource
		base.RestoreSource = &restoreSource
	}

	// Set property "RestoreTimestampInUtc":
	if typedInput.RestoreTimestampInUtc != nil {
		restoreTimestampInUtc := *typedInput.RestoreTimestampInUtc
		base.RestoreTimestampInUtc = &restoreTimestampInUtc
	}

	// Set property "RestoreWithTtlDisabled":
	if typedInput.RestoreWithTtlDisabled != nil {
		restoreWithTtlDisabled := *typedInput.RestoreWithTtlDisabled
		base.RestoreWithTtlDisabled = &restoreWithTtlDisabled
	}

	// No error
	return nil
}

// AssignProperties_From_RestoreParametersBase populates our RestoreParametersBase from the provided source RestoreParametersBase
func (base *RestoreParametersBase) AssignProperties_From_RestoreParametersBase(source *storage.RestoreParametersBase) error {

	// RestoreSource
	base.RestoreSource = genruntime.ClonePointerToString(source.RestoreSource)

	// RestoreTimestampInUtc
	base.RestoreTimestampInUtc = genruntime.ClonePointerToString(source.RestoreTimestampInUtc)

	// RestoreWithTtlDisabled
	if source.RestoreWithTtlDisabled != nil {
		restoreWithTtlDisabled := *source.RestoreWithTtlDisabled
		base.RestoreWithTtlDisabled = &restoreWithTtlDisabled
	} else {
		base.RestoreWithTtlDisabled = nil
	}

	// No error
	return nil
}

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

	// RestoreSource
	destination.RestoreSource = genruntime.ClonePointerToString(base.RestoreSource)

	// RestoreTimestampInUtc
	destination.RestoreTimestampInUtc = genruntime.ClonePointerToString(base.RestoreTimestampInUtc)

	// RestoreWithTtlDisabled
	if base.RestoreWithTtlDisabled != nil {
		restoreWithTtlDisabled := *base.RestoreWithTtlDisabled
		destination.RestoreWithTtlDisabled = &restoreWithTtlDisabled
	} else {
		destination.RestoreWithTtlDisabled = nil
	}

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

	// No error
	return nil
}

// Initialize_From_RestoreParametersBase_STATUS populates our RestoreParametersBase from the provided source RestoreParametersBase_STATUS
func (base *RestoreParametersBase) Initialize_From_RestoreParametersBase_STATUS(source *RestoreParametersBase_STATUS) error {

	// RestoreSource
	base.RestoreSource = genruntime.ClonePointerToString(source.RestoreSource)

	// RestoreTimestampInUtc
	base.RestoreTimestampInUtc = genruntime.ClonePointerToString(source.RestoreTimestampInUtc)

	// RestoreWithTtlDisabled
	if source.RestoreWithTtlDisabled != nil {
		restoreWithTtlDisabled := *source.RestoreWithTtlDisabled
		base.RestoreWithTtlDisabled = &restoreWithTtlDisabled
	} else {
		base.RestoreWithTtlDisabled = nil
	}

	// No error
	return nil
}

// Parameters to indicate the information about the restore.
type RestoreParametersBase_STATUS struct {
	// RestoreSource: The id of the restorable database account from which the restore has to be initiated. For example:
	// /subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{restorableDatabaseAccountName}
	RestoreSource *string `json:"restoreSource,omitempty"`

	// RestoreTimestampInUtc: Time to which the account has to be restored (ISO-8601 format).
	RestoreTimestampInUtc *string `json:"restoreTimestampInUtc,omitempty"`

	// RestoreWithTtlDisabled: Specifies whether the restored account will have Time-To-Live disabled upon the successful
	// restore.
	RestoreWithTtlDisabled *bool `json:"restoreWithTtlDisabled,omitempty"`
}

var _ genruntime.FromARMConverter = &RestoreParametersBase_STATUS{}

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

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

	// Set property "RestoreSource":
	if typedInput.RestoreSource != nil {
		restoreSource := *typedInput.RestoreSource
		base.RestoreSource = &restoreSource
	}

	// Set property "RestoreTimestampInUtc":
	if typedInput.RestoreTimestampInUtc != nil {
		restoreTimestampInUtc := *typedInput.RestoreTimestampInUtc
		base.RestoreTimestampInUtc = &restoreTimestampInUtc
	}

	// Set property "RestoreWithTtlDisabled":
	if typedInput.RestoreWithTtlDisabled != nil {
		restoreWithTtlDisabled := *typedInput.RestoreWithTtlDisabled
		base.RestoreWithTtlDisabled = &restoreWithTtlDisabled
	}

	// No error
	return nil
}

// AssignProperties_From_RestoreParametersBase_STATUS populates our RestoreParametersBase_STATUS from the provided source RestoreParametersBase_STATUS
func (base *RestoreParametersBase_STATUS) AssignProperties_From_RestoreParametersBase_STATUS(source *storage.RestoreParametersBase_STATUS) error {

	// RestoreSource
	base.RestoreSource = genruntime.ClonePointerToString(source.RestoreSource)

	// RestoreTimestampInUtc
	base.RestoreTimestampInUtc = genruntime.ClonePointerToString(source.RestoreTimestampInUtc)

	// RestoreWithTtlDisabled
	if source.RestoreWithTtlDisabled != nil {
		restoreWithTtlDisabled := *source.RestoreWithTtlDisabled
		base.RestoreWithTtlDisabled = &restoreWithTtlDisabled
	} else {
		base.RestoreWithTtlDisabled = nil
	}

	// No error
	return nil
}

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

	// RestoreSource
	destination.RestoreSource = genruntime.ClonePointerToString(base.RestoreSource)

	// RestoreTimestampInUtc
	destination.RestoreTimestampInUtc = genruntime.ClonePointerToString(base.RestoreTimestampInUtc)

	// RestoreWithTtlDisabled
	if base.RestoreWithTtlDisabled != nil {
		restoreWithTtlDisabled := *base.RestoreWithTtlDisabled
		destination.RestoreWithTtlDisabled = &restoreWithTtlDisabled
	} else {
		destination.RestoreWithTtlDisabled = nil
	}

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

	// No error
	return nil
}

func init() {
	SchemeBuilder.Register(&MongodbDatabase{}, &MongodbDatabaseList{})
}
