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

import (
	"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"
)

// +kubebuilder:rbac:groups=insights.azure.com,resources=activitylogalerts,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=insights.azure.com,resources={activitylogalerts/status,activitylogalerts/finalizers},verbs=get;update;patch

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,insights}
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// +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"
// Storage version of v1api20201001.ActivityLogAlert
// Generator information:
// - Generated from: /monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/activityLogAlerts_API.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}
type ActivityLogAlert struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              ActivityLogAlert_Spec   `json:"spec,omitempty"`
	Status            ActivityLogAlert_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &ActivityLogAlert{}

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

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

var _ configmaps.Exporter = &ActivityLogAlert{}

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

var _ secrets.Exporter = &ActivityLogAlert{}

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

var _ genruntime.KubernetesResource = &ActivityLogAlert{}

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

// GetAPIVersion returns the ARM API version of the resource. This is always "2020-10-01"
func (alert ActivityLogAlert) GetAPIVersion() string {
	return "2020-10-01"
}

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.Insights/activityLogAlerts"
func (alert *ActivityLogAlert) GetType() string {
	return "Microsoft.Insights/activityLogAlerts"
}

// NewEmptyStatus returns a new empty (blank) status
func (alert *ActivityLogAlert) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &ActivityLogAlert_STATUS{}
}

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

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

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

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

	alert.Status = st
	return nil
}

// Hub marks that this ActivityLogAlert is the hub type for conversion
func (alert *ActivityLogAlert) Hub() {}

// OriginalGVK returns a GroupValueKind for the original API version used to create the resource
func (alert *ActivityLogAlert) OriginalGVK() *schema.GroupVersionKind {
	return &schema.GroupVersionKind{
		Group:   GroupVersion.Group,
		Version: alert.Spec.OriginalVersion,
		Kind:    "ActivityLogAlert",
	}
}

// +kubebuilder:object:root=true
// Storage version of v1api20201001.ActivityLogAlert
// Generator information:
// - Generated from: /monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/activityLogAlerts_API.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}
type ActivityLogAlertList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []ActivityLogAlert `json:"items"`
}

// Storage version of v1api20201001.ActivityLogAlert_Spec
type ActivityLogAlert_Spec struct {
	Actions *ActionList `json:"actions,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"`
	Condition       *AlertRuleAllOfCondition      `json:"condition,omitempty"`
	Description     *string                       `json:"description,omitempty"`
	Enabled         *bool                         `json:"enabled,omitempty"`
	Location        *string                       `json:"location,omitempty"`
	OperatorSpec    *ActivityLogAlertOperatorSpec `json:"operatorSpec,omitempty"`
	OriginalVersion string                        `json:"originalVersion,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"`
	PropertyBag      genruntime.PropertyBag             `json:"$propertyBag,omitempty"`
	ScopesReferences []genruntime.ResourceReference     `armReference:"Scopes" json:"scopesReferences,omitempty"`
	Tags             map[string]string                  `json:"tags,omitempty"`
}

var _ genruntime.ConvertibleSpec = &ActivityLogAlert_Spec{}

// ConvertSpecFrom populates our ActivityLogAlert_Spec from the provided source
func (alert *ActivityLogAlert_Spec) ConvertSpecFrom(source genruntime.ConvertibleSpec) error {
	if source == alert {
		return eris.New("attempted conversion between unrelated implementations of github.com/Azure/azure-service-operator/v2/pkg/genruntime/ConvertibleSpec")
	}

	return source.ConvertSpecTo(alert)
}

// ConvertSpecTo populates the provided destination from our ActivityLogAlert_Spec
func (alert *ActivityLogAlert_Spec) ConvertSpecTo(destination genruntime.ConvertibleSpec) error {
	if destination == alert {
		return eris.New("attempted conversion between unrelated implementations of github.com/Azure/azure-service-operator/v2/pkg/genruntime/ConvertibleSpec")
	}

	return destination.ConvertSpecFrom(alert)
}

// Storage version of v1api20201001.ActivityLogAlert_STATUS
type ActivityLogAlert_STATUS struct {
	Actions     *ActionList_STATUS              `json:"actions,omitempty"`
	Condition   *AlertRuleAllOfCondition_STATUS `json:"condition,omitempty"`
	Conditions  []conditions.Condition          `json:"conditions,omitempty"`
	Description *string                         `json:"description,omitempty"`
	Enabled     *bool                           `json:"enabled,omitempty"`
	Id          *string                         `json:"id,omitempty"`
	Location    *string                         `json:"location,omitempty"`
	Name        *string                         `json:"name,omitempty"`
	PropertyBag genruntime.PropertyBag          `json:"$propertyBag,omitempty"`
	Scopes      []string                        `json:"scopes,omitempty"`
	Tags        map[string]string               `json:"tags,omitempty"`
	Type        *string                         `json:"type,omitempty"`
}

var _ genruntime.ConvertibleStatus = &ActivityLogAlert_STATUS{}

// ConvertStatusFrom populates our ActivityLogAlert_STATUS from the provided source
func (alert *ActivityLogAlert_STATUS) ConvertStatusFrom(source genruntime.ConvertibleStatus) error {
	if source == alert {
		return eris.New("attempted conversion between unrelated implementations of github.com/Azure/azure-service-operator/v2/pkg/genruntime/ConvertibleStatus")
	}

	return source.ConvertStatusTo(alert)
}

// ConvertStatusTo populates the provided destination from our ActivityLogAlert_STATUS
func (alert *ActivityLogAlert_STATUS) ConvertStatusTo(destination genruntime.ConvertibleStatus) error {
	if destination == alert {
		return eris.New("attempted conversion between unrelated implementations of github.com/Azure/azure-service-operator/v2/pkg/genruntime/ConvertibleStatus")
	}

	return destination.ConvertStatusFrom(alert)
}

// Storage version of v1api20201001.APIVersion
// +kubebuilder:validation:Enum={"2020-10-01"}
type APIVersion string

const APIVersion_Value = APIVersion("2020-10-01")

// Storage version of v1api20201001.ActionList
// A list of Activity Log Alert rule actions.
type ActionList struct {
	ActionGroups []ActionGroupReference `json:"actionGroups,omitempty"`
	PropertyBag  genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20201001.ActionList_STATUS
// A list of Activity Log Alert rule actions.
type ActionList_STATUS struct {
	ActionGroups []ActionGroup_STATUS   `json:"actionGroups,omitempty"`
	PropertyBag  genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20201001.ActivityLogAlertOperatorSpec
// Details for configuring operator behavior. Fields in this struct are interpreted by the operator directly rather than being passed to Azure
type ActivityLogAlertOperatorSpec struct {
	ConfigMapExpressions []*core.DestinationExpression `json:"configMapExpressions,omitempty"`
	PropertyBag          genruntime.PropertyBag        `json:"$propertyBag,omitempty"`
	SecretExpressions    []*core.DestinationExpression `json:"secretExpressions,omitempty"`
}

// Storage version of v1api20201001.AlertRuleAllOfCondition
// An Activity Log Alert rule condition that is met when all its member conditions are met.
type AlertRuleAllOfCondition struct {
	AllOf       []AlertRuleAnyOfOrLeafCondition `json:"allOf,omitempty"`
	PropertyBag genruntime.PropertyBag          `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20201001.AlertRuleAllOfCondition_STATUS
// An Activity Log Alert rule condition that is met when all its member conditions are met.
type AlertRuleAllOfCondition_STATUS struct {
	AllOf       []AlertRuleAnyOfOrLeafCondition_STATUS `json:"allOf,omitempty"`
	PropertyBag genruntime.PropertyBag                 `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20201001.ActionGroup_STATUS
// A pointer to an Azure Action Group.
type ActionGroup_STATUS struct {
	ActionGroupId     *string                `json:"actionGroupId,omitempty"`
	PropertyBag       genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	WebhookProperties map[string]string      `json:"webhookProperties,omitempty"`
}

// Storage version of v1api20201001.ActionGroupReference
// A pointer to an Azure Action Group.
type ActionGroupReference struct {
	// +kubebuilder:validation:Required
	// ActionGroupReference: The resource ID of the Action Group. This cannot be null or empty.
	ActionGroupReference *genruntime.ResourceReference `armReference:"ActionGroupId" json:"actionGroupReference,omitempty"`
	PropertyBag          genruntime.PropertyBag        `json:"$propertyBag,omitempty"`
	WebhookProperties    map[string]string             `json:"webhookProperties,omitempty"`
}

// Storage version of v1api20201001.AlertRuleAnyOfOrLeafCondition
// An Activity Log Alert rule condition that is met when all its member conditions are met.
// Each condition can be of one of
// the following types:
// __Important__: Each type has its unique subset of properties. Properties from different types
// CANNOT exist in one condition.
// * __Leaf Condition -__ must contain 'field' and either 'equals' or 'containsAny'.
// _Please note, 'anyOf' should __not__ be set in a Leaf Condition._
// * __AnyOf Condition -__ must contain __only__
// 'anyOf' (which is an array of Leaf Conditions).
// _Please note, 'field', 'equals' and 'containsAny' should __not__ be
// set in an AnyOf Condition._
type AlertRuleAnyOfOrLeafCondition struct {
	AnyOf       []AlertRuleLeafCondition `json:"anyOf,omitempty"`
	ContainsAny []string                 `json:"containsAny,omitempty"`
	Equals      *string                  `json:"equals,omitempty"`
	Field       *string                  `json:"field,omitempty"`
	PropertyBag genruntime.PropertyBag   `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20201001.AlertRuleAnyOfOrLeafCondition_STATUS
// An Activity Log Alert rule condition that is met when all its member conditions are met.
// Each condition can be of one of
// the following types:
// __Important__: Each type has its unique subset of properties. Properties from different types
// CANNOT exist in one condition.
// * __Leaf Condition -__ must contain 'field' and either 'equals' or 'containsAny'.
// _Please note, 'anyOf' should __not__ be set in a Leaf Condition._
// * __AnyOf Condition -__ must contain __only__
// 'anyOf' (which is an array of Leaf Conditions).
// _Please note, 'field', 'equals' and 'containsAny' should __not__ be
// set in an AnyOf Condition._
type AlertRuleAnyOfOrLeafCondition_STATUS struct {
	AnyOf       []AlertRuleLeafCondition_STATUS `json:"anyOf,omitempty"`
	ContainsAny []string                        `json:"containsAny,omitempty"`
	Equals      *string                         `json:"equals,omitempty"`
	Field       *string                         `json:"field,omitempty"`
	PropertyBag genruntime.PropertyBag          `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20201001.AlertRuleLeafCondition
// An Activity Log Alert rule condition that is met by comparing the field and value of an Activity Log event.
// This
// condition must contain 'field' and either 'equals' or 'containsAny'.
type AlertRuleLeafCondition struct {
	ContainsAny []string               `json:"containsAny,omitempty"`
	Equals      *string                `json:"equals,omitempty"`
	Field       *string                `json:"field,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20201001.AlertRuleLeafCondition_STATUS
// An Activity Log Alert rule condition that is met by comparing the field and value of an Activity Log event.
// This
// condition must contain 'field' and either 'equals' or 'containsAny'.
type AlertRuleLeafCondition_STATUS struct {
	ContainsAny []string               `json:"containsAny,omitempty"`
	Equals      *string                `json:"equals,omitempty"`
	Field       *string                `json:"field,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

func init() {
	SchemeBuilder.Register(&ActivityLogAlert{}, &ActivityLogAlertList{})
}
