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

import (
	"fmt"
	arm "github.com/Azure/azure-service-operator/v2/api/alertsmanagement/v1api20210401/arm"
	storage "github.com/Azure/azure-service-operator/v2/api/alertsmanagement/v1api20210401/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"
	"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
	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,alertsmanagement}
// +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: /alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-04-01/SmartDetectorAlertRulesApi.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}
type SmartDetectorAlertRule struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              SmartDetectorAlertRule_Spec   `json:"spec,omitempty"`
	Status            SmartDetectorAlertRule_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &SmartDetectorAlertRule{}

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

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

var _ conversion.Convertible = &SmartDetectorAlertRule{}

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

	return rule.AssignProperties_From_SmartDetectorAlertRule(source)
}

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

	return rule.AssignProperties_To_SmartDetectorAlertRule(destination)
}

var _ configmaps.Exporter = &SmartDetectorAlertRule{}

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

var _ secrets.Exporter = &SmartDetectorAlertRule{}

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

var _ genruntime.ImportableResource = &SmartDetectorAlertRule{}

// InitializeSpec initializes the spec for this resource from the given status
func (rule *SmartDetectorAlertRule) InitializeSpec(status genruntime.ConvertibleStatus) error {
	if s, ok := status.(*SmartDetectorAlertRule_STATUS); ok {
		return rule.Spec.Initialize_From_SmartDetectorAlertRule_STATUS(s)
	}

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

var _ genruntime.KubernetesResource = &SmartDetectorAlertRule{}

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

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

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "microsoft.alertsManagement/smartDetectorAlertRules"
func (rule *SmartDetectorAlertRule) GetType() string {
	return "microsoft.alertsManagement/smartDetectorAlertRules"
}

// NewEmptyStatus returns a new empty (blank) status
func (rule *SmartDetectorAlertRule) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &SmartDetectorAlertRule_STATUS{}
}

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

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

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

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

	rule.Status = st
	return nil
}

// AssignProperties_From_SmartDetectorAlertRule populates our SmartDetectorAlertRule from the provided source SmartDetectorAlertRule
func (rule *SmartDetectorAlertRule) AssignProperties_From_SmartDetectorAlertRule(source *storage.SmartDetectorAlertRule) error {

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

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

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

	// No error
	return nil
}

// AssignProperties_To_SmartDetectorAlertRule populates the provided destination SmartDetectorAlertRule from our SmartDetectorAlertRule
func (rule *SmartDetectorAlertRule) AssignProperties_To_SmartDetectorAlertRule(destination *storage.SmartDetectorAlertRule) error {

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

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

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

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-04-01/SmartDetectorAlertRulesApi.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}
type SmartDetectorAlertRuleList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []SmartDetectorAlertRule `json:"items"`
}

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

const APIVersion_Value = APIVersion("2021-04-01")

type SmartDetectorAlertRule_Spec struct {
	// +kubebuilder:validation:Required
	// ActionGroups: The alert rule actions.
	ActionGroups *ActionGroupsInformation `json:"actionGroups,omitempty"`

	// 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"`

	// Description: The alert rule description.
	Description *string `json:"description,omitempty"`

	// +kubebuilder:validation:Required
	// Detector: The alert rule's detector.
	Detector *Detector `json:"detector,omitempty"`

	// +kubebuilder:validation:Required
	// Frequency: The alert rule frequency in ISO8601 format. The time granularity must be in minutes and minimum value is 1
	// minute, depending on the detector.
	Frequency *string `json:"frequency,omitempty"`

	// Location: The resource location.
	Location *string `json:"location,omitempty"`

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

	// +kubebuilder:validation:Required
	// ScopeReferences: The alert rule resources scope.
	ScopeReferences []genruntime.ResourceReference `armReference:"Scope" json:"scopeReferences,omitempty"`

	// +kubebuilder:validation:Required
	// Severity: The alert rule severity.
	Severity *AlertRuleProperties_Severity `json:"severity,omitempty"`

	// +kubebuilder:validation:Required
	// State: The alert rule state.
	State *AlertRuleProperties_State `json:"state,omitempty"`

	// Tags: The resource tags.
	Tags map[string]string `json:"tags,omitempty"`

	// Throttling: The alert rule throttling information.
	Throttling *ThrottlingInformation `json:"throttling,omitempty"`
}

var _ genruntime.ARMTransformer = &SmartDetectorAlertRule_Spec{}

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

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

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

	// Set property "Properties":
	if rule.ActionGroups != nil ||
		rule.Description != nil ||
		rule.Detector != nil ||
		rule.Frequency != nil ||
		rule.ScopeReferences != nil ||
		rule.Severity != nil ||
		rule.State != nil ||
		rule.Throttling != nil {
		result.Properties = &arm.AlertRuleProperties{}
	}
	if rule.ActionGroups != nil {
		actionGroups_ARM, err := rule.ActionGroups.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		actionGroups := *actionGroups_ARM.(*arm.ActionGroupsInformation)
		result.Properties.ActionGroups = &actionGroups
	}
	if rule.Description != nil {
		description := *rule.Description
		result.Properties.Description = &description
	}
	if rule.Detector != nil {
		detector_ARM, err := rule.Detector.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		detector := *detector_ARM.(*arm.Detector)
		result.Properties.Detector = &detector
	}
	if rule.Frequency != nil {
		frequency := *rule.Frequency
		result.Properties.Frequency = &frequency
	}
	for _, item := range rule.ScopeReferences {
		itemARMID, err := resolved.ResolvedReferences.Lookup(item)
		if err != nil {
			return nil, err
		}
		result.Properties.Scope = append(result.Properties.Scope, itemARMID)
	}
	if rule.Severity != nil {
		var temp string
		temp = string(*rule.Severity)
		severity := arm.AlertRuleProperties_Severity(temp)
		result.Properties.Severity = &severity
	}
	if rule.State != nil {
		var temp string
		temp = string(*rule.State)
		state := arm.AlertRuleProperties_State(temp)
		result.Properties.State = &state
	}
	if rule.Throttling != nil {
		throttling_ARM, err := rule.Throttling.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		throttling := *throttling_ARM.(*arm.ThrottlingInformation)
		result.Properties.Throttling = &throttling
	}

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

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

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

	// Set property "ActionGroups":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ActionGroups != nil {
			var actionGroups1 ActionGroupsInformation
			err := actionGroups1.PopulateFromARM(owner, *typedInput.Properties.ActionGroups)
			if err != nil {
				return err
			}
			actionGroups := actionGroups1
			rule.ActionGroups = &actionGroups
		}
	}

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

	// Set property "Description":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Description != nil {
			description := *typedInput.Properties.Description
			rule.Description = &description
		}
	}

	// Set property "Detector":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Detector != nil {
			var detector1 Detector
			err := detector1.PopulateFromARM(owner, *typedInput.Properties.Detector)
			if err != nil {
				return err
			}
			detector := detector1
			rule.Detector = &detector
		}
	}

	// Set property "Frequency":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Frequency != nil {
			frequency := *typedInput.Properties.Frequency
			rule.Frequency = &frequency
		}
	}

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

	// no assignment for property "OperatorSpec"

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

	// no assignment for property "ScopeReferences"

	// Set property "Severity":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Severity != nil {
			var temp string
			temp = string(*typedInput.Properties.Severity)
			severity := AlertRuleProperties_Severity(temp)
			rule.Severity = &severity
		}
	}

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

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

	// Set property "Throttling":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Throttling != nil {
			var throttling1 ThrottlingInformation
			err := throttling1.PopulateFromARM(owner, *typedInput.Properties.Throttling)
			if err != nil {
				return err
			}
			throttling := throttling1
			rule.Throttling = &throttling
		}
	}

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &SmartDetectorAlertRule_Spec{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.SmartDetectorAlertRule_Spec{}
	err := rule.AssignProperties_To_SmartDetectorAlertRule_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_SmartDetectorAlertRule_Spec populates our SmartDetectorAlertRule_Spec from the provided source SmartDetectorAlertRule_Spec
func (rule *SmartDetectorAlertRule_Spec) AssignProperties_From_SmartDetectorAlertRule_Spec(source *storage.SmartDetectorAlertRule_Spec) error {

	// ActionGroups
	if source.ActionGroups != nil {
		var actionGroup ActionGroupsInformation
		err := actionGroup.AssignProperties_From_ActionGroupsInformation(source.ActionGroups)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_ActionGroupsInformation() to populate field ActionGroups")
		}
		rule.ActionGroups = &actionGroup
	} else {
		rule.ActionGroups = nil
	}

	// AzureName
	rule.AzureName = source.AzureName

	// Description
	rule.Description = genruntime.ClonePointerToString(source.Description)

	// Detector
	if source.Detector != nil {
		var detector Detector
		err := detector.AssignProperties_From_Detector(source.Detector)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_Detector() to populate field Detector")
		}
		rule.Detector = &detector
	} else {
		rule.Detector = nil
	}

	// Frequency
	rule.Frequency = genruntime.ClonePointerToString(source.Frequency)

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

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

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

	// ScopeReferences
	if source.ScopeReferences != nil {
		scopeReferenceList := make([]genruntime.ResourceReference, len(source.ScopeReferences))
		for scopeReferenceIndex, scopeReferenceItem := range source.ScopeReferences {
			scopeReferenceList[scopeReferenceIndex] = scopeReferenceItem.Copy()
		}
		rule.ScopeReferences = scopeReferenceList
	} else {
		rule.ScopeReferences = nil
	}

	// Severity
	if source.Severity != nil {
		severity := *source.Severity
		severityTemp := genruntime.ToEnum(severity, alertRuleProperties_Severity_Values)
		rule.Severity = &severityTemp
	} else {
		rule.Severity = nil
	}

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

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

	// Throttling
	if source.Throttling != nil {
		var throttling ThrottlingInformation
		err := throttling.AssignProperties_From_ThrottlingInformation(source.Throttling)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_ThrottlingInformation() to populate field Throttling")
		}
		rule.Throttling = &throttling
	} else {
		rule.Throttling = nil
	}

	// No error
	return nil
}

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

	// ActionGroups
	if rule.ActionGroups != nil {
		var actionGroup storage.ActionGroupsInformation
		err := rule.ActionGroups.AssignProperties_To_ActionGroupsInformation(&actionGroup)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_ActionGroupsInformation() to populate field ActionGroups")
		}
		destination.ActionGroups = &actionGroup
	} else {
		destination.ActionGroups = nil
	}

	// AzureName
	destination.AzureName = rule.AzureName

	// Description
	destination.Description = genruntime.ClonePointerToString(rule.Description)

	// Detector
	if rule.Detector != nil {
		var detector storage.Detector
		err := rule.Detector.AssignProperties_To_Detector(&detector)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_Detector() to populate field Detector")
		}
		destination.Detector = &detector
	} else {
		destination.Detector = nil
	}

	// Frequency
	destination.Frequency = genruntime.ClonePointerToString(rule.Frequency)

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

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

	// OriginalVersion
	destination.OriginalVersion = rule.OriginalVersion()

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

	// ScopeReferences
	if rule.ScopeReferences != nil {
		scopeReferenceList := make([]genruntime.ResourceReference, len(rule.ScopeReferences))
		for scopeReferenceIndex, scopeReferenceItem := range rule.ScopeReferences {
			scopeReferenceList[scopeReferenceIndex] = scopeReferenceItem.Copy()
		}
		destination.ScopeReferences = scopeReferenceList
	} else {
		destination.ScopeReferences = nil
	}

	// Severity
	if rule.Severity != nil {
		severity := string(*rule.Severity)
		destination.Severity = &severity
	} else {
		destination.Severity = nil
	}

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

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

	// Throttling
	if rule.Throttling != nil {
		var throttling storage.ThrottlingInformation
		err := rule.Throttling.AssignProperties_To_ThrottlingInformation(&throttling)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_ThrottlingInformation() to populate field Throttling")
		}
		destination.Throttling = &throttling
	} else {
		destination.Throttling = nil
	}

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

	// No error
	return nil
}

// Initialize_From_SmartDetectorAlertRule_STATUS populates our SmartDetectorAlertRule_Spec from the provided source SmartDetectorAlertRule_STATUS
func (rule *SmartDetectorAlertRule_Spec) Initialize_From_SmartDetectorAlertRule_STATUS(source *SmartDetectorAlertRule_STATUS) error {

	// ActionGroups
	if source.ActionGroups != nil {
		var actionGroup ActionGroupsInformation
		err := actionGroup.Initialize_From_ActionGroupsInformation_STATUS(source.ActionGroups)
		if err != nil {
			return eris.Wrap(err, "calling Initialize_From_ActionGroupsInformation_STATUS() to populate field ActionGroups")
		}
		rule.ActionGroups = &actionGroup
	} else {
		rule.ActionGroups = nil
	}

	// Description
	rule.Description = genruntime.ClonePointerToString(source.Description)

	// Detector
	if source.Detector != nil {
		var detector Detector
		err := detector.Initialize_From_Detector_STATUS(source.Detector)
		if err != nil {
			return eris.Wrap(err, "calling Initialize_From_Detector_STATUS() to populate field Detector")
		}
		rule.Detector = &detector
	} else {
		rule.Detector = nil
	}

	// Frequency
	rule.Frequency = genruntime.ClonePointerToString(source.Frequency)

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

	// Severity
	if source.Severity != nil {
		severity := genruntime.ToEnum(string(*source.Severity), alertRuleProperties_Severity_Values)
		rule.Severity = &severity
	} else {
		rule.Severity = nil
	}

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

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

	// Throttling
	if source.Throttling != nil {
		var throttling ThrottlingInformation
		err := throttling.Initialize_From_ThrottlingInformation_STATUS(source.Throttling)
		if err != nil {
			return eris.Wrap(err, "calling Initialize_From_ThrottlingInformation_STATUS() to populate field Throttling")
		}
		rule.Throttling = &throttling
	} else {
		rule.Throttling = nil
	}

	// No error
	return nil
}

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

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

type SmartDetectorAlertRule_STATUS struct {
	// ActionGroups: The alert rule actions.
	ActionGroups *ActionGroupsInformation_STATUS `json:"actionGroups,omitempty"`

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

	// Description: The alert rule description.
	Description *string `json:"description,omitempty"`

	// Detector: The alert rule's detector.
	Detector *Detector_STATUS `json:"detector,omitempty"`

	// Frequency: The alert rule frequency in ISO8601 format. The time granularity must be in minutes and minimum value is 1
	// minute, depending on the detector.
	Frequency *string `json:"frequency,omitempty"`

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

	// Location: The resource location.
	Location *string `json:"location,omitempty"`

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

	// Scope: The alert rule resources scope.
	Scope []string `json:"scope,omitempty"`

	// Severity: The alert rule severity.
	Severity *AlertRuleProperties_Severity_STATUS `json:"severity,omitempty"`

	// State: The alert rule state.
	State *AlertRuleProperties_State_STATUS `json:"state,omitempty"`

	// Tags: The resource tags.
	Tags map[string]string `json:"tags,omitempty"`

	// Throttling: The alert rule throttling information.
	Throttling *ThrottlingInformation_STATUS `json:"throttling,omitempty"`

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

var _ genruntime.ConvertibleStatus = &SmartDetectorAlertRule_STATUS{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.SmartDetectorAlertRule_STATUS{}
	err := rule.AssignProperties_To_SmartDetectorAlertRule_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 = &SmartDetectorAlertRule_STATUS{}

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

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

	// Set property "ActionGroups":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ActionGroups != nil {
			var actionGroups1 ActionGroupsInformation_STATUS
			err := actionGroups1.PopulateFromARM(owner, *typedInput.Properties.ActionGroups)
			if err != nil {
				return err
			}
			actionGroups := actionGroups1
			rule.ActionGroups = &actionGroups
		}
	}

	// no assignment for property "Conditions"

	// Set property "Description":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Description != nil {
			description := *typedInput.Properties.Description
			rule.Description = &description
		}
	}

	// Set property "Detector":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Detector != nil {
			var detector1 Detector_STATUS
			err := detector1.PopulateFromARM(owner, *typedInput.Properties.Detector)
			if err != nil {
				return err
			}
			detector := detector1
			rule.Detector = &detector
		}
	}

	// Set property "Frequency":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Frequency != nil {
			frequency := *typedInput.Properties.Frequency
			rule.Frequency = &frequency
		}
	}

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

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

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

	// Set property "Scope":
	// copying flattened property:
	if typedInput.Properties != nil {
		for _, item := range typedInput.Properties.Scope {
			rule.Scope = append(rule.Scope, item)
		}
	}

	// Set property "Severity":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Severity != nil {
			var temp string
			temp = string(*typedInput.Properties.Severity)
			severity := AlertRuleProperties_Severity_STATUS(temp)
			rule.Severity = &severity
		}
	}

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

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

	// Set property "Throttling":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Throttling != nil {
			var throttling1 ThrottlingInformation_STATUS
			err := throttling1.PopulateFromARM(owner, *typedInput.Properties.Throttling)
			if err != nil {
				return err
			}
			throttling := throttling1
			rule.Throttling = &throttling
		}
	}

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

	// No error
	return nil
}

// AssignProperties_From_SmartDetectorAlertRule_STATUS populates our SmartDetectorAlertRule_STATUS from the provided source SmartDetectorAlertRule_STATUS
func (rule *SmartDetectorAlertRule_STATUS) AssignProperties_From_SmartDetectorAlertRule_STATUS(source *storage.SmartDetectorAlertRule_STATUS) error {

	// ActionGroups
	if source.ActionGroups != nil {
		var actionGroup ActionGroupsInformation_STATUS
		err := actionGroup.AssignProperties_From_ActionGroupsInformation_STATUS(source.ActionGroups)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_ActionGroupsInformation_STATUS() to populate field ActionGroups")
		}
		rule.ActionGroups = &actionGroup
	} else {
		rule.ActionGroups = nil
	}

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

	// Description
	rule.Description = genruntime.ClonePointerToString(source.Description)

	// Detector
	if source.Detector != nil {
		var detector Detector_STATUS
		err := detector.AssignProperties_From_Detector_STATUS(source.Detector)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_Detector_STATUS() to populate field Detector")
		}
		rule.Detector = &detector
	} else {
		rule.Detector = nil
	}

	// Frequency
	rule.Frequency = genruntime.ClonePointerToString(source.Frequency)

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

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

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

	// Scope
	rule.Scope = genruntime.CloneSliceOfString(source.Scope)

	// Severity
	if source.Severity != nil {
		severity := *source.Severity
		severityTemp := genruntime.ToEnum(severity, alertRuleProperties_Severity_STATUS_Values)
		rule.Severity = &severityTemp
	} else {
		rule.Severity = nil
	}

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

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

	// Throttling
	if source.Throttling != nil {
		var throttling ThrottlingInformation_STATUS
		err := throttling.AssignProperties_From_ThrottlingInformation_STATUS(source.Throttling)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_ThrottlingInformation_STATUS() to populate field Throttling")
		}
		rule.Throttling = &throttling
	} else {
		rule.Throttling = nil
	}

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

	// No error
	return nil
}

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

	// ActionGroups
	if rule.ActionGroups != nil {
		var actionGroup storage.ActionGroupsInformation_STATUS
		err := rule.ActionGroups.AssignProperties_To_ActionGroupsInformation_STATUS(&actionGroup)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_ActionGroupsInformation_STATUS() to populate field ActionGroups")
		}
		destination.ActionGroups = &actionGroup
	} else {
		destination.ActionGroups = nil
	}

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

	// Description
	destination.Description = genruntime.ClonePointerToString(rule.Description)

	// Detector
	if rule.Detector != nil {
		var detector storage.Detector_STATUS
		err := rule.Detector.AssignProperties_To_Detector_STATUS(&detector)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_Detector_STATUS() to populate field Detector")
		}
		destination.Detector = &detector
	} else {
		destination.Detector = nil
	}

	// Frequency
	destination.Frequency = genruntime.ClonePointerToString(rule.Frequency)

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

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

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

	// Scope
	destination.Scope = genruntime.CloneSliceOfString(rule.Scope)

	// Severity
	if rule.Severity != nil {
		severity := string(*rule.Severity)
		destination.Severity = &severity
	} else {
		destination.Severity = nil
	}

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

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

	// Throttling
	if rule.Throttling != nil {
		var throttling storage.ThrottlingInformation_STATUS
		err := rule.Throttling.AssignProperties_To_ThrottlingInformation_STATUS(&throttling)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_ThrottlingInformation_STATUS() to populate field Throttling")
		}
		destination.Throttling = &throttling
	} else {
		destination.Throttling = nil
	}

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

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

	// No error
	return nil
}

// The Action Groups information, used by the alert rule.
type ActionGroupsInformation struct {
	// CustomEmailSubject: An optional custom email subject to use in email notifications.
	CustomEmailSubject *string `json:"customEmailSubject,omitempty"`

	// CustomWebhookPayload: An optional custom web-hook payload to use in web-hook notifications.
	CustomWebhookPayload *string `json:"customWebhookPayload,omitempty"`

	// +kubebuilder:validation:Required
	// GroupReferences: The Action Group resource IDs.
	GroupReferences []genruntime.ResourceReference `armReference:"GroupIds" json:"groupReferences,omitempty"`
}

var _ genruntime.ARMTransformer = &ActionGroupsInformation{}

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

	// Set property "CustomEmailSubject":
	if information.CustomEmailSubject != nil {
		customEmailSubject := *information.CustomEmailSubject
		result.CustomEmailSubject = &customEmailSubject
	}

	// Set property "CustomWebhookPayload":
	if information.CustomWebhookPayload != nil {
		customWebhookPayload := *information.CustomWebhookPayload
		result.CustomWebhookPayload = &customWebhookPayload
	}

	// Set property "GroupIds":
	for _, item := range information.GroupReferences {
		itemARMID, err := resolved.ResolvedReferences.Lookup(item)
		if err != nil {
			return nil, err
		}
		result.GroupIds = append(result.GroupIds, itemARMID)
	}
	return result, nil
}

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

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

	// Set property "CustomEmailSubject":
	if typedInput.CustomEmailSubject != nil {
		customEmailSubject := *typedInput.CustomEmailSubject
		information.CustomEmailSubject = &customEmailSubject
	}

	// Set property "CustomWebhookPayload":
	if typedInput.CustomWebhookPayload != nil {
		customWebhookPayload := *typedInput.CustomWebhookPayload
		information.CustomWebhookPayload = &customWebhookPayload
	}

	// no assignment for property "GroupReferences"

	// No error
	return nil
}

// AssignProperties_From_ActionGroupsInformation populates our ActionGroupsInformation from the provided source ActionGroupsInformation
func (information *ActionGroupsInformation) AssignProperties_From_ActionGroupsInformation(source *storage.ActionGroupsInformation) error {

	// CustomEmailSubject
	information.CustomEmailSubject = genruntime.ClonePointerToString(source.CustomEmailSubject)

	// CustomWebhookPayload
	information.CustomWebhookPayload = genruntime.ClonePointerToString(source.CustomWebhookPayload)

	// GroupReferences
	if source.GroupReferences != nil {
		groupReferenceList := make([]genruntime.ResourceReference, len(source.GroupReferences))
		for groupReferenceIndex, groupReferenceItem := range source.GroupReferences {
			groupReferenceList[groupReferenceIndex] = groupReferenceItem.Copy()
		}
		information.GroupReferences = groupReferenceList
	} else {
		information.GroupReferences = nil
	}

	// No error
	return nil
}

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

	// CustomEmailSubject
	destination.CustomEmailSubject = genruntime.ClonePointerToString(information.CustomEmailSubject)

	// CustomWebhookPayload
	destination.CustomWebhookPayload = genruntime.ClonePointerToString(information.CustomWebhookPayload)

	// GroupReferences
	if information.GroupReferences != nil {
		groupReferenceList := make([]genruntime.ResourceReference, len(information.GroupReferences))
		for groupReferenceIndex, groupReferenceItem := range information.GroupReferences {
			groupReferenceList[groupReferenceIndex] = groupReferenceItem.Copy()
		}
		destination.GroupReferences = groupReferenceList
	} else {
		destination.GroupReferences = nil
	}

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

	// No error
	return nil
}

// Initialize_From_ActionGroupsInformation_STATUS populates our ActionGroupsInformation from the provided source ActionGroupsInformation_STATUS
func (information *ActionGroupsInformation) Initialize_From_ActionGroupsInformation_STATUS(source *ActionGroupsInformation_STATUS) error {

	// CustomEmailSubject
	information.CustomEmailSubject = genruntime.ClonePointerToString(source.CustomEmailSubject)

	// CustomWebhookPayload
	information.CustomWebhookPayload = genruntime.ClonePointerToString(source.CustomWebhookPayload)

	// No error
	return nil
}

// The Action Groups information, used by the alert rule.
type ActionGroupsInformation_STATUS struct {
	// CustomEmailSubject: An optional custom email subject to use in email notifications.
	CustomEmailSubject *string `json:"customEmailSubject,omitempty"`

	// CustomWebhookPayload: An optional custom web-hook payload to use in web-hook notifications.
	CustomWebhookPayload *string `json:"customWebhookPayload,omitempty"`

	// GroupIds: The Action Group resource IDs.
	GroupIds []string `json:"groupIds,omitempty"`
}

var _ genruntime.FromARMConverter = &ActionGroupsInformation_STATUS{}

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

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

	// Set property "CustomEmailSubject":
	if typedInput.CustomEmailSubject != nil {
		customEmailSubject := *typedInput.CustomEmailSubject
		information.CustomEmailSubject = &customEmailSubject
	}

	// Set property "CustomWebhookPayload":
	if typedInput.CustomWebhookPayload != nil {
		customWebhookPayload := *typedInput.CustomWebhookPayload
		information.CustomWebhookPayload = &customWebhookPayload
	}

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

	// No error
	return nil
}

// AssignProperties_From_ActionGroupsInformation_STATUS populates our ActionGroupsInformation_STATUS from the provided source ActionGroupsInformation_STATUS
func (information *ActionGroupsInformation_STATUS) AssignProperties_From_ActionGroupsInformation_STATUS(source *storage.ActionGroupsInformation_STATUS) error {

	// CustomEmailSubject
	information.CustomEmailSubject = genruntime.ClonePointerToString(source.CustomEmailSubject)

	// CustomWebhookPayload
	information.CustomWebhookPayload = genruntime.ClonePointerToString(source.CustomWebhookPayload)

	// GroupIds
	information.GroupIds = genruntime.CloneSliceOfString(source.GroupIds)

	// No error
	return nil
}

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

	// CustomEmailSubject
	destination.CustomEmailSubject = genruntime.ClonePointerToString(information.CustomEmailSubject)

	// CustomWebhookPayload
	destination.CustomWebhookPayload = genruntime.ClonePointerToString(information.CustomWebhookPayload)

	// GroupIds
	destination.GroupIds = genruntime.CloneSliceOfString(information.GroupIds)

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

	// No error
	return nil
}

// +kubebuilder:validation:Enum={"Sev0","Sev1","Sev2","Sev3","Sev4"}
type AlertRuleProperties_Severity string

const (
	AlertRuleProperties_Severity_Sev0 = AlertRuleProperties_Severity("Sev0")
	AlertRuleProperties_Severity_Sev1 = AlertRuleProperties_Severity("Sev1")
	AlertRuleProperties_Severity_Sev2 = AlertRuleProperties_Severity("Sev2")
	AlertRuleProperties_Severity_Sev3 = AlertRuleProperties_Severity("Sev3")
	AlertRuleProperties_Severity_Sev4 = AlertRuleProperties_Severity("Sev4")
)

// Mapping from string to AlertRuleProperties_Severity
var alertRuleProperties_Severity_Values = map[string]AlertRuleProperties_Severity{
	"sev0": AlertRuleProperties_Severity_Sev0,
	"sev1": AlertRuleProperties_Severity_Sev1,
	"sev2": AlertRuleProperties_Severity_Sev2,
	"sev3": AlertRuleProperties_Severity_Sev3,
	"sev4": AlertRuleProperties_Severity_Sev4,
}

type AlertRuleProperties_Severity_STATUS string

const (
	AlertRuleProperties_Severity_STATUS_Sev0 = AlertRuleProperties_Severity_STATUS("Sev0")
	AlertRuleProperties_Severity_STATUS_Sev1 = AlertRuleProperties_Severity_STATUS("Sev1")
	AlertRuleProperties_Severity_STATUS_Sev2 = AlertRuleProperties_Severity_STATUS("Sev2")
	AlertRuleProperties_Severity_STATUS_Sev3 = AlertRuleProperties_Severity_STATUS("Sev3")
	AlertRuleProperties_Severity_STATUS_Sev4 = AlertRuleProperties_Severity_STATUS("Sev4")
)

// Mapping from string to AlertRuleProperties_Severity_STATUS
var alertRuleProperties_Severity_STATUS_Values = map[string]AlertRuleProperties_Severity_STATUS{
	"sev0": AlertRuleProperties_Severity_STATUS_Sev0,
	"sev1": AlertRuleProperties_Severity_STATUS_Sev1,
	"sev2": AlertRuleProperties_Severity_STATUS_Sev2,
	"sev3": AlertRuleProperties_Severity_STATUS_Sev3,
	"sev4": AlertRuleProperties_Severity_STATUS_Sev4,
}

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

const (
	AlertRuleProperties_State_Disabled = AlertRuleProperties_State("Disabled")
	AlertRuleProperties_State_Enabled  = AlertRuleProperties_State("Enabled")
)

// Mapping from string to AlertRuleProperties_State
var alertRuleProperties_State_Values = map[string]AlertRuleProperties_State{
	"disabled": AlertRuleProperties_State_Disabled,
	"enabled":  AlertRuleProperties_State_Enabled,
}

type AlertRuleProperties_State_STATUS string

const (
	AlertRuleProperties_State_STATUS_Disabled = AlertRuleProperties_State_STATUS("Disabled")
	AlertRuleProperties_State_STATUS_Enabled  = AlertRuleProperties_State_STATUS("Enabled")
)

// Mapping from string to AlertRuleProperties_State_STATUS
var alertRuleProperties_State_STATUS_Values = map[string]AlertRuleProperties_State_STATUS{
	"disabled": AlertRuleProperties_State_STATUS_Disabled,
	"enabled":  AlertRuleProperties_State_STATUS_Enabled,
}

// The detector information. By default this is not populated, unless it's specified in expandDetector
type Detector struct {
	// +kubebuilder:validation:Required
	// Id: The detector id.
	Id *string `json:"id,omitempty"`

	// Parameters: The detector's parameters.'
	Parameters map[string]v1.JSON `json:"parameters,omitempty"`
}

var _ genruntime.ARMTransformer = &Detector{}

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

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

	// Set property "Parameters":
	if detector.Parameters != nil {
		result.Parameters = make(map[string]v1.JSON, len(detector.Parameters))
		for key, value := range detector.Parameters {
			result.Parameters[key] = *value.DeepCopy()
		}
	}
	return result, nil
}

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

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

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

	// Set property "Parameters":
	if typedInput.Parameters != nil {
		detector.Parameters = make(map[string]v1.JSON, len(typedInput.Parameters))
		for key, value := range typedInput.Parameters {
			detector.Parameters[key] = *value.DeepCopy()
		}
	}

	// No error
	return nil
}

// AssignProperties_From_Detector populates our Detector from the provided source Detector
func (detector *Detector) AssignProperties_From_Detector(source *storage.Detector) error {

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

	// Parameters
	if source.Parameters != nil {
		parameterMap := make(map[string]v1.JSON, len(source.Parameters))
		for parameterKey, parameterValue := range source.Parameters {
			parameterMap[parameterKey] = *parameterValue.DeepCopy()
		}
		detector.Parameters = parameterMap
	} else {
		detector.Parameters = nil
	}

	// No error
	return nil
}

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

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

	// Parameters
	if detector.Parameters != nil {
		parameterMap := make(map[string]v1.JSON, len(detector.Parameters))
		for parameterKey, parameterValue := range detector.Parameters {
			parameterMap[parameterKey] = *parameterValue.DeepCopy()
		}
		destination.Parameters = parameterMap
	} else {
		destination.Parameters = nil
	}

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

	// No error
	return nil
}

// Initialize_From_Detector_STATUS populates our Detector from the provided source Detector_STATUS
func (detector *Detector) Initialize_From_Detector_STATUS(source *Detector_STATUS) error {

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

	// Parameters
	if source.Parameters != nil {
		parameterMap := make(map[string]v1.JSON, len(source.Parameters))
		for parameterKey, parameterValue := range source.Parameters {
			parameterMap[parameterKey] = *parameterValue.DeepCopy()
		}
		detector.Parameters = parameterMap
	} else {
		detector.Parameters = nil
	}

	// No error
	return nil
}

// The detector information. By default this is not populated, unless it's specified in expandDetector
type Detector_STATUS struct {
	// Description: The Smart Detector description.
	Description *string `json:"description,omitempty"`

	// Id: The detector id.
	Id *string `json:"id,omitempty"`

	// ImagePaths: The Smart Detector image path. By default this is not populated, unless it's specified in expandDetector
	ImagePaths []string `json:"imagePaths,omitempty"`

	// Name: The Smart Detector name.
	Name *string `json:"name,omitempty"`

	// ParameterDefinitions: The Smart Detector parameters definitions.'
	ParameterDefinitions []DetectorParameterDefinition_STATUS `json:"parameterDefinitions,omitempty"`

	// Parameters: The detector's parameters.'
	Parameters map[string]v1.JSON `json:"parameters,omitempty"`

	// SupportedCadences: The Smart Detector supported cadences.
	SupportedCadences []int `json:"supportedCadences,omitempty"`

	// SupportedResourceTypes: The Smart Detector supported resource types.
	SupportedResourceTypes []string `json:"supportedResourceTypes,omitempty"`
}

var _ genruntime.FromARMConverter = &Detector_STATUS{}

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

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

	// Set property "Description":
	if typedInput.Description != nil {
		description := *typedInput.Description
		detector.Description = &description
	}

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

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

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

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

	// Set property "Parameters":
	if typedInput.Parameters != nil {
		detector.Parameters = make(map[string]v1.JSON, len(typedInput.Parameters))
		for key, value := range typedInput.Parameters {
			detector.Parameters[key] = *value.DeepCopy()
		}
	}

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

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

	// No error
	return nil
}

// AssignProperties_From_Detector_STATUS populates our Detector_STATUS from the provided source Detector_STATUS
func (detector *Detector_STATUS) AssignProperties_From_Detector_STATUS(source *storage.Detector_STATUS) error {

	// Description
	detector.Description = genruntime.ClonePointerToString(source.Description)

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

	// ImagePaths
	detector.ImagePaths = genruntime.CloneSliceOfString(source.ImagePaths)

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

	// ParameterDefinitions
	if source.ParameterDefinitions != nil {
		parameterDefinitionList := make([]DetectorParameterDefinition_STATUS, len(source.ParameterDefinitions))
		for parameterDefinitionIndex, parameterDefinitionItem := range source.ParameterDefinitions {
			var parameterDefinition DetectorParameterDefinition_STATUS
			err := parameterDefinition.AssignProperties_From_DetectorParameterDefinition_STATUS(&parameterDefinitionItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_DetectorParameterDefinition_STATUS() to populate field ParameterDefinitions")
			}
			parameterDefinitionList[parameterDefinitionIndex] = parameterDefinition
		}
		detector.ParameterDefinitions = parameterDefinitionList
	} else {
		detector.ParameterDefinitions = nil
	}

	// Parameters
	if source.Parameters != nil {
		parameterMap := make(map[string]v1.JSON, len(source.Parameters))
		for parameterKey, parameterValue := range source.Parameters {
			parameterMap[parameterKey] = *parameterValue.DeepCopy()
		}
		detector.Parameters = parameterMap
	} else {
		detector.Parameters = nil
	}

	// SupportedCadences
	if source.SupportedCadences != nil {
		supportedCadenceList := make([]int, len(source.SupportedCadences))
		for supportedCadenceIndex, supportedCadenceItem := range source.SupportedCadences {
			supportedCadenceList[supportedCadenceIndex] = supportedCadenceItem
		}
		detector.SupportedCadences = supportedCadenceList
	} else {
		detector.SupportedCadences = nil
	}

	// SupportedResourceTypes
	detector.SupportedResourceTypes = genruntime.CloneSliceOfString(source.SupportedResourceTypes)

	// No error
	return nil
}

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

	// Description
	destination.Description = genruntime.ClonePointerToString(detector.Description)

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

	// ImagePaths
	destination.ImagePaths = genruntime.CloneSliceOfString(detector.ImagePaths)

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

	// ParameterDefinitions
	if detector.ParameterDefinitions != nil {
		parameterDefinitionList := make([]storage.DetectorParameterDefinition_STATUS, len(detector.ParameterDefinitions))
		for parameterDefinitionIndex, parameterDefinitionItem := range detector.ParameterDefinitions {
			var parameterDefinition storage.DetectorParameterDefinition_STATUS
			err := parameterDefinitionItem.AssignProperties_To_DetectorParameterDefinition_STATUS(&parameterDefinition)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_DetectorParameterDefinition_STATUS() to populate field ParameterDefinitions")
			}
			parameterDefinitionList[parameterDefinitionIndex] = parameterDefinition
		}
		destination.ParameterDefinitions = parameterDefinitionList
	} else {
		destination.ParameterDefinitions = nil
	}

	// Parameters
	if detector.Parameters != nil {
		parameterMap := make(map[string]v1.JSON, len(detector.Parameters))
		for parameterKey, parameterValue := range detector.Parameters {
			parameterMap[parameterKey] = *parameterValue.DeepCopy()
		}
		destination.Parameters = parameterMap
	} else {
		destination.Parameters = nil
	}

	// SupportedCadences
	if detector.SupportedCadences != nil {
		supportedCadenceList := make([]int, len(detector.SupportedCadences))
		for supportedCadenceIndex, supportedCadenceItem := range detector.SupportedCadences {
			supportedCadenceList[supportedCadenceIndex] = supportedCadenceItem
		}
		destination.SupportedCadences = supportedCadenceList
	} else {
		destination.SupportedCadences = nil
	}

	// SupportedResourceTypes
	destination.SupportedResourceTypes = genruntime.CloneSliceOfString(detector.SupportedResourceTypes)

	// 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 SmartDetectorAlertRuleOperatorSpec 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_SmartDetectorAlertRuleOperatorSpec populates our SmartDetectorAlertRuleOperatorSpec from the provided source SmartDetectorAlertRuleOperatorSpec
func (operator *SmartDetectorAlertRuleOperatorSpec) AssignProperties_From_SmartDetectorAlertRuleOperatorSpec(source *storage.SmartDetectorAlertRuleOperatorSpec) 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_SmartDetectorAlertRuleOperatorSpec populates the provided destination SmartDetectorAlertRuleOperatorSpec from our SmartDetectorAlertRuleOperatorSpec
func (operator *SmartDetectorAlertRuleOperatorSpec) AssignProperties_To_SmartDetectorAlertRuleOperatorSpec(destination *storage.SmartDetectorAlertRuleOperatorSpec) 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
}

// Optional throttling information for the alert rule.
type ThrottlingInformation struct {
	// Duration: The required duration (in ISO8601 format) to wait before notifying on the alert rule again. The time
	// granularity must be in minutes and minimum value is 0 minutes
	Duration *string `json:"duration,omitempty"`
}

var _ genruntime.ARMTransformer = &ThrottlingInformation{}

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

	// Set property "Duration":
	if information.Duration != nil {
		duration := *information.Duration
		result.Duration = &duration
	}
	return result, nil
}

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

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

	// Set property "Duration":
	if typedInput.Duration != nil {
		duration := *typedInput.Duration
		information.Duration = &duration
	}

	// No error
	return nil
}

// AssignProperties_From_ThrottlingInformation populates our ThrottlingInformation from the provided source ThrottlingInformation
func (information *ThrottlingInformation) AssignProperties_From_ThrottlingInformation(source *storage.ThrottlingInformation) error {

	// Duration
	information.Duration = genruntime.ClonePointerToString(source.Duration)

	// No error
	return nil
}

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

	// Duration
	destination.Duration = genruntime.ClonePointerToString(information.Duration)

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

	// No error
	return nil
}

// Initialize_From_ThrottlingInformation_STATUS populates our ThrottlingInformation from the provided source ThrottlingInformation_STATUS
func (information *ThrottlingInformation) Initialize_From_ThrottlingInformation_STATUS(source *ThrottlingInformation_STATUS) error {

	// Duration
	information.Duration = genruntime.ClonePointerToString(source.Duration)

	// No error
	return nil
}

// Optional throttling information for the alert rule.
type ThrottlingInformation_STATUS struct {
	// Duration: The required duration (in ISO8601 format) to wait before notifying on the alert rule again. The time
	// granularity must be in minutes and minimum value is 0 minutes
	Duration *string `json:"duration,omitempty"`
}

var _ genruntime.FromARMConverter = &ThrottlingInformation_STATUS{}

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

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

	// Set property "Duration":
	if typedInput.Duration != nil {
		duration := *typedInput.Duration
		information.Duration = &duration
	}

	// No error
	return nil
}

// AssignProperties_From_ThrottlingInformation_STATUS populates our ThrottlingInformation_STATUS from the provided source ThrottlingInformation_STATUS
func (information *ThrottlingInformation_STATUS) AssignProperties_From_ThrottlingInformation_STATUS(source *storage.ThrottlingInformation_STATUS) error {

	// Duration
	information.Duration = genruntime.ClonePointerToString(source.Duration)

	// No error
	return nil
}

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

	// Duration
	destination.Duration = genruntime.ClonePointerToString(information.Duration)

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

	// No error
	return nil
}

// The detector parameter definition.
type DetectorParameterDefinition_STATUS struct {
	// Description: The detector parameter description.
	Description *string `json:"description,omitempty"`

	// DisplayName: The detector parameter display name.
	DisplayName *string `json:"displayName,omitempty"`

	// IsMandatory: A value indicating whether this detector parameter is mandatory.
	IsMandatory *bool `json:"isMandatory,omitempty"`

	// Name: The detector parameter name.
	Name *string `json:"name,omitempty"`

	// Type: The detector parameter type.
	Type *DetectorParameterDefinition_Type_STATUS `json:"type,omitempty"`
}

var _ genruntime.FromARMConverter = &DetectorParameterDefinition_STATUS{}

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

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

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

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

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

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

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

	// No error
	return nil
}

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

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

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

	// IsMandatory
	if source.IsMandatory != nil {
		isMandatory := *source.IsMandatory
		definition.IsMandatory = &isMandatory
	} else {
		definition.IsMandatory = nil
	}

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

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

	// No error
	return nil
}

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

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

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

	// IsMandatory
	if definition.IsMandatory != nil {
		isMandatory := *definition.IsMandatory
		destination.IsMandatory = &isMandatory
	} else {
		destination.IsMandatory = nil
	}

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

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

type DetectorParameterDefinition_Type_STATUS string

const (
	DetectorParameterDefinition_Type_STATUS_Boolean  = DetectorParameterDefinition_Type_STATUS("Boolean")
	DetectorParameterDefinition_Type_STATUS_DateTime = DetectorParameterDefinition_Type_STATUS("DateTime")
	DetectorParameterDefinition_Type_STATUS_Double   = DetectorParameterDefinition_Type_STATUS("Double")
	DetectorParameterDefinition_Type_STATUS_Integer  = DetectorParameterDefinition_Type_STATUS("Integer")
	DetectorParameterDefinition_Type_STATUS_String   = DetectorParameterDefinition_Type_STATUS("String")
)

// Mapping from string to DetectorParameterDefinition_Type_STATUS
var detectorParameterDefinition_Type_STATUS_Values = map[string]DetectorParameterDefinition_Type_STATUS{
	"boolean":  DetectorParameterDefinition_Type_STATUS_Boolean,
	"datetime": DetectorParameterDefinition_Type_STATUS_DateTime,
	"double":   DetectorParameterDefinition_Type_STATUS_Double,
	"integer":  DetectorParameterDefinition_Type_STATUS_Integer,
	"string":   DetectorParameterDefinition_Type_STATUS_String,
}

func init() {
	SchemeBuilder.Register(&SmartDetectorAlertRule{}, &SmartDetectorAlertRuleList{})
}
