# 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 warnings
import pulumi
import pulumi.runtime
from typing import Any, Dict, List, Mapping, Optional, Tuple, Union
from .. import _utilities, _tables
from . import outputs
from ._inputs import *

__all__ = ['MetricAlert']


class MetricAlert(pulumi.CustomResource):
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 actions: Optional[pulumi.Input[List[pulumi.Input[pulumi.InputType['MetricAlertActionArgs']]]]] = None,
                 application_insights_web_test_location_availability_criteria: Optional[pulumi.Input[pulumi.InputType['MetricAlertApplicationInsightsWebTestLocationAvailabilityCriteriaArgs']]] = None,
                 auto_mitigate: Optional[pulumi.Input[bool]] = None,
                 criterias: Optional[pulumi.Input[List[pulumi.Input[pulumi.InputType['MetricAlertCriteriaArgs']]]]] = None,
                 description: Optional[pulumi.Input[str]] = None,
                 dynamic_criteria: Optional[pulumi.Input[pulumi.InputType['MetricAlertDynamicCriteriaArgs']]] = None,
                 enabled: Optional[pulumi.Input[bool]] = None,
                 frequency: Optional[pulumi.Input[str]] = None,
                 name: Optional[pulumi.Input[str]] = None,
                 resource_group_name: Optional[pulumi.Input[str]] = None,
                 scopes: Optional[pulumi.Input[List[pulumi.Input[str]]]] = None,
                 severity: Optional[pulumi.Input[float]] = None,
                 tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
                 target_resource_location: Optional[pulumi.Input[str]] = None,
                 target_resource_type: Optional[pulumi.Input[str]] = None,
                 window_size: Optional[pulumi.Input[str]] = None,
                 __props__=None,
                 __name__=None,
                 __opts__=None):
        """
        Manages a Metric Alert within Azure Monitor.

        ## Example Usage

        ```python
        import pulumi
        import pulumi_azure as azure

        main_resource_group = azure.core.ResourceGroup("mainResourceGroup", location="West US")
        to_monitor = azure.storage.Account("toMonitor",
            resource_group_name=main_resource_group.name,
            location=main_resource_group.location,
            account_tier="Standard",
            account_replication_type="LRS")
        main_action_group = azure.monitoring.ActionGroup("mainActionGroup",
            resource_group_name=main_resource_group.name,
            short_name="exampleact",
            webhook_receivers=[azure.monitoring.ActionGroupWebhookReceiverArgs(
                name="callmyapi",
                service_uri="http://example.com/alert",
            )])
        example = azure.monitoring.MetricAlert("example",
            resource_group_name=main_resource_group.name,
            scopes=[to_monitor.id],
            description="Action will be triggered when Transactions count is greater than 50.",
            criterias=[azure.monitoring.MetricAlertCriteriaArgs(
                metric_namespace="Microsoft.Storage/storageAccounts",
                metric_name="Transactions",
                aggregation="Total",
                operator="GreaterThan",
                threshold=50,
                dimensions=[azure.monitoring.MetricAlertCriteriaDimensionArgs(
                    name="ApiName",
                    operator="Include",
                    values=["*"],
                )],
            )],
            actions=[azure.monitoring.MetricAlertActionArgs(
                action_group_id=main_action_group.id,
            )])
        ```

        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[List[pulumi.Input[pulumi.InputType['MetricAlertActionArgs']]]] actions: One or more `action` blocks as defined below.
        :param pulumi.Input[pulumi.InputType['MetricAlertApplicationInsightsWebTestLocationAvailabilityCriteriaArgs']] application_insights_web_test_location_availability_criteria: A `application_insights_web_test_location_availability_criteria` block as defined below.
        :param pulumi.Input[bool] auto_mitigate: Should the alerts in this Metric Alert be auto resolved? Defaults to `true`.
        :param pulumi.Input[List[pulumi.Input[pulumi.InputType['MetricAlertCriteriaArgs']]]] criterias: One or more (static) `criteria` blocks as defined below.
        :param pulumi.Input[str] description: The description of this Metric Alert.
        :param pulumi.Input[pulumi.InputType['MetricAlertDynamicCriteriaArgs']] dynamic_criteria: A `dynamic_criteria` block as defined below.
        :param pulumi.Input[bool] enabled: Should this Metric Alert be enabled? Defaults to `true`.
        :param pulumi.Input[str] frequency: The evaluation frequency of this Metric Alert, represented in ISO 8601 duration format. Possible values are `PT1M`, `PT5M`, `PT15M`, `PT30M` and `PT1H`. Defaults to `PT1M`.
        :param pulumi.Input[str] name: The name of the Metric Alert. Changing this forces a new resource to be created.
        :param pulumi.Input[str] resource_group_name: The name of the resource group in which to create the Metric Alert instance.
        :param pulumi.Input[List[pulumi.Input[str]]] scopes: A set of strings of resource IDs at which the metric criteria should be applied.
        :param pulumi.Input[float] severity: The severity of this Metric Alert. Possible values are `0`, `1`, `2`, `3` and `4`. Defaults to `3`.
        :param pulumi.Input[Mapping[str, pulumi.Input[str]]] tags: A mapping of tags to assign to the resource.
        :param pulumi.Input[str] target_resource_location: The location of the target resource.
        :param pulumi.Input[str] target_resource_type: The resource type (e.g. `Microsoft.Compute/virtualMachines`) of the target resource.
        :param pulumi.Input[str] window_size: The period of time that is used to monitor alert activity, represented in ISO 8601 duration format. This value must be greater than `frequency`. Possible values are `PT1M`, `PT5M`, `PT15M`, `PT30M`, `PT1H`, `PT6H`, `PT12H` and `P1D`. Defaults to `PT5M`.
        """
        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()

            __props__['actions'] = actions
            __props__['application_insights_web_test_location_availability_criteria'] = application_insights_web_test_location_availability_criteria
            __props__['auto_mitigate'] = auto_mitigate
            __props__['criterias'] = criterias
            __props__['description'] = description
            __props__['dynamic_criteria'] = dynamic_criteria
            __props__['enabled'] = enabled
            __props__['frequency'] = frequency
            __props__['name'] = name
            if resource_group_name is None:
                raise TypeError("Missing required property 'resource_group_name'")
            __props__['resource_group_name'] = resource_group_name
            if scopes is None:
                raise TypeError("Missing required property 'scopes'")
            __props__['scopes'] = scopes
            __props__['severity'] = severity
            __props__['tags'] = tags
            __props__['target_resource_location'] = target_resource_location
            __props__['target_resource_type'] = target_resource_type
            __props__['window_size'] = window_size
        super(MetricAlert, __self__).__init__(
            'azure:monitoring/metricAlert:MetricAlert',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            actions: Optional[pulumi.Input[List[pulumi.Input[pulumi.InputType['MetricAlertActionArgs']]]]] = None,
            application_insights_web_test_location_availability_criteria: Optional[pulumi.Input[pulumi.InputType['MetricAlertApplicationInsightsWebTestLocationAvailabilityCriteriaArgs']]] = None,
            auto_mitigate: Optional[pulumi.Input[bool]] = None,
            criterias: Optional[pulumi.Input[List[pulumi.Input[pulumi.InputType['MetricAlertCriteriaArgs']]]]] = None,
            description: Optional[pulumi.Input[str]] = None,
            dynamic_criteria: Optional[pulumi.Input[pulumi.InputType['MetricAlertDynamicCriteriaArgs']]] = None,
            enabled: Optional[pulumi.Input[bool]] = None,
            frequency: Optional[pulumi.Input[str]] = None,
            name: Optional[pulumi.Input[str]] = None,
            resource_group_name: Optional[pulumi.Input[str]] = None,
            scopes: Optional[pulumi.Input[List[pulumi.Input[str]]]] = None,
            severity: Optional[pulumi.Input[float]] = None,
            tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
            target_resource_location: Optional[pulumi.Input[str]] = None,
            target_resource_type: Optional[pulumi.Input[str]] = None,
            window_size: Optional[pulumi.Input[str]] = None) -> 'MetricAlert':
        """
        Get an existing MetricAlert 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 pulumi.Input[str] id: The unique provider ID of the resource to lookup.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[List[pulumi.Input[pulumi.InputType['MetricAlertActionArgs']]]] actions: One or more `action` blocks as defined below.
        :param pulumi.Input[pulumi.InputType['MetricAlertApplicationInsightsWebTestLocationAvailabilityCriteriaArgs']] application_insights_web_test_location_availability_criteria: A `application_insights_web_test_location_availability_criteria` block as defined below.
        :param pulumi.Input[bool] auto_mitigate: Should the alerts in this Metric Alert be auto resolved? Defaults to `true`.
        :param pulumi.Input[List[pulumi.Input[pulumi.InputType['MetricAlertCriteriaArgs']]]] criterias: One or more (static) `criteria` blocks as defined below.
        :param pulumi.Input[str] description: The description of this Metric Alert.
        :param pulumi.Input[pulumi.InputType['MetricAlertDynamicCriteriaArgs']] dynamic_criteria: A `dynamic_criteria` block as defined below.
        :param pulumi.Input[bool] enabled: Should this Metric Alert be enabled? Defaults to `true`.
        :param pulumi.Input[str] frequency: The evaluation frequency of this Metric Alert, represented in ISO 8601 duration format. Possible values are `PT1M`, `PT5M`, `PT15M`, `PT30M` and `PT1H`. Defaults to `PT1M`.
        :param pulumi.Input[str] name: The name of the Metric Alert. Changing this forces a new resource to be created.
        :param pulumi.Input[str] resource_group_name: The name of the resource group in which to create the Metric Alert instance.
        :param pulumi.Input[List[pulumi.Input[str]]] scopes: A set of strings of resource IDs at which the metric criteria should be applied.
        :param pulumi.Input[float] severity: The severity of this Metric Alert. Possible values are `0`, `1`, `2`, `3` and `4`. Defaults to `3`.
        :param pulumi.Input[Mapping[str, pulumi.Input[str]]] tags: A mapping of tags to assign to the resource.
        :param pulumi.Input[str] target_resource_location: The location of the target resource.
        :param pulumi.Input[str] target_resource_type: The resource type (e.g. `Microsoft.Compute/virtualMachines`) of the target resource.
        :param pulumi.Input[str] window_size: The period of time that is used to monitor alert activity, represented in ISO 8601 duration format. This value must be greater than `frequency`. Possible values are `PT1M`, `PT5M`, `PT15M`, `PT30M`, `PT1H`, `PT6H`, `PT12H` and `P1D`. Defaults to `PT5M`.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = dict()

        __props__["actions"] = actions
        __props__["application_insights_web_test_location_availability_criteria"] = application_insights_web_test_location_availability_criteria
        __props__["auto_mitigate"] = auto_mitigate
        __props__["criterias"] = criterias
        __props__["description"] = description
        __props__["dynamic_criteria"] = dynamic_criteria
        __props__["enabled"] = enabled
        __props__["frequency"] = frequency
        __props__["name"] = name
        __props__["resource_group_name"] = resource_group_name
        __props__["scopes"] = scopes
        __props__["severity"] = severity
        __props__["tags"] = tags
        __props__["target_resource_location"] = target_resource_location
        __props__["target_resource_type"] = target_resource_type
        __props__["window_size"] = window_size
        return MetricAlert(resource_name, opts=opts, __props__=__props__)

    @property
    @pulumi.getter
    def actions(self) -> pulumi.Output[Optional[List['outputs.MetricAlertAction']]]:
        """
        One or more `action` blocks as defined below.
        """
        return pulumi.get(self, "actions")

    @property
    @pulumi.getter(name="applicationInsightsWebTestLocationAvailabilityCriteria")
    def application_insights_web_test_location_availability_criteria(self) -> pulumi.Output[Optional['outputs.MetricAlertApplicationInsightsWebTestLocationAvailabilityCriteria']]:
        """
        A `application_insights_web_test_location_availability_criteria` block as defined below.
        """
        return pulumi.get(self, "application_insights_web_test_location_availability_criteria")

    @property
    @pulumi.getter(name="autoMitigate")
    def auto_mitigate(self) -> pulumi.Output[Optional[bool]]:
        """
        Should the alerts in this Metric Alert be auto resolved? Defaults to `true`.
        """
        return pulumi.get(self, "auto_mitigate")

    @property
    @pulumi.getter
    def criterias(self) -> pulumi.Output[Optional[List['outputs.MetricAlertCriteria']]]:
        """
        One or more (static) `criteria` blocks as defined below.
        """
        return pulumi.get(self, "criterias")

    @property
    @pulumi.getter
    def description(self) -> pulumi.Output[Optional[str]]:
        """
        The description of this Metric Alert.
        """
        return pulumi.get(self, "description")

    @property
    @pulumi.getter(name="dynamicCriteria")
    def dynamic_criteria(self) -> pulumi.Output[Optional['outputs.MetricAlertDynamicCriteria']]:
        """
        A `dynamic_criteria` block as defined below.
        """
        return pulumi.get(self, "dynamic_criteria")

    @property
    @pulumi.getter
    def enabled(self) -> pulumi.Output[Optional[bool]]:
        """
        Should this Metric Alert be enabled? Defaults to `true`.
        """
        return pulumi.get(self, "enabled")

    @property
    @pulumi.getter
    def frequency(self) -> pulumi.Output[Optional[str]]:
        """
        The evaluation frequency of this Metric Alert, represented in ISO 8601 duration format. Possible values are `PT1M`, `PT5M`, `PT15M`, `PT30M` and `PT1H`. Defaults to `PT1M`.
        """
        return pulumi.get(self, "frequency")

    @property
    @pulumi.getter
    def name(self) -> pulumi.Output[str]:
        """
        The name of the Metric Alert. Changing this forces a new resource to be created.
        """
        return pulumi.get(self, "name")

    @property
    @pulumi.getter(name="resourceGroupName")
    def resource_group_name(self) -> pulumi.Output[str]:
        """
        The name of the resource group in which to create the Metric Alert instance.
        """
        return pulumi.get(self, "resource_group_name")

    @property
    @pulumi.getter
    def scopes(self) -> pulumi.Output[List[str]]:
        """
        A set of strings of resource IDs at which the metric criteria should be applied.
        """
        return pulumi.get(self, "scopes")

    @property
    @pulumi.getter
    def severity(self) -> pulumi.Output[Optional[float]]:
        """
        The severity of this Metric Alert. Possible values are `0`, `1`, `2`, `3` and `4`. Defaults to `3`.
        """
        return pulumi.get(self, "severity")

    @property
    @pulumi.getter
    def tags(self) -> pulumi.Output[Optional[Mapping[str, str]]]:
        """
        A mapping of tags to assign to the resource.
        """
        return pulumi.get(self, "tags")

    @property
    @pulumi.getter(name="targetResourceLocation")
    def target_resource_location(self) -> pulumi.Output[str]:
        """
        The location of the target resource.
        """
        return pulumi.get(self, "target_resource_location")

    @property
    @pulumi.getter(name="targetResourceType")
    def target_resource_type(self) -> pulumi.Output[str]:
        """
        The resource type (e.g. `Microsoft.Compute/virtualMachines`) of the target resource.
        """
        return pulumi.get(self, "target_resource_type")

    @property
    @pulumi.getter(name="windowSize")
    def window_size(self) -> pulumi.Output[Optional[str]]:
        """
        The period of time that is used to monitor alert activity, represented in ISO 8601 duration format. This value must be greater than `frequency`. Possible values are `PT1M`, `PT5M`, `PT15M`, `PT30M`, `PT1H`, `PT6H`, `PT12H` and `P1D`. Defaults to `PT5M`.
        """
        return pulumi.get(self, "window_size")

    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

