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

import (
	"fmt"
	arm "github.com/Azure/azure-service-operator/v2/api/alertsmanagement/v1api20230301/arm"
	storage "github.com/Azure/azure-service-operator/v2/api/alertsmanagement/v1api20230301/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,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/2023-03-01/PrometheusRuleGroups.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/prometheusRuleGroups/{ruleGroupName}
type PrometheusRuleGroup struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              PrometheusRuleGroup_Spec   `json:"spec,omitempty"`
	Status            PrometheusRuleGroup_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &PrometheusRuleGroup{}

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

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

var _ conversion.Convertible = &PrometheusRuleGroup{}

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

	return group.AssignProperties_From_PrometheusRuleGroup(source)
}

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

	return group.AssignProperties_To_PrometheusRuleGroup(destination)
}

var _ configmaps.Exporter = &PrometheusRuleGroup{}

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

var _ secrets.Exporter = &PrometheusRuleGroup{}

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

var _ genruntime.ImportableResource = &PrometheusRuleGroup{}

// InitializeSpec initializes the spec for this resource from the given status
func (group *PrometheusRuleGroup) InitializeSpec(status genruntime.ConvertibleStatus) error {
	if s, ok := status.(*PrometheusRuleGroup_STATUS); ok {
		return group.Spec.Initialize_From_PrometheusRuleGroup_STATUS(s)
	}

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

var _ genruntime.KubernetesResource = &PrometheusRuleGroup{}

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

// GetAPIVersion returns the ARM API version of the resource. This is always "2023-03-01"
func (group PrometheusRuleGroup) GetAPIVersion() string {
	return "2023-03-01"
}

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

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

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

// GetSupportedOperations returns the operations supported by the resource
func (group *PrometheusRuleGroup) 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/prometheusRuleGroups"
func (group *PrometheusRuleGroup) GetType() string {
	return "Microsoft.AlertsManagement/prometheusRuleGroups"
}

// NewEmptyStatus returns a new empty (blank) status
func (group *PrometheusRuleGroup) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &PrometheusRuleGroup_STATUS{}
}

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

	ownerGroup, ownerKind := genruntime.LookupOwnerGroupKind(group.Spec)
	return group.Spec.Owner.AsResourceReference(ownerGroup, ownerKind)
}

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

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

	group.Status = st
	return nil
}

// AssignProperties_From_PrometheusRuleGroup populates our PrometheusRuleGroup from the provided source PrometheusRuleGroup
func (group *PrometheusRuleGroup) AssignProperties_From_PrometheusRuleGroup(source *storage.PrometheusRuleGroup) error {

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

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

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

	// No error
	return nil
}

// AssignProperties_To_PrometheusRuleGroup populates the provided destination PrometheusRuleGroup from our PrometheusRuleGroup
func (group *PrometheusRuleGroup) AssignProperties_To_PrometheusRuleGroup(destination *storage.PrometheusRuleGroup) error {

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

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

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

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2023-03-01/PrometheusRuleGroups.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/prometheusRuleGroups/{ruleGroupName}
type PrometheusRuleGroupList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []PrometheusRuleGroup `json:"items"`
}

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

const APIVersion_Value = APIVersion("2023-03-01")

type PrometheusRuleGroup_Spec struct {
	// +kubebuilder:validation:Pattern="^[^:@/#{}%&+*<>?]+$"
	// 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"`

	// ClusterName: Apply rule to data from a specific cluster.
	ClusterName *string `json:"clusterName,omitempty"`

	// Description: Rule group description.
	Description *string `json:"description,omitempty"`

	// Enabled: Enable/disable rule group.
	Enabled *bool `json:"enabled,omitempty"`

	// Interval: The interval in which to run the Prometheus rule group represented in ISO 8601 duration format. Should be
	// between 1 and 15 minutes
	Interval *string `json:"interval,omitempty"`

	// +kubebuilder:validation:Required
	// Location: The geo-location where the resource lives
	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 *PrometheusRuleGroupOperatorSpec `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
	// Rules: Defines the rules in the Prometheus rule group.
	Rules []PrometheusRule `json:"rules,omitempty"`

	// +kubebuilder:validation:Required
	// ScopesReferences: Target Azure Monitor workspaces resource ids. This api-version is currently limited to creating with
	// one scope. This may change in future.
	ScopesReferences []genruntime.ResourceReference `armReference:"Scopes" json:"scopesReferences,omitempty"`

	// Tags: Resource tags.
	Tags map[string]string `json:"tags,omitempty"`
}

var _ genruntime.ARMTransformer = &PrometheusRuleGroup_Spec{}

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

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

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

	// Set property "Properties":
	if group.ClusterName != nil ||
		group.Description != nil ||
		group.Enabled != nil ||
		group.Interval != nil ||
		group.Rules != nil ||
		group.ScopesReferences != nil {
		result.Properties = &arm.PrometheusRuleGroupProperties{}
	}
	if group.ClusterName != nil {
		clusterName := *group.ClusterName
		result.Properties.ClusterName = &clusterName
	}
	if group.Description != nil {
		description := *group.Description
		result.Properties.Description = &description
	}
	if group.Enabled != nil {
		enabled := *group.Enabled
		result.Properties.Enabled = &enabled
	}
	if group.Interval != nil {
		interval := *group.Interval
		result.Properties.Interval = &interval
	}
	for _, item := range group.Rules {
		item_ARM, err := item.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		result.Properties.Rules = append(result.Properties.Rules, *item_ARM.(*arm.PrometheusRule))
	}
	for _, item := range group.ScopesReferences {
		itemARMID, err := resolved.ResolvedReferences.Lookup(item)
		if err != nil {
			return nil, err
		}
		result.Properties.Scopes = append(result.Properties.Scopes, itemARMID)
	}

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

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

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

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

	// Set property "ClusterName":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ClusterName != nil {
			clusterName := *typedInput.Properties.ClusterName
			group.ClusterName = &clusterName
		}
	}

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

	// Set property "Enabled":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Enabled != nil {
			enabled := *typedInput.Properties.Enabled
			group.Enabled = &enabled
		}
	}

	// Set property "Interval":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Interval != nil {
			interval := *typedInput.Properties.Interval
			group.Interval = &interval
		}
	}

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

	// no assignment for property "OperatorSpec"

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

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

	// no assignment for property "ScopesReferences"

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

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &PrometheusRuleGroup_Spec{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.PrometheusRuleGroup_Spec{}
	err := group.AssignProperties_To_PrometheusRuleGroup_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_PrometheusRuleGroup_Spec populates our PrometheusRuleGroup_Spec from the provided source PrometheusRuleGroup_Spec
func (group *PrometheusRuleGroup_Spec) AssignProperties_From_PrometheusRuleGroup_Spec(source *storage.PrometheusRuleGroup_Spec) error {

	// AzureName
	group.AzureName = source.AzureName

	// ClusterName
	group.ClusterName = genruntime.ClonePointerToString(source.ClusterName)

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

	// Enabled
	if source.Enabled != nil {
		enabled := *source.Enabled
		group.Enabled = &enabled
	} else {
		group.Enabled = nil
	}

	// Interval
	group.Interval = genruntime.ClonePointerToString(source.Interval)

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

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

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

	// Rules
	if source.Rules != nil {
		ruleList := make([]PrometheusRule, len(source.Rules))
		for ruleIndex, ruleItem := range source.Rules {
			var rule PrometheusRule
			err := rule.AssignProperties_From_PrometheusRule(&ruleItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_PrometheusRule() to populate field Rules")
			}
			ruleList[ruleIndex] = rule
		}
		group.Rules = ruleList
	} else {
		group.Rules = nil
	}

	// ScopesReferences
	if source.ScopesReferences != nil {
		scopesReferenceList := make([]genruntime.ResourceReference, len(source.ScopesReferences))
		for scopesReferenceIndex, scopesReferenceItem := range source.ScopesReferences {
			scopesReferenceList[scopesReferenceIndex] = scopesReferenceItem.Copy()
		}
		group.ScopesReferences = scopesReferenceList
	} else {
		group.ScopesReferences = nil
	}

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

	// No error
	return nil
}

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

	// AzureName
	destination.AzureName = group.AzureName

	// ClusterName
	destination.ClusterName = genruntime.ClonePointerToString(group.ClusterName)

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

	// Enabled
	if group.Enabled != nil {
		enabled := *group.Enabled
		destination.Enabled = &enabled
	} else {
		destination.Enabled = nil
	}

	// Interval
	destination.Interval = genruntime.ClonePointerToString(group.Interval)

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

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

	// OriginalVersion
	destination.OriginalVersion = group.OriginalVersion()

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

	// Rules
	if group.Rules != nil {
		ruleList := make([]storage.PrometheusRule, len(group.Rules))
		for ruleIndex, ruleItem := range group.Rules {
			var rule storage.PrometheusRule
			err := ruleItem.AssignProperties_To_PrometheusRule(&rule)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_PrometheusRule() to populate field Rules")
			}
			ruleList[ruleIndex] = rule
		}
		destination.Rules = ruleList
	} else {
		destination.Rules = nil
	}

	// ScopesReferences
	if group.ScopesReferences != nil {
		scopesReferenceList := make([]genruntime.ResourceReference, len(group.ScopesReferences))
		for scopesReferenceIndex, scopesReferenceItem := range group.ScopesReferences {
			scopesReferenceList[scopesReferenceIndex] = scopesReferenceItem.Copy()
		}
		destination.ScopesReferences = scopesReferenceList
	} else {
		destination.ScopesReferences = nil
	}

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

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

	// No error
	return nil
}

// Initialize_From_PrometheusRuleGroup_STATUS populates our PrometheusRuleGroup_Spec from the provided source PrometheusRuleGroup_STATUS
func (group *PrometheusRuleGroup_Spec) Initialize_From_PrometheusRuleGroup_STATUS(source *PrometheusRuleGroup_STATUS) error {

	// ClusterName
	group.ClusterName = genruntime.ClonePointerToString(source.ClusterName)

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

	// Enabled
	if source.Enabled != nil {
		enabled := *source.Enabled
		group.Enabled = &enabled
	} else {
		group.Enabled = nil
	}

	// Interval
	group.Interval = genruntime.ClonePointerToString(source.Interval)

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

	// Rules
	if source.Rules != nil {
		ruleList := make([]PrometheusRule, len(source.Rules))
		for ruleIndex, ruleItem := range source.Rules {
			var rule PrometheusRule
			err := rule.Initialize_From_PrometheusRule_STATUS(&ruleItem)
			if err != nil {
				return eris.Wrap(err, "calling Initialize_From_PrometheusRule_STATUS() to populate field Rules")
			}
			ruleList[ruleIndex] = rule
		}
		group.Rules = ruleList
	} else {
		group.Rules = nil
	}

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

	// No error
	return nil
}

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

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

type PrometheusRuleGroup_STATUS struct {
	// ClusterName: Apply rule to data from a specific cluster.
	ClusterName *string `json:"clusterName,omitempty"`

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

	// Description: Rule group description.
	Description *string `json:"description,omitempty"`

	// Enabled: Enable/disable rule group.
	Enabled *bool `json:"enabled,omitempty"`

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

	// Interval: The interval in which to run the Prometheus rule group represented in ISO 8601 duration format. Should be
	// between 1 and 15 minutes
	Interval *string `json:"interval,omitempty"`

	// Location: The geo-location where the resource lives
	Location *string `json:"location,omitempty"`

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

	// Rules: Defines the rules in the Prometheus rule group.
	Rules []PrometheusRule_STATUS `json:"rules,omitempty"`

	// Scopes: Target Azure Monitor workspaces resource ids. This api-version is currently limited to creating with one scope.
	// This may change in future.
	Scopes []string `json:"scopes,omitempty"`

	// SystemData: Azure Resource Manager metadata containing createdBy and modifiedBy information.
	SystemData *SystemData_STATUS `json:"systemData,omitempty"`

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

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

var _ genruntime.ConvertibleStatus = &PrometheusRuleGroup_STATUS{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.PrometheusRuleGroup_STATUS{}
	err := group.AssignProperties_To_PrometheusRuleGroup_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 = &PrometheusRuleGroup_STATUS{}

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

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

	// Set property "ClusterName":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ClusterName != nil {
			clusterName := *typedInput.Properties.ClusterName
			group.ClusterName = &clusterName
		}
	}

	// no assignment for property "Conditions"

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

	// Set property "Enabled":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Enabled != nil {
			enabled := *typedInput.Properties.Enabled
			group.Enabled = &enabled
		}
	}

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

	// Set property "Interval":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Interval != nil {
			interval := *typedInput.Properties.Interval
			group.Interval = &interval
		}
	}

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

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

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

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

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

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

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

	// No error
	return nil
}

// AssignProperties_From_PrometheusRuleGroup_STATUS populates our PrometheusRuleGroup_STATUS from the provided source PrometheusRuleGroup_STATUS
func (group *PrometheusRuleGroup_STATUS) AssignProperties_From_PrometheusRuleGroup_STATUS(source *storage.PrometheusRuleGroup_STATUS) error {

	// ClusterName
	group.ClusterName = genruntime.ClonePointerToString(source.ClusterName)

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

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

	// Enabled
	if source.Enabled != nil {
		enabled := *source.Enabled
		group.Enabled = &enabled
	} else {
		group.Enabled = nil
	}

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

	// Interval
	group.Interval = genruntime.ClonePointerToString(source.Interval)

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

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

	// Rules
	if source.Rules != nil {
		ruleList := make([]PrometheusRule_STATUS, len(source.Rules))
		for ruleIndex, ruleItem := range source.Rules {
			var rule PrometheusRule_STATUS
			err := rule.AssignProperties_From_PrometheusRule_STATUS(&ruleItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_PrometheusRule_STATUS() to populate field Rules")
			}
			ruleList[ruleIndex] = rule
		}
		group.Rules = ruleList
	} else {
		group.Rules = nil
	}

	// Scopes
	group.Scopes = genruntime.CloneSliceOfString(source.Scopes)

	// 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")
		}
		group.SystemData = &systemDatum
	} else {
		group.SystemData = nil
	}

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

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

	// No error
	return nil
}

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

	// ClusterName
	destination.ClusterName = genruntime.ClonePointerToString(group.ClusterName)

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

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

	// Enabled
	if group.Enabled != nil {
		enabled := *group.Enabled
		destination.Enabled = &enabled
	} else {
		destination.Enabled = nil
	}

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

	// Interval
	destination.Interval = genruntime.ClonePointerToString(group.Interval)

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

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

	// Rules
	if group.Rules != nil {
		ruleList := make([]storage.PrometheusRule_STATUS, len(group.Rules))
		for ruleIndex, ruleItem := range group.Rules {
			var rule storage.PrometheusRule_STATUS
			err := ruleItem.AssignProperties_To_PrometheusRule_STATUS(&rule)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_PrometheusRule_STATUS() to populate field Rules")
			}
			ruleList[ruleIndex] = rule
		}
		destination.Rules = ruleList
	} else {
		destination.Rules = nil
	}

	// Scopes
	destination.Scopes = genruntime.CloneSliceOfString(group.Scopes)

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

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

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

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

	// No error
	return nil
}

// An Azure Prometheus alerting or recording rule.
type PrometheusRule struct {
	// Actions: Actions that are performed when the alert rule becomes active, and when an alert condition is resolved.
	Actions []PrometheusRuleGroupAction `json:"actions,omitempty"`

	// Alert: Alert rule name.
	Alert *string `json:"alert,omitempty"`

	// Annotations: The annotations clause specifies a set of informational labels that can be used to store longer additional
	// information such as alert descriptions or runbook links. The annotation values can be templated.
	Annotations map[string]string `json:"annotations,omitempty"`

	// Enabled: Enable/disable rule.
	Enabled *bool `json:"enabled,omitempty"`

	// +kubebuilder:validation:Required
	// Expression: The PromQL expression to evaluate. https://prometheus.io/docs/prometheus/latest/querying/basics/. Evaluated
	// periodically as given by 'interval', and the result recorded as a new set of time series with the metric name as given
	// by 'record'.
	Expression *string `json:"expression,omitempty"`

	// For: The amount of time alert must be active before firing.
	For *string `json:"for,omitempty"`

	// Labels: Labels to add or overwrite before storing the result.
	Labels map[string]string `json:"labels,omitempty"`

	// Record: Recorded metrics name.
	Record *string `json:"record,omitempty"`

	// ResolveConfiguration: Defines the configuration for resolving fired alerts. Only relevant for alerts.
	ResolveConfiguration *PrometheusRuleResolveConfiguration `json:"resolveConfiguration,omitempty"`

	// Severity: The severity of the alerts fired by the rule. Must be between 0 and 4.
	Severity *int `json:"severity,omitempty"`
}

var _ genruntime.ARMTransformer = &PrometheusRule{}

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

	// Set property "Actions":
	for _, item := range rule.Actions {
		item_ARM, err := item.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		result.Actions = append(result.Actions, *item_ARM.(*arm.PrometheusRuleGroupAction))
	}

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

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

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

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

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

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

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

	// Set property "ResolveConfiguration":
	if rule.ResolveConfiguration != nil {
		resolveConfiguration_ARM, err := rule.ResolveConfiguration.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		resolveConfiguration := *resolveConfiguration_ARM.(*arm.PrometheusRuleResolveConfiguration)
		result.ResolveConfiguration = &resolveConfiguration
	}

	// Set property "Severity":
	if rule.Severity != nil {
		severity := *rule.Severity
		result.Severity = &severity
	}
	return result, nil
}

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

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

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

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

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

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

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

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

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

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

	// Set property "ResolveConfiguration":
	if typedInput.ResolveConfiguration != nil {
		var resolveConfiguration1 PrometheusRuleResolveConfiguration
		err := resolveConfiguration1.PopulateFromARM(owner, *typedInput.ResolveConfiguration)
		if err != nil {
			return err
		}
		resolveConfiguration := resolveConfiguration1
		rule.ResolveConfiguration = &resolveConfiguration
	}

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

	// No error
	return nil
}

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

	// Actions
	if source.Actions != nil {
		actionList := make([]PrometheusRuleGroupAction, len(source.Actions))
		for actionIndex, actionItem := range source.Actions {
			var action PrometheusRuleGroupAction
			err := action.AssignProperties_From_PrometheusRuleGroupAction(&actionItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_PrometheusRuleGroupAction() to populate field Actions")
			}
			actionList[actionIndex] = action
		}
		rule.Actions = actionList
	} else {
		rule.Actions = nil
	}

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

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

	// Enabled
	if source.Enabled != nil {
		enabled := *source.Enabled
		rule.Enabled = &enabled
	} else {
		rule.Enabled = nil
	}

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

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

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

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

	// ResolveConfiguration
	if source.ResolveConfiguration != nil {
		var resolveConfiguration PrometheusRuleResolveConfiguration
		err := resolveConfiguration.AssignProperties_From_PrometheusRuleResolveConfiguration(source.ResolveConfiguration)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_PrometheusRuleResolveConfiguration() to populate field ResolveConfiguration")
		}
		rule.ResolveConfiguration = &resolveConfiguration
	} else {
		rule.ResolveConfiguration = nil
	}

	// Severity
	rule.Severity = genruntime.ClonePointerToInt(source.Severity)

	// No error
	return nil
}

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

	// Actions
	if rule.Actions != nil {
		actionList := make([]storage.PrometheusRuleGroupAction, len(rule.Actions))
		for actionIndex, actionItem := range rule.Actions {
			var action storage.PrometheusRuleGroupAction
			err := actionItem.AssignProperties_To_PrometheusRuleGroupAction(&action)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_PrometheusRuleGroupAction() to populate field Actions")
			}
			actionList[actionIndex] = action
		}
		destination.Actions = actionList
	} else {
		destination.Actions = nil
	}

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

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

	// Enabled
	if rule.Enabled != nil {
		enabled := *rule.Enabled
		destination.Enabled = &enabled
	} else {
		destination.Enabled = nil
	}

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

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

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

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

	// ResolveConfiguration
	if rule.ResolveConfiguration != nil {
		var resolveConfiguration storage.PrometheusRuleResolveConfiguration
		err := rule.ResolveConfiguration.AssignProperties_To_PrometheusRuleResolveConfiguration(&resolveConfiguration)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_PrometheusRuleResolveConfiguration() to populate field ResolveConfiguration")
		}
		destination.ResolveConfiguration = &resolveConfiguration
	} else {
		destination.ResolveConfiguration = nil
	}

	// Severity
	destination.Severity = genruntime.ClonePointerToInt(rule.Severity)

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

	// No error
	return nil
}

// Initialize_From_PrometheusRule_STATUS populates our PrometheusRule from the provided source PrometheusRule_STATUS
func (rule *PrometheusRule) Initialize_From_PrometheusRule_STATUS(source *PrometheusRule_STATUS) error {

	// Actions
	if source.Actions != nil {
		actionList := make([]PrometheusRuleGroupAction, len(source.Actions))
		for actionIndex, actionItem := range source.Actions {
			var action PrometheusRuleGroupAction
			err := action.Initialize_From_PrometheusRuleGroupAction_STATUS(&actionItem)
			if err != nil {
				return eris.Wrap(err, "calling Initialize_From_PrometheusRuleGroupAction_STATUS() to populate field Actions")
			}
			actionList[actionIndex] = action
		}
		rule.Actions = actionList
	} else {
		rule.Actions = nil
	}

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

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

	// Enabled
	if source.Enabled != nil {
		enabled := *source.Enabled
		rule.Enabled = &enabled
	} else {
		rule.Enabled = nil
	}

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

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

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

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

	// ResolveConfiguration
	if source.ResolveConfiguration != nil {
		var resolveConfiguration PrometheusRuleResolveConfiguration
		err := resolveConfiguration.Initialize_From_PrometheusRuleResolveConfiguration_STATUS(source.ResolveConfiguration)
		if err != nil {
			return eris.Wrap(err, "calling Initialize_From_PrometheusRuleResolveConfiguration_STATUS() to populate field ResolveConfiguration")
		}
		rule.ResolveConfiguration = &resolveConfiguration
	} else {
		rule.ResolveConfiguration = nil
	}

	// Severity
	rule.Severity = genruntime.ClonePointerToInt(source.Severity)

	// No error
	return nil
}

// An Azure Prometheus alerting or recording rule.
type PrometheusRule_STATUS struct {
	// Actions: Actions that are performed when the alert rule becomes active, and when an alert condition is resolved.
	Actions []PrometheusRuleGroupAction_STATUS `json:"actions,omitempty"`

	// Alert: Alert rule name.
	Alert *string `json:"alert,omitempty"`

	// Annotations: The annotations clause specifies a set of informational labels that can be used to store longer additional
	// information such as alert descriptions or runbook links. The annotation values can be templated.
	Annotations map[string]string `json:"annotations,omitempty"`

	// Enabled: Enable/disable rule.
	Enabled *bool `json:"enabled,omitempty"`

	// Expression: The PromQL expression to evaluate. https://prometheus.io/docs/prometheus/latest/querying/basics/. Evaluated
	// periodically as given by 'interval', and the result recorded as a new set of time series with the metric name as given
	// by 'record'.
	Expression *string `json:"expression,omitempty"`

	// For: The amount of time alert must be active before firing.
	For *string `json:"for,omitempty"`

	// Labels: Labels to add or overwrite before storing the result.
	Labels map[string]string `json:"labels,omitempty"`

	// Record: Recorded metrics name.
	Record *string `json:"record,omitempty"`

	// ResolveConfiguration: Defines the configuration for resolving fired alerts. Only relevant for alerts.
	ResolveConfiguration *PrometheusRuleResolveConfiguration_STATUS `json:"resolveConfiguration,omitempty"`

	// Severity: The severity of the alerts fired by the rule. Must be between 0 and 4.
	Severity *int `json:"severity,omitempty"`
}

var _ genruntime.FromARMConverter = &PrometheusRule_STATUS{}

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

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

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

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

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

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

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

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

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

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

	// Set property "ResolveConfiguration":
	if typedInput.ResolveConfiguration != nil {
		var resolveConfiguration1 PrometheusRuleResolveConfiguration_STATUS
		err := resolveConfiguration1.PopulateFromARM(owner, *typedInput.ResolveConfiguration)
		if err != nil {
			return err
		}
		resolveConfiguration := resolveConfiguration1
		rule.ResolveConfiguration = &resolveConfiguration
	}

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

	// No error
	return nil
}

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

	// Actions
	if source.Actions != nil {
		actionList := make([]PrometheusRuleGroupAction_STATUS, len(source.Actions))
		for actionIndex, actionItem := range source.Actions {
			var action PrometheusRuleGroupAction_STATUS
			err := action.AssignProperties_From_PrometheusRuleGroupAction_STATUS(&actionItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_PrometheusRuleGroupAction_STATUS() to populate field Actions")
			}
			actionList[actionIndex] = action
		}
		rule.Actions = actionList
	} else {
		rule.Actions = nil
	}

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

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

	// Enabled
	if source.Enabled != nil {
		enabled := *source.Enabled
		rule.Enabled = &enabled
	} else {
		rule.Enabled = nil
	}

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

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

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

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

	// ResolveConfiguration
	if source.ResolveConfiguration != nil {
		var resolveConfiguration PrometheusRuleResolveConfiguration_STATUS
		err := resolveConfiguration.AssignProperties_From_PrometheusRuleResolveConfiguration_STATUS(source.ResolveConfiguration)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_PrometheusRuleResolveConfiguration_STATUS() to populate field ResolveConfiguration")
		}
		rule.ResolveConfiguration = &resolveConfiguration
	} else {
		rule.ResolveConfiguration = nil
	}

	// Severity
	rule.Severity = genruntime.ClonePointerToInt(source.Severity)

	// No error
	return nil
}

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

	// Actions
	if rule.Actions != nil {
		actionList := make([]storage.PrometheusRuleGroupAction_STATUS, len(rule.Actions))
		for actionIndex, actionItem := range rule.Actions {
			var action storage.PrometheusRuleGroupAction_STATUS
			err := actionItem.AssignProperties_To_PrometheusRuleGroupAction_STATUS(&action)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_PrometheusRuleGroupAction_STATUS() to populate field Actions")
			}
			actionList[actionIndex] = action
		}
		destination.Actions = actionList
	} else {
		destination.Actions = nil
	}

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

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

	// Enabled
	if rule.Enabled != nil {
		enabled := *rule.Enabled
		destination.Enabled = &enabled
	} else {
		destination.Enabled = nil
	}

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

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

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

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

	// ResolveConfiguration
	if rule.ResolveConfiguration != nil {
		var resolveConfiguration storage.PrometheusRuleResolveConfiguration_STATUS
		err := rule.ResolveConfiguration.AssignProperties_To_PrometheusRuleResolveConfiguration_STATUS(&resolveConfiguration)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_PrometheusRuleResolveConfiguration_STATUS() to populate field ResolveConfiguration")
		}
		destination.ResolveConfiguration = &resolveConfiguration
	} else {
		destination.ResolveConfiguration = nil
	}

	// Severity
	destination.Severity = genruntime.ClonePointerToInt(rule.Severity)

	// 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 PrometheusRuleGroupOperatorSpec 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_PrometheusRuleGroupOperatorSpec populates our PrometheusRuleGroupOperatorSpec from the provided source PrometheusRuleGroupOperatorSpec
func (operator *PrometheusRuleGroupOperatorSpec) AssignProperties_From_PrometheusRuleGroupOperatorSpec(source *storage.PrometheusRuleGroupOperatorSpec) 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_PrometheusRuleGroupOperatorSpec populates the provided destination PrometheusRuleGroupOperatorSpec from our PrometheusRuleGroupOperatorSpec
func (operator *PrometheusRuleGroupOperatorSpec) AssignProperties_To_PrometheusRuleGroupOperatorSpec(destination *storage.PrometheusRuleGroupOperatorSpec) 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
}

// An alert action. Only relevant for alerts.
type PrometheusRuleGroupAction struct {
	// ActionGroupReference: The resource id of the action group to use.
	ActionGroupReference *genruntime.ResourceReference `armReference:"ActionGroupId" json:"actionGroupReference,omitempty"`

	// ActionProperties: The properties of an action group object.
	ActionProperties map[string]string `json:"actionProperties,omitempty"`
}

var _ genruntime.ARMTransformer = &PrometheusRuleGroupAction{}

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

	// Set property "ActionGroupId":
	if action.ActionGroupReference != nil {
		actionGroupReferenceARMID, err := resolved.ResolvedReferences.Lookup(*action.ActionGroupReference)
		if err != nil {
			return nil, err
		}
		actionGroupReference := actionGroupReferenceARMID
		result.ActionGroupId = &actionGroupReference
	}

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

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

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

	// no assignment for property "ActionGroupReference"

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

	// No error
	return nil
}

// AssignProperties_From_PrometheusRuleGroupAction populates our PrometheusRuleGroupAction from the provided source PrometheusRuleGroupAction
func (action *PrometheusRuleGroupAction) AssignProperties_From_PrometheusRuleGroupAction(source *storage.PrometheusRuleGroupAction) error {

	// ActionGroupReference
	if source.ActionGroupReference != nil {
		actionGroupReference := source.ActionGroupReference.Copy()
		action.ActionGroupReference = &actionGroupReference
	} else {
		action.ActionGroupReference = nil
	}

	// ActionProperties
	action.ActionProperties = genruntime.CloneMapOfStringToString(source.ActionProperties)

	// No error
	return nil
}

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

	// ActionGroupReference
	if action.ActionGroupReference != nil {
		actionGroupReference := action.ActionGroupReference.Copy()
		destination.ActionGroupReference = &actionGroupReference
	} else {
		destination.ActionGroupReference = nil
	}

	// ActionProperties
	destination.ActionProperties = genruntime.CloneMapOfStringToString(action.ActionProperties)

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

	// No error
	return nil
}

// Initialize_From_PrometheusRuleGroupAction_STATUS populates our PrometheusRuleGroupAction from the provided source PrometheusRuleGroupAction_STATUS
func (action *PrometheusRuleGroupAction) Initialize_From_PrometheusRuleGroupAction_STATUS(source *PrometheusRuleGroupAction_STATUS) error {

	// ActionGroupReference
	if source.ActionGroupId != nil {
		actionGroupReference := genruntime.CreateResourceReferenceFromARMID(*source.ActionGroupId)
		action.ActionGroupReference = &actionGroupReference
	} else {
		action.ActionGroupReference = nil
	}

	// ActionProperties
	action.ActionProperties = genruntime.CloneMapOfStringToString(source.ActionProperties)

	// No error
	return nil
}

// An alert action. Only relevant for alerts.
type PrometheusRuleGroupAction_STATUS struct {
	// ActionGroupId: The resource id of the action group to use.
	ActionGroupId *string `json:"actionGroupId,omitempty"`

	// ActionProperties: The properties of an action group object.
	ActionProperties map[string]string `json:"actionProperties,omitempty"`
}

var _ genruntime.FromARMConverter = &PrometheusRuleGroupAction_STATUS{}

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

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

	// Set property "ActionGroupId":
	if typedInput.ActionGroupId != nil {
		actionGroupId := *typedInput.ActionGroupId
		action.ActionGroupId = &actionGroupId
	}

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

	// No error
	return nil
}

// AssignProperties_From_PrometheusRuleGroupAction_STATUS populates our PrometheusRuleGroupAction_STATUS from the provided source PrometheusRuleGroupAction_STATUS
func (action *PrometheusRuleGroupAction_STATUS) AssignProperties_From_PrometheusRuleGroupAction_STATUS(source *storage.PrometheusRuleGroupAction_STATUS) error {

	// ActionGroupId
	action.ActionGroupId = genruntime.ClonePointerToString(source.ActionGroupId)

	// ActionProperties
	action.ActionProperties = genruntime.CloneMapOfStringToString(source.ActionProperties)

	// No error
	return nil
}

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

	// ActionGroupId
	destination.ActionGroupId = genruntime.ClonePointerToString(action.ActionGroupId)

	// ActionProperties
	destination.ActionProperties = genruntime.CloneMapOfStringToString(action.ActionProperties)

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

	// No error
	return nil
}

// Specifies the Prometheus alert rule configuration.
type PrometheusRuleResolveConfiguration struct {
	// AutoResolved: Enable alert auto-resolution.
	AutoResolved *bool `json:"autoResolved,omitempty"`

	// TimeToResolve: Alert auto-resolution timeout.
	TimeToResolve *string `json:"timeToResolve,omitempty"`
}

var _ genruntime.ARMTransformer = &PrometheusRuleResolveConfiguration{}

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

	// Set property "AutoResolved":
	if configuration.AutoResolved != nil {
		autoResolved := *configuration.AutoResolved
		result.AutoResolved = &autoResolved
	}

	// Set property "TimeToResolve":
	if configuration.TimeToResolve != nil {
		timeToResolve := *configuration.TimeToResolve
		result.TimeToResolve = &timeToResolve
	}
	return result, nil
}

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

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

	// Set property "AutoResolved":
	if typedInput.AutoResolved != nil {
		autoResolved := *typedInput.AutoResolved
		configuration.AutoResolved = &autoResolved
	}

	// Set property "TimeToResolve":
	if typedInput.TimeToResolve != nil {
		timeToResolve := *typedInput.TimeToResolve
		configuration.TimeToResolve = &timeToResolve
	}

	// No error
	return nil
}

// AssignProperties_From_PrometheusRuleResolveConfiguration populates our PrometheusRuleResolveConfiguration from the provided source PrometheusRuleResolveConfiguration
func (configuration *PrometheusRuleResolveConfiguration) AssignProperties_From_PrometheusRuleResolveConfiguration(source *storage.PrometheusRuleResolveConfiguration) error {

	// AutoResolved
	if source.AutoResolved != nil {
		autoResolved := *source.AutoResolved
		configuration.AutoResolved = &autoResolved
	} else {
		configuration.AutoResolved = nil
	}

	// TimeToResolve
	configuration.TimeToResolve = genruntime.ClonePointerToString(source.TimeToResolve)

	// No error
	return nil
}

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

	// AutoResolved
	if configuration.AutoResolved != nil {
		autoResolved := *configuration.AutoResolved
		destination.AutoResolved = &autoResolved
	} else {
		destination.AutoResolved = nil
	}

	// TimeToResolve
	destination.TimeToResolve = genruntime.ClonePointerToString(configuration.TimeToResolve)

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

	// No error
	return nil
}

// Initialize_From_PrometheusRuleResolveConfiguration_STATUS populates our PrometheusRuleResolveConfiguration from the provided source PrometheusRuleResolveConfiguration_STATUS
func (configuration *PrometheusRuleResolveConfiguration) Initialize_From_PrometheusRuleResolveConfiguration_STATUS(source *PrometheusRuleResolveConfiguration_STATUS) error {

	// AutoResolved
	if source.AutoResolved != nil {
		autoResolved := *source.AutoResolved
		configuration.AutoResolved = &autoResolved
	} else {
		configuration.AutoResolved = nil
	}

	// TimeToResolve
	configuration.TimeToResolve = genruntime.ClonePointerToString(source.TimeToResolve)

	// No error
	return nil
}

// Specifies the Prometheus alert rule configuration.
type PrometheusRuleResolveConfiguration_STATUS struct {
	// AutoResolved: Enable alert auto-resolution.
	AutoResolved *bool `json:"autoResolved,omitempty"`

	// TimeToResolve: Alert auto-resolution timeout.
	TimeToResolve *string `json:"timeToResolve,omitempty"`
}

var _ genruntime.FromARMConverter = &PrometheusRuleResolveConfiguration_STATUS{}

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

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

	// Set property "AutoResolved":
	if typedInput.AutoResolved != nil {
		autoResolved := *typedInput.AutoResolved
		configuration.AutoResolved = &autoResolved
	}

	// Set property "TimeToResolve":
	if typedInput.TimeToResolve != nil {
		timeToResolve := *typedInput.TimeToResolve
		configuration.TimeToResolve = &timeToResolve
	}

	// No error
	return nil
}

// AssignProperties_From_PrometheusRuleResolveConfiguration_STATUS populates our PrometheusRuleResolveConfiguration_STATUS from the provided source PrometheusRuleResolveConfiguration_STATUS
func (configuration *PrometheusRuleResolveConfiguration_STATUS) AssignProperties_From_PrometheusRuleResolveConfiguration_STATUS(source *storage.PrometheusRuleResolveConfiguration_STATUS) error {

	// AutoResolved
	if source.AutoResolved != nil {
		autoResolved := *source.AutoResolved
		configuration.AutoResolved = &autoResolved
	} else {
		configuration.AutoResolved = nil
	}

	// TimeToResolve
	configuration.TimeToResolve = genruntime.ClonePointerToString(source.TimeToResolve)

	// No error
	return nil
}

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

	// AutoResolved
	if configuration.AutoResolved != nil {
		autoResolved := *configuration.AutoResolved
		destination.AutoResolved = &autoResolved
	} else {
		destination.AutoResolved = nil
	}

	// TimeToResolve
	destination.TimeToResolve = genruntime.ClonePointerToString(configuration.TimeToResolve)

	// 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(&PrometheusRuleGroup{}, &PrometheusRuleGroupList{})
}
