# coding=utf-8
# *** WARNING: this file was generated by pulumi-language-python. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***

import builtins as _builtins
import warnings
import sys
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union, overload
if sys.version_info >= (3, 11):
    from typing import NotRequired, TypedDict, TypeAlias
else:
    from typing_extensions import NotRequired, TypedDict, TypeAlias
from . import _utilities

__all__ = ['DatabaseUserArgs', 'DatabaseUser']

@pulumi.input_type
class DatabaseUserArgs:
    def __init__(__self__, *,
                 instance_id: pulumi.Input[_builtins.str],
                 is_admin: Optional[pulumi.Input[_builtins.bool]] = None,
                 name: Optional[pulumi.Input[_builtins.str]] = None,
                 password: Optional[pulumi.Input[_builtins.str]] = None,
                 password_wo: Optional[pulumi.Input[_builtins.str]] = None,
                 password_wo_version: Optional[pulumi.Input[_builtins.int]] = None,
                 region: Optional[pulumi.Input[_builtins.str]] = None):
        """
        The set of arguments for constructing a DatabaseUser resource.
        :param pulumi.Input[_builtins.str] instance_id: UUID of the Database Instance.
               
               > **Important:** Updates to `instance_id` will recreate the database user.
        :param pulumi.Input[_builtins.bool] is_admin: Grant admin permissions to the database user.
        :param pulumi.Input[_builtins.str] name: database user name.
               
               > **Important:** Updates to `name` will recreate the database user.
        :param pulumi.Input[_builtins.str] password: database user password. The password must meet the following requirements based on ISO27001 standards:
               - **Length**: 8-128 characters
               - **Character types required**:
               - At least 1 lowercase letter (a-z)
               - At least 1 uppercase letter (A-Z)
               - At least 1 digit (0-9)
               - At least 1 special character (!@#$%^&*()_+-=[]{}|;:,.<>?)
               
               For secure password generation, consider using the `random_password` resource with appropriate parameters.
        :param pulumi.Input[_builtins.str] password_wo: **NOTE:** This field is write-only and its value will not be updated in state as part of read operations.
        :param pulumi.Input[_builtins.int] password_wo_version: The version of the write-only password. To update the `password_wo`, you must also update the `password_wo_version`.
        :param pulumi.Input[_builtins.str] region: The Scaleway region this resource resides in.
        """
        pulumi.set(__self__, "instance_id", instance_id)
        if is_admin is not None:
            pulumi.set(__self__, "is_admin", is_admin)
        if name is not None:
            pulumi.set(__self__, "name", name)
        if password is not None:
            pulumi.set(__self__, "password", password)
        if password_wo is not None:
            pulumi.set(__self__, "password_wo", password_wo)
        if password_wo_version is not None:
            pulumi.set(__self__, "password_wo_version", password_wo_version)
        if region is not None:
            pulumi.set(__self__, "region", region)

    @_builtins.property
    @pulumi.getter(name="instanceId")
    def instance_id(self) -> pulumi.Input[_builtins.str]:
        """
        UUID of the Database Instance.

        > **Important:** Updates to `instance_id` will recreate the database user.
        """
        return pulumi.get(self, "instance_id")

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

    @_builtins.property
    @pulumi.getter(name="isAdmin")
    def is_admin(self) -> Optional[pulumi.Input[_builtins.bool]]:
        """
        Grant admin permissions to the database user.
        """
        return pulumi.get(self, "is_admin")

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

    @_builtins.property
    @pulumi.getter
    def name(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        database user name.

        > **Important:** Updates to `name` will recreate the database user.
        """
        return pulumi.get(self, "name")

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

    @_builtins.property
    @pulumi.getter
    def password(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        database user password. The password must meet the following requirements based on ISO27001 standards:
        - **Length**: 8-128 characters
        - **Character types required**:
        - At least 1 lowercase letter (a-z)
        - At least 1 uppercase letter (A-Z)
        - At least 1 digit (0-9)
        - At least 1 special character (!@#$%^&*()_+-=[]{}|;:,.<>?)

        For secure password generation, consider using the `random_password` resource with appropriate parameters.
        """
        return pulumi.get(self, "password")

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

    @_builtins.property
    @pulumi.getter(name="passwordWo")
    def password_wo(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        **NOTE:** This field is write-only and its value will not be updated in state as part of read operations.
        """
        return pulumi.get(self, "password_wo")

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

    @_builtins.property
    @pulumi.getter(name="passwordWoVersion")
    def password_wo_version(self) -> Optional[pulumi.Input[_builtins.int]]:
        """
        The version of the write-only password. To update the `password_wo`, you must also update the `password_wo_version`.
        """
        return pulumi.get(self, "password_wo_version")

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

    @_builtins.property
    @pulumi.getter
    def region(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        The Scaleway region this resource resides in.
        """
        return pulumi.get(self, "region")

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


@pulumi.input_type
class _DatabaseUserState:
    def __init__(__self__, *,
                 instance_id: Optional[pulumi.Input[_builtins.str]] = None,
                 is_admin: Optional[pulumi.Input[_builtins.bool]] = None,
                 name: Optional[pulumi.Input[_builtins.str]] = None,
                 password: Optional[pulumi.Input[_builtins.str]] = None,
                 password_wo: Optional[pulumi.Input[_builtins.str]] = None,
                 password_wo_version: Optional[pulumi.Input[_builtins.int]] = None,
                 region: Optional[pulumi.Input[_builtins.str]] = None):
        """
        Input properties used for looking up and filtering DatabaseUser resources.
        :param pulumi.Input[_builtins.str] instance_id: UUID of the Database Instance.
               
               > **Important:** Updates to `instance_id` will recreate the database user.
        :param pulumi.Input[_builtins.bool] is_admin: Grant admin permissions to the database user.
        :param pulumi.Input[_builtins.str] name: database user name.
               
               > **Important:** Updates to `name` will recreate the database user.
        :param pulumi.Input[_builtins.str] password: database user password. The password must meet the following requirements based on ISO27001 standards:
               - **Length**: 8-128 characters
               - **Character types required**:
               - At least 1 lowercase letter (a-z)
               - At least 1 uppercase letter (A-Z)
               - At least 1 digit (0-9)
               - At least 1 special character (!@#$%^&*()_+-=[]{}|;:,.<>?)
               
               For secure password generation, consider using the `random_password` resource with appropriate parameters.
        :param pulumi.Input[_builtins.str] password_wo: **NOTE:** This field is write-only and its value will not be updated in state as part of read operations.
        :param pulumi.Input[_builtins.int] password_wo_version: The version of the write-only password. To update the `password_wo`, you must also update the `password_wo_version`.
        :param pulumi.Input[_builtins.str] region: The Scaleway region this resource resides in.
        """
        if instance_id is not None:
            pulumi.set(__self__, "instance_id", instance_id)
        if is_admin is not None:
            pulumi.set(__self__, "is_admin", is_admin)
        if name is not None:
            pulumi.set(__self__, "name", name)
        if password is not None:
            pulumi.set(__self__, "password", password)
        if password_wo is not None:
            pulumi.set(__self__, "password_wo", password_wo)
        if password_wo_version is not None:
            pulumi.set(__self__, "password_wo_version", password_wo_version)
        if region is not None:
            pulumi.set(__self__, "region", region)

    @_builtins.property
    @pulumi.getter(name="instanceId")
    def instance_id(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        UUID of the Database Instance.

        > **Important:** Updates to `instance_id` will recreate the database user.
        """
        return pulumi.get(self, "instance_id")

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

    @_builtins.property
    @pulumi.getter(name="isAdmin")
    def is_admin(self) -> Optional[pulumi.Input[_builtins.bool]]:
        """
        Grant admin permissions to the database user.
        """
        return pulumi.get(self, "is_admin")

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

    @_builtins.property
    @pulumi.getter
    def name(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        database user name.

        > **Important:** Updates to `name` will recreate the database user.
        """
        return pulumi.get(self, "name")

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

    @_builtins.property
    @pulumi.getter
    def password(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        database user password. The password must meet the following requirements based on ISO27001 standards:
        - **Length**: 8-128 characters
        - **Character types required**:
        - At least 1 lowercase letter (a-z)
        - At least 1 uppercase letter (A-Z)
        - At least 1 digit (0-9)
        - At least 1 special character (!@#$%^&*()_+-=[]{}|;:,.<>?)

        For secure password generation, consider using the `random_password` resource with appropriate parameters.
        """
        return pulumi.get(self, "password")

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

    @_builtins.property
    @pulumi.getter(name="passwordWo")
    def password_wo(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        **NOTE:** This field is write-only and its value will not be updated in state as part of read operations.
        """
        return pulumi.get(self, "password_wo")

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

    @_builtins.property
    @pulumi.getter(name="passwordWoVersion")
    def password_wo_version(self) -> Optional[pulumi.Input[_builtins.int]]:
        """
        The version of the write-only password. To update the `password_wo`, you must also update the `password_wo_version`.
        """
        return pulumi.get(self, "password_wo_version")

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

    @_builtins.property
    @pulumi.getter
    def region(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        The Scaleway region this resource resides in.
        """
        return pulumi.get(self, "region")

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


warnings.warn("""scaleway.index/databaseuser.DatabaseUser has been deprecated in favor of scaleway.databases/user.User""", DeprecationWarning)


@pulumi.type_token("scaleway:index/databaseUser:DatabaseUser")
class DatabaseUser(pulumi.CustomResource):
    warnings.warn("""scaleway.index/databaseuser.DatabaseUser has been deprecated in favor of scaleway.databases/user.User""", DeprecationWarning)

    @overload
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 instance_id: Optional[pulumi.Input[_builtins.str]] = None,
                 is_admin: Optional[pulumi.Input[_builtins.bool]] = None,
                 name: Optional[pulumi.Input[_builtins.str]] = None,
                 password: Optional[pulumi.Input[_builtins.str]] = None,
                 password_wo: Optional[pulumi.Input[_builtins.str]] = None,
                 password_wo_version: Optional[pulumi.Input[_builtins.int]] = None,
                 region: Optional[pulumi.Input[_builtins.str]] = None,
                 __props__=None):
        """
        The `databases.User` resource creates and manages database users.
        For more information refer to the [API documentation](https://www.scaleway.com/en/developers/api/managed-database-postgre-mysql/).

        ## Example Usage

        ```python
        import pulumi
        import pulumi_random as random
        import pulumiverse_scaleway as scaleway

        ### Basic user creation
        main = scaleway.databases.Instance("main",
            name="test-rdb",
            node_type="DB-DEV-S",
            engine="PostgreSQL-15",
            is_ha_cluster=True,
            disable_backup=True,
            user_name="my_initial_user",
            password="thiZ_is_v&ry_s3cret")
        db_password = random.index.Password("db_password",
            length=20,
            special=True,
            upper=True,
            lower=True,
            numeric=True,
            min_upper=1,
            min_lower=1,
            min_numeric=1,
            min_special=1,
            override_special=!@#$%^&*()_+-=[]{}|;:,.<>?)
        db_admin = scaleway.databases.User("db_admin",
            instance_id=main.id,
            name="devtools",
            password=db_password["result"],
            is_admin=True)
        ```

        ## Import

        Database users can be imported using `{region}/{instance_id}/{user_name}`, e.g.

        bash

        ```sh
        $ pulumi import scaleway:index/databaseUser:DatabaseUser admin fr-par/11111111-1111-1111-1111-111111111111/admin
        ```

        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[_builtins.str] instance_id: UUID of the Database Instance.
               
               > **Important:** Updates to `instance_id` will recreate the database user.
        :param pulumi.Input[_builtins.bool] is_admin: Grant admin permissions to the database user.
        :param pulumi.Input[_builtins.str] name: database user name.
               
               > **Important:** Updates to `name` will recreate the database user.
        :param pulumi.Input[_builtins.str] password: database user password. The password must meet the following requirements based on ISO27001 standards:
               - **Length**: 8-128 characters
               - **Character types required**:
               - At least 1 lowercase letter (a-z)
               - At least 1 uppercase letter (A-Z)
               - At least 1 digit (0-9)
               - At least 1 special character (!@#$%^&*()_+-=[]{}|;:,.<>?)
               
               For secure password generation, consider using the `random_password` resource with appropriate parameters.
        :param pulumi.Input[_builtins.str] password_wo: **NOTE:** This field is write-only and its value will not be updated in state as part of read operations.
        :param pulumi.Input[_builtins.int] password_wo_version: The version of the write-only password. To update the `password_wo`, you must also update the `password_wo_version`.
        :param pulumi.Input[_builtins.str] region: The Scaleway region this resource resides in.
        """
        ...
    @overload
    def __init__(__self__,
                 resource_name: str,
                 args: DatabaseUserArgs,
                 opts: Optional[pulumi.ResourceOptions] = None):
        """
        The `databases.User` resource creates and manages database users.
        For more information refer to the [API documentation](https://www.scaleway.com/en/developers/api/managed-database-postgre-mysql/).

        ## Example Usage

        ```python
        import pulumi
        import pulumi_random as random
        import pulumiverse_scaleway as scaleway

        ### Basic user creation
        main = scaleway.databases.Instance("main",
            name="test-rdb",
            node_type="DB-DEV-S",
            engine="PostgreSQL-15",
            is_ha_cluster=True,
            disable_backup=True,
            user_name="my_initial_user",
            password="thiZ_is_v&ry_s3cret")
        db_password = random.index.Password("db_password",
            length=20,
            special=True,
            upper=True,
            lower=True,
            numeric=True,
            min_upper=1,
            min_lower=1,
            min_numeric=1,
            min_special=1,
            override_special=!@#$%^&*()_+-=[]{}|;:,.<>?)
        db_admin = scaleway.databases.User("db_admin",
            instance_id=main.id,
            name="devtools",
            password=db_password["result"],
            is_admin=True)
        ```

        ## Import

        Database users can be imported using `{region}/{instance_id}/{user_name}`, e.g.

        bash

        ```sh
        $ pulumi import scaleway:index/databaseUser:DatabaseUser admin fr-par/11111111-1111-1111-1111-111111111111/admin
        ```

        :param str resource_name: The name of the resource.
        :param DatabaseUserArgs 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(DatabaseUserArgs, 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,
                 instance_id: Optional[pulumi.Input[_builtins.str]] = None,
                 is_admin: Optional[pulumi.Input[_builtins.bool]] = None,
                 name: Optional[pulumi.Input[_builtins.str]] = None,
                 password: Optional[pulumi.Input[_builtins.str]] = None,
                 password_wo: Optional[pulumi.Input[_builtins.str]] = None,
                 password_wo_version: Optional[pulumi.Input[_builtins.int]] = None,
                 region: Optional[pulumi.Input[_builtins.str]] = None,
                 __props__=None):
        pulumi.log.warn("""DatabaseUser is deprecated: scaleway.index/databaseuser.DatabaseUser has been deprecated in favor of scaleway.databases/user.User""")
        opts = pulumi.ResourceOptions.merge(_utilities.get_resource_opts_defaults(), opts)
        if not isinstance(opts, pulumi.ResourceOptions):
            raise TypeError('Expected resource options to be a ResourceOptions instance')
        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__ = DatabaseUserArgs.__new__(DatabaseUserArgs)

            if instance_id is None and not opts.urn:
                raise TypeError("Missing required property 'instance_id'")
            __props__.__dict__["instance_id"] = instance_id
            __props__.__dict__["is_admin"] = is_admin
            __props__.__dict__["name"] = name
            __props__.__dict__["password"] = None if password is None else pulumi.Output.secret(password)
            __props__.__dict__["password_wo"] = None if password_wo is None else pulumi.Output.secret(password_wo)
            __props__.__dict__["password_wo_version"] = password_wo_version
            __props__.__dict__["region"] = region
        secret_opts = pulumi.ResourceOptions(additional_secret_outputs=["password", "passwordWo"])
        opts = pulumi.ResourceOptions.merge(opts, secret_opts)
        super(DatabaseUser, __self__).__init__(
            'scaleway:index/databaseUser:DatabaseUser',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            instance_id: Optional[pulumi.Input[_builtins.str]] = None,
            is_admin: Optional[pulumi.Input[_builtins.bool]] = None,
            name: Optional[pulumi.Input[_builtins.str]] = None,
            password: Optional[pulumi.Input[_builtins.str]] = None,
            password_wo: Optional[pulumi.Input[_builtins.str]] = None,
            password_wo_version: Optional[pulumi.Input[_builtins.int]] = None,
            region: Optional[pulumi.Input[_builtins.str]] = None) -> 'DatabaseUser':
        """
        Get an existing DatabaseUser 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[_builtins.str] instance_id: UUID of the Database Instance.
               
               > **Important:** Updates to `instance_id` will recreate the database user.
        :param pulumi.Input[_builtins.bool] is_admin: Grant admin permissions to the database user.
        :param pulumi.Input[_builtins.str] name: database user name.
               
               > **Important:** Updates to `name` will recreate the database user.
        :param pulumi.Input[_builtins.str] password: database user password. The password must meet the following requirements based on ISO27001 standards:
               - **Length**: 8-128 characters
               - **Character types required**:
               - At least 1 lowercase letter (a-z)
               - At least 1 uppercase letter (A-Z)
               - At least 1 digit (0-9)
               - At least 1 special character (!@#$%^&*()_+-=[]{}|;:,.<>?)
               
               For secure password generation, consider using the `random_password` resource with appropriate parameters.
        :param pulumi.Input[_builtins.str] password_wo: **NOTE:** This field is write-only and its value will not be updated in state as part of read operations.
        :param pulumi.Input[_builtins.int] password_wo_version: The version of the write-only password. To update the `password_wo`, you must also update the `password_wo_version`.
        :param pulumi.Input[_builtins.str] region: The Scaleway region this resource resides in.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = _DatabaseUserState.__new__(_DatabaseUserState)

        __props__.__dict__["instance_id"] = instance_id
        __props__.__dict__["is_admin"] = is_admin
        __props__.__dict__["name"] = name
        __props__.__dict__["password"] = password
        __props__.__dict__["password_wo"] = password_wo
        __props__.__dict__["password_wo_version"] = password_wo_version
        __props__.__dict__["region"] = region
        return DatabaseUser(resource_name, opts=opts, __props__=__props__)

    @_builtins.property
    @pulumi.getter(name="instanceId")
    def instance_id(self) -> pulumi.Output[_builtins.str]:
        """
        UUID of the Database Instance.

        > **Important:** Updates to `instance_id` will recreate the database user.
        """
        return pulumi.get(self, "instance_id")

    @_builtins.property
    @pulumi.getter(name="isAdmin")
    def is_admin(self) -> pulumi.Output[Optional[_builtins.bool]]:
        """
        Grant admin permissions to the database user.
        """
        return pulumi.get(self, "is_admin")

    @_builtins.property
    @pulumi.getter
    def name(self) -> pulumi.Output[_builtins.str]:
        """
        database user name.

        > **Important:** Updates to `name` will recreate the database user.
        """
        return pulumi.get(self, "name")

    @_builtins.property
    @pulumi.getter
    def password(self) -> pulumi.Output[Optional[_builtins.str]]:
        """
        database user password. The password must meet the following requirements based on ISO27001 standards:
        - **Length**: 8-128 characters
        - **Character types required**:
        - At least 1 lowercase letter (a-z)
        - At least 1 uppercase letter (A-Z)
        - At least 1 digit (0-9)
        - At least 1 special character (!@#$%^&*()_+-=[]{}|;:,.<>?)

        For secure password generation, consider using the `random_password` resource with appropriate parameters.
        """
        return pulumi.get(self, "password")

    @_builtins.property
    @pulumi.getter(name="passwordWo")
    def password_wo(self) -> pulumi.Output[Optional[_builtins.str]]:
        """
        **NOTE:** This field is write-only and its value will not be updated in state as part of read operations.
        """
        return pulumi.get(self, "password_wo")

    @_builtins.property
    @pulumi.getter(name="passwordWoVersion")
    def password_wo_version(self) -> pulumi.Output[Optional[_builtins.int]]:
        """
        The version of the write-only password. To update the `password_wo`, you must also update the `password_wo_version`.
        """
        return pulumi.get(self, "password_wo_version")

    @_builtins.property
    @pulumi.getter
    def region(self) -> pulumi.Output[Optional[_builtins.str]]:
        """
        The Scaleway region this resource resides in.
        """
        return pulumi.get(self, "region")

