# 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
from . import _utilities, _tables
from . import outputs
from ._inputs import *

__all__ = ['NodeBalancerConfig']


class NodeBalancerConfig(pulumi.CustomResource):
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 algorithm: Optional[pulumi.Input[str]] = None,
                 check: Optional[pulumi.Input[str]] = None,
                 check_attempts: Optional[pulumi.Input[int]] = None,
                 check_body: Optional[pulumi.Input[str]] = None,
                 check_interval: Optional[pulumi.Input[int]] = None,
                 check_passive: Optional[pulumi.Input[bool]] = None,
                 check_path: Optional[pulumi.Input[str]] = None,
                 check_timeout: Optional[pulumi.Input[int]] = None,
                 cipher_suite: Optional[pulumi.Input[str]] = None,
                 nodebalancer_id: Optional[pulumi.Input[int]] = None,
                 port: Optional[pulumi.Input[int]] = None,
                 protocol: Optional[pulumi.Input[str]] = None,
                 proxy_protocol: Optional[pulumi.Input[str]] = None,
                 ssl_cert: Optional[pulumi.Input[str]] = None,
                 ssl_key: Optional[pulumi.Input[str]] = None,
                 stickiness: Optional[pulumi.Input[str]] = None,
                 __props__=None,
                 __name__=None,
                 __opts__=None):
        """
        Provides a Linode NodeBalancer Config resource.  This can be used to create, modify, and delete Linodes NodeBalancer Configs.
        For more information, see [Getting Started with NodeBalancers](https://www.linode.com/docs/platform/nodebalancer/getting-started-with-nodebalancers/) and the [Linode APIv4 docs](https://developers.linode.com/api/v4#operation/createNodeBalancerConfig).

        ## Example Usage

        The following example shows how one might use this resource to configure a NodeBalancer Config attached to a Linode instance.

        ```python
        import pulumi
        import pulumi_linode as linode

        foobar = linode.NodeBalancer("foobar",
            client_conn_throttle=20,
            label="mynodebalancer",
            region="us-east")
        foofig = linode.NodeBalancerConfig("foofig",
            algorithm="source",
            check="http",
            check_attempts=3,
            check_path="/foo",
            check_timeout=30,
            nodebalancer_id=foobar.id,
            port=8088,
            protocol="http",
            stickiness="http_cookie")
        ```
        ## Attributes

        This resource exports the following attributes:

        * `ssl_commonname` - The common name for the SSL certification this port is serving if this port is not configured to use SSL.

        * `ssl_fingerprint` - The fingerprint for the SSL certification this port is serving if this port is not configured to use SSL.

        * `node_status` - The status of the attached nodes.

        ### node_status

        The following attributes are available on node_status:

        * `up` - The number of backends considered to be 'UP' and healthy, and that are serving requests.

        * `down` - The number of backends considered to be 'DOWN' and unhealthy. These are not in rotation, and not serving requests.

        ## Import

        NodeBalancer Configs can be imported using the NodeBalancer `nodebalancer_id` followed by the NodeBalancer Config `id` separated by a comma, e.g.

        ```sh
         $ pulumi import linode:index/nodeBalancerConfig:NodeBalancerConfig http-foobar 1234567,7654321
        ```

         The Linode Guide, [Import Existing Infrastructure to Terraform](https://www.linode.com/docs/applications/configuration-management/import-existing-infrastructure-to-terraform/), offers resource importing examples for NodeBalancer Configs and other Linode resource types.

        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[str] algorithm: What algorithm this NodeBalancer should use for routing traffic to backends: roundrobin, leastconn, source
        :param pulumi.Input[str] check: The type of check to perform against backends to ensure they are serving requests. This is used to determine if backends are up or down. If none no check is performed. connection requires only a connection to the backend to succeed. http and http_body rely on the backend serving HTTP, and that the response returned matches what is expected.
        :param pulumi.Input[int] check_attempts: How many times to attempt a check before considering a backend to be down. (1-30)
        :param pulumi.Input[str] check_body: This value must be present in the response body of the check in order for it to pass. If this value is not present in
               the response body of a check request, the backend is considered to be down
        :param pulumi.Input[int] check_interval: How often, in seconds, to check that backends are up and serving requests.
        :param pulumi.Input[bool] check_passive: If true, any response from this backend with a 5xx status code will be enough for it to be considered unhealthy and taken out of rotation.
        :param pulumi.Input[str] check_path: The URL path to check on each backend. If the backend does not respond to this request it is considered to be down.
        :param pulumi.Input[int] check_timeout: How long, in seconds, to wait for a check attempt before considering it failed. (1-30)
        :param pulumi.Input[str] cipher_suite: What ciphers to use for SSL connections served by this NodeBalancer. `legacy` is considered insecure and should only be used if necessary.
        :param pulumi.Input[int] nodebalancer_id: The ID of the NodeBalancer to access.
        :param pulumi.Input[int] port: The TCP port this Config is for. These values must be unique across configs on a single NodeBalancer (you can't have two configs for port 80, for example). While some ports imply some protocols, no enforcement is done and you may configure your NodeBalancer however is useful to you. For example, while port 443 is generally used for HTTPS, you do not need SSL configured to have a NodeBalancer listening on port 443. (Defaults to 80)
        :param pulumi.Input[str] protocol: The protocol this port is configured to serve. If this is set to https you must include an ssl_cert and an ssl_key. (Defaults to "http")
        :param pulumi.Input[str] proxy_protocol: The version of ProxyProtocol to use for the underlying NodeBalancer. This requires protocol to be `tcp`. Valid values are `none`, `v1`, and `v2`. (Defaults to `none`)
        :param pulumi.Input[str] ssl_cert: The certificate this port is serving. This is not returned. If set, this field will come back as `<REDACTED>`. Please use the ssl_commonname and ssl_fingerprint to identify the certificate.
        :param pulumi.Input[str] ssl_key: The private key corresponding to this port's certificate. This is not returned. If set, this field will come back as `<REDACTED>`. Please use the ssl_commonname and ssl_fingerprint to identify the certificate.
        :param pulumi.Input[str] stickiness: Controls how session stickiness is handled on this port: 'none', 'table', 'http_cookie'
        """
        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__['algorithm'] = algorithm
            __props__['check'] = check
            __props__['check_attempts'] = check_attempts
            __props__['check_body'] = check_body
            __props__['check_interval'] = check_interval
            __props__['check_passive'] = check_passive
            __props__['check_path'] = check_path
            __props__['check_timeout'] = check_timeout
            __props__['cipher_suite'] = cipher_suite
            if nodebalancer_id is None and not opts.urn:
                raise TypeError("Missing required property 'nodebalancer_id'")
            __props__['nodebalancer_id'] = nodebalancer_id
            __props__['port'] = port
            __props__['protocol'] = protocol
            __props__['proxy_protocol'] = proxy_protocol
            __props__['ssl_cert'] = ssl_cert
            __props__['ssl_key'] = ssl_key
            __props__['stickiness'] = stickiness
            __props__['node_statuses'] = None
            __props__['ssl_commonname'] = None
            __props__['ssl_fingerprint'] = None
        super(NodeBalancerConfig, __self__).__init__(
            'linode:index/nodeBalancerConfig:NodeBalancerConfig',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            algorithm: Optional[pulumi.Input[str]] = None,
            check: Optional[pulumi.Input[str]] = None,
            check_attempts: Optional[pulumi.Input[int]] = None,
            check_body: Optional[pulumi.Input[str]] = None,
            check_interval: Optional[pulumi.Input[int]] = None,
            check_passive: Optional[pulumi.Input[bool]] = None,
            check_path: Optional[pulumi.Input[str]] = None,
            check_timeout: Optional[pulumi.Input[int]] = None,
            cipher_suite: Optional[pulumi.Input[str]] = None,
            node_statuses: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['NodeBalancerConfigNodeStatusArgs']]]]] = None,
            nodebalancer_id: Optional[pulumi.Input[int]] = None,
            port: Optional[pulumi.Input[int]] = None,
            protocol: Optional[pulumi.Input[str]] = None,
            proxy_protocol: Optional[pulumi.Input[str]] = None,
            ssl_cert: Optional[pulumi.Input[str]] = None,
            ssl_commonname: Optional[pulumi.Input[str]] = None,
            ssl_fingerprint: Optional[pulumi.Input[str]] = None,
            ssl_key: Optional[pulumi.Input[str]] = None,
            stickiness: Optional[pulumi.Input[str]] = None) -> 'NodeBalancerConfig':
        """
        Get an existing NodeBalancerConfig 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[str] algorithm: What algorithm this NodeBalancer should use for routing traffic to backends: roundrobin, leastconn, source
        :param pulumi.Input[str] check: The type of check to perform against backends to ensure they are serving requests. This is used to determine if backends are up or down. If none no check is performed. connection requires only a connection to the backend to succeed. http and http_body rely on the backend serving HTTP, and that the response returned matches what is expected.
        :param pulumi.Input[int] check_attempts: How many times to attempt a check before considering a backend to be down. (1-30)
        :param pulumi.Input[str] check_body: This value must be present in the response body of the check in order for it to pass. If this value is not present in
               the response body of a check request, the backend is considered to be down
        :param pulumi.Input[int] check_interval: How often, in seconds, to check that backends are up and serving requests.
        :param pulumi.Input[bool] check_passive: If true, any response from this backend with a 5xx status code will be enough for it to be considered unhealthy and taken out of rotation.
        :param pulumi.Input[str] check_path: The URL path to check on each backend. If the backend does not respond to this request it is considered to be down.
        :param pulumi.Input[int] check_timeout: How long, in seconds, to wait for a check attempt before considering it failed. (1-30)
        :param pulumi.Input[str] cipher_suite: What ciphers to use for SSL connections served by this NodeBalancer. `legacy` is considered insecure and should only be used if necessary.
        :param pulumi.Input[int] nodebalancer_id: The ID of the NodeBalancer to access.
        :param pulumi.Input[int] port: The TCP port this Config is for. These values must be unique across configs on a single NodeBalancer (you can't have two configs for port 80, for example). While some ports imply some protocols, no enforcement is done and you may configure your NodeBalancer however is useful to you. For example, while port 443 is generally used for HTTPS, you do not need SSL configured to have a NodeBalancer listening on port 443. (Defaults to 80)
        :param pulumi.Input[str] protocol: The protocol this port is configured to serve. If this is set to https you must include an ssl_cert and an ssl_key. (Defaults to "http")
        :param pulumi.Input[str] proxy_protocol: The version of ProxyProtocol to use for the underlying NodeBalancer. This requires protocol to be `tcp`. Valid values are `none`, `v1`, and `v2`. (Defaults to `none`)
        :param pulumi.Input[str] ssl_cert: The certificate this port is serving. This is not returned. If set, this field will come back as `<REDACTED>`. Please use the ssl_commonname and ssl_fingerprint to identify the certificate.
        :param pulumi.Input[str] ssl_commonname: The common name for the SSL certification this port is serving if this port is not configured to use SSL.
        :param pulumi.Input[str] ssl_fingerprint: The fingerprint for the SSL certification this port is serving if this port is not configured to use SSL.
        :param pulumi.Input[str] ssl_key: The private key corresponding to this port's certificate. This is not returned. If set, this field will come back as `<REDACTED>`. Please use the ssl_commonname and ssl_fingerprint to identify the certificate.
        :param pulumi.Input[str] stickiness: Controls how session stickiness is handled on this port: 'none', 'table', 'http_cookie'
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = dict()

        __props__["algorithm"] = algorithm
        __props__["check"] = check
        __props__["check_attempts"] = check_attempts
        __props__["check_body"] = check_body
        __props__["check_interval"] = check_interval
        __props__["check_passive"] = check_passive
        __props__["check_path"] = check_path
        __props__["check_timeout"] = check_timeout
        __props__["cipher_suite"] = cipher_suite
        __props__["node_statuses"] = node_statuses
        __props__["nodebalancer_id"] = nodebalancer_id
        __props__["port"] = port
        __props__["protocol"] = protocol
        __props__["proxy_protocol"] = proxy_protocol
        __props__["ssl_cert"] = ssl_cert
        __props__["ssl_commonname"] = ssl_commonname
        __props__["ssl_fingerprint"] = ssl_fingerprint
        __props__["ssl_key"] = ssl_key
        __props__["stickiness"] = stickiness
        return NodeBalancerConfig(resource_name, opts=opts, __props__=__props__)

    @property
    @pulumi.getter
    def algorithm(self) -> pulumi.Output[str]:
        """
        What algorithm this NodeBalancer should use for routing traffic to backends: roundrobin, leastconn, source
        """
        return pulumi.get(self, "algorithm")

    @property
    @pulumi.getter
    def check(self) -> pulumi.Output[str]:
        """
        The type of check to perform against backends to ensure they are serving requests. This is used to determine if backends are up or down. If none no check is performed. connection requires only a connection to the backend to succeed. http and http_body rely on the backend serving HTTP, and that the response returned matches what is expected.
        """
        return pulumi.get(self, "check")

    @property
    @pulumi.getter(name="checkAttempts")
    def check_attempts(self) -> pulumi.Output[int]:
        """
        How many times to attempt a check before considering a backend to be down. (1-30)
        """
        return pulumi.get(self, "check_attempts")

    @property
    @pulumi.getter(name="checkBody")
    def check_body(self) -> pulumi.Output[str]:
        """
        This value must be present in the response body of the check in order for it to pass. If this value is not present in
        the response body of a check request, the backend is considered to be down
        """
        return pulumi.get(self, "check_body")

    @property
    @pulumi.getter(name="checkInterval")
    def check_interval(self) -> pulumi.Output[int]:
        """
        How often, in seconds, to check that backends are up and serving requests.
        """
        return pulumi.get(self, "check_interval")

    @property
    @pulumi.getter(name="checkPassive")
    def check_passive(self) -> pulumi.Output[bool]:
        """
        If true, any response from this backend with a 5xx status code will be enough for it to be considered unhealthy and taken out of rotation.
        """
        return pulumi.get(self, "check_passive")

    @property
    @pulumi.getter(name="checkPath")
    def check_path(self) -> pulumi.Output[str]:
        """
        The URL path to check on each backend. If the backend does not respond to this request it is considered to be down.
        """
        return pulumi.get(self, "check_path")

    @property
    @pulumi.getter(name="checkTimeout")
    def check_timeout(self) -> pulumi.Output[int]:
        """
        How long, in seconds, to wait for a check attempt before considering it failed. (1-30)
        """
        return pulumi.get(self, "check_timeout")

    @property
    @pulumi.getter(name="cipherSuite")
    def cipher_suite(self) -> pulumi.Output[str]:
        """
        What ciphers to use for SSL connections served by this NodeBalancer. `legacy` is considered insecure and should only be used if necessary.
        """
        return pulumi.get(self, "cipher_suite")

    @property
    @pulumi.getter(name="nodeStatuses")
    def node_statuses(self) -> pulumi.Output[Sequence['outputs.NodeBalancerConfigNodeStatus']]:
        return pulumi.get(self, "node_statuses")

    @property
    @pulumi.getter(name="nodebalancerId")
    def nodebalancer_id(self) -> pulumi.Output[int]:
        """
        The ID of the NodeBalancer to access.
        """
        return pulumi.get(self, "nodebalancer_id")

    @property
    @pulumi.getter
    def port(self) -> pulumi.Output[Optional[int]]:
        """
        The TCP port this Config is for. These values must be unique across configs on a single NodeBalancer (you can't have two configs for port 80, for example). While some ports imply some protocols, no enforcement is done and you may configure your NodeBalancer however is useful to you. For example, while port 443 is generally used for HTTPS, you do not need SSL configured to have a NodeBalancer listening on port 443. (Defaults to 80)
        """
        return pulumi.get(self, "port")

    @property
    @pulumi.getter
    def protocol(self) -> pulumi.Output[Optional[str]]:
        """
        The protocol this port is configured to serve. If this is set to https you must include an ssl_cert and an ssl_key. (Defaults to "http")
        """
        return pulumi.get(self, "protocol")

    @property
    @pulumi.getter(name="proxyProtocol")
    def proxy_protocol(self) -> pulumi.Output[Optional[str]]:
        """
        The version of ProxyProtocol to use for the underlying NodeBalancer. This requires protocol to be `tcp`. Valid values are `none`, `v1`, and `v2`. (Defaults to `none`)
        """
        return pulumi.get(self, "proxy_protocol")

    @property
    @pulumi.getter(name="sslCert")
    def ssl_cert(self) -> pulumi.Output[Optional[str]]:
        """
        The certificate this port is serving. This is not returned. If set, this field will come back as `<REDACTED>`. Please use the ssl_commonname and ssl_fingerprint to identify the certificate.
        """
        return pulumi.get(self, "ssl_cert")

    @property
    @pulumi.getter(name="sslCommonname")
    def ssl_commonname(self) -> pulumi.Output[str]:
        """
        The common name for the SSL certification this port is serving if this port is not configured to use SSL.
        """
        return pulumi.get(self, "ssl_commonname")

    @property
    @pulumi.getter(name="sslFingerprint")
    def ssl_fingerprint(self) -> pulumi.Output[str]:
        """
        The fingerprint for the SSL certification this port is serving if this port is not configured to use SSL.
        """
        return pulumi.get(self, "ssl_fingerprint")

    @property
    @pulumi.getter(name="sslKey")
    def ssl_key(self) -> pulumi.Output[Optional[str]]:
        """
        The private key corresponding to this port's certificate. This is not returned. If set, this field will come back as `<REDACTED>`. Please use the ssl_commonname and ssl_fingerprint to identify the certificate.
        """
        return pulumi.get(self, "ssl_key")

    @property
    @pulumi.getter
    def stickiness(self) -> pulumi.Output[str]:
        """
        Controls how session stickiness is handled on this port: 'none', 'table', 'http_cookie'
        """
        return pulumi.get(self, "stickiness")

    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

