/******************************************************************************
 * Copyright (c)  2023 PingCAP, Inc.                                          *
 * Licensed under the Apache License, Version 2.0 (the "License");            *
 * you may not use this file except in compliance with the License.           *
 * You may obtain a copy of the License at                                    *
 *                                                                            *
 * http://www.apache.org/licenses/LICENSE-2.0                                 *
 *                                                                            *
 * Unless required by applicable law or agreed to in writing, software        *
 * distributed under the License is distributed on an "AS IS" BASIS,          *
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   *
 * See the License for the specific language governing permissions and        *
 * limitations under the License.                                             *
 ******************************************************************************/

package constants

type AlertRuleStatus string

const (
	RULE_ACTIVE   AlertRuleStatus = "active"
	RULE_DISABLED AlertRuleStatus = "disabled"
)

const (
	RULE_CANEDIT_ALL    string = "all"
	RULE_CANEDIT_STATUS string = "statusonly"
	RULE_CANEDIT_NONE   string = "none"
)

type AlertRuleSource string

const (
	//RULE_SOURCE_TEMPLATE AlertRuleSource  = "template"
	//RULE_SOURCE_UDF AlertRuleSource = "udf"
	RULE_EXPR_REGEXP       = `(==|>|<|!=|>=|<=)\s*(-?\d+(?:\.\d+)?)\s*$`
	OVERLAY_NAME_TEMPATE   = "overlay-%s"
	RULEID_TEMPLATE        = "%s:%s" //group.name:labels.ruleID
	RULE_CACHEKEY_TEMPLATE = "%s:%s:%s:%s"
	MAX_TRIGGERINTERVAL    = 600
)

const (
	PlaceholderPrefix                       string = "{"
	PlaceholderSufix                        string = "}"
	PlaceHolderThreshold                    string = "threshold"
	PlaceHolderSeverity                     string = "severity"
	PlaceHolderTriggerInteval               string = "triggerInterval"
	PlaceHolderThresholdPercentage          string = "thresholdPercentage"
	PlaceHolderRemainingThresholdPercentage string = "remainPercentage"
)

const (
	RuleStatusModifiedMask    = 1 //001
	RuleThresholdModifiedMask = 2 //010
	RuleForModifiedMask       = 4 //100
)

var Placeholder = []string{
	PlaceHolderThreshold, PlaceHolderSeverity, PlaceHolderTriggerInteval, PlaceHolderThresholdPercentage, PlaceHolderRemainingThresholdPercentage,
}

const RuleTemplateNamespace = "default"
