// 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/mongorbac.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}
type MongodbRoleDefinition struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              MongodbRoleDefinition_Spec   `json:"spec,omitempty"`
	Status            MongodbRoleDefinition_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &MongodbRoleDefinition{}

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

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

var _ conversion.Convertible = &MongodbRoleDefinition{}

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

	return definition.AssignProperties_From_MongodbRoleDefinition(source)
}

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

	return definition.AssignProperties_To_MongodbRoleDefinition(destination)
}

var _ configmaps.Exporter = &MongodbRoleDefinition{}

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

var _ secrets.Exporter = &MongodbRoleDefinition{}

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

var _ genruntime.ImportableResource = &MongodbRoleDefinition{}

// InitializeSpec initializes the spec for this resource from the given status
func (definition *MongodbRoleDefinition) InitializeSpec(status genruntime.ConvertibleStatus) error {
	if s, ok := status.(*MongodbRoleDefinition_STATUS); ok {
		return definition.Spec.Initialize_From_MongodbRoleDefinition_STATUS(s)
	}

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

var _ genruntime.KubernetesResource = &MongodbRoleDefinition{}

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

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

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

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

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

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

// NewEmptyStatus returns a new empty (blank) status
func (definition *MongodbRoleDefinition) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &MongodbRoleDefinition_STATUS{}
}

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

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

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

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

	definition.Status = st
	return nil
}

// AssignProperties_From_MongodbRoleDefinition populates our MongodbRoleDefinition from the provided source MongodbRoleDefinition
func (definition *MongodbRoleDefinition) AssignProperties_From_MongodbRoleDefinition(source *storage.MongodbRoleDefinition) error {

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

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

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

	// No error
	return nil
}

// AssignProperties_To_MongodbRoleDefinition populates the provided destination MongodbRoleDefinition from our MongodbRoleDefinition
func (definition *MongodbRoleDefinition) AssignProperties_To_MongodbRoleDefinition(destination *storage.MongodbRoleDefinition) error {

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

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

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

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

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

	// DatabaseName: The database name for which access is being granted for this Role Definition.
	DatabaseName *string `json:"databaseName,omitempty"`

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

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

	// Privileges: A set of privileges contained by the Role Definition. This will allow application of this Role Definition on
	// the entire database account or any underlying Database / Collection. Scopes higher than Database are not enforceable as
	// privilege.
	Privileges []Privilege `json:"privileges,omitempty"`

	// RoleName: A user-friendly name for the Role Definition. Must be unique for the database account.
	RoleName *string `json:"roleName,omitempty"`

	// Roles: The set of roles inherited by this Role Definition.
	Roles []Role `json:"roles,omitempty"`

	// Type: Indicates whether the Role Definition was built-in or user created.
	Type *MongoRoleDefinitionResource_Type `json:"type,omitempty"`
}

var _ genruntime.ARMTransformer = &MongodbRoleDefinition_Spec{}

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

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

	// Set property "Properties":
	if definition.DatabaseName != nil ||
		definition.Privileges != nil ||
		definition.RoleName != nil ||
		definition.Roles != nil ||
		definition.Type != nil {
		result.Properties = &arm.MongoRoleDefinitionResource{}
	}
	if definition.DatabaseName != nil {
		databaseName := *definition.DatabaseName
		result.Properties.DatabaseName = &databaseName
	}
	for _, item := range definition.Privileges {
		item_ARM, err := item.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		result.Properties.Privileges = append(result.Properties.Privileges, *item_ARM.(*arm.Privilege))
	}
	if definition.RoleName != nil {
		roleName := *definition.RoleName
		result.Properties.RoleName = &roleName
	}
	for _, item := range definition.Roles {
		item_ARM, err := item.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		result.Properties.Roles = append(result.Properties.Roles, *item_ARM.(*arm.Role))
	}
	if definition.Type != nil {
		var temp string
		temp = string(*definition.Type)
		typeVar := arm.MongoRoleDefinitionResource_Type(temp)
		result.Properties.Type = &typeVar
	}
	return result, nil
}

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

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

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

	// Set property "DatabaseName":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.DatabaseName != nil {
			databaseName := *typedInput.Properties.DatabaseName
			definition.DatabaseName = &databaseName
		}
	}

	// no assignment for property "OperatorSpec"

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

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

	// Set property "RoleName":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.RoleName != nil {
			roleName := *typedInput.Properties.RoleName
			definition.RoleName = &roleName
		}
	}

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

	// Set property "Type":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Type != nil {
			var temp string
			temp = string(*typedInput.Properties.Type)
			typeVar := MongoRoleDefinitionResource_Type(temp)
			definition.Type = &typeVar
		}
	}

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &MongodbRoleDefinition_Spec{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.MongodbRoleDefinition_Spec{}
	err := definition.AssignProperties_To_MongodbRoleDefinition_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_MongodbRoleDefinition_Spec populates our MongodbRoleDefinition_Spec from the provided source MongodbRoleDefinition_Spec
func (definition *MongodbRoleDefinition_Spec) AssignProperties_From_MongodbRoleDefinition_Spec(source *storage.MongodbRoleDefinition_Spec) error {

	// AzureName
	definition.AzureName = source.AzureName

	// DatabaseName
	definition.DatabaseName = genruntime.ClonePointerToString(source.DatabaseName)

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

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

	// Privileges
	if source.Privileges != nil {
		privilegeList := make([]Privilege, len(source.Privileges))
		for privilegeIndex, privilegeItem := range source.Privileges {
			var privilege Privilege
			err := privilege.AssignProperties_From_Privilege(&privilegeItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_Privilege() to populate field Privileges")
			}
			privilegeList[privilegeIndex] = privilege
		}
		definition.Privileges = privilegeList
	} else {
		definition.Privileges = nil
	}

	// RoleName
	definition.RoleName = genruntime.ClonePointerToString(source.RoleName)

	// Roles
	if source.Roles != nil {
		roleList := make([]Role, len(source.Roles))
		for roleIndex, roleItem := range source.Roles {
			var role Role
			err := role.AssignProperties_From_Role(&roleItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_Role() to populate field Roles")
			}
			roleList[roleIndex] = role
		}
		definition.Roles = roleList
	} else {
		definition.Roles = nil
	}

	// Type
	if source.Type != nil {
		typeVar := *source.Type
		typeTemp := genruntime.ToEnum(typeVar, mongoRoleDefinitionResource_Type_Values)
		definition.Type = &typeTemp
	} else {
		definition.Type = nil
	}

	// No error
	return nil
}

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

	// AzureName
	destination.AzureName = definition.AzureName

	// DatabaseName
	destination.DatabaseName = genruntime.ClonePointerToString(definition.DatabaseName)

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

	// OriginalVersion
	destination.OriginalVersion = definition.OriginalVersion()

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

	// Privileges
	if definition.Privileges != nil {
		privilegeList := make([]storage.Privilege, len(definition.Privileges))
		for privilegeIndex, privilegeItem := range definition.Privileges {
			var privilege storage.Privilege
			err := privilegeItem.AssignProperties_To_Privilege(&privilege)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_Privilege() to populate field Privileges")
			}
			privilegeList[privilegeIndex] = privilege
		}
		destination.Privileges = privilegeList
	} else {
		destination.Privileges = nil
	}

	// RoleName
	destination.RoleName = genruntime.ClonePointerToString(definition.RoleName)

	// Roles
	if definition.Roles != nil {
		roleList := make([]storage.Role, len(definition.Roles))
		for roleIndex, roleItem := range definition.Roles {
			var role storage.Role
			err := roleItem.AssignProperties_To_Role(&role)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_Role() to populate field Roles")
			}
			roleList[roleIndex] = role
		}
		destination.Roles = roleList
	} else {
		destination.Roles = nil
	}

	// Type
	if definition.Type != nil {
		typeVar := string(*definition.Type)
		destination.Type = &typeVar
	} else {
		destination.Type = nil
	}

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

	// No error
	return nil
}

// Initialize_From_MongodbRoleDefinition_STATUS populates our MongodbRoleDefinition_Spec from the provided source MongodbRoleDefinition_STATUS
func (definition *MongodbRoleDefinition_Spec) Initialize_From_MongodbRoleDefinition_STATUS(source *MongodbRoleDefinition_STATUS) error {

	// DatabaseName
	definition.DatabaseName = genruntime.ClonePointerToString(source.DatabaseName)

	// Privileges
	if source.Privileges != nil {
		privilegeList := make([]Privilege, len(source.Privileges))
		for privilegeIndex, privilegeItem := range source.Privileges {
			var privilege Privilege
			err := privilege.Initialize_From_Privilege_STATUS(&privilegeItem)
			if err != nil {
				return eris.Wrap(err, "calling Initialize_From_Privilege_STATUS() to populate field Privileges")
			}
			privilegeList[privilegeIndex] = privilege
		}
		definition.Privileges = privilegeList
	} else {
		definition.Privileges = nil
	}

	// RoleName
	definition.RoleName = genruntime.ClonePointerToString(source.RoleName)

	// Roles
	if source.Roles != nil {
		roleList := make([]Role, len(source.Roles))
		for roleIndex, roleItem := range source.Roles {
			var role Role
			err := role.Initialize_From_Role_STATUS(&roleItem)
			if err != nil {
				return eris.Wrap(err, "calling Initialize_From_Role_STATUS() to populate field Roles")
			}
			roleList[roleIndex] = role
		}
		definition.Roles = roleList
	} else {
		definition.Roles = nil
	}

	// No error
	return nil
}

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

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

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

	// DatabaseName: The database name for which access is being granted for this Role Definition.
	DatabaseName *string `json:"databaseName,omitempty"`

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

	// Name: The name of the database account.
	Name *string `json:"name,omitempty"`

	// Privileges: A set of privileges contained by the Role Definition. This will allow application of this Role Definition on
	// the entire database account or any underlying Database / Collection. Scopes higher than Database are not enforceable as
	// privilege.
	Privileges []Privilege_STATUS `json:"privileges,omitempty"`

	// RoleName: A user-friendly name for the Role Definition. Must be unique for the database account.
	RoleName *string `json:"roleName,omitempty"`

	// Roles: The set of roles inherited by this Role Definition.
	Roles []Role_STATUS `json:"roles,omitempty"`

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

var _ genruntime.ConvertibleStatus = &MongodbRoleDefinition_STATUS{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.MongodbRoleDefinition_STATUS{}
	err := definition.AssignProperties_To_MongodbRoleDefinition_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 = &MongodbRoleDefinition_STATUS{}

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

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

	// no assignment for property "Conditions"

	// Set property "DatabaseName":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.DatabaseName != nil {
			databaseName := *typedInput.Properties.DatabaseName
			definition.DatabaseName = &databaseName
		}
	}

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

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

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

	// Set property "RoleName":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.RoleName != nil {
			roleName := *typedInput.Properties.RoleName
			definition.RoleName = &roleName
		}
	}

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

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

	// No error
	return nil
}

// AssignProperties_From_MongodbRoleDefinition_STATUS populates our MongodbRoleDefinition_STATUS from the provided source MongodbRoleDefinition_STATUS
func (definition *MongodbRoleDefinition_STATUS) AssignProperties_From_MongodbRoleDefinition_STATUS(source *storage.MongodbRoleDefinition_STATUS) error {

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

	// DatabaseName
	definition.DatabaseName = genruntime.ClonePointerToString(source.DatabaseName)

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

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

	// Privileges
	if source.Privileges != nil {
		privilegeList := make([]Privilege_STATUS, len(source.Privileges))
		for privilegeIndex, privilegeItem := range source.Privileges {
			var privilege Privilege_STATUS
			err := privilege.AssignProperties_From_Privilege_STATUS(&privilegeItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_Privilege_STATUS() to populate field Privileges")
			}
			privilegeList[privilegeIndex] = privilege
		}
		definition.Privileges = privilegeList
	} else {
		definition.Privileges = nil
	}

	// RoleName
	definition.RoleName = genruntime.ClonePointerToString(source.RoleName)

	// Roles
	if source.Roles != nil {
		roleList := make([]Role_STATUS, len(source.Roles))
		for roleIndex, roleItem := range source.Roles {
			var role Role_STATUS
			err := role.AssignProperties_From_Role_STATUS(&roleItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_Role_STATUS() to populate field Roles")
			}
			roleList[roleIndex] = role
		}
		definition.Roles = roleList
	} else {
		definition.Roles = nil
	}

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

	// No error
	return nil
}

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

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

	// DatabaseName
	destination.DatabaseName = genruntime.ClonePointerToString(definition.DatabaseName)

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

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

	// Privileges
	if definition.Privileges != nil {
		privilegeList := make([]storage.Privilege_STATUS, len(definition.Privileges))
		for privilegeIndex, privilegeItem := range definition.Privileges {
			var privilege storage.Privilege_STATUS
			err := privilegeItem.AssignProperties_To_Privilege_STATUS(&privilege)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_Privilege_STATUS() to populate field Privileges")
			}
			privilegeList[privilegeIndex] = privilege
		}
		destination.Privileges = privilegeList
	} else {
		destination.Privileges = nil
	}

	// RoleName
	destination.RoleName = genruntime.ClonePointerToString(definition.RoleName)

	// Roles
	if definition.Roles != nil {
		roleList := make([]storage.Role_STATUS, len(definition.Roles))
		for roleIndex, roleItem := range definition.Roles {
			var role storage.Role_STATUS
			err := roleItem.AssignProperties_To_Role_STATUS(&role)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_Role_STATUS() to populate field Roles")
			}
			roleList[roleIndex] = role
		}
		destination.Roles = roleList
	} else {
		destination.Roles = nil
	}

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

	// 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 MongodbRoleDefinitionOperatorSpec 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_MongodbRoleDefinitionOperatorSpec populates our MongodbRoleDefinitionOperatorSpec from the provided source MongodbRoleDefinitionOperatorSpec
func (operator *MongodbRoleDefinitionOperatorSpec) AssignProperties_From_MongodbRoleDefinitionOperatorSpec(source *storage.MongodbRoleDefinitionOperatorSpec) 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_MongodbRoleDefinitionOperatorSpec populates the provided destination MongodbRoleDefinitionOperatorSpec from our MongodbRoleDefinitionOperatorSpec
func (operator *MongodbRoleDefinitionOperatorSpec) AssignProperties_To_MongodbRoleDefinitionOperatorSpec(destination *storage.MongodbRoleDefinitionOperatorSpec) 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
}

// +kubebuilder:validation:Enum={"BuiltInRole","CustomRole"}
type MongoRoleDefinitionResource_Type string

const (
	MongoRoleDefinitionResource_Type_BuiltInRole = MongoRoleDefinitionResource_Type("BuiltInRole")
	MongoRoleDefinitionResource_Type_CustomRole  = MongoRoleDefinitionResource_Type("CustomRole")
)

// Mapping from string to MongoRoleDefinitionResource_Type
var mongoRoleDefinitionResource_Type_Values = map[string]MongoRoleDefinitionResource_Type{
	"builtinrole": MongoRoleDefinitionResource_Type_BuiltInRole,
	"customrole":  MongoRoleDefinitionResource_Type_CustomRole,
}

// The set of data plane operations permitted through this Role Definition.
type Privilege struct {
	// Actions: An array of actions that are allowed.
	Actions []string `json:"actions,omitempty"`

	// Resource: An Azure Cosmos DB Mongo DB Resource.
	Resource *Privilege_Resource `json:"resource,omitempty"`
}

var _ genruntime.ARMTransformer = &Privilege{}

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

	// Set property "Actions":
	for _, item := range privilege.Actions {
		result.Actions = append(result.Actions, item)
	}

	// Set property "Resource":
	if privilege.Resource != nil {
		resource_ARM, err := privilege.Resource.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		resource := *resource_ARM.(*arm.Privilege_Resource)
		result.Resource = &resource
	}
	return result, nil
}

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

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

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

	// Set property "Resource":
	if typedInput.Resource != nil {
		var resource1 Privilege_Resource
		err := resource1.PopulateFromARM(owner, *typedInput.Resource)
		if err != nil {
			return err
		}
		resource := resource1
		privilege.Resource = &resource
	}

	// No error
	return nil
}

// AssignProperties_From_Privilege populates our Privilege from the provided source Privilege
func (privilege *Privilege) AssignProperties_From_Privilege(source *storage.Privilege) error {

	// Actions
	privilege.Actions = genruntime.CloneSliceOfString(source.Actions)

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

	// No error
	return nil
}

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

	// Actions
	destination.Actions = genruntime.CloneSliceOfString(privilege.Actions)

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

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

	// No error
	return nil
}

// Initialize_From_Privilege_STATUS populates our Privilege from the provided source Privilege_STATUS
func (privilege *Privilege) Initialize_From_Privilege_STATUS(source *Privilege_STATUS) error {

	// Actions
	privilege.Actions = genruntime.CloneSliceOfString(source.Actions)

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

	// No error
	return nil
}

// The set of data plane operations permitted through this Role Definition.
type Privilege_STATUS struct {
	// Actions: An array of actions that are allowed.
	Actions []string `json:"actions,omitempty"`

	// Resource: An Azure Cosmos DB Mongo DB Resource.
	Resource *Privilege_Resource_STATUS `json:"resource,omitempty"`
}

var _ genruntime.FromARMConverter = &Privilege_STATUS{}

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

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

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

	// Set property "Resource":
	if typedInput.Resource != nil {
		var resource1 Privilege_Resource_STATUS
		err := resource1.PopulateFromARM(owner, *typedInput.Resource)
		if err != nil {
			return err
		}
		resource := resource1
		privilege.Resource = &resource
	}

	// No error
	return nil
}

// AssignProperties_From_Privilege_STATUS populates our Privilege_STATUS from the provided source Privilege_STATUS
func (privilege *Privilege_STATUS) AssignProperties_From_Privilege_STATUS(source *storage.Privilege_STATUS) error {

	// Actions
	privilege.Actions = genruntime.CloneSliceOfString(source.Actions)

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

	// No error
	return nil
}

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

	// Actions
	destination.Actions = genruntime.CloneSliceOfString(privilege.Actions)

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

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

	// No error
	return nil
}

// The set of roles permitted through this Role Definition.
type Role struct {
	// Db: The database name the role is applied.
	Db *string `json:"db,omitempty"`

	// Role: The role name.
	Role *string `json:"role,omitempty"`
}

var _ genruntime.ARMTransformer = &Role{}

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

	// Set property "Db":
	if role.Db != nil {
		db := *role.Db
		result.Db = &db
	}

	// Set property "Role":
	if role.Role != nil {
		role1 := *role.Role
		result.Role = &role1
	}
	return result, nil
}

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

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

	// Set property "Db":
	if typedInput.Db != nil {
		db := *typedInput.Db
		role.Db = &db
	}

	// Set property "Role":
	if typedInput.Role != nil {
		role1 := *typedInput.Role
		role.Role = &role1
	}

	// No error
	return nil
}

// AssignProperties_From_Role populates our Role from the provided source Role
func (role *Role) AssignProperties_From_Role(source *storage.Role) error {

	// Db
	role.Db = genruntime.ClonePointerToString(source.Db)

	// Role
	role.Role = genruntime.ClonePointerToString(source.Role)

	// No error
	return nil
}

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

	// Db
	destination.Db = genruntime.ClonePointerToString(role.Db)

	// Role
	destination.Role = genruntime.ClonePointerToString(role.Role)

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

	// No error
	return nil
}

// Initialize_From_Role_STATUS populates our Role from the provided source Role_STATUS
func (role *Role) Initialize_From_Role_STATUS(source *Role_STATUS) error {

	// Db
	role.Db = genruntime.ClonePointerToString(source.Db)

	// Role
	role.Role = genruntime.ClonePointerToString(source.Role)

	// No error
	return nil
}

// The set of roles permitted through this Role Definition.
type Role_STATUS struct {
	// Db: The database name the role is applied.
	Db *string `json:"db,omitempty"`

	// Role: The role name.
	Role *string `json:"role,omitempty"`
}

var _ genruntime.FromARMConverter = &Role_STATUS{}

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

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

	// Set property "Db":
	if typedInput.Db != nil {
		db := *typedInput.Db
		role.Db = &db
	}

	// Set property "Role":
	if typedInput.Role != nil {
		role1 := *typedInput.Role
		role.Role = &role1
	}

	// No error
	return nil
}

// AssignProperties_From_Role_STATUS populates our Role_STATUS from the provided source Role_STATUS
func (role *Role_STATUS) AssignProperties_From_Role_STATUS(source *storage.Role_STATUS) error {

	// Db
	role.Db = genruntime.ClonePointerToString(source.Db)

	// Role
	role.Role = genruntime.ClonePointerToString(source.Role)

	// No error
	return nil
}

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

	// Db
	destination.Db = genruntime.ClonePointerToString(role.Db)

	// Role
	destination.Role = genruntime.ClonePointerToString(role.Role)

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

	// No error
	return nil
}

type Privilege_Resource struct {
	// Collection: The collection name the role is applied.
	Collection *string `json:"collection,omitempty"`

	// Db: The database name the role is applied.
	Db *string `json:"db,omitempty"`
}

var _ genruntime.ARMTransformer = &Privilege_Resource{}

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

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

	// Set property "Db":
	if resource.Db != nil {
		db := *resource.Db
		result.Db = &db
	}
	return result, nil
}

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

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

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

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

	// No error
	return nil
}

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

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

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

	// No error
	return nil
}

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

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

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

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

	// No error
	return nil
}

// Initialize_From_Privilege_Resource_STATUS populates our Privilege_Resource from the provided source Privilege_Resource_STATUS
func (resource *Privilege_Resource) Initialize_From_Privilege_Resource_STATUS(source *Privilege_Resource_STATUS) error {

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

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

	// No error
	return nil
}

type Privilege_Resource_STATUS struct {
	// Collection: The collection name the role is applied.
	Collection *string `json:"collection,omitempty"`

	// Db: The database name the role is applied.
	Db *string `json:"db,omitempty"`
}

var _ genruntime.FromARMConverter = &Privilege_Resource_STATUS{}

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

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

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

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

	// No error
	return nil
}

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

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

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

	// No error
	return nil
}

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

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

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

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

	// No error
	return nil
}

func init() {
	SchemeBuilder.Register(&MongodbRoleDefinition{}, &MongodbRoleDefinitionList{})
}
