# 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 copy
import warnings
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union, overload
from . import _utilities

__all__ = ['SqlLoginArgs', 'SqlLogin']

@pulumi.input_type
class SqlLoginArgs:
    def __init__(__self__, *,
                 password: pulumi.Input[str],
                 check_password_expiration: Optional[pulumi.Input[bool]] = None,
                 check_password_policy: Optional[pulumi.Input[bool]] = None,
                 default_database_id: Optional[pulumi.Input[str]] = None,
                 default_language: Optional[pulumi.Input[str]] = None,
                 must_change_password: Optional[pulumi.Input[bool]] = None,
                 name: Optional[pulumi.Input[str]] = None):
        """
        The set of arguments for constructing a SqlLogin resource.
        :param pulumi.Input[str] password: Password for the login. Must follow strong password policies defined for SQL server. Passwords are case-sensitive, length must be 8-128 chars, can include all characters except `'` or `name`.
        :param pulumi.Input[bool] check_password_expiration: When `true`, password expiration policy is enforced for this login. Defaults to `false`. > **Note** In case of Azure
               SQL, which does not support this feature, the flag will be ignored.
        :param pulumi.Input[bool] check_password_policy: When `true`, the Windows password policies of the computer on which SQL Server is running are enforced on this login.
               Defaults to `true`. > **Note** In case of Azure SQL, which does not support this feature, the flag will be ignored.
        :param pulumi.Input[str] default_database_id: ID of login's default DB. The ID can be retrieved using `Database` data resource. Defaults to ID of `master`. > **Note**
               In case of Azure SQL, which does not support this feature, the flag will be ignored.
        :param pulumi.Input[str] default_language: Default language assigned to login. Defaults to current default language of the server. If the default language of the
               server is later changed, the default language of the login remains unchanged. > **Note** In case of Azure SQL, which
               does not support this feature, the flag will be ignored.
        :param pulumi.Input[str] name: Login name. Must follow [Regular Identifiers rules](https://docs.microsoft.com/en-us/sql/relational-databases/databases/database-identifiers#rules-for-regular-identifiers) and cannot contain `\\`
        """
        pulumi.set(__self__, "password", password)
        if check_password_expiration is not None:
            pulumi.set(__self__, "check_password_expiration", check_password_expiration)
        if check_password_policy is not None:
            pulumi.set(__self__, "check_password_policy", check_password_policy)
        if default_database_id is not None:
            pulumi.set(__self__, "default_database_id", default_database_id)
        if default_language is not None:
            pulumi.set(__self__, "default_language", default_language)
        if must_change_password is not None:
            pulumi.set(__self__, "must_change_password", must_change_password)
        if name is not None:
            pulumi.set(__self__, "name", name)

    @property
    @pulumi.getter
    def password(self) -> pulumi.Input[str]:
        """
        Password for the login. Must follow strong password policies defined for SQL server. Passwords are case-sensitive, length must be 8-128 chars, can include all characters except `'` or `name`.
        """
        return pulumi.get(self, "password")

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

    @property
    @pulumi.getter(name="checkPasswordExpiration")
    def check_password_expiration(self) -> Optional[pulumi.Input[bool]]:
        """
        When `true`, password expiration policy is enforced for this login. Defaults to `false`. > **Note** In case of Azure
        SQL, which does not support this feature, the flag will be ignored.
        """
        return pulumi.get(self, "check_password_expiration")

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

    @property
    @pulumi.getter(name="checkPasswordPolicy")
    def check_password_policy(self) -> Optional[pulumi.Input[bool]]:
        """
        When `true`, the Windows password policies of the computer on which SQL Server is running are enforced on this login.
        Defaults to `true`. > **Note** In case of Azure SQL, which does not support this feature, the flag will be ignored.
        """
        return pulumi.get(self, "check_password_policy")

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

    @property
    @pulumi.getter(name="defaultDatabaseId")
    def default_database_id(self) -> Optional[pulumi.Input[str]]:
        """
        ID of login's default DB. The ID can be retrieved using `Database` data resource. Defaults to ID of `master`. > **Note**
        In case of Azure SQL, which does not support this feature, the flag will be ignored.
        """
        return pulumi.get(self, "default_database_id")

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

    @property
    @pulumi.getter(name="defaultLanguage")
    def default_language(self) -> Optional[pulumi.Input[str]]:
        """
        Default language assigned to login. Defaults to current default language of the server. If the default language of the
        server is later changed, the default language of the login remains unchanged. > **Note** In case of Azure SQL, which
        does not support this feature, the flag will be ignored.
        """
        return pulumi.get(self, "default_language")

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

    @property
    @pulumi.getter(name="mustChangePassword")
    def must_change_password(self) -> Optional[pulumi.Input[bool]]:
        return pulumi.get(self, "must_change_password")

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

    @property
    @pulumi.getter
    def name(self) -> Optional[pulumi.Input[str]]:
        """
        Login name. Must follow [Regular Identifiers rules](https://docs.microsoft.com/en-us/sql/relational-databases/databases/database-identifiers#rules-for-regular-identifiers) and cannot contain `\\`
        """
        return pulumi.get(self, "name")

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


@pulumi.input_type
class _SqlLoginState:
    def __init__(__self__, *,
                 check_password_expiration: Optional[pulumi.Input[bool]] = None,
                 check_password_policy: Optional[pulumi.Input[bool]] = None,
                 default_database_id: Optional[pulumi.Input[str]] = None,
                 default_language: Optional[pulumi.Input[str]] = None,
                 must_change_password: Optional[pulumi.Input[bool]] = None,
                 name: Optional[pulumi.Input[str]] = None,
                 password: Optional[pulumi.Input[str]] = None,
                 principal_id: Optional[pulumi.Input[str]] = None):
        """
        Input properties used for looking up and filtering SqlLogin resources.
        :param pulumi.Input[bool] check_password_expiration: When `true`, password expiration policy is enforced for this login. Defaults to `false`. > **Note** In case of Azure
               SQL, which does not support this feature, the flag will be ignored.
        :param pulumi.Input[bool] check_password_policy: When `true`, the Windows password policies of the computer on which SQL Server is running are enforced on this login.
               Defaults to `true`. > **Note** In case of Azure SQL, which does not support this feature, the flag will be ignored.
        :param pulumi.Input[str] default_database_id: ID of login's default DB. The ID can be retrieved using `Database` data resource. Defaults to ID of `master`. > **Note**
               In case of Azure SQL, which does not support this feature, the flag will be ignored.
        :param pulumi.Input[str] default_language: Default language assigned to login. Defaults to current default language of the server. If the default language of the
               server is later changed, the default language of the login remains unchanged. > **Note** In case of Azure SQL, which
               does not support this feature, the flag will be ignored.
        :param pulumi.Input[str] name: Login name. Must follow [Regular Identifiers rules](https://docs.microsoft.com/en-us/sql/relational-databases/databases/database-identifiers#rules-for-regular-identifiers) and cannot contain `\\`
        :param pulumi.Input[str] password: Password for the login. Must follow strong password policies defined for SQL server. Passwords are case-sensitive, length must be 8-128 chars, can include all characters except `'` or `name`.
        :param pulumi.Input[str] principal_id: ID used to reference SQL Login in other resources, e.g. `server_role`. Can be retrieved from `sys.sql_logins`.
        """
        if check_password_expiration is not None:
            pulumi.set(__self__, "check_password_expiration", check_password_expiration)
        if check_password_policy is not None:
            pulumi.set(__self__, "check_password_policy", check_password_policy)
        if default_database_id is not None:
            pulumi.set(__self__, "default_database_id", default_database_id)
        if default_language is not None:
            pulumi.set(__self__, "default_language", default_language)
        if must_change_password is not None:
            pulumi.set(__self__, "must_change_password", must_change_password)
        if name is not None:
            pulumi.set(__self__, "name", name)
        if password is not None:
            pulumi.set(__self__, "password", password)
        if principal_id is not None:
            pulumi.set(__self__, "principal_id", principal_id)

    @property
    @pulumi.getter(name="checkPasswordExpiration")
    def check_password_expiration(self) -> Optional[pulumi.Input[bool]]:
        """
        When `true`, password expiration policy is enforced for this login. Defaults to `false`. > **Note** In case of Azure
        SQL, which does not support this feature, the flag will be ignored.
        """
        return pulumi.get(self, "check_password_expiration")

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

    @property
    @pulumi.getter(name="checkPasswordPolicy")
    def check_password_policy(self) -> Optional[pulumi.Input[bool]]:
        """
        When `true`, the Windows password policies of the computer on which SQL Server is running are enforced on this login.
        Defaults to `true`. > **Note** In case of Azure SQL, which does not support this feature, the flag will be ignored.
        """
        return pulumi.get(self, "check_password_policy")

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

    @property
    @pulumi.getter(name="defaultDatabaseId")
    def default_database_id(self) -> Optional[pulumi.Input[str]]:
        """
        ID of login's default DB. The ID can be retrieved using `Database` data resource. Defaults to ID of `master`. > **Note**
        In case of Azure SQL, which does not support this feature, the flag will be ignored.
        """
        return pulumi.get(self, "default_database_id")

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

    @property
    @pulumi.getter(name="defaultLanguage")
    def default_language(self) -> Optional[pulumi.Input[str]]:
        """
        Default language assigned to login. Defaults to current default language of the server. If the default language of the
        server is later changed, the default language of the login remains unchanged. > **Note** In case of Azure SQL, which
        does not support this feature, the flag will be ignored.
        """
        return pulumi.get(self, "default_language")

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

    @property
    @pulumi.getter(name="mustChangePassword")
    def must_change_password(self) -> Optional[pulumi.Input[bool]]:
        return pulumi.get(self, "must_change_password")

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

    @property
    @pulumi.getter
    def name(self) -> Optional[pulumi.Input[str]]:
        """
        Login name. Must follow [Regular Identifiers rules](https://docs.microsoft.com/en-us/sql/relational-databases/databases/database-identifiers#rules-for-regular-identifiers) and cannot contain `\\`
        """
        return pulumi.get(self, "name")

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

    @property
    @pulumi.getter
    def password(self) -> Optional[pulumi.Input[str]]:
        """
        Password for the login. Must follow strong password policies defined for SQL server. Passwords are case-sensitive, length must be 8-128 chars, can include all characters except `'` or `name`.
        """
        return pulumi.get(self, "password")

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

    @property
    @pulumi.getter(name="principalId")
    def principal_id(self) -> Optional[pulumi.Input[str]]:
        """
        ID used to reference SQL Login in other resources, e.g. `server_role`. Can be retrieved from `sys.sql_logins`.
        """
        return pulumi.get(self, "principal_id")

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


class SqlLogin(pulumi.CustomResource):
    @overload
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 check_password_expiration: Optional[pulumi.Input[bool]] = None,
                 check_password_policy: Optional[pulumi.Input[bool]] = None,
                 default_database_id: Optional[pulumi.Input[str]] = None,
                 default_language: Optional[pulumi.Input[str]] = None,
                 must_change_password: Optional[pulumi.Input[bool]] = None,
                 name: Optional[pulumi.Input[str]] = None,
                 password: Optional[pulumi.Input[str]] = None,
                 __props__=None):
        """
        Manages single login.

        ## Example Usage

        ```python
        import pulumi
        import pulumi_mssql as mssql
        import pulumiverse_mssql as mssql

        example_database = mssql.get_database(name="example")
        example_sql_login = mssql.SqlLogin("exampleSqlLogin",
            password="Str0ngPa$$word12",
            must_change_password=True,
            default_database_id=example_database.id,
            default_language="english",
            check_password_expiration=True,
            check_password_policy=True)
        pulumi.export("loginId", example_sql_login.id)
        ```

        ## Import

        import using login ID - can be retrieved using `SELECT SUSER_SID('<login_name>')`

        ```sh
        $ pulumi import mssql:index/sqlLogin:SqlLogin example 0x27578D8516843E4094EFA2CEED085C82
        ```

        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[bool] check_password_expiration: When `true`, password expiration policy is enforced for this login. Defaults to `false`. > **Note** In case of Azure
               SQL, which does not support this feature, the flag will be ignored.
        :param pulumi.Input[bool] check_password_policy: When `true`, the Windows password policies of the computer on which SQL Server is running are enforced on this login.
               Defaults to `true`. > **Note** In case of Azure SQL, which does not support this feature, the flag will be ignored.
        :param pulumi.Input[str] default_database_id: ID of login's default DB. The ID can be retrieved using `Database` data resource. Defaults to ID of `master`. > **Note**
               In case of Azure SQL, which does not support this feature, the flag will be ignored.
        :param pulumi.Input[str] default_language: Default language assigned to login. Defaults to current default language of the server. If the default language of the
               server is later changed, the default language of the login remains unchanged. > **Note** In case of Azure SQL, which
               does not support this feature, the flag will be ignored.
        :param pulumi.Input[str] name: Login name. Must follow [Regular Identifiers rules](https://docs.microsoft.com/en-us/sql/relational-databases/databases/database-identifiers#rules-for-regular-identifiers) and cannot contain `\\`
        :param pulumi.Input[str] password: Password for the login. Must follow strong password policies defined for SQL server. Passwords are case-sensitive, length must be 8-128 chars, can include all characters except `'` or `name`.
        """
        ...
    @overload
    def __init__(__self__,
                 resource_name: str,
                 args: SqlLoginArgs,
                 opts: Optional[pulumi.ResourceOptions] = None):
        """
        Manages single login.

        ## Example Usage

        ```python
        import pulumi
        import pulumi_mssql as mssql
        import pulumiverse_mssql as mssql

        example_database = mssql.get_database(name="example")
        example_sql_login = mssql.SqlLogin("exampleSqlLogin",
            password="Str0ngPa$$word12",
            must_change_password=True,
            default_database_id=example_database.id,
            default_language="english",
            check_password_expiration=True,
            check_password_policy=True)
        pulumi.export("loginId", example_sql_login.id)
        ```

        ## Import

        import using login ID - can be retrieved using `SELECT SUSER_SID('<login_name>')`

        ```sh
        $ pulumi import mssql:index/sqlLogin:SqlLogin example 0x27578D8516843E4094EFA2CEED085C82
        ```

        :param str resource_name: The name of the resource.
        :param SqlLoginArgs 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(SqlLoginArgs, 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,
                 check_password_expiration: Optional[pulumi.Input[bool]] = None,
                 check_password_policy: Optional[pulumi.Input[bool]] = None,
                 default_database_id: Optional[pulumi.Input[str]] = None,
                 default_language: Optional[pulumi.Input[str]] = None,
                 must_change_password: Optional[pulumi.Input[bool]] = None,
                 name: Optional[pulumi.Input[str]] = None,
                 password: Optional[pulumi.Input[str]] = None,
                 __props__=None):
        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__ = SqlLoginArgs.__new__(SqlLoginArgs)

            __props__.__dict__["check_password_expiration"] = check_password_expiration
            __props__.__dict__["check_password_policy"] = check_password_policy
            __props__.__dict__["default_database_id"] = default_database_id
            __props__.__dict__["default_language"] = default_language
            __props__.__dict__["must_change_password"] = must_change_password
            __props__.__dict__["name"] = name
            if password is None and not opts.urn:
                raise TypeError("Missing required property 'password'")
            __props__.__dict__["password"] = None if password is None else pulumi.Output.secret(password)
            __props__.__dict__["principal_id"] = None
        secret_opts = pulumi.ResourceOptions(additional_secret_outputs=["password"])
        opts = pulumi.ResourceOptions.merge(opts, secret_opts)
        super(SqlLogin, __self__).__init__(
            'mssql:index/sqlLogin:SqlLogin',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            check_password_expiration: Optional[pulumi.Input[bool]] = None,
            check_password_policy: Optional[pulumi.Input[bool]] = None,
            default_database_id: Optional[pulumi.Input[str]] = None,
            default_language: Optional[pulumi.Input[str]] = None,
            must_change_password: Optional[pulumi.Input[bool]] = None,
            name: Optional[pulumi.Input[str]] = None,
            password: Optional[pulumi.Input[str]] = None,
            principal_id: Optional[pulumi.Input[str]] = None) -> 'SqlLogin':
        """
        Get an existing SqlLogin resource's state with the given name, id, and optional extra
        properties used to qualify the lookup.

        :param str resource_name: The unique name of the resulting resource.
        :param pulumi.Input[str] id: The unique provider ID of the resource to lookup.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[bool] check_password_expiration: When `true`, password expiration policy is enforced for this login. Defaults to `false`. > **Note** In case of Azure
               SQL, which does not support this feature, the flag will be ignored.
        :param pulumi.Input[bool] check_password_policy: When `true`, the Windows password policies of the computer on which SQL Server is running are enforced on this login.
               Defaults to `true`. > **Note** In case of Azure SQL, which does not support this feature, the flag will be ignored.
        :param pulumi.Input[str] default_database_id: ID of login's default DB. The ID can be retrieved using `Database` data resource. Defaults to ID of `master`. > **Note**
               In case of Azure SQL, which does not support this feature, the flag will be ignored.
        :param pulumi.Input[str] default_language: Default language assigned to login. Defaults to current default language of the server. If the default language of the
               server is later changed, the default language of the login remains unchanged. > **Note** In case of Azure SQL, which
               does not support this feature, the flag will be ignored.
        :param pulumi.Input[str] name: Login name. Must follow [Regular Identifiers rules](https://docs.microsoft.com/en-us/sql/relational-databases/databases/database-identifiers#rules-for-regular-identifiers) and cannot contain `\\`
        :param pulumi.Input[str] password: Password for the login. Must follow strong password policies defined for SQL server. Passwords are case-sensitive, length must be 8-128 chars, can include all characters except `'` or `name`.
        :param pulumi.Input[str] principal_id: ID used to reference SQL Login in other resources, e.g. `server_role`. Can be retrieved from `sys.sql_logins`.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = _SqlLoginState.__new__(_SqlLoginState)

        __props__.__dict__["check_password_expiration"] = check_password_expiration
        __props__.__dict__["check_password_policy"] = check_password_policy
        __props__.__dict__["default_database_id"] = default_database_id
        __props__.__dict__["default_language"] = default_language
        __props__.__dict__["must_change_password"] = must_change_password
        __props__.__dict__["name"] = name
        __props__.__dict__["password"] = password
        __props__.__dict__["principal_id"] = principal_id
        return SqlLogin(resource_name, opts=opts, __props__=__props__)

    @property
    @pulumi.getter(name="checkPasswordExpiration")
    def check_password_expiration(self) -> pulumi.Output[Optional[bool]]:
        """
        When `true`, password expiration policy is enforced for this login. Defaults to `false`. > **Note** In case of Azure
        SQL, which does not support this feature, the flag will be ignored.
        """
        return pulumi.get(self, "check_password_expiration")

    @property
    @pulumi.getter(name="checkPasswordPolicy")
    def check_password_policy(self) -> pulumi.Output[Optional[bool]]:
        """
        When `true`, the Windows password policies of the computer on which SQL Server is running are enforced on this login.
        Defaults to `true`. > **Note** In case of Azure SQL, which does not support this feature, the flag will be ignored.
        """
        return pulumi.get(self, "check_password_policy")

    @property
    @pulumi.getter(name="defaultDatabaseId")
    def default_database_id(self) -> pulumi.Output[Optional[str]]:
        """
        ID of login's default DB. The ID can be retrieved using `Database` data resource. Defaults to ID of `master`. > **Note**
        In case of Azure SQL, which does not support this feature, the flag will be ignored.
        """
        return pulumi.get(self, "default_database_id")

    @property
    @pulumi.getter(name="defaultLanguage")
    def default_language(self) -> pulumi.Output[Optional[str]]:
        """
        Default language assigned to login. Defaults to current default language of the server. If the default language of the
        server is later changed, the default language of the login remains unchanged. > **Note** In case of Azure SQL, which
        does not support this feature, the flag will be ignored.
        """
        return pulumi.get(self, "default_language")

    @property
    @pulumi.getter(name="mustChangePassword")
    def must_change_password(self) -> pulumi.Output[Optional[bool]]:
        return pulumi.get(self, "must_change_password")

    @property
    @pulumi.getter
    def name(self) -> pulumi.Output[str]:
        """
        Login name. Must follow [Regular Identifiers rules](https://docs.microsoft.com/en-us/sql/relational-databases/databases/database-identifiers#rules-for-regular-identifiers) and cannot contain `\\`
        """
        return pulumi.get(self, "name")

    @property
    @pulumi.getter
    def password(self) -> pulumi.Output[str]:
        """
        Password for the login. Must follow strong password policies defined for SQL server. Passwords are case-sensitive, length must be 8-128 chars, can include all characters except `'` or `name`.
        """
        return pulumi.get(self, "password")

    @property
    @pulumi.getter(name="principalId")
    def principal_id(self) -> pulumi.Output[str]:
        """
        ID used to reference SQL Login in other resources, e.g. `server_role`. Can be retrieved from `sys.sql_logins`.
        """
        return pulumi.get(self, "principal_id")

