# coding=utf-8
# *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***

import json
import warnings
import pulumi
import pulumi.runtime
from typing import Union
from .. import utilities, tables

class Alarm(pulumi.CustomResource):
    contact_groups: pulumi.Output[list]
    """
    List contact groups of the alarm rule, which must have been created on the console.
    """
    dimensions: pulumi.Output[dict]
    """
    Map of the resources associated with the alarm rule, such as "instanceId", "device" and "port". Each key's value is a string and it uses comma to split multiple items. For more information, see [Metrics Reference](https://www.alibabacloud.com/help/doc-detail/28619.htm).
    """
    effective_interval: pulumi.Output[str]
    enabled: pulumi.Output[bool]
    """
    Whether to enable alarm rule. Default to true.
    * `webhook`- (Optional, Available in 1.46.0+) The webhook that should be called when the alarm is triggered. Currently, only http protocol is supported. Default is empty string.
    """
    end_time: pulumi.Output[float]
    """
    End time of the alarm effective period. Default value 24 and it indicates the time 24:00. Valid value range: [0, 24].
    """
    metric: pulumi.Output[str]
    """
    Name of the monitoring metrics corresponding to a project, such as "CPUUtilization" and "networkin_rate". For more information, see [Metrics Reference](https://www.alibabacloud.com/help/doc-detail/28619.htm).
    """
    name: pulumi.Output[str]
    """
    The alarm rule name.
    """
    operator: pulumi.Output[str]
    """
    Alarm comparison operator. Valid values: ["<=", "<", ">", ">=", "==", "!="]. Default to "==".
    """
    period: pulumi.Output[float]
    """
    Index query cycle, which must be consistent with that defined for metrics. Default to 300, in seconds.
    """
    project: pulumi.Output[str]
    """
    Monitor project name, such as "acs_ecs_dashboard" and "acs_rds_dashboard". For more information, see [Metrics Reference](https://www.alibabacloud.com/help/doc-detail/28619.htm).
    """
    silence_time: pulumi.Output[float]
    """
    Notification silence period in the alarm state, in seconds. Valid value range: [300, 86400]. Default to 86400
    """
    start_time: pulumi.Output[float]
    """
    Start time of the alarm effective period. Default to 0 and it indicates the time 00:00. Valid value range: [0, 24].
    """
    statistics: pulumi.Output[str]
    """
    Statistical method. It must be consistent with that defined for metrics. Valid values: ["Average", "Minimum", "Maximum"]. Default to "Average".
    """
    status: pulumi.Output[str]
    """
    The current alarm rule status.
    * `webhook`- The webhook that is called when the alarm is triggered.
    """
    threshold: pulumi.Output[str]
    """
    Alarm threshold value, which must be a numeric value currently.
    """
    triggered_count: pulumi.Output[float]
    """
    Number of consecutive times it has been detected that the values exceed the threshold. Default to 3.
    """
    webhook: pulumi.Output[str]
    def __init__(__self__, resource_name, opts=None, contact_groups=None, dimensions=None, effective_interval=None, enabled=None, end_time=None, metric=None, name=None, operator=None, period=None, project=None, silence_time=None, start_time=None, statistics=None, threshold=None, triggered_count=None, webhook=None, __props__=None, __name__=None, __opts__=None):
        """
        This resource provides a alarm rule resource and it can be used to monitor several cloud services according different metrics.
        Details for [alarm rule](https://www.alibabacloud.com/help/doc-detail/28608.htm).
        
        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[list] contact_groups: List contact groups of the alarm rule, which must have been created on the console.
        :param pulumi.Input[dict] dimensions: Map of the resources associated with the alarm rule, such as "instanceId", "device" and "port". Each key's value is a string and it uses comma to split multiple items. For more information, see [Metrics Reference](https://www.alibabacloud.com/help/doc-detail/28619.htm).
        :param pulumi.Input[bool] enabled: Whether to enable alarm rule. Default to true.
               * `webhook`- (Optional, Available in 1.46.0+) The webhook that should be called when the alarm is triggered. Currently, only http protocol is supported. Default is empty string.
        :param pulumi.Input[float] end_time: End time of the alarm effective period. Default value 24 and it indicates the time 24:00. Valid value range: [0, 24].
        :param pulumi.Input[str] metric: Name of the monitoring metrics corresponding to a project, such as "CPUUtilization" and "networkin_rate". For more information, see [Metrics Reference](https://www.alibabacloud.com/help/doc-detail/28619.htm).
        :param pulumi.Input[str] name: The alarm rule name.
        :param pulumi.Input[str] operator: Alarm comparison operator. Valid values: ["<=", "<", ">", ">=", "==", "!="]. Default to "==".
        :param pulumi.Input[float] period: Index query cycle, which must be consistent with that defined for metrics. Default to 300, in seconds.
        :param pulumi.Input[str] project: Monitor project name, such as "acs_ecs_dashboard" and "acs_rds_dashboard". For more information, see [Metrics Reference](https://www.alibabacloud.com/help/doc-detail/28619.htm).
        :param pulumi.Input[float] silence_time: Notification silence period in the alarm state, in seconds. Valid value range: [300, 86400]. Default to 86400
        :param pulumi.Input[float] start_time: Start time of the alarm effective period. Default to 0 and it indicates the time 00:00. Valid value range: [0, 24].
        :param pulumi.Input[str] statistics: Statistical method. It must be consistent with that defined for metrics. Valid values: ["Average", "Minimum", "Maximum"]. Default to "Average".
        :param pulumi.Input[str] threshold: Alarm threshold value, which must be a numeric value currently.
        :param pulumi.Input[float] triggered_count: Number of consecutive times it has been detected that the values exceed the threshold. Default to 3.

        > This content is derived from https://github.com/terraform-providers/terraform-provider-alicloud/blob/master/website/docs/r/cms_alarm.html.markdown.
        """
        if __name__ is not None:
            warnings.warn("explicit use of __name__ is deprecated", DeprecationWarning)
            resource_name = __name__
        if __opts__ is not None:
            warnings.warn("explicit use of __opts__ is deprecated, use 'opts' instead", DeprecationWarning)
            opts = __opts__
        if opts is None:
            opts = pulumi.ResourceOptions()
        if not isinstance(opts, pulumi.ResourceOptions):
            raise TypeError('Expected resource options to be a ResourceOptions instance')
        if opts.version is None:
            opts.version = utilities.get_version()
        if opts.id is None:
            if __props__ is not None:
                raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')
            __props__ = dict()

            if contact_groups is None:
                raise TypeError("Missing required property 'contact_groups'")
            __props__['contact_groups'] = contact_groups
            if dimensions is None:
                raise TypeError("Missing required property 'dimensions'")
            __props__['dimensions'] = dimensions
            __props__['effective_interval'] = effective_interval
            __props__['enabled'] = enabled
            __props__['end_time'] = end_time
            if metric is None:
                raise TypeError("Missing required property 'metric'")
            __props__['metric'] = metric
            __props__['name'] = name
            __props__['operator'] = operator
            __props__['period'] = period
            if project is None:
                raise TypeError("Missing required property 'project'")
            __props__['project'] = project
            __props__['silence_time'] = silence_time
            __props__['start_time'] = start_time
            __props__['statistics'] = statistics
            if threshold is None:
                raise TypeError("Missing required property 'threshold'")
            __props__['threshold'] = threshold
            __props__['triggered_count'] = triggered_count
            __props__['webhook'] = webhook
            __props__['status'] = None
        super(Alarm, __self__).__init__(
            'alicloud:cms/alarm:Alarm',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name, id, opts=None, contact_groups=None, dimensions=None, effective_interval=None, enabled=None, end_time=None, metric=None, name=None, operator=None, period=None, project=None, silence_time=None, start_time=None, statistics=None, status=None, threshold=None, triggered_count=None, webhook=None):
        """
        Get an existing Alarm resource's state with the given name, id, and optional extra
        properties used to qualify the lookup.
        
        :param str resource_name: The unique name of the resulting resource.
        :param str id: The unique provider ID of the resource to lookup.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[list] contact_groups: List contact groups of the alarm rule, which must have been created on the console.
        :param pulumi.Input[dict] dimensions: Map of the resources associated with the alarm rule, such as "instanceId", "device" and "port". Each key's value is a string and it uses comma to split multiple items. For more information, see [Metrics Reference](https://www.alibabacloud.com/help/doc-detail/28619.htm).
        :param pulumi.Input[bool] enabled: Whether to enable alarm rule. Default to true.
               * `webhook`- (Optional, Available in 1.46.0+) The webhook that should be called when the alarm is triggered. Currently, only http protocol is supported. Default is empty string.
        :param pulumi.Input[float] end_time: End time of the alarm effective period. Default value 24 and it indicates the time 24:00. Valid value range: [0, 24].
        :param pulumi.Input[str] metric: Name of the monitoring metrics corresponding to a project, such as "CPUUtilization" and "networkin_rate". For more information, see [Metrics Reference](https://www.alibabacloud.com/help/doc-detail/28619.htm).
        :param pulumi.Input[str] name: The alarm rule name.
        :param pulumi.Input[str] operator: Alarm comparison operator. Valid values: ["<=", "<", ">", ">=", "==", "!="]. Default to "==".
        :param pulumi.Input[float] period: Index query cycle, which must be consistent with that defined for metrics. Default to 300, in seconds.
        :param pulumi.Input[str] project: Monitor project name, such as "acs_ecs_dashboard" and "acs_rds_dashboard". For more information, see [Metrics Reference](https://www.alibabacloud.com/help/doc-detail/28619.htm).
        :param pulumi.Input[float] silence_time: Notification silence period in the alarm state, in seconds. Valid value range: [300, 86400]. Default to 86400
        :param pulumi.Input[float] start_time: Start time of the alarm effective period. Default to 0 and it indicates the time 00:00. Valid value range: [0, 24].
        :param pulumi.Input[str] statistics: Statistical method. It must be consistent with that defined for metrics. Valid values: ["Average", "Minimum", "Maximum"]. Default to "Average".
        :param pulumi.Input[str] status: The current alarm rule status.
               * `webhook`- The webhook that is called when the alarm is triggered.
        :param pulumi.Input[str] threshold: Alarm threshold value, which must be a numeric value currently.
        :param pulumi.Input[float] triggered_count: Number of consecutive times it has been detected that the values exceed the threshold. Default to 3.

        > This content is derived from https://github.com/terraform-providers/terraform-provider-alicloud/blob/master/website/docs/r/cms_alarm.html.markdown.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = dict()
        __props__["contact_groups"] = contact_groups
        __props__["dimensions"] = dimensions
        __props__["effective_interval"] = effective_interval
        __props__["enabled"] = enabled
        __props__["end_time"] = end_time
        __props__["metric"] = metric
        __props__["name"] = name
        __props__["operator"] = operator
        __props__["period"] = period
        __props__["project"] = project
        __props__["silence_time"] = silence_time
        __props__["start_time"] = start_time
        __props__["statistics"] = statistics
        __props__["status"] = status
        __props__["threshold"] = threshold
        __props__["triggered_count"] = triggered_count
        __props__["webhook"] = webhook
        return Alarm(resource_name, opts=opts, __props__=__props__)
    def translate_output_property(self, prop):
        return tables._CAMEL_TO_SNAKE_CASE_TABLE.get(prop) or prop

    def translate_input_property(self, prop):
        return tables._SNAKE_TO_CAMEL_CASE_TABLE.get(prop) or prop

