# 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__ = [
    'GetSqlUserResult',
    'AwaitableGetSqlUserResult',
    'get_sql_user',
    'get_sql_user_output',
]

@pulumi.output_type
class GetSqlUserResult:
    """
    A collection of values returned by getSqlUser.
    """
    def __init__(__self__, database_id=None, id=None, login_id=None, name=None):
        if database_id and not isinstance(database_id, str):
            raise TypeError("Expected argument 'database_id' to be a str")
        pulumi.set(__self__, "database_id", database_id)
        if id and not isinstance(id, str):
            raise TypeError("Expected argument 'id' to be a str")
        pulumi.set(__self__, "id", id)
        if login_id and not isinstance(login_id, str):
            raise TypeError("Expected argument 'login_id' to be a str")
        pulumi.set(__self__, "login_id", login_id)
        if name and not isinstance(name, str):
            raise TypeError("Expected argument 'name' to be a str")
        pulumi.set(__self__, "name", name)

    @property
    @pulumi.getter(name="databaseId")
    def database_id(self) -> str:
        """
        ID of database. Can be retrieved using `Database` or `SELECT DB_ID('<db_name>')`.
        """
        return pulumi.get(self, "database_id")

    @property
    @pulumi.getter
    def id(self) -> str:
        """
        `<database_id>/<user_id>`. User ID can be retrieved using `SELECT DATABASE_PRINCIPAL_ID('<user_name>')`.
        """
        return pulumi.get(self, "id")

    @property
    @pulumi.getter(name="loginId")
    def login_id(self) -> str:
        """
        SID of SQL login. Can be retrieved using `SqlLogin` or `SELECT SUSER_SID('<login_name>')`.
        """
        return pulumi.get(self, "login_id")

    @property
    @pulumi.getter
    def name(self) -> str:
        """
        User name. Cannot be longer than 128 chars.
        """
        return pulumi.get(self, "name")


class AwaitableGetSqlUserResult(GetSqlUserResult):
    # pylint: disable=using-constant-test
    def __await__(self):
        if False:
            yield self
        return GetSqlUserResult(
            database_id=self.database_id,
            id=self.id,
            login_id=self.login_id,
            name=self.name)


def get_sql_user(database_id: Optional[str] = None,
                 name: Optional[str] = None,
                 opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetSqlUserResult:
    """
    Obtains information about single SQL database user.

    ## Example Usage

    ```python
    import pulumi
    import pulumi_mssql as mssql

    master = mssql.get_database(name="master")
    example = mssql.get_sql_user(name="dbo",
        database_id=master.id)
    pulumi.export("id", example.id)
    ```


    :param str database_id: ID of database. Can be retrieved using `Database` or `SELECT DB_ID('<db_name>')`.
    :param str name: User name. Cannot be longer than 128 chars.
    """
    __args__ = dict()
    __args__['databaseId'] = database_id
    __args__['name'] = name
    opts = pulumi.InvokeOptions.merge(_utilities.get_invoke_opts_defaults(), opts)
    __ret__ = pulumi.runtime.invoke('mssql:index/getSqlUser:getSqlUser', __args__, opts=opts, typ=GetSqlUserResult).value

    return AwaitableGetSqlUserResult(
        database_id=pulumi.get(__ret__, 'database_id'),
        id=pulumi.get(__ret__, 'id'),
        login_id=pulumi.get(__ret__, 'login_id'),
        name=pulumi.get(__ret__, 'name'))


@_utilities.lift_output_func(get_sql_user)
def get_sql_user_output(database_id: Optional[pulumi.Input[Optional[str]]] = None,
                        name: Optional[pulumi.Input[str]] = None,
                        opts: Optional[pulumi.InvokeOptions] = None) -> pulumi.Output[GetSqlUserResult]:
    """
    Obtains information about single SQL database user.

    ## Example Usage

    ```python
    import pulumi
    import pulumi_mssql as mssql

    master = mssql.get_database(name="master")
    example = mssql.get_sql_user(name="dbo",
        database_id=master.id)
    pulumi.export("id", example.id)
    ```


    :param str database_id: ID of database. Can be retrieved using `Database` or `SELECT DB_ID('<db_name>')`.
    :param str name: User name. Cannot be longer than 128 chars.
    """
    ...
