# 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 Rule(pulumi.CustomResource):
    cookie: pulumi.Output[str]
    """
    The cookie configured on the server. It is mandatory when `sticky_session` is "on" and `sticky_session_type` is "server". Otherwise, it will be ignored. Valid value：String in line with RFC 2965, with length being 1- 200. It only contains characters such as ASCII codes, English letters and digits instead of the comma, semicolon or spacing, and it cannot start with $.
    """
    cookie_timeout: pulumi.Output[float]
    """
    Cookie timeout. It is mandatory when `sticky_session` is "on" and `sticky_session_type` is "insert". Otherwise, it will be ignored. Valid value range: [1-86400] in seconds.
    """
    delete_protection_validation: pulumi.Output[bool]
    """
    Checking DeleteProtection of SLB instance before deleting. If true, this resource will not be deleted when its SLB instance enabled DeleteProtection. Default to false.
    """
    domain: pulumi.Output[str]
    """
    Domain name of the forwarding rule. It can contain letters a-z, numbers 0-9, hyphens (-), and periods (.),
    and wildcard characters. The following two domain name formats are supported:
    - Standard domain name: www.test.com
    - Wildcard domain name: *.test.com. wildcard (*) must be the first character in the format of (*.)
    """
    frontend_port: pulumi.Output[float]
    """
    The listener frontend port which is used to launch the new forwarding rule. Valid range: [1-65535].
    """
    health_check: pulumi.Output[str]
    """
    Whether to enable health check. Valid values are`on` and `off`. TCP and UDP listener's HealthCheck is always on, so it will be ignore when launching TCP or UDP listener. This parameter is required  and takes effect only when ListenerSync is set to off.
    """
    health_check_connect_port: pulumi.Output[float]
    """
    Port used for health check. Valid value range: [1-65535]. Default to "None" means the backend server port is used.
    """
    health_check_domain: pulumi.Output[str]
    """
    Domain name used for health check. When it used to launch TCP listener, `health_check_type` must be "http". Its length is limited to 1-80 and only characters such as letters, digits, ‘-‘ and ‘.’ are allowed. When it is not set or empty,  Server Load Balancer uses the private network IP address of each backend server as Domain used for health check.
    """
    health_check_http_code: pulumi.Output[str]
    """
    Regular health check HTTP status code. Multiple codes are segmented by “,”. It is required when `health_check` is on. Default to `http_2xx`.  Valid values are: `http_2xx`,  `http_3xx`, `http_4xx` and `http_5xx`.
    """
    health_check_interval: pulumi.Output[float]
    """
    Time interval of health checks. It is required when `health_check` is on. Valid value range: [1-50] in seconds. Default to 2.
    """
    health_check_timeout: pulumi.Output[float]
    """
    Maximum timeout of each health check response. It is required when `health_check` is on. Valid value range: [1-300] in seconds. Default to 5. Note: If `health_check_timeout` < `health_check_interval`, its will be replaced by `health_check_interval`.
    """
    health_check_uri: pulumi.Output[str]
    """
    URI used for health check. When it used to launch TCP listener, `health_check_type` must be "http". Its length is limited to 1-80 and it must start with /. Only characters such as letters, digits, ‘-’, ‘/’, ‘.’, ‘%’, ‘?’, #’ and ‘&’ are allowed.
    """
    healthy_threshold: pulumi.Output[float]
    """
    Threshold determining the result of the health check is success. It is required when `health_check` is on. Valid value range: [1-10] in seconds. Default to 3.
    """
    listener_sync: pulumi.Output[str]
    """
    Indicates whether a forwarding rule inherits the settings of a health check , session persistence, and scheduling algorithm from a listener. Default to on.
    """
    load_balancer_id: pulumi.Output[str]
    """
    The Load Balancer ID which is used to launch the new forwarding rule.
    """
    name: pulumi.Output[str]
    """
    Name of the forwarding rule. Our plugin provides a default name: "tf-slb-rule".
    """
    scheduler: pulumi.Output[str]
    """
    Scheduling algorithm, Valid values are `wrr`, `rr` and `wlc`.  Default to "wrr". This parameter is required  and takes effect only when ListenerSync is set to off.
    """
    server_group_id: pulumi.Output[str]
    """
    ID of a virtual server group that will be forwarded.
    """
    sticky_session: pulumi.Output[str]
    """
    Whether to enable session persistence, Valid values are `on` and `off`. Default to `off`. This parameter is required  and takes effect only when ListenerSync is set to off.                                                                                                                                                                                                                                                 
    """
    sticky_session_type: pulumi.Output[str]
    """
    Mode for handling the cookie. If `sticky_session` is "on", it is mandatory. Otherwise, it will be ignored. Valid values are `insert` and `server`. `insert` means it is inserted from Server Load Balancer; `server` means the Server Load Balancer learns from the backend server.
    """
    unhealthy_threshold: pulumi.Output[float]
    """
    Threshold determining the result of the health check is fail. It is required when `health_check` is on. Valid value range: [1-10] in seconds. Default to 3.
    """
    url: pulumi.Output[str]
    """
    Domain of the forwarding rule. It must be 2-80 characters in length. Only letters a-z, numbers 0-9,
    and characters '-' '/' '?' '%' '#' and '&' are allowed. URLs must be started with the character '/', but cannot be '/' alone.
    """
    def __init__(__self__, resource_name, opts=None, cookie=None, cookie_timeout=None, delete_protection_validation=None, domain=None, frontend_port=None, health_check=None, health_check_connect_port=None, health_check_domain=None, health_check_http_code=None, health_check_interval=None, health_check_timeout=None, health_check_uri=None, healthy_threshold=None, listener_sync=None, load_balancer_id=None, name=None, scheduler=None, server_group_id=None, sticky_session=None, sticky_session_type=None, unhealthy_threshold=None, url=None, __props__=None, __name__=None, __opts__=None):
        """
        A forwarding rule is configured in `HTTP`/`HTTPS` listener and it used to listen a list of backend servers which in one specified virtual backend server group.
        You can add forwarding rules to a listener to forward requests based on the domain names or the URL in the request.

        > **NOTE:** One virtual backend server group can be attached in multiple forwarding rules.

        > **NOTE:** At least one "Domain" or "Url" must be specified when creating a new rule.

        > **NOTE:** Having the same 'Domain' and 'Url' rule can not be created repeatedly in the one listener.

        > **NOTE:** Rule only be created in the `HTTP` or `HTTPS` listener.

        > **NOTE:** Only rule's virtual server group can be modified.

        > This content is derived from https://github.com/terraform-providers/terraform-provider-alicloud/blob/master/website/docs/r/slb_rule.html.markdown.

        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[str] cookie: The cookie configured on the server. It is mandatory when `sticky_session` is "on" and `sticky_session_type` is "server". Otherwise, it will be ignored. Valid value：String in line with RFC 2965, with length being 1- 200. It only contains characters such as ASCII codes, English letters and digits instead of the comma, semicolon or spacing, and it cannot start with $.
        :param pulumi.Input[float] cookie_timeout: Cookie timeout. It is mandatory when `sticky_session` is "on" and `sticky_session_type` is "insert". Otherwise, it will be ignored. Valid value range: [1-86400] in seconds.
        :param pulumi.Input[bool] delete_protection_validation: Checking DeleteProtection of SLB instance before deleting. If true, this resource will not be deleted when its SLB instance enabled DeleteProtection. Default to false.
        :param pulumi.Input[str] domain: Domain name of the forwarding rule. It can contain letters a-z, numbers 0-9, hyphens (-), and periods (.),
               and wildcard characters. The following two domain name formats are supported:
               - Standard domain name: www.test.com
               - Wildcard domain name: *.test.com. wildcard (*) must be the first character in the format of (*.)
        :param pulumi.Input[float] frontend_port: The listener frontend port which is used to launch the new forwarding rule. Valid range: [1-65535].
        :param pulumi.Input[str] health_check: Whether to enable health check. Valid values are`on` and `off`. TCP and UDP listener's HealthCheck is always on, so it will be ignore when launching TCP or UDP listener. This parameter is required  and takes effect only when ListenerSync is set to off.
        :param pulumi.Input[float] health_check_connect_port: Port used for health check. Valid value range: [1-65535]. Default to "None" means the backend server port is used.
        :param pulumi.Input[str] health_check_domain: Domain name used for health check. When it used to launch TCP listener, `health_check_type` must be "http". Its length is limited to 1-80 and only characters such as letters, digits, ‘-‘ and ‘.’ are allowed. When it is not set or empty,  Server Load Balancer uses the private network IP address of each backend server as Domain used for health check.
        :param pulumi.Input[str] health_check_http_code: Regular health check HTTP status code. Multiple codes are segmented by “,”. It is required when `health_check` is on. Default to `http_2xx`.  Valid values are: `http_2xx`,  `http_3xx`, `http_4xx` and `http_5xx`.
        :param pulumi.Input[float] health_check_interval: Time interval of health checks. It is required when `health_check` is on. Valid value range: [1-50] in seconds. Default to 2.
        :param pulumi.Input[float] health_check_timeout: Maximum timeout of each health check response. It is required when `health_check` is on. Valid value range: [1-300] in seconds. Default to 5. Note: If `health_check_timeout` < `health_check_interval`, its will be replaced by `health_check_interval`.
        :param pulumi.Input[str] health_check_uri: URI used for health check. When it used to launch TCP listener, `health_check_type` must be "http". Its length is limited to 1-80 and it must start with /. Only characters such as letters, digits, ‘-’, ‘/’, ‘.’, ‘%’, ‘?’, #’ and ‘&’ are allowed.
        :param pulumi.Input[float] healthy_threshold: Threshold determining the result of the health check is success. It is required when `health_check` is on. Valid value range: [1-10] in seconds. Default to 3.
        :param pulumi.Input[str] listener_sync: Indicates whether a forwarding rule inherits the settings of a health check , session persistence, and scheduling algorithm from a listener. Default to on.
        :param pulumi.Input[str] load_balancer_id: The Load Balancer ID which is used to launch the new forwarding rule.
        :param pulumi.Input[str] name: Name of the forwarding rule. Our plugin provides a default name: "tf-slb-rule".
        :param pulumi.Input[str] scheduler: Scheduling algorithm, Valid values are `wrr`, `rr` and `wlc`.  Default to "wrr". This parameter is required  and takes effect only when ListenerSync is set to off.
        :param pulumi.Input[str] server_group_id: ID of a virtual server group that will be forwarded.
        :param pulumi.Input[str] sticky_session: Whether to enable session persistence, Valid values are `on` and `off`. Default to `off`. This parameter is required  and takes effect only when ListenerSync is set to off.                                                                                                                                                                                                                                                 
        :param pulumi.Input[str] sticky_session_type: Mode for handling the cookie. If `sticky_session` is "on", it is mandatory. Otherwise, it will be ignored. Valid values are `insert` and `server`. `insert` means it is inserted from Server Load Balancer; `server` means the Server Load Balancer learns from the backend server.
        :param pulumi.Input[float] unhealthy_threshold: Threshold determining the result of the health check is fail. It is required when `health_check` is on. Valid value range: [1-10] in seconds. Default to 3.
        :param pulumi.Input[str] url: Domain of the forwarding rule. It must be 2-80 characters in length. Only letters a-z, numbers 0-9,
               and characters '-' '/' '?' '%' '#' and '&' are allowed. URLs must be started with the character '/', but cannot be '/' alone.
        """
        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__['cookie'] = cookie
            __props__['cookie_timeout'] = cookie_timeout
            __props__['delete_protection_validation'] = delete_protection_validation
            __props__['domain'] = domain
            if frontend_port is None:
                raise TypeError("Missing required property 'frontend_port'")
            __props__['frontend_port'] = frontend_port
            __props__['health_check'] = health_check
            __props__['health_check_connect_port'] = health_check_connect_port
            __props__['health_check_domain'] = health_check_domain
            __props__['health_check_http_code'] = health_check_http_code
            __props__['health_check_interval'] = health_check_interval
            __props__['health_check_timeout'] = health_check_timeout
            __props__['health_check_uri'] = health_check_uri
            __props__['healthy_threshold'] = healthy_threshold
            __props__['listener_sync'] = listener_sync
            if load_balancer_id is None:
                raise TypeError("Missing required property 'load_balancer_id'")
            __props__['load_balancer_id'] = load_balancer_id
            __props__['name'] = name
            __props__['scheduler'] = scheduler
            if server_group_id is None:
                raise TypeError("Missing required property 'server_group_id'")
            __props__['server_group_id'] = server_group_id
            __props__['sticky_session'] = sticky_session
            __props__['sticky_session_type'] = sticky_session_type
            __props__['unhealthy_threshold'] = unhealthy_threshold
            __props__['url'] = url
        super(Rule, __self__).__init__(
            'alicloud:slb/rule:Rule',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name, id, opts=None, cookie=None, cookie_timeout=None, delete_protection_validation=None, domain=None, frontend_port=None, health_check=None, health_check_connect_port=None, health_check_domain=None, health_check_http_code=None, health_check_interval=None, health_check_timeout=None, health_check_uri=None, healthy_threshold=None, listener_sync=None, load_balancer_id=None, name=None, scheduler=None, server_group_id=None, sticky_session=None, sticky_session_type=None, unhealthy_threshold=None, url=None):
        """
        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 str id: The unique provider ID of the resource to lookup.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[str] cookie: The cookie configured on the server. It is mandatory when `sticky_session` is "on" and `sticky_session_type` is "server". Otherwise, it will be ignored. Valid value：String in line with RFC 2965, with length being 1- 200. It only contains characters such as ASCII codes, English letters and digits instead of the comma, semicolon or spacing, and it cannot start with $.
        :param pulumi.Input[float] cookie_timeout: Cookie timeout. It is mandatory when `sticky_session` is "on" and `sticky_session_type` is "insert". Otherwise, it will be ignored. Valid value range: [1-86400] in seconds.
        :param pulumi.Input[bool] delete_protection_validation: Checking DeleteProtection of SLB instance before deleting. If true, this resource will not be deleted when its SLB instance enabled DeleteProtection. Default to false.
        :param pulumi.Input[str] domain: Domain name of the forwarding rule. It can contain letters a-z, numbers 0-9, hyphens (-), and periods (.),
               and wildcard characters. The following two domain name formats are supported:
               - Standard domain name: www.test.com
               - Wildcard domain name: *.test.com. wildcard (*) must be the first character in the format of (*.)
        :param pulumi.Input[float] frontend_port: The listener frontend port which is used to launch the new forwarding rule. Valid range: [1-65535].
        :param pulumi.Input[str] health_check: Whether to enable health check. Valid values are`on` and `off`. TCP and UDP listener's HealthCheck is always on, so it will be ignore when launching TCP or UDP listener. This parameter is required  and takes effect only when ListenerSync is set to off.
        :param pulumi.Input[float] health_check_connect_port: Port used for health check. Valid value range: [1-65535]. Default to "None" means the backend server port is used.
        :param pulumi.Input[str] health_check_domain: Domain name used for health check. When it used to launch TCP listener, `health_check_type` must be "http". Its length is limited to 1-80 and only characters such as letters, digits, ‘-‘ and ‘.’ are allowed. When it is not set or empty,  Server Load Balancer uses the private network IP address of each backend server as Domain used for health check.
        :param pulumi.Input[str] health_check_http_code: Regular health check HTTP status code. Multiple codes are segmented by “,”. It is required when `health_check` is on. Default to `http_2xx`.  Valid values are: `http_2xx`,  `http_3xx`, `http_4xx` and `http_5xx`.
        :param pulumi.Input[float] health_check_interval: Time interval of health checks. It is required when `health_check` is on. Valid value range: [1-50] in seconds. Default to 2.
        :param pulumi.Input[float] health_check_timeout: Maximum timeout of each health check response. It is required when `health_check` is on. Valid value range: [1-300] in seconds. Default to 5. Note: If `health_check_timeout` < `health_check_interval`, its will be replaced by `health_check_interval`.
        :param pulumi.Input[str] health_check_uri: URI used for health check. When it used to launch TCP listener, `health_check_type` must be "http". Its length is limited to 1-80 and it must start with /. Only characters such as letters, digits, ‘-’, ‘/’, ‘.’, ‘%’, ‘?’, #’ and ‘&’ are allowed.
        :param pulumi.Input[float] healthy_threshold: Threshold determining the result of the health check is success. It is required when `health_check` is on. Valid value range: [1-10] in seconds. Default to 3.
        :param pulumi.Input[str] listener_sync: Indicates whether a forwarding rule inherits the settings of a health check , session persistence, and scheduling algorithm from a listener. Default to on.
        :param pulumi.Input[str] load_balancer_id: The Load Balancer ID which is used to launch the new forwarding rule.
        :param pulumi.Input[str] name: Name of the forwarding rule. Our plugin provides a default name: "tf-slb-rule".
        :param pulumi.Input[str] scheduler: Scheduling algorithm, Valid values are `wrr`, `rr` and `wlc`.  Default to "wrr". This parameter is required  and takes effect only when ListenerSync is set to off.
        :param pulumi.Input[str] server_group_id: ID of a virtual server group that will be forwarded.
        :param pulumi.Input[str] sticky_session: Whether to enable session persistence, Valid values are `on` and `off`. Default to `off`. This parameter is required  and takes effect only when ListenerSync is set to off.                                                                                                                                                                                                                                                 
        :param pulumi.Input[str] sticky_session_type: Mode for handling the cookie. If `sticky_session` is "on", it is mandatory. Otherwise, it will be ignored. Valid values are `insert` and `server`. `insert` means it is inserted from Server Load Balancer; `server` means the Server Load Balancer learns from the backend server.
        :param pulumi.Input[float] unhealthy_threshold: Threshold determining the result of the health check is fail. It is required when `health_check` is on. Valid value range: [1-10] in seconds. Default to 3.
        :param pulumi.Input[str] url: Domain of the forwarding rule. It must be 2-80 characters in length. Only letters a-z, numbers 0-9,
               and characters '-' '/' '?' '%' '#' and '&' are allowed. URLs must be started with the character '/', but cannot be '/' alone.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = dict()

        __props__["cookie"] = cookie
        __props__["cookie_timeout"] = cookie_timeout
        __props__["delete_protection_validation"] = delete_protection_validation
        __props__["domain"] = domain
        __props__["frontend_port"] = frontend_port
        __props__["health_check"] = health_check
        __props__["health_check_connect_port"] = health_check_connect_port
        __props__["health_check_domain"] = health_check_domain
        __props__["health_check_http_code"] = health_check_http_code
        __props__["health_check_interval"] = health_check_interval
        __props__["health_check_timeout"] = health_check_timeout
        __props__["health_check_uri"] = health_check_uri
        __props__["healthy_threshold"] = healthy_threshold
        __props__["listener_sync"] = listener_sync
        __props__["load_balancer_id"] = load_balancer_id
        __props__["name"] = name
        __props__["scheduler"] = scheduler
        __props__["server_group_id"] = server_group_id
        __props__["sticky_session"] = sticky_session
        __props__["sticky_session_type"] = sticky_session_type
        __props__["unhealthy_threshold"] = unhealthy_threshold
        __props__["url"] = url
        return Rule(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

