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

import (
	"fmt"
	arm "github.com/Azure/azure-service-operator/v2/api/dbformysql/v1api20220101/arm"
	storage "github.com/Azure/azure-service-operator/v2/api/dbformysql/v1api20220101/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,dbformysql}
// +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: /mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2022-01-01/AzureADAdministrator.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}
type FlexibleServersAdministrator struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              FlexibleServersAdministrator_Spec   `json:"spec,omitempty"`
	Status            FlexibleServersAdministrator_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &FlexibleServersAdministrator{}

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

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

var _ conversion.Convertible = &FlexibleServersAdministrator{}

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

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

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

	return nil
}

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

	return nil
}

var _ configmaps.Exporter = &FlexibleServersAdministrator{}

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

var _ secrets.Exporter = &FlexibleServersAdministrator{}

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

var _ genruntime.KubernetesResource = &FlexibleServersAdministrator{}

// AzureName returns the Azure name of the resource (always "ActiveDirectory")
func (administrator *FlexibleServersAdministrator) AzureName() string {
	return "ActiveDirectory"
}

// GetAPIVersion returns the ARM API version of the resource. This is always "2022-01-01"
func (administrator FlexibleServersAdministrator) GetAPIVersion() string {
	return "2022-01-01"
}

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.DBforMySQL/flexibleServers/administrators"
func (administrator *FlexibleServersAdministrator) GetType() string {
	return "Microsoft.DBforMySQL/flexibleServers/administrators"
}

// NewEmptyStatus returns a new empty (blank) status
func (administrator *FlexibleServersAdministrator) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &FlexibleServersAdministrator_STATUS{}
}

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

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

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

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

	administrator.Status = st
	return nil
}

// AssignProperties_From_FlexibleServersAdministrator populates our FlexibleServersAdministrator from the provided source FlexibleServersAdministrator
func (administrator *FlexibleServersAdministrator) AssignProperties_From_FlexibleServersAdministrator(source *storage.FlexibleServersAdministrator) error {

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

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

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

	// No error
	return nil
}

// AssignProperties_To_FlexibleServersAdministrator populates the provided destination FlexibleServersAdministrator from our FlexibleServersAdministrator
func (administrator *FlexibleServersAdministrator) AssignProperties_To_FlexibleServersAdministrator(destination *storage.FlexibleServersAdministrator) error {

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

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

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

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2022-01-01/AzureADAdministrator.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}
type FlexibleServersAdministratorList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []FlexibleServersAdministrator `json:"items"`
}

// +kubebuilder:validation:Enum={"2022-01-01"}
type APIVersion string

const APIVersion_Value = APIVersion("2022-01-01")

type FlexibleServersAdministrator_Spec struct {
	// AdministratorType: Type of the sever administrator.
	AdministratorType *AdministratorProperties_AdministratorType `json:"administratorType,omitempty"`

	// IdentityResourceReference: The resource id of the identity used for AAD Authentication.
	IdentityResourceReference *genruntime.ResourceReference `armReference:"IdentityResourceId" json:"identityResourceReference,omitempty"`

	// Login: Login name of the server administrator.
	Login *string `json:"login,omitempty"`

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

	// Sid: SID (object ID) of the server administrator.
	Sid *string `json:"sid,omitempty" optionalConfigMapPair:"Sid"`

	// SidFromConfig: SID (object ID) of the server administrator.
	SidFromConfig *genruntime.ConfigMapReference `json:"sidFromConfig,omitempty" optionalConfigMapPair:"Sid"`

	// TenantId: Tenant ID of the administrator.
	TenantId *string `json:"tenantId,omitempty" optionalConfigMapPair:"TenantId"`

	// TenantIdFromConfig: Tenant ID of the administrator.
	TenantIdFromConfig *genruntime.ConfigMapReference `json:"tenantIdFromConfig,omitempty" optionalConfigMapPair:"TenantId"`
}

var _ genruntime.ARMTransformer = &FlexibleServersAdministrator_Spec{}

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

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

	// Set property "Properties":
	if administrator.AdministratorType != nil ||
		administrator.IdentityResourceReference != nil ||
		administrator.Login != nil ||
		administrator.Sid != nil ||
		administrator.SidFromConfig != nil ||
		administrator.TenantId != nil ||
		administrator.TenantIdFromConfig != nil {
		result.Properties = &arm.AdministratorProperties{}
	}
	if administrator.AdministratorType != nil {
		var temp string
		temp = string(*administrator.AdministratorType)
		administratorType := arm.AdministratorProperties_AdministratorType(temp)
		result.Properties.AdministratorType = &administratorType
	}
	if administrator.IdentityResourceReference != nil {
		identityResourceIdARMID, err := resolved.ResolvedReferences.Lookup(*administrator.IdentityResourceReference)
		if err != nil {
			return nil, err
		}
		identityResourceId := identityResourceIdARMID
		result.Properties.IdentityResourceId = &identityResourceId
	}
	if administrator.Login != nil {
		login := *administrator.Login
		result.Properties.Login = &login
	}
	if administrator.Sid != nil {
		sid := *administrator.Sid
		result.Properties.Sid = &sid
	}
	if administrator.SidFromConfig != nil {
		sidValue, err := resolved.ResolvedConfigMaps.Lookup(*administrator.SidFromConfig)
		if err != nil {
			return nil, eris.Wrap(err, "looking up configmap for property Sid")
		}
		sid := sidValue
		result.Properties.Sid = &sid
	}
	if administrator.TenantId != nil {
		tenantId := *administrator.TenantId
		result.Properties.TenantId = &tenantId
	}
	if administrator.TenantIdFromConfig != nil {
		tenantIdValue, err := resolved.ResolvedConfigMaps.Lookup(*administrator.TenantIdFromConfig)
		if err != nil {
			return nil, eris.Wrap(err, "looking up configmap for property TenantId")
		}
		tenantId := tenantIdValue
		result.Properties.TenantId = &tenantId
	}
	return result, nil
}

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

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

	// Set property "AdministratorType":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.AdministratorType != nil {
			var temp string
			temp = string(*typedInput.Properties.AdministratorType)
			administratorType := AdministratorProperties_AdministratorType(temp)
			administrator.AdministratorType = &administratorType
		}
	}

	// no assignment for property "IdentityResourceReference"

	// Set property "Login":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Login != nil {
			login := *typedInput.Properties.Login
			administrator.Login = &login
		}
	}

	// no assignment for property "OperatorSpec"

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

	// Set property "Sid":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Sid != nil {
			sid := *typedInput.Properties.Sid
			administrator.Sid = &sid
		}
	}

	// no assignment for property "SidFromConfig"

	// Set property "TenantId":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.TenantId != nil {
			tenantId := *typedInput.Properties.TenantId
			administrator.TenantId = &tenantId
		}
	}

	// no assignment for property "TenantIdFromConfig"

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &FlexibleServersAdministrator_Spec{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.FlexibleServersAdministrator_Spec{}
	err := administrator.AssignProperties_To_FlexibleServersAdministrator_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_FlexibleServersAdministrator_Spec populates our FlexibleServersAdministrator_Spec from the provided source FlexibleServersAdministrator_Spec
func (administrator *FlexibleServersAdministrator_Spec) AssignProperties_From_FlexibleServersAdministrator_Spec(source *storage.FlexibleServersAdministrator_Spec) error {

	// AdministratorType
	if source.AdministratorType != nil {
		administratorType := *source.AdministratorType
		administratorTypeTemp := genruntime.ToEnum(administratorType, administratorProperties_AdministratorType_Values)
		administrator.AdministratorType = &administratorTypeTemp
	} else {
		administrator.AdministratorType = nil
	}

	// IdentityResourceReference
	if source.IdentityResourceReference != nil {
		identityResourceReference := source.IdentityResourceReference.Copy()
		administrator.IdentityResourceReference = &identityResourceReference
	} else {
		administrator.IdentityResourceReference = nil
	}

	// Login
	administrator.Login = genruntime.ClonePointerToString(source.Login)

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

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

	// Sid
	administrator.Sid = genruntime.ClonePointerToString(source.Sid)

	// SidFromConfig
	if source.SidFromConfig != nil {
		sidFromConfig := source.SidFromConfig.Copy()
		administrator.SidFromConfig = &sidFromConfig
	} else {
		administrator.SidFromConfig = nil
	}

	// TenantId
	administrator.TenantId = genruntime.ClonePointerToString(source.TenantId)

	// TenantIdFromConfig
	if source.TenantIdFromConfig != nil {
		tenantIdFromConfig := source.TenantIdFromConfig.Copy()
		administrator.TenantIdFromConfig = &tenantIdFromConfig
	} else {
		administrator.TenantIdFromConfig = nil
	}

	// No error
	return nil
}

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

	// AdministratorType
	if administrator.AdministratorType != nil {
		administratorType := string(*administrator.AdministratorType)
		destination.AdministratorType = &administratorType
	} else {
		destination.AdministratorType = nil
	}

	// IdentityResourceReference
	if administrator.IdentityResourceReference != nil {
		identityResourceReference := administrator.IdentityResourceReference.Copy()
		destination.IdentityResourceReference = &identityResourceReference
	} else {
		destination.IdentityResourceReference = nil
	}

	// Login
	destination.Login = genruntime.ClonePointerToString(administrator.Login)

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

	// OriginalVersion
	destination.OriginalVersion = administrator.OriginalVersion()

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

	// Sid
	destination.Sid = genruntime.ClonePointerToString(administrator.Sid)

	// SidFromConfig
	if administrator.SidFromConfig != nil {
		sidFromConfig := administrator.SidFromConfig.Copy()
		destination.SidFromConfig = &sidFromConfig
	} else {
		destination.SidFromConfig = nil
	}

	// TenantId
	destination.TenantId = genruntime.ClonePointerToString(administrator.TenantId)

	// TenantIdFromConfig
	if administrator.TenantIdFromConfig != nil {
		tenantIdFromConfig := administrator.TenantIdFromConfig.Copy()
		destination.TenantIdFromConfig = &tenantIdFromConfig
	} else {
		destination.TenantIdFromConfig = nil
	}

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

	// No error
	return nil
}

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

type FlexibleServersAdministrator_STATUS struct {
	// AdministratorType: Type of the sever administrator.
	AdministratorType *AdministratorProperties_AdministratorType_STATUS `json:"administratorType,omitempty"`

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

	// Id: Fully qualified resource ID for the resource. Ex -
	// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
	Id *string `json:"id,omitempty"`

	// IdentityResourceId: The resource id of the identity used for AAD Authentication.
	IdentityResourceId *string `json:"identityResourceId,omitempty"`

	// Login: Login name of the server administrator.
	Login *string `json:"login,omitempty"`

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

	// Sid: SID (object ID) of the server administrator.
	Sid *string `json:"sid,omitempty"`

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

	// TenantId: Tenant ID of the administrator.
	TenantId *string `json:"tenantId,omitempty"`

	// Type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
	Type *string `json:"type,omitempty"`
}

var _ genruntime.ConvertibleStatus = &FlexibleServersAdministrator_STATUS{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.FlexibleServersAdministrator_STATUS{}
	err := administrator.AssignProperties_To_FlexibleServersAdministrator_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 = &FlexibleServersAdministrator_STATUS{}

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

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

	// Set property "AdministratorType":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.AdministratorType != nil {
			var temp string
			temp = string(*typedInput.Properties.AdministratorType)
			administratorType := AdministratorProperties_AdministratorType_STATUS(temp)
			administrator.AdministratorType = &administratorType
		}
	}

	// no assignment for property "Conditions"

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

	// Set property "IdentityResourceId":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.IdentityResourceId != nil {
			identityResourceId := *typedInput.Properties.IdentityResourceId
			administrator.IdentityResourceId = &identityResourceId
		}
	}

	// Set property "Login":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Login != nil {
			login := *typedInput.Properties.Login
			administrator.Login = &login
		}
	}

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

	// Set property "Sid":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Sid != nil {
			sid := *typedInput.Properties.Sid
			administrator.Sid = &sid
		}
	}

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

	// Set property "TenantId":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.TenantId != nil {
			tenantId := *typedInput.Properties.TenantId
			administrator.TenantId = &tenantId
		}
	}

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

	// No error
	return nil
}

// AssignProperties_From_FlexibleServersAdministrator_STATUS populates our FlexibleServersAdministrator_STATUS from the provided source FlexibleServersAdministrator_STATUS
func (administrator *FlexibleServersAdministrator_STATUS) AssignProperties_From_FlexibleServersAdministrator_STATUS(source *storage.FlexibleServersAdministrator_STATUS) error {

	// AdministratorType
	if source.AdministratorType != nil {
		administratorType := *source.AdministratorType
		administratorTypeTemp := genruntime.ToEnum(administratorType, administratorProperties_AdministratorType_STATUS_Values)
		administrator.AdministratorType = &administratorTypeTemp
	} else {
		administrator.AdministratorType = nil
	}

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

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

	// IdentityResourceId
	administrator.IdentityResourceId = genruntime.ClonePointerToString(source.IdentityResourceId)

	// Login
	administrator.Login = genruntime.ClonePointerToString(source.Login)

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

	// Sid
	administrator.Sid = genruntime.ClonePointerToString(source.Sid)

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

	// TenantId
	administrator.TenantId = genruntime.ClonePointerToString(source.TenantId)

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

	// No error
	return nil
}

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

	// AdministratorType
	if administrator.AdministratorType != nil {
		administratorType := string(*administrator.AdministratorType)
		destination.AdministratorType = &administratorType
	} else {
		destination.AdministratorType = nil
	}

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

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

	// IdentityResourceId
	destination.IdentityResourceId = genruntime.ClonePointerToString(administrator.IdentityResourceId)

	// Login
	destination.Login = genruntime.ClonePointerToString(administrator.Login)

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

	// Sid
	destination.Sid = genruntime.ClonePointerToString(administrator.Sid)

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

	// TenantId
	destination.TenantId = genruntime.ClonePointerToString(administrator.TenantId)

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

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

	// No error
	return nil
}

// +kubebuilder:validation:Enum={"ActiveDirectory"}
type AdministratorProperties_AdministratorType string

const AdministratorProperties_AdministratorType_ActiveDirectory = AdministratorProperties_AdministratorType("ActiveDirectory")

// Mapping from string to AdministratorProperties_AdministratorType
var administratorProperties_AdministratorType_Values = map[string]AdministratorProperties_AdministratorType{
	"activedirectory": AdministratorProperties_AdministratorType_ActiveDirectory,
}

type AdministratorProperties_AdministratorType_STATUS string

const AdministratorProperties_AdministratorType_STATUS_ActiveDirectory = AdministratorProperties_AdministratorType_STATUS("ActiveDirectory")

// Mapping from string to AdministratorProperties_AdministratorType_STATUS
var administratorProperties_AdministratorType_STATUS_Values = map[string]AdministratorProperties_AdministratorType_STATUS{
	"activedirectory": AdministratorProperties_AdministratorType_STATUS_ActiveDirectory,
}

// Details for configuring operator behavior. Fields in this struct are interpreted by the operator directly rather than being passed to Azure
type FlexibleServersAdministratorOperatorSpec 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_FlexibleServersAdministratorOperatorSpec populates our FlexibleServersAdministratorOperatorSpec from the provided source FlexibleServersAdministratorOperatorSpec
func (operator *FlexibleServersAdministratorOperatorSpec) AssignProperties_From_FlexibleServersAdministratorOperatorSpec(source *storage.FlexibleServersAdministratorOperatorSpec) 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_FlexibleServersAdministratorOperatorSpec populates the provided destination FlexibleServersAdministratorOperatorSpec from our FlexibleServersAdministratorOperatorSpec
func (operator *FlexibleServersAdministratorOperatorSpec) AssignProperties_To_FlexibleServersAdministratorOperatorSpec(destination *storage.FlexibleServersAdministratorOperatorSpec) 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
}

// Metadata pertaining to creation and last modification of the resource.
type SystemData_STATUS struct {
	// CreatedAt: The timestamp of resource creation (UTC).
	CreatedAt *string `json:"createdAt,omitempty"`

	// CreatedBy: The identity that created the resource.
	CreatedBy *string `json:"createdBy,omitempty"`

	// CreatedByType: The type of identity that created the resource.
	CreatedByType *SystemData_CreatedByType_STATUS `json:"createdByType,omitempty"`

	// LastModifiedAt: The timestamp of resource last modification (UTC)
	LastModifiedAt *string `json:"lastModifiedAt,omitempty"`

	// LastModifiedBy: The identity that last modified the resource.
	LastModifiedBy *string `json:"lastModifiedBy,omitempty"`

	// LastModifiedByType: The type of identity that last modified the resource.
	LastModifiedByType *SystemData_LastModifiedByType_STATUS `json:"lastModifiedByType,omitempty"`
}

var _ genruntime.FromARMConverter = &SystemData_STATUS{}

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

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

	// Set property "CreatedAt":
	if typedInput.CreatedAt != nil {
		createdAt := *typedInput.CreatedAt
		data.CreatedAt = &createdAt
	}

	// Set property "CreatedBy":
	if typedInput.CreatedBy != nil {
		createdBy := *typedInput.CreatedBy
		data.CreatedBy = &createdBy
	}

	// Set property "CreatedByType":
	if typedInput.CreatedByType != nil {
		var temp string
		temp = string(*typedInput.CreatedByType)
		createdByType := SystemData_CreatedByType_STATUS(temp)
		data.CreatedByType = &createdByType
	}

	// Set property "LastModifiedAt":
	if typedInput.LastModifiedAt != nil {
		lastModifiedAt := *typedInput.LastModifiedAt
		data.LastModifiedAt = &lastModifiedAt
	}

	// Set property "LastModifiedBy":
	if typedInput.LastModifiedBy != nil {
		lastModifiedBy := *typedInput.LastModifiedBy
		data.LastModifiedBy = &lastModifiedBy
	}

	// Set property "LastModifiedByType":
	if typedInput.LastModifiedByType != nil {
		var temp string
		temp = string(*typedInput.LastModifiedByType)
		lastModifiedByType := SystemData_LastModifiedByType_STATUS(temp)
		data.LastModifiedByType = &lastModifiedByType
	}

	// No error
	return nil
}

// AssignProperties_From_SystemData_STATUS populates our SystemData_STATUS from the provided source SystemData_STATUS
func (data *SystemData_STATUS) AssignProperties_From_SystemData_STATUS(source *storage.SystemData_STATUS) error {

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

	// CreatedBy
	data.CreatedBy = genruntime.ClonePointerToString(source.CreatedBy)

	// CreatedByType
	if source.CreatedByType != nil {
		createdByType := *source.CreatedByType
		createdByTypeTemp := genruntime.ToEnum(createdByType, systemData_CreatedByType_STATUS_Values)
		data.CreatedByType = &createdByTypeTemp
	} else {
		data.CreatedByType = nil
	}

	// LastModifiedAt
	data.LastModifiedAt = genruntime.ClonePointerToString(source.LastModifiedAt)

	// LastModifiedBy
	data.LastModifiedBy = genruntime.ClonePointerToString(source.LastModifiedBy)

	// LastModifiedByType
	if source.LastModifiedByType != nil {
		lastModifiedByType := *source.LastModifiedByType
		lastModifiedByTypeTemp := genruntime.ToEnum(lastModifiedByType, systemData_LastModifiedByType_STATUS_Values)
		data.LastModifiedByType = &lastModifiedByTypeTemp
	} else {
		data.LastModifiedByType = nil
	}

	// No error
	return nil
}

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

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

	// CreatedBy
	destination.CreatedBy = genruntime.ClonePointerToString(data.CreatedBy)

	// CreatedByType
	if data.CreatedByType != nil {
		createdByType := string(*data.CreatedByType)
		destination.CreatedByType = &createdByType
	} else {
		destination.CreatedByType = nil
	}

	// LastModifiedAt
	destination.LastModifiedAt = genruntime.ClonePointerToString(data.LastModifiedAt)

	// LastModifiedBy
	destination.LastModifiedBy = genruntime.ClonePointerToString(data.LastModifiedBy)

	// LastModifiedByType
	if data.LastModifiedByType != nil {
		lastModifiedByType := string(*data.LastModifiedByType)
		destination.LastModifiedByType = &lastModifiedByType
	} else {
		destination.LastModifiedByType = nil
	}

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

	// No error
	return nil
}

type SystemData_CreatedByType_STATUS string

const (
	SystemData_CreatedByType_STATUS_Application     = SystemData_CreatedByType_STATUS("Application")
	SystemData_CreatedByType_STATUS_Key             = SystemData_CreatedByType_STATUS("Key")
	SystemData_CreatedByType_STATUS_ManagedIdentity = SystemData_CreatedByType_STATUS("ManagedIdentity")
	SystemData_CreatedByType_STATUS_User            = SystemData_CreatedByType_STATUS("User")
)

// Mapping from string to SystemData_CreatedByType_STATUS
var systemData_CreatedByType_STATUS_Values = map[string]SystemData_CreatedByType_STATUS{
	"application":     SystemData_CreatedByType_STATUS_Application,
	"key":             SystemData_CreatedByType_STATUS_Key,
	"managedidentity": SystemData_CreatedByType_STATUS_ManagedIdentity,
	"user":            SystemData_CreatedByType_STATUS_User,
}

type SystemData_LastModifiedByType_STATUS string

const (
	SystemData_LastModifiedByType_STATUS_Application     = SystemData_LastModifiedByType_STATUS("Application")
	SystemData_LastModifiedByType_STATUS_Key             = SystemData_LastModifiedByType_STATUS("Key")
	SystemData_LastModifiedByType_STATUS_ManagedIdentity = SystemData_LastModifiedByType_STATUS("ManagedIdentity")
	SystemData_LastModifiedByType_STATUS_User            = SystemData_LastModifiedByType_STATUS("User")
)

// Mapping from string to SystemData_LastModifiedByType_STATUS
var systemData_LastModifiedByType_STATUS_Values = map[string]SystemData_LastModifiedByType_STATUS{
	"application":     SystemData_LastModifiedByType_STATUS_Application,
	"key":             SystemData_LastModifiedByType_STATUS_Key,
	"managedidentity": SystemData_LastModifiedByType_STATUS_ManagedIdentity,
	"user":            SystemData_LastModifiedByType_STATUS_User,
}

func init() {
	SchemeBuilder.Register(&FlexibleServersAdministrator{}, &FlexibleServersAdministratorList{})
}
