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

import (
	"fmt"
	arm "github.com/Azure/azure-service-operator/v2/api/sql/v1api20211101/arm"
	storage "github.com/Azure/azure-service-operator/v2/api/sql/v1api20211101/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,sql}
// +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: /sql/resource-manager/Microsoft.Sql/stable/2021-11-01/ServerAdvancedThreatProtectionSettings.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advancedThreatProtectionSettings/Default
type ServersAdvancedThreatProtectionSetting struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              ServersAdvancedThreatProtectionSetting_Spec   `json:"spec,omitempty"`
	Status            ServersAdvancedThreatProtectionSetting_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &ServersAdvancedThreatProtectionSetting{}

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

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

var _ conversion.Convertible = &ServersAdvancedThreatProtectionSetting{}

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

	return setting.AssignProperties_From_ServersAdvancedThreatProtectionSetting(source)
}

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

	return setting.AssignProperties_To_ServersAdvancedThreatProtectionSetting(destination)
}

var _ configmaps.Exporter = &ServersAdvancedThreatProtectionSetting{}

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

var _ secrets.Exporter = &ServersAdvancedThreatProtectionSetting{}

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

var _ genruntime.ImportableResource = &ServersAdvancedThreatProtectionSetting{}

// InitializeSpec initializes the spec for this resource from the given status
func (setting *ServersAdvancedThreatProtectionSetting) InitializeSpec(status genruntime.ConvertibleStatus) error {
	if s, ok := status.(*ServersAdvancedThreatProtectionSetting_STATUS); ok {
		return setting.Spec.Initialize_From_ServersAdvancedThreatProtectionSetting_STATUS(s)
	}

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

var _ genruntime.KubernetesResource = &ServersAdvancedThreatProtectionSetting{}

// AzureName returns the Azure name of the resource (always "Default")
func (setting *ServersAdvancedThreatProtectionSetting) AzureName() string {
	return "Default"
}

// GetAPIVersion returns the ARM API version of the resource. This is always "2021-11-01"
func (setting ServersAdvancedThreatProtectionSetting) GetAPIVersion() string {
	return "2021-11-01"
}

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.Sql/servers/advancedThreatProtectionSettings"
func (setting *ServersAdvancedThreatProtectionSetting) GetType() string {
	return "Microsoft.Sql/servers/advancedThreatProtectionSettings"
}

// NewEmptyStatus returns a new empty (blank) status
func (setting *ServersAdvancedThreatProtectionSetting) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &ServersAdvancedThreatProtectionSetting_STATUS{}
}

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

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

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

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

	setting.Status = st
	return nil
}

// AssignProperties_From_ServersAdvancedThreatProtectionSetting populates our ServersAdvancedThreatProtectionSetting from the provided source ServersAdvancedThreatProtectionSetting
func (setting *ServersAdvancedThreatProtectionSetting) AssignProperties_From_ServersAdvancedThreatProtectionSetting(source *storage.ServersAdvancedThreatProtectionSetting) error {

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

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

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

	// No error
	return nil
}

// AssignProperties_To_ServersAdvancedThreatProtectionSetting populates the provided destination ServersAdvancedThreatProtectionSetting from our ServersAdvancedThreatProtectionSetting
func (setting *ServersAdvancedThreatProtectionSetting) AssignProperties_To_ServersAdvancedThreatProtectionSetting(destination *storage.ServersAdvancedThreatProtectionSetting) error {

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

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

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

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /sql/resource-manager/Microsoft.Sql/stable/2021-11-01/ServerAdvancedThreatProtectionSettings.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advancedThreatProtectionSettings/Default
type ServersAdvancedThreatProtectionSettingList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []ServersAdvancedThreatProtectionSetting `json:"items"`
}

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

	// +kubebuilder:validation:Required
	// State: Specifies the state of the Advanced Threat Protection, whether it is enabled or disabled or a state has not been
	// applied yet on the specific database or server.
	State *AdvancedThreatProtectionProperties_State `json:"state,omitempty"`
}

var _ genruntime.ARMTransformer = &ServersAdvancedThreatProtectionSetting_Spec{}

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

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

	// Set property "Properties":
	if setting.State != nil {
		result.Properties = &arm.AdvancedThreatProtectionProperties{}
	}
	if setting.State != nil {
		var temp string
		temp = string(*setting.State)
		state := arm.AdvancedThreatProtectionProperties_State(temp)
		result.Properties.State = &state
	}
	return result, nil
}

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

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

	// no assignment for property "OperatorSpec"

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

	// Set property "State":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.State != nil {
			var temp string
			temp = string(*typedInput.Properties.State)
			state := AdvancedThreatProtectionProperties_State(temp)
			setting.State = &state
		}
	}

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &ServersAdvancedThreatProtectionSetting_Spec{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.ServersAdvancedThreatProtectionSetting_Spec{}
	err := setting.AssignProperties_To_ServersAdvancedThreatProtectionSetting_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_ServersAdvancedThreatProtectionSetting_Spec populates our ServersAdvancedThreatProtectionSetting_Spec from the provided source ServersAdvancedThreatProtectionSetting_Spec
func (setting *ServersAdvancedThreatProtectionSetting_Spec) AssignProperties_From_ServersAdvancedThreatProtectionSetting_Spec(source *storage.ServersAdvancedThreatProtectionSetting_Spec) error {

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

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

	// State
	if source.State != nil {
		state := *source.State
		stateTemp := genruntime.ToEnum(state, advancedThreatProtectionProperties_State_Values)
		setting.State = &stateTemp
	} else {
		setting.State = nil
	}

	// No error
	return nil
}

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

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

	// OriginalVersion
	destination.OriginalVersion = setting.OriginalVersion()

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

	// State
	if setting.State != nil {
		state := string(*setting.State)
		destination.State = &state
	} else {
		destination.State = nil
	}

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

	// No error
	return nil
}

// Initialize_From_ServersAdvancedThreatProtectionSetting_STATUS populates our ServersAdvancedThreatProtectionSetting_Spec from the provided source ServersAdvancedThreatProtectionSetting_STATUS
func (setting *ServersAdvancedThreatProtectionSetting_Spec) Initialize_From_ServersAdvancedThreatProtectionSetting_STATUS(source *ServersAdvancedThreatProtectionSetting_STATUS) error {

	// State
	if source.State != nil {
		state := genruntime.ToEnum(string(*source.State), advancedThreatProtectionProperties_State_Values)
		setting.State = &state
	} else {
		setting.State = nil
	}

	// No error
	return nil
}

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

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

	// CreationTime: Specifies the UTC creation time of the policy.
	CreationTime *string `json:"creationTime,omitempty"`

	// Id: Resource ID.
	Id *string `json:"id,omitempty"`

	// Name: Resource name.
	Name *string `json:"name,omitempty"`

	// State: Specifies the state of the Advanced Threat Protection, whether it is enabled or disabled or a state has not been
	// applied yet on the specific database or server.
	State *AdvancedThreatProtectionProperties_State_STATUS `json:"state,omitempty"`

	// SystemData: SystemData of AdvancedThreatProtectionResource.
	SystemData *SystemData_STATUS `json:"systemData,omitempty"`

	// Type: Resource type.
	Type *string `json:"type,omitempty"`
}

var _ genruntime.ConvertibleStatus = &ServersAdvancedThreatProtectionSetting_STATUS{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.ServersAdvancedThreatProtectionSetting_STATUS{}
	err := setting.AssignProperties_To_ServersAdvancedThreatProtectionSetting_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 = &ServersAdvancedThreatProtectionSetting_STATUS{}

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

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

	// no assignment for property "Conditions"

	// Set property "CreationTime":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.CreationTime != nil {
			creationTime := *typedInput.Properties.CreationTime
			setting.CreationTime = &creationTime
		}
	}

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

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

	// Set property "State":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.State != nil {
			var temp string
			temp = string(*typedInput.Properties.State)
			state := AdvancedThreatProtectionProperties_State_STATUS(temp)
			setting.State = &state
		}
	}

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

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

	// No error
	return nil
}

// AssignProperties_From_ServersAdvancedThreatProtectionSetting_STATUS populates our ServersAdvancedThreatProtectionSetting_STATUS from the provided source ServersAdvancedThreatProtectionSetting_STATUS
func (setting *ServersAdvancedThreatProtectionSetting_STATUS) AssignProperties_From_ServersAdvancedThreatProtectionSetting_STATUS(source *storage.ServersAdvancedThreatProtectionSetting_STATUS) error {

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

	// CreationTime
	setting.CreationTime = genruntime.ClonePointerToString(source.CreationTime)

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

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

	// State
	if source.State != nil {
		state := *source.State
		stateTemp := genruntime.ToEnum(state, advancedThreatProtectionProperties_State_STATUS_Values)
		setting.State = &stateTemp
	} else {
		setting.State = nil
	}

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

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

	// No error
	return nil
}

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

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

	// CreationTime
	destination.CreationTime = genruntime.ClonePointerToString(setting.CreationTime)

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

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

	// State
	if setting.State != nil {
		state := string(*setting.State)
		destination.State = &state
	} else {
		destination.State = nil
	}

	// SystemData
	if setting.SystemData != nil {
		var systemDatum storage.SystemData_STATUS
		err := setting.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
	}

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

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

	// No error
	return nil
}

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

const (
	AdvancedThreatProtectionProperties_State_Disabled = AdvancedThreatProtectionProperties_State("Disabled")
	AdvancedThreatProtectionProperties_State_Enabled  = AdvancedThreatProtectionProperties_State("Enabled")
	AdvancedThreatProtectionProperties_State_New      = AdvancedThreatProtectionProperties_State("New")
)

// Mapping from string to AdvancedThreatProtectionProperties_State
var advancedThreatProtectionProperties_State_Values = map[string]AdvancedThreatProtectionProperties_State{
	"disabled": AdvancedThreatProtectionProperties_State_Disabled,
	"enabled":  AdvancedThreatProtectionProperties_State_Enabled,
	"new":      AdvancedThreatProtectionProperties_State_New,
}

type AdvancedThreatProtectionProperties_State_STATUS string

const (
	AdvancedThreatProtectionProperties_State_STATUS_Disabled = AdvancedThreatProtectionProperties_State_STATUS("Disabled")
	AdvancedThreatProtectionProperties_State_STATUS_Enabled  = AdvancedThreatProtectionProperties_State_STATUS("Enabled")
	AdvancedThreatProtectionProperties_State_STATUS_New      = AdvancedThreatProtectionProperties_State_STATUS("New")
)

// Mapping from string to AdvancedThreatProtectionProperties_State_STATUS
var advancedThreatProtectionProperties_State_STATUS_Values = map[string]AdvancedThreatProtectionProperties_State_STATUS{
	"disabled": AdvancedThreatProtectionProperties_State_STATUS_Disabled,
	"enabled":  AdvancedThreatProtectionProperties_State_STATUS_Enabled,
	"new":      AdvancedThreatProtectionProperties_State_STATUS_New,
}

// Details for configuring operator behavior. Fields in this struct are interpreted by the operator directly rather than being passed to Azure
type ServersAdvancedThreatProtectionSettingOperatorSpec 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_ServersAdvancedThreatProtectionSettingOperatorSpec populates our ServersAdvancedThreatProtectionSettingOperatorSpec from the provided source ServersAdvancedThreatProtectionSettingOperatorSpec
func (operator *ServersAdvancedThreatProtectionSettingOperatorSpec) AssignProperties_From_ServersAdvancedThreatProtectionSettingOperatorSpec(source *storage.ServersAdvancedThreatProtectionSettingOperatorSpec) 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_ServersAdvancedThreatProtectionSettingOperatorSpec populates the provided destination ServersAdvancedThreatProtectionSettingOperatorSpec from our ServersAdvancedThreatProtectionSettingOperatorSpec
func (operator *ServersAdvancedThreatProtectionSettingOperatorSpec) AssignProperties_To_ServersAdvancedThreatProtectionSettingOperatorSpec(destination *storage.ServersAdvancedThreatProtectionSettingOperatorSpec) 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(&ServersAdvancedThreatProtectionSetting{}, &ServersAdvancedThreatProtectionSettingList{})
}
