# 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, Mapping, Optional, Sequence, Union, overload
from .. import _utilities
from . import outputs
from ._inputs import *

__all__ = ['RuleArgs', 'Rule']

@pulumi.input_type
class RuleArgs:
    def __init__(__self__, *,
                 listener_id: pulumi.Input[str],
                 priority: pulumi.Input[int],
                 rule_actions: pulumi.Input[Sequence[pulumi.Input['RuleRuleActionArgs']]],
                 rule_conditions: pulumi.Input[Sequence[pulumi.Input['RuleRuleConditionArgs']]],
                 rule_name: pulumi.Input[str],
                 dry_run: Optional[pulumi.Input[bool]] = None):
        """
        The set of arguments for constructing a Rule resource.
        :param pulumi.Input[str] listener_id: The ID of the listener to which the forwarding rule belongs.
        :param pulumi.Input[int] priority: The priority of the rule. Valid values: 1 to 10000. A smaller value indicates a higher priority. **Note*:* The priority of each rule within the same listener must be unique.
        :param pulumi.Input[Sequence[pulumi.Input['RuleRuleActionArgs']]] rule_actions: The actions of the forwarding rules. See the following `Block rule_actions`.
        :param pulumi.Input[Sequence[pulumi.Input['RuleRuleConditionArgs']]] rule_conditions: The conditions of the forwarding rule. See the following `Block rule_conditions`.
        :param pulumi.Input[str] rule_name: The name of the forwarding rule. The name must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter.
        :param pulumi.Input[bool] dry_run: Specifies whether to precheck this request.
        """
        pulumi.set(__self__, "listener_id", listener_id)
        pulumi.set(__self__, "priority", priority)
        pulumi.set(__self__, "rule_actions", rule_actions)
        pulumi.set(__self__, "rule_conditions", rule_conditions)
        pulumi.set(__self__, "rule_name", rule_name)
        if dry_run is not None:
            pulumi.set(__self__, "dry_run", dry_run)

    @property
    @pulumi.getter(name="listenerId")
    def listener_id(self) -> pulumi.Input[str]:
        """
        The ID of the listener to which the forwarding rule belongs.
        """
        return pulumi.get(self, "listener_id")

    @listener_id.setter
    def listener_id(self, value: pulumi.Input[str]):
        pulumi.set(self, "listener_id", value)

    @property
    @pulumi.getter
    def priority(self) -> pulumi.Input[int]:
        """
        The priority of the rule. Valid values: 1 to 10000. A smaller value indicates a higher priority. **Note*:* The priority of each rule within the same listener must be unique.
        """
        return pulumi.get(self, "priority")

    @priority.setter
    def priority(self, value: pulumi.Input[int]):
        pulumi.set(self, "priority", value)

    @property
    @pulumi.getter(name="ruleActions")
    def rule_actions(self) -> pulumi.Input[Sequence[pulumi.Input['RuleRuleActionArgs']]]:
        """
        The actions of the forwarding rules. See the following `Block rule_actions`.
        """
        return pulumi.get(self, "rule_actions")

    @rule_actions.setter
    def rule_actions(self, value: pulumi.Input[Sequence[pulumi.Input['RuleRuleActionArgs']]]):
        pulumi.set(self, "rule_actions", value)

    @property
    @pulumi.getter(name="ruleConditions")
    def rule_conditions(self) -> pulumi.Input[Sequence[pulumi.Input['RuleRuleConditionArgs']]]:
        """
        The conditions of the forwarding rule. See the following `Block rule_conditions`.
        """
        return pulumi.get(self, "rule_conditions")

    @rule_conditions.setter
    def rule_conditions(self, value: pulumi.Input[Sequence[pulumi.Input['RuleRuleConditionArgs']]]):
        pulumi.set(self, "rule_conditions", value)

    @property
    @pulumi.getter(name="ruleName")
    def rule_name(self) -> pulumi.Input[str]:
        """
        The name of the forwarding rule. The name must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter.
        """
        return pulumi.get(self, "rule_name")

    @rule_name.setter
    def rule_name(self, value: pulumi.Input[str]):
        pulumi.set(self, "rule_name", value)

    @property
    @pulumi.getter(name="dryRun")
    def dry_run(self) -> Optional[pulumi.Input[bool]]:
        """
        Specifies whether to precheck this request.
        """
        return pulumi.get(self, "dry_run")

    @dry_run.setter
    def dry_run(self, value: Optional[pulumi.Input[bool]]):
        pulumi.set(self, "dry_run", value)


@pulumi.input_type
class _RuleState:
    def __init__(__self__, *,
                 dry_run: Optional[pulumi.Input[bool]] = None,
                 listener_id: Optional[pulumi.Input[str]] = None,
                 priority: Optional[pulumi.Input[int]] = None,
                 rule_actions: Optional[pulumi.Input[Sequence[pulumi.Input['RuleRuleActionArgs']]]] = None,
                 rule_conditions: Optional[pulumi.Input[Sequence[pulumi.Input['RuleRuleConditionArgs']]]] = None,
                 rule_name: Optional[pulumi.Input[str]] = None,
                 status: Optional[pulumi.Input[str]] = None):
        """
        Input properties used for looking up and filtering Rule resources.
        :param pulumi.Input[bool] dry_run: Specifies whether to precheck this request.
        :param pulumi.Input[str] listener_id: The ID of the listener to which the forwarding rule belongs.
        :param pulumi.Input[int] priority: The priority of the rule. Valid values: 1 to 10000. A smaller value indicates a higher priority. **Note*:* The priority of each rule within the same listener must be unique.
        :param pulumi.Input[Sequence[pulumi.Input['RuleRuleActionArgs']]] rule_actions: The actions of the forwarding rules. See the following `Block rule_actions`.
        :param pulumi.Input[Sequence[pulumi.Input['RuleRuleConditionArgs']]] rule_conditions: The conditions of the forwarding rule. See the following `Block rule_conditions`.
        :param pulumi.Input[str] rule_name: The name of the forwarding rule. The name must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter.
        :param pulumi.Input[str] status: The status of the resource.
        """
        if dry_run is not None:
            pulumi.set(__self__, "dry_run", dry_run)
        if listener_id is not None:
            pulumi.set(__self__, "listener_id", listener_id)
        if priority is not None:
            pulumi.set(__self__, "priority", priority)
        if rule_actions is not None:
            pulumi.set(__self__, "rule_actions", rule_actions)
        if rule_conditions is not None:
            pulumi.set(__self__, "rule_conditions", rule_conditions)
        if rule_name is not None:
            pulumi.set(__self__, "rule_name", rule_name)
        if status is not None:
            pulumi.set(__self__, "status", status)

    @property
    @pulumi.getter(name="dryRun")
    def dry_run(self) -> Optional[pulumi.Input[bool]]:
        """
        Specifies whether to precheck this request.
        """
        return pulumi.get(self, "dry_run")

    @dry_run.setter
    def dry_run(self, value: Optional[pulumi.Input[bool]]):
        pulumi.set(self, "dry_run", value)

    @property
    @pulumi.getter(name="listenerId")
    def listener_id(self) -> Optional[pulumi.Input[str]]:
        """
        The ID of the listener to which the forwarding rule belongs.
        """
        return pulumi.get(self, "listener_id")

    @listener_id.setter
    def listener_id(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "listener_id", value)

    @property
    @pulumi.getter
    def priority(self) -> Optional[pulumi.Input[int]]:
        """
        The priority of the rule. Valid values: 1 to 10000. A smaller value indicates a higher priority. **Note*:* The priority of each rule within the same listener must be unique.
        """
        return pulumi.get(self, "priority")

    @priority.setter
    def priority(self, value: Optional[pulumi.Input[int]]):
        pulumi.set(self, "priority", value)

    @property
    @pulumi.getter(name="ruleActions")
    def rule_actions(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['RuleRuleActionArgs']]]]:
        """
        The actions of the forwarding rules. See the following `Block rule_actions`.
        """
        return pulumi.get(self, "rule_actions")

    @rule_actions.setter
    def rule_actions(self, value: Optional[pulumi.Input[Sequence[pulumi.Input['RuleRuleActionArgs']]]]):
        pulumi.set(self, "rule_actions", value)

    @property
    @pulumi.getter(name="ruleConditions")
    def rule_conditions(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['RuleRuleConditionArgs']]]]:
        """
        The conditions of the forwarding rule. See the following `Block rule_conditions`.
        """
        return pulumi.get(self, "rule_conditions")

    @rule_conditions.setter
    def rule_conditions(self, value: Optional[pulumi.Input[Sequence[pulumi.Input['RuleRuleConditionArgs']]]]):
        pulumi.set(self, "rule_conditions", value)

    @property
    @pulumi.getter(name="ruleName")
    def rule_name(self) -> Optional[pulumi.Input[str]]:
        """
        The name of the forwarding rule. The name must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter.
        """
        return pulumi.get(self, "rule_name")

    @rule_name.setter
    def rule_name(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "rule_name", value)

    @property
    @pulumi.getter
    def status(self) -> Optional[pulumi.Input[str]]:
        """
        The status of the resource.
        """
        return pulumi.get(self, "status")

    @status.setter
    def status(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "status", value)


class Rule(pulumi.CustomResource):
    @overload
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 dry_run: Optional[pulumi.Input[bool]] = None,
                 listener_id: Optional[pulumi.Input[str]] = None,
                 priority: Optional[pulumi.Input[int]] = None,
                 rule_actions: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['RuleRuleActionArgs']]]]] = None,
                 rule_conditions: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['RuleRuleConditionArgs']]]]] = None,
                 rule_name: Optional[pulumi.Input[str]] = None,
                 __props__=None):
        """
        Provides a Application Load Balancer (ALB) Rule resource.

        For information about Application Load Balancer (ALB) Rule and how to use it, see [What is Rule](https://www.alibabacloud.com/help/doc-detail/214375.htm).

        > **NOTE:** Available in v1.133.0+.

        > **NOTE:** This version only supports forwarding rules in the request direction.

        ## Import

        Application Load Balancer (ALB) Rule can be imported using the id, e.g.

        ```sh
         $ pulumi import alicloud:alb/rule:Rule example <id>
        ```

        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[bool] dry_run: Specifies whether to precheck this request.
        :param pulumi.Input[str] listener_id: The ID of the listener to which the forwarding rule belongs.
        :param pulumi.Input[int] priority: The priority of the rule. Valid values: 1 to 10000. A smaller value indicates a higher priority. **Note*:* The priority of each rule within the same listener must be unique.
        :param pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['RuleRuleActionArgs']]]] rule_actions: The actions of the forwarding rules. See the following `Block rule_actions`.
        :param pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['RuleRuleConditionArgs']]]] rule_conditions: The conditions of the forwarding rule. See the following `Block rule_conditions`.
        :param pulumi.Input[str] rule_name: The name of the forwarding rule. The name must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter.
        """
        ...
    @overload
    def __init__(__self__,
                 resource_name: str,
                 args: RuleArgs,
                 opts: Optional[pulumi.ResourceOptions] = None):
        """
        Provides a Application Load Balancer (ALB) Rule resource.

        For information about Application Load Balancer (ALB) Rule and how to use it, see [What is Rule](https://www.alibabacloud.com/help/doc-detail/214375.htm).

        > **NOTE:** Available in v1.133.0+.

        > **NOTE:** This version only supports forwarding rules in the request direction.

        ## Import

        Application Load Balancer (ALB) Rule can be imported using the id, e.g.

        ```sh
         $ pulumi import alicloud:alb/rule:Rule example <id>
        ```

        :param str resource_name: The name of the resource.
        :param RuleArgs args: The arguments to use to populate this resource's properties.
        :param pulumi.ResourceOptions opts: Options for the resource.
        """
        ...
    def __init__(__self__, resource_name: str, *args, **kwargs):
        resource_args, opts = _utilities.get_resource_args_opts(RuleArgs, pulumi.ResourceOptions, *args, **kwargs)
        if resource_args is not None:
            __self__._internal_init(resource_name, opts, **resource_args.__dict__)
        else:
            __self__._internal_init(resource_name, *args, **kwargs)

    def _internal_init(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 dry_run: Optional[pulumi.Input[bool]] = None,
                 listener_id: Optional[pulumi.Input[str]] = None,
                 priority: Optional[pulumi.Input[int]] = None,
                 rule_actions: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['RuleRuleActionArgs']]]]] = None,
                 rule_conditions: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['RuleRuleConditionArgs']]]]] = None,
                 rule_name: Optional[pulumi.Input[str]] = None,
                 __props__=None):
        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__ = RuleArgs.__new__(RuleArgs)

            __props__.__dict__["dry_run"] = dry_run
            if listener_id is None and not opts.urn:
                raise TypeError("Missing required property 'listener_id'")
            __props__.__dict__["listener_id"] = listener_id
            if priority is None and not opts.urn:
                raise TypeError("Missing required property 'priority'")
            __props__.__dict__["priority"] = priority
            if rule_actions is None and not opts.urn:
                raise TypeError("Missing required property 'rule_actions'")
            __props__.__dict__["rule_actions"] = rule_actions
            if rule_conditions is None and not opts.urn:
                raise TypeError("Missing required property 'rule_conditions'")
            __props__.__dict__["rule_conditions"] = rule_conditions
            if rule_name is None and not opts.urn:
                raise TypeError("Missing required property 'rule_name'")
            __props__.__dict__["rule_name"] = rule_name
            __props__.__dict__["status"] = None
        super(Rule, __self__).__init__(
            'alicloud:alb/rule:Rule',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            dry_run: Optional[pulumi.Input[bool]] = None,
            listener_id: Optional[pulumi.Input[str]] = None,
            priority: Optional[pulumi.Input[int]] = None,
            rule_actions: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['RuleRuleActionArgs']]]]] = None,
            rule_conditions: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['RuleRuleConditionArgs']]]]] = None,
            rule_name: Optional[pulumi.Input[str]] = None,
            status: Optional[pulumi.Input[str]] = None) -> 'Rule':
        """
        Get an existing Rule 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[bool] dry_run: Specifies whether to precheck this request.
        :param pulumi.Input[str] listener_id: The ID of the listener to which the forwarding rule belongs.
        :param pulumi.Input[int] priority: The priority of the rule. Valid values: 1 to 10000. A smaller value indicates a higher priority. **Note*:* The priority of each rule within the same listener must be unique.
        :param pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['RuleRuleActionArgs']]]] rule_actions: The actions of the forwarding rules. See the following `Block rule_actions`.
        :param pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['RuleRuleConditionArgs']]]] rule_conditions: The conditions of the forwarding rule. See the following `Block rule_conditions`.
        :param pulumi.Input[str] rule_name: The name of the forwarding rule. The name must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter.
        :param pulumi.Input[str] status: The status of the resource.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = _RuleState.__new__(_RuleState)

        __props__.__dict__["dry_run"] = dry_run
        __props__.__dict__["listener_id"] = listener_id
        __props__.__dict__["priority"] = priority
        __props__.__dict__["rule_actions"] = rule_actions
        __props__.__dict__["rule_conditions"] = rule_conditions
        __props__.__dict__["rule_name"] = rule_name
        __props__.__dict__["status"] = status
        return Rule(resource_name, opts=opts, __props__=__props__)

    @property
    @pulumi.getter(name="dryRun")
    def dry_run(self) -> pulumi.Output[Optional[bool]]:
        """
        Specifies whether to precheck this request.
        """
        return pulumi.get(self, "dry_run")

    @property
    @pulumi.getter(name="listenerId")
    def listener_id(self) -> pulumi.Output[str]:
        """
        The ID of the listener to which the forwarding rule belongs.
        """
        return pulumi.get(self, "listener_id")

    @property
    @pulumi.getter
    def priority(self) -> pulumi.Output[int]:
        """
        The priority of the rule. Valid values: 1 to 10000. A smaller value indicates a higher priority. **Note*:* The priority of each rule within the same listener must be unique.
        """
        return pulumi.get(self, "priority")

    @property
    @pulumi.getter(name="ruleActions")
    def rule_actions(self) -> pulumi.Output[Sequence['outputs.RuleRuleAction']]:
        """
        The actions of the forwarding rules. See the following `Block rule_actions`.
        """
        return pulumi.get(self, "rule_actions")

    @property
    @pulumi.getter(name="ruleConditions")
    def rule_conditions(self) -> pulumi.Output[Sequence['outputs.RuleRuleCondition']]:
        """
        The conditions of the forwarding rule. See the following `Block rule_conditions`.
        """
        return pulumi.get(self, "rule_conditions")

    @property
    @pulumi.getter(name="ruleName")
    def rule_name(self) -> pulumi.Output[str]:
        """
        The name of the forwarding rule. The name must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter.
        """
        return pulumi.get(self, "rule_name")

    @property
    @pulumi.getter
    def status(self) -> pulumi.Output[str]:
        """
        The status of the resource.
        """
        return pulumi.get(self, "status")

