<reponame>pulumi/pulumi-aiven
# 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

__all__ = ['ConnectionPoolArgs', 'ConnectionPool']

@pulumi.input_type
class ConnectionPoolArgs:
    def __init__(__self__, *,
                 database_name: pulumi.Input[str],
                 pool_name: pulumi.Input[str],
                 project: pulumi.Input[str],
                 service_name: pulumi.Input[str],
                 pool_mode: Optional[pulumi.Input[str]] = None,
                 pool_size: Optional[pulumi.Input[int]] = None,
                 username: Optional[pulumi.Input[str]] = None):
        """
        The set of arguments for constructing a ConnectionPool resource.
        :param pulumi.Input[str] database_name: is the name of the database the pool connects to. This should be
               defined using reference as shown above to set up dependencies correctly.
        :param pulumi.Input[str] pool_name: is the name of the pool.
        :param pulumi.Input[str] project: and `service_name` - (Required) define the project and service the connection pool
               belongs to. They should be defined using reference as shown above to set up dependencies
               correctly. These properties cannot be changed once the service is created. Doing so will
               result in the connection pool being deleted and new one created instead.
        :param pulumi.Input[str] service_name: Service to link the connection pool to
        :param pulumi.Input[str] pool_mode: is the mode the pool operates in (session, transaction, statement). The
               default value for this is `transaction`.
        :param pulumi.Input[int] pool_size: is the number of connections the pool may create towards the backend
               server. This does not affect the number of incoming connections, which is always a much
               larger number. The default value for this is 10.
        :param pulumi.Input[str] username: is the name of the service user used to connect to the database. This should
               be defined using reference as shown above to set up dependencies correctly.
        """
        pulumi.set(__self__, "database_name", database_name)
        pulumi.set(__self__, "pool_name", pool_name)
        pulumi.set(__self__, "project", project)
        pulumi.set(__self__, "service_name", service_name)
        if pool_mode is not None:
            pulumi.set(__self__, "pool_mode", pool_mode)
        if pool_size is not None:
            pulumi.set(__self__, "pool_size", pool_size)
        if username is not None:
            pulumi.set(__self__, "username", username)

    @property
    @pulumi.getter(name="databaseName")
    def database_name(self) -> pulumi.Input[str]:
        """
        is the name of the database the pool connects to. This should be
        defined using reference as shown above to set up dependencies correctly.
        """
        return pulumi.get(self, "database_name")

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

    @property
    @pulumi.getter(name="poolName")
    def pool_name(self) -> pulumi.Input[str]:
        """
        is the name of the pool.
        """
        return pulumi.get(self, "pool_name")

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

    @property
    @pulumi.getter
    def project(self) -> pulumi.Input[str]:
        """
        and `service_name` - (Required) define the project and service the connection pool
        belongs to. They should be defined using reference as shown above to set up dependencies
        correctly. These properties cannot be changed once the service is created. Doing so will
        result in the connection pool being deleted and new one created instead.
        """
        return pulumi.get(self, "project")

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

    @property
    @pulumi.getter(name="serviceName")
    def service_name(self) -> pulumi.Input[str]:
        """
        Service to link the connection pool to
        """
        return pulumi.get(self, "service_name")

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

    @property
    @pulumi.getter(name="poolMode")
    def pool_mode(self) -> Optional[pulumi.Input[str]]:
        """
        is the mode the pool operates in (session, transaction, statement). The
        default value for this is `transaction`.
        """
        return pulumi.get(self, "pool_mode")

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

    @property
    @pulumi.getter(name="poolSize")
    def pool_size(self) -> Optional[pulumi.Input[int]]:
        """
        is the number of connections the pool may create towards the backend
        server. This does not affect the number of incoming connections, which is always a much
        larger number. The default value for this is 10.
        """
        return pulumi.get(self, "pool_size")

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

    @property
    @pulumi.getter
    def username(self) -> Optional[pulumi.Input[str]]:
        """
        is the name of the service user used to connect to the database. This should
        be defined using reference as shown above to set up dependencies correctly.
        """
        return pulumi.get(self, "username")

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


@pulumi.input_type
class _ConnectionPoolState:
    def __init__(__self__, *,
                 connection_uri: Optional[pulumi.Input[str]] = None,
                 database_name: Optional[pulumi.Input[str]] = None,
                 pool_mode: Optional[pulumi.Input[str]] = None,
                 pool_name: Optional[pulumi.Input[str]] = None,
                 pool_size: Optional[pulumi.Input[int]] = None,
                 project: Optional[pulumi.Input[str]] = None,
                 service_name: Optional[pulumi.Input[str]] = None,
                 username: Optional[pulumi.Input[str]] = None):
        """
        Input properties used for looking up and filtering ConnectionPool resources.
        :param pulumi.Input[str] connection_uri: (Optional) is a computed property that tells the URI for connecting to the pool.
               This value cannot be set, only read.
        :param pulumi.Input[str] database_name: is the name of the database the pool connects to. This should be
               defined using reference as shown above to set up dependencies correctly.
        :param pulumi.Input[str] pool_mode: is the mode the pool operates in (session, transaction, statement). The
               default value for this is `transaction`.
        :param pulumi.Input[str] pool_name: is the name of the pool.
        :param pulumi.Input[int] pool_size: is the number of connections the pool may create towards the backend
               server. This does not affect the number of incoming connections, which is always a much
               larger number. The default value for this is 10.
        :param pulumi.Input[str] project: and `service_name` - (Required) define the project and service the connection pool
               belongs to. They should be defined using reference as shown above to set up dependencies
               correctly. These properties cannot be changed once the service is created. Doing so will
               result in the connection pool being deleted and new one created instead.
        :param pulumi.Input[str] service_name: Service to link the connection pool to
        :param pulumi.Input[str] username: is the name of the service user used to connect to the database. This should
               be defined using reference as shown above to set up dependencies correctly.
        """
        if connection_uri is not None:
            pulumi.set(__self__, "connection_uri", connection_uri)
        if database_name is not None:
            pulumi.set(__self__, "database_name", database_name)
        if pool_mode is not None:
            pulumi.set(__self__, "pool_mode", pool_mode)
        if pool_name is not None:
            pulumi.set(__self__, "pool_name", pool_name)
        if pool_size is not None:
            pulumi.set(__self__, "pool_size", pool_size)
        if project is not None:
            pulumi.set(__self__, "project", project)
        if service_name is not None:
            pulumi.set(__self__, "service_name", service_name)
        if username is not None:
            pulumi.set(__self__, "username", username)

    @property
    @pulumi.getter(name="connectionUri")
    def connection_uri(self) -> Optional[pulumi.Input[str]]:
        """
        (Optional) is a computed property that tells the URI for connecting to the pool.
        This value cannot be set, only read.
        """
        return pulumi.get(self, "connection_uri")

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

    @property
    @pulumi.getter(name="databaseName")
    def database_name(self) -> Optional[pulumi.Input[str]]:
        """
        is the name of the database the pool connects to. This should be
        defined using reference as shown above to set up dependencies correctly.
        """
        return pulumi.get(self, "database_name")

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

    @property
    @pulumi.getter(name="poolMode")
    def pool_mode(self) -> Optional[pulumi.Input[str]]:
        """
        is the mode the pool operates in (session, transaction, statement). The
        default value for this is `transaction`.
        """
        return pulumi.get(self, "pool_mode")

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

    @property
    @pulumi.getter(name="poolName")
    def pool_name(self) -> Optional[pulumi.Input[str]]:
        """
        is the name of the pool.
        """
        return pulumi.get(self, "pool_name")

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

    @property
    @pulumi.getter(name="poolSize")
    def pool_size(self) -> Optional[pulumi.Input[int]]:
        """
        is the number of connections the pool may create towards the backend
        server. This does not affect the number of incoming connections, which is always a much
        larger number. The default value for this is 10.
        """
        return pulumi.get(self, "pool_size")

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

    @property
    @pulumi.getter
    def project(self) -> Optional[pulumi.Input[str]]:
        """
        and `service_name` - (Required) define the project and service the connection pool
        belongs to. They should be defined using reference as shown above to set up dependencies
        correctly. These properties cannot be changed once the service is created. Doing so will
        result in the connection pool being deleted and new one created instead.
        """
        return pulumi.get(self, "project")

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

    @property
    @pulumi.getter(name="serviceName")
    def service_name(self) -> Optional[pulumi.Input[str]]:
        """
        Service to link the connection pool to
        """
        return pulumi.get(self, "service_name")

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

    @property
    @pulumi.getter
    def username(self) -> Optional[pulumi.Input[str]]:
        """
        is the name of the service user used to connect to the database. This should
        be defined using reference as shown above to set up dependencies correctly.
        """
        return pulumi.get(self, "username")

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


class ConnectionPool(pulumi.CustomResource):
    @overload
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 database_name: Optional[pulumi.Input[str]] = None,
                 pool_mode: Optional[pulumi.Input[str]] = None,
                 pool_name: Optional[pulumi.Input[str]] = None,
                 pool_size: Optional[pulumi.Input[int]] = None,
                 project: Optional[pulumi.Input[str]] = None,
                 service_name: Optional[pulumi.Input[str]] = None,
                 username: Optional[pulumi.Input[str]] = None,
                 __props__=None):
        """
        ## # Connection Pool Resource

        The Connection Pool resource allows the creation and management of Aiven Connection Pools.

        ## Example Usage

        ```python
        import pulumi
        import pulumi_aiven as aiven

        mytestpool = aiven.ConnectionPool("mytestpool",
            project=aiven_project["myproject"]["project"],
            service_name=aiven_service["myservice"]["service_name"],
            database_name=aiven_database["mydatabase"]["database_name"],
            pool_mode="transaction",
            pool_name="mypool",
            pool_size=10,
            username=aiven_service_user["myserviceuser"]["username"],
            opts=pulumi.ResourceOptions(depends_on=[aiven_database["mydatabase"]]))
        ```

        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[str] database_name: is the name of the database the pool connects to. This should be
               defined using reference as shown above to set up dependencies correctly.
        :param pulumi.Input[str] pool_mode: is the mode the pool operates in (session, transaction, statement). The
               default value for this is `transaction`.
        :param pulumi.Input[str] pool_name: is the name of the pool.
        :param pulumi.Input[int] pool_size: is the number of connections the pool may create towards the backend
               server. This does not affect the number of incoming connections, which is always a much
               larger number. The default value for this is 10.
        :param pulumi.Input[str] project: and `service_name` - (Required) define the project and service the connection pool
               belongs to. They should be defined using reference as shown above to set up dependencies
               correctly. These properties cannot be changed once the service is created. Doing so will
               result in the connection pool being deleted and new one created instead.
        :param pulumi.Input[str] service_name: Service to link the connection pool to
        :param pulumi.Input[str] username: is the name of the service user used to connect to the database. This should
               be defined using reference as shown above to set up dependencies correctly.
        """
        ...
    @overload
    def __init__(__self__,
                 resource_name: str,
                 args: ConnectionPoolArgs,
                 opts: Optional[pulumi.ResourceOptions] = None):
        """
        ## # Connection Pool Resource

        The Connection Pool resource allows the creation and management of Aiven Connection Pools.

        ## Example Usage

        ```python
        import pulumi
        import pulumi_aiven as aiven

        mytestpool = aiven.ConnectionPool("mytestpool",
            project=aiven_project["myproject"]["project"],
            service_name=aiven_service["myservice"]["service_name"],
            database_name=aiven_database["mydatabase"]["database_name"],
            pool_mode="transaction",
            pool_name="mypool",
            pool_size=10,
            username=aiven_service_user["myserviceuser"]["username"],
            opts=pulumi.ResourceOptions(depends_on=[aiven_database["mydatabase"]]))
        ```

        :param str resource_name: The name of the resource.
        :param ConnectionPoolArgs 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(ConnectionPoolArgs, 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,
                 database_name: Optional[pulumi.Input[str]] = None,
                 pool_mode: Optional[pulumi.Input[str]] = None,
                 pool_name: Optional[pulumi.Input[str]] = None,
                 pool_size: Optional[pulumi.Input[int]] = None,
                 project: Optional[pulumi.Input[str]] = None,
                 service_name: Optional[pulumi.Input[str]] = None,
                 username: 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__ = ConnectionPoolArgs.__new__(ConnectionPoolArgs)

            if database_name is None and not opts.urn:
                raise TypeError("Missing required property 'database_name'")
            __props__.__dict__["database_name"] = database_name
            __props__.__dict__["pool_mode"] = pool_mode
            if pool_name is None and not opts.urn:
                raise TypeError("Missing required property 'pool_name'")
            __props__.__dict__["pool_name"] = pool_name
            __props__.__dict__["pool_size"] = pool_size
            if project is None and not opts.urn:
                raise TypeError("Missing required property 'project'")
            __props__.__dict__["project"] = project
            if service_name is None and not opts.urn:
                raise TypeError("Missing required property 'service_name'")
            __props__.__dict__["service_name"] = service_name
            __props__.__dict__["username"] = username
            __props__.__dict__["connection_uri"] = None
        super(ConnectionPool, __self__).__init__(
            'aiven:index/connectionPool:ConnectionPool',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            connection_uri: Optional[pulumi.Input[str]] = None,
            database_name: Optional[pulumi.Input[str]] = None,
            pool_mode: Optional[pulumi.Input[str]] = None,
            pool_name: Optional[pulumi.Input[str]] = None,
            pool_size: Optional[pulumi.Input[int]] = None,
            project: Optional[pulumi.Input[str]] = None,
            service_name: Optional[pulumi.Input[str]] = None,
            username: Optional[pulumi.Input[str]] = None) -> 'ConnectionPool':
        """
        Get an existing ConnectionPool 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] connection_uri: (Optional) is a computed property that tells the URI for connecting to the pool.
               This value cannot be set, only read.
        :param pulumi.Input[str] database_name: is the name of the database the pool connects to. This should be
               defined using reference as shown above to set up dependencies correctly.
        :param pulumi.Input[str] pool_mode: is the mode the pool operates in (session, transaction, statement). The
               default value for this is `transaction`.
        :param pulumi.Input[str] pool_name: is the name of the pool.
        :param pulumi.Input[int] pool_size: is the number of connections the pool may create towards the backend
               server. This does not affect the number of incoming connections, which is always a much
               larger number. The default value for this is 10.
        :param pulumi.Input[str] project: and `service_name` - (Required) define the project and service the connection pool
               belongs to. They should be defined using reference as shown above to set up dependencies
               correctly. These properties cannot be changed once the service is created. Doing so will
               result in the connection pool being deleted and new one created instead.
        :param pulumi.Input[str] service_name: Service to link the connection pool to
        :param pulumi.Input[str] username: is the name of the service user used to connect to the database. This should
               be defined using reference as shown above to set up dependencies correctly.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = _ConnectionPoolState.__new__(_ConnectionPoolState)

        __props__.__dict__["connection_uri"] = connection_uri
        __props__.__dict__["database_name"] = database_name
        __props__.__dict__["pool_mode"] = pool_mode
        __props__.__dict__["pool_name"] = pool_name
        __props__.__dict__["pool_size"] = pool_size
        __props__.__dict__["project"] = project
        __props__.__dict__["service_name"] = service_name
        __props__.__dict__["username"] = username
        return ConnectionPool(resource_name, opts=opts, __props__=__props__)

    @property
    @pulumi.getter(name="connectionUri")
    def connection_uri(self) -> pulumi.Output[str]:
        """
        (Optional) is a computed property that tells the URI for connecting to the pool.
        This value cannot be set, only read.
        """
        return pulumi.get(self, "connection_uri")

    @property
    @pulumi.getter(name="databaseName")
    def database_name(self) -> pulumi.Output[str]:
        """
        is the name of the database the pool connects to. This should be
        defined using reference as shown above to set up dependencies correctly.
        """
        return pulumi.get(self, "database_name")

    @property
    @pulumi.getter(name="poolMode")
    def pool_mode(self) -> pulumi.Output[Optional[str]]:
        """
        is the mode the pool operates in (session, transaction, statement). The
        default value for this is `transaction`.
        """
        return pulumi.get(self, "pool_mode")

    @property
    @pulumi.getter(name="poolName")
    def pool_name(self) -> pulumi.Output[str]:
        """
        is the name of the pool.
        """
        return pulumi.get(self, "pool_name")

    @property
    @pulumi.getter(name="poolSize")
    def pool_size(self) -> pulumi.Output[Optional[int]]:
        """
        is the number of connections the pool may create towards the backend
        server. This does not affect the number of incoming connections, which is always a much
        larger number. The default value for this is 10.
        """
        return pulumi.get(self, "pool_size")

    @property
    @pulumi.getter
    def project(self) -> pulumi.Output[str]:
        """
        and `service_name` - (Required) define the project and service the connection pool
        belongs to. They should be defined using reference as shown above to set up dependencies
        correctly. These properties cannot be changed once the service is created. Doing so will
        result in the connection pool being deleted and new one created instead.
        """
        return pulumi.get(self, "project")

    @property
    @pulumi.getter(name="serviceName")
    def service_name(self) -> pulumi.Output[str]:
        """
        Service to link the connection pool to
        """
        return pulumi.get(self, "service_name")

    @property
    @pulumi.getter
    def username(self) -> pulumi.Output[Optional[str]]:
        """
        is the name of the service user used to connect to the database. This should
        be defined using reference as shown above to set up dependencies correctly.
        """
        return pulumi.get(self, "username")

