<reponame>stmcallister/pulumi-pagerduty
# 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 RulesetRule(pulumi.CustomResource):
    actions: pulumi.Output[dict]
    """
    Actions to apply to an event if the conditions match.

      * `annotates` (`list`) - Note added to the event.
        * `value` (`str`) - Boolean value that indicates if the alert should be suppressed before the indicated threshold values are met.

      * `eventActions` (`list`)
        * `value` (`str`) - Boolean value that indicates if the alert should be suppressed before the indicated threshold values are met.

      * `extractions` (`list`) - Allows you to copy important data from one event field to another. Extraction rules must use valid [RE2 regular expression syntax](https://github.com/google/re2/wiki/Syntax). Extraction objects consist of the following fields:
        * `regex` (`str`) - The conditions that need to be met for the extraction to happen.
          * *NOTE: A rule can have multiple `extraction` objects attributed to it.*
        * `source` (`str`) - Field where the data is being copied from.
        * `target` (`str`) - Field where the data is being copied to.

      * `priorities` (`list`) - The ID of the priority applied to the event.
        * `value` (`str`) - Boolean value that indicates if the alert should be suppressed before the indicated threshold values are met.

      * `routes` (`list`) - The ID of the service where the event will be routed.
        * `value` (`str`) - Boolean value that indicates if the alert should be suppressed before the indicated threshold values are met.

      * `severities` (`list`) - The [severity level](https://support.pagerduty.com/docs/rulesets#section-set-severity-with-event-rules) of the event. Can be either `info`,`error`,`warning`, or `critical`.
        * `value` (`str`) - Boolean value that indicates if the alert should be suppressed before the indicated threshold values are met.

      * `suppresses` (`list`) - Controls whether an alert is [suppressed](https://support.pagerduty.com/docs/rulesets#section-suppress-but-create-triggering-thresholds-with-event-rules) (does not create an incident).
        * `thresholdTimeAmount` (`float`) - The number value of the `threshold_time_unit` before an incident is created.
        * `thresholdTimeUnit` (`str`) - The `minutes`,`hours`, or `days` that the `threshold_time_amount` should be measured. 
        * `thresholdValue` (`float`) - The number of alerts that should be suppressed.
        * `value` (`bool`) - Boolean value that indicates if the alert should be suppressed before the indicated threshold values are met.
    """
    conditions: pulumi.Output[dict]
    """
    Conditions evaluated to check if an event matches this event rule. Is always empty for the catch all rule, though.

      * `operator` (`str`) - Operator to combine sub-conditions. Can be `and` or `or`.
      * `subconditions` (`list`) - List of sub-conditions that define the the condition. 
        * `operator` (`str`) - Type of operator to apply to the sub-condition. Can be `exists`,`nexists`,`equals`,`nequals`,`contains`,`ncontains`,`matches`, or `nmatches`.
        * `parameters` (`list`) - Parameter for the sub-condition. It requires both a `path` and `value` to be set.
          * `path` (`str`)
          * `value` (`str`) - Boolean value that indicates if the alert should be suppressed before the indicated threshold values are met.
    """
    disabled: pulumi.Output[bool]
    """
    Indicates whether the rule is disabled and would therefore not be evaluated.
    """
    position: pulumi.Output[float]
    """
    Position/index of the rule within the ruleset.
    """
    ruleset: pulumi.Output[str]
    """
    The ID of the ruleset that the rule belongs to.
    """
    time_frame: pulumi.Output[dict]
    """
    Settings for [scheduling the rule](https://support.pagerduty.com/docs/rulesets#section-scheduled-event-rules). 

      * `activeBetweens` (`list`) - Values for executing the rule during a specific time period.
        * `end_time` (`float`) - Ending of the scheduled time when the rule should execute.  Unix timestamp in milliseconds.
        * `start_time` (`float`) - Time when the schedule will start. Unix timestamp in milliseconds. For example, if you have a rule with a `start_time` of `0` and a `duration` of `60,000` then that rule would be active from `00:00` to `00:01`. If the `start_time` was `3,600,000` the it would be active starting at `01:00`.

      * `scheduledWeeklies` (`list`) - Values for executing the rule on a recurring schedule.
        * `duration` (`float`) - Length of time the schedule will be active.  Unix timestamp in milliseconds.
        * `start_time` (`float`) - Time when the schedule will start. Unix timestamp in milliseconds. For example, if you have a rule with a `start_time` of `0` and a `duration` of `60,000` then that rule would be active from `00:00` to `00:01`. If the `start_time` was `3,600,000` the it would be active starting at `01:00`.
        * `timezone` (`str`) - Timezone for the given schedule.
        * `weekdays` (`list`) - An integer array representing which days during the week the rule executes. For example `weekdays = [1,3,7]` would execute on Monday, Wednesday and Sunday.
    """
    def __init__(__self__, resource_name, opts=None, actions=None, conditions=None, disabled=None, position=None, ruleset=None, time_frame=None, __props__=None, __name__=None, __opts__=None):
        """
        Create a RulesetRule resource with the given unique name, props, and options.
        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[dict] actions: Actions to apply to an event if the conditions match.
        :param pulumi.Input[dict] conditions: Conditions evaluated to check if an event matches this event rule. Is always empty for the catch all rule, though.
        :param pulumi.Input[bool] disabled: Indicates whether the rule is disabled and would therefore not be evaluated.
        :param pulumi.Input[float] position: Position/index of the rule within the ruleset.
        :param pulumi.Input[str] ruleset: The ID of the ruleset that the rule belongs to.
        :param pulumi.Input[dict] time_frame: Settings for [scheduling the rule](https://support.pagerduty.com/docs/rulesets#section-scheduled-event-rules). 

        The **actions** object supports the following:

          * `annotates` (`pulumi.Input[list]`) - Note added to the event.
            * `value` (`pulumi.Input[str]`) - Boolean value that indicates if the alert should be suppressed before the indicated threshold values are met.

          * `eventActions` (`pulumi.Input[list]`)
            * `value` (`pulumi.Input[str]`) - Boolean value that indicates if the alert should be suppressed before the indicated threshold values are met.

          * `extractions` (`pulumi.Input[list]`) - Allows you to copy important data from one event field to another. Extraction rules must use valid [RE2 regular expression syntax](https://github.com/google/re2/wiki/Syntax). Extraction objects consist of the following fields:
            * `regex` (`pulumi.Input[str]`) - The conditions that need to be met for the extraction to happen.
              * *NOTE: A rule can have multiple `extraction` objects attributed to it.*
            * `source` (`pulumi.Input[str]`) - Field where the data is being copied from.
            * `target` (`pulumi.Input[str]`) - Field where the data is being copied to.

          * `priorities` (`pulumi.Input[list]`) - The ID of the priority applied to the event.
            * `value` (`pulumi.Input[str]`) - Boolean value that indicates if the alert should be suppressed before the indicated threshold values are met.

          * `routes` (`pulumi.Input[list]`) - The ID of the service where the event will be routed.
            * `value` (`pulumi.Input[str]`) - Boolean value that indicates if the alert should be suppressed before the indicated threshold values are met.

          * `severities` (`pulumi.Input[list]`) - The [severity level](https://support.pagerduty.com/docs/rulesets#section-set-severity-with-event-rules) of the event. Can be either `info`,`error`,`warning`, or `critical`.
            * `value` (`pulumi.Input[str]`) - Boolean value that indicates if the alert should be suppressed before the indicated threshold values are met.

          * `suppresses` (`pulumi.Input[list]`) - Controls whether an alert is [suppressed](https://support.pagerduty.com/docs/rulesets#section-suppress-but-create-triggering-thresholds-with-event-rules) (does not create an incident).
            * `thresholdTimeAmount` (`pulumi.Input[float]`) - The number value of the `threshold_time_unit` before an incident is created.
            * `thresholdTimeUnit` (`pulumi.Input[str]`) - The `minutes`,`hours`, or `days` that the `threshold_time_amount` should be measured. 
            * `thresholdValue` (`pulumi.Input[float]`) - The number of alerts that should be suppressed.
            * `value` (`pulumi.Input[bool]`) - Boolean value that indicates if the alert should be suppressed before the indicated threshold values are met.

        The **conditions** object supports the following:

          * `operator` (`pulumi.Input[str]`) - Operator to combine sub-conditions. Can be `and` or `or`.
          * `subconditions` (`pulumi.Input[list]`) - List of sub-conditions that define the the condition. 
            * `operator` (`pulumi.Input[str]`) - Type of operator to apply to the sub-condition. Can be `exists`,`nexists`,`equals`,`nequals`,`contains`,`ncontains`,`matches`, or `nmatches`.
            * `parameters` (`pulumi.Input[list]`) - Parameter for the sub-condition. It requires both a `path` and `value` to be set.
              * `path` (`pulumi.Input[str]`)
              * `value` (`pulumi.Input[str]`) - Boolean value that indicates if the alert should be suppressed before the indicated threshold values are met.

        The **time_frame** object supports the following:

          * `activeBetweens` (`pulumi.Input[list]`) - Values for executing the rule during a specific time period.
            * `end_time` (`pulumi.Input[float]`) - Ending of the scheduled time when the rule should execute.  Unix timestamp in milliseconds.
            * `start_time` (`pulumi.Input[float]`) - Time when the schedule will start. Unix timestamp in milliseconds. For example, if you have a rule with a `start_time` of `0` and a `duration` of `60,000` then that rule would be active from `00:00` to `00:01`. If the `start_time` was `3,600,000` the it would be active starting at `01:00`.

          * `scheduledWeeklies` (`pulumi.Input[list]`) - Values for executing the rule on a recurring schedule.
            * `duration` (`pulumi.Input[float]`) - Length of time the schedule will be active.  Unix timestamp in milliseconds.
            * `start_time` (`pulumi.Input[float]`) - Time when the schedule will start. Unix timestamp in milliseconds. For example, if you have a rule with a `start_time` of `0` and a `duration` of `60,000` then that rule would be active from `00:00` to `00:01`. If the `start_time` was `3,600,000` the it would be active starting at `01:00`.
            * `timezone` (`pulumi.Input[str]`) - Timezone for the given schedule.
            * `weekdays` (`pulumi.Input[list]`) - An integer array representing which days during the week the rule executes. For example `weekdays = [1,3,7]` would execute on Monday, Wednesday and Sunday.
        """
        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__['conditions'] = conditions
            __props__['disabled'] = disabled
            __props__['position'] = position
            if ruleset is None:
                raise TypeError("Missing required property 'ruleset'")
            __props__['ruleset'] = ruleset
            __props__['time_frame'] = time_frame
        super(RulesetRule, __self__).__init__(
            'pagerduty:index/rulesetRule:RulesetRule',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name, id, opts=None, actions=None, conditions=None, disabled=None, position=None, ruleset=None, time_frame=None):
        """
        Get an existing RulesetRule 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[dict] actions: Actions to apply to an event if the conditions match.
        :param pulumi.Input[dict] conditions: Conditions evaluated to check if an event matches this event rule. Is always empty for the catch all rule, though.
        :param pulumi.Input[bool] disabled: Indicates whether the rule is disabled and would therefore not be evaluated.
        :param pulumi.Input[float] position: Position/index of the rule within the ruleset.
        :param pulumi.Input[str] ruleset: The ID of the ruleset that the rule belongs to.
        :param pulumi.Input[dict] time_frame: Settings for [scheduling the rule](https://support.pagerduty.com/docs/rulesets#section-scheduled-event-rules). 

        The **actions** object supports the following:

          * `annotates` (`pulumi.Input[list]`) - Note added to the event.
            * `value` (`pulumi.Input[str]`) - Boolean value that indicates if the alert should be suppressed before the indicated threshold values are met.

          * `eventActions` (`pulumi.Input[list]`)
            * `value` (`pulumi.Input[str]`) - Boolean value that indicates if the alert should be suppressed before the indicated threshold values are met.

          * `extractions` (`pulumi.Input[list]`) - Allows you to copy important data from one event field to another. Extraction rules must use valid [RE2 regular expression syntax](https://github.com/google/re2/wiki/Syntax). Extraction objects consist of the following fields:
            * `regex` (`pulumi.Input[str]`) - The conditions that need to be met for the extraction to happen.
              * *NOTE: A rule can have multiple `extraction` objects attributed to it.*
            * `source` (`pulumi.Input[str]`) - Field where the data is being copied from.
            * `target` (`pulumi.Input[str]`) - Field where the data is being copied to.

          * `priorities` (`pulumi.Input[list]`) - The ID of the priority applied to the event.
            * `value` (`pulumi.Input[str]`) - Boolean value that indicates if the alert should be suppressed before the indicated threshold values are met.

          * `routes` (`pulumi.Input[list]`) - The ID of the service where the event will be routed.
            * `value` (`pulumi.Input[str]`) - Boolean value that indicates if the alert should be suppressed before the indicated threshold values are met.

          * `severities` (`pulumi.Input[list]`) - The [severity level](https://support.pagerduty.com/docs/rulesets#section-set-severity-with-event-rules) of the event. Can be either `info`,`error`,`warning`, or `critical`.
            * `value` (`pulumi.Input[str]`) - Boolean value that indicates if the alert should be suppressed before the indicated threshold values are met.

          * `suppresses` (`pulumi.Input[list]`) - Controls whether an alert is [suppressed](https://support.pagerduty.com/docs/rulesets#section-suppress-but-create-triggering-thresholds-with-event-rules) (does not create an incident).
            * `thresholdTimeAmount` (`pulumi.Input[float]`) - The number value of the `threshold_time_unit` before an incident is created.
            * `thresholdTimeUnit` (`pulumi.Input[str]`) - The `minutes`,`hours`, or `days` that the `threshold_time_amount` should be measured. 
            * `thresholdValue` (`pulumi.Input[float]`) - The number of alerts that should be suppressed.
            * `value` (`pulumi.Input[bool]`) - Boolean value that indicates if the alert should be suppressed before the indicated threshold values are met.

        The **conditions** object supports the following:

          * `operator` (`pulumi.Input[str]`) - Operator to combine sub-conditions. Can be `and` or `or`.
          * `subconditions` (`pulumi.Input[list]`) - List of sub-conditions that define the the condition. 
            * `operator` (`pulumi.Input[str]`) - Type of operator to apply to the sub-condition. Can be `exists`,`nexists`,`equals`,`nequals`,`contains`,`ncontains`,`matches`, or `nmatches`.
            * `parameters` (`pulumi.Input[list]`) - Parameter for the sub-condition. It requires both a `path` and `value` to be set.
              * `path` (`pulumi.Input[str]`)
              * `value` (`pulumi.Input[str]`) - Boolean value that indicates if the alert should be suppressed before the indicated threshold values are met.

        The **time_frame** object supports the following:

          * `activeBetweens` (`pulumi.Input[list]`) - Values for executing the rule during a specific time period.
            * `end_time` (`pulumi.Input[float]`) - Ending of the scheduled time when the rule should execute.  Unix timestamp in milliseconds.
            * `start_time` (`pulumi.Input[float]`) - Time when the schedule will start. Unix timestamp in milliseconds. For example, if you have a rule with a `start_time` of `0` and a `duration` of `60,000` then that rule would be active from `00:00` to `00:01`. If the `start_time` was `3,600,000` the it would be active starting at `01:00`.

          * `scheduledWeeklies` (`pulumi.Input[list]`) - Values for executing the rule on a recurring schedule.
            * `duration` (`pulumi.Input[float]`) - Length of time the schedule will be active.  Unix timestamp in milliseconds.
            * `start_time` (`pulumi.Input[float]`) - Time when the schedule will start. Unix timestamp in milliseconds. For example, if you have a rule with a `start_time` of `0` and a `duration` of `60,000` then that rule would be active from `00:00` to `00:01`. If the `start_time` was `3,600,000` the it would be active starting at `01:00`.
            * `timezone` (`pulumi.Input[str]`) - Timezone for the given schedule.
            * `weekdays` (`pulumi.Input[list]`) - An integer array representing which days during the week the rule executes. For example `weekdays = [1,3,7]` would execute on Monday, Wednesday and Sunday.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = dict()

        __props__["actions"] = actions
        __props__["conditions"] = conditions
        __props__["disabled"] = disabled
        __props__["position"] = position
        __props__["ruleset"] = ruleset
        __props__["time_frame"] = time_frame
        return RulesetRule(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

