# 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
from . import outputs

__all__ = [
    'GetDatabaseRoleResult',
    'AwaitableGetDatabaseRoleResult',
    'get_database_role',
    'get_database_role_output',
]

@pulumi.output_type
class GetDatabaseRoleResult:
    """
    A collection of values returned by getDatabaseRole.
    """
    def __init__(__self__, database_id=None, id=None, members=None, name=None, owner_id=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 members and not isinstance(members, list):
            raise TypeError("Expected argument 'members' to be a list")
        pulumi.set(__self__, "members", members)
        if name and not isinstance(name, str):
            raise TypeError("Expected argument 'name' to be a str")
        pulumi.set(__self__, "name", name)
        if owner_id and not isinstance(owner_id, str):
            raise TypeError("Expected argument 'owner_id' to be a str")
        pulumi.set(__self__, "owner_id", owner_id)

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

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

    @property
    @pulumi.getter
    def members(self) -> Sequence['outputs.GetDatabaseRoleMemberResult']:
        """
        Set of role members
        """
        return pulumi.get(self, "members")

    @property
    @pulumi.getter
    def name(self) -> str:
        """
        Role name. Must follow [Regular Identifiers rules](https://docs.microsoft.com/en-us/sql/relational-databases/databases/database-identifiers#rules-for-regular-identifiers) and cannot be longer than 128 chars.
        """
        return pulumi.get(self, "name")

    @property
    @pulumi.getter(name="ownerId")
    def owner_id(self) -> str:
        """
        ID of another database role or user owning this role. Can be retrieved using `DatabaseRole` or `SqlUser`.
        """
        return pulumi.get(self, "owner_id")


class AwaitableGetDatabaseRoleResult(GetDatabaseRoleResult):
    # pylint: disable=using-constant-test
    def __await__(self):
        if False:
            yield self
        return GetDatabaseRoleResult(
            database_id=self.database_id,
            id=self.id,
            members=self.members,
            name=self.name,
            owner_id=self.owner_id)


def get_database_role(database_id: Optional[str] = None,
                      name: Optional[str] = None,
                      opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetDatabaseRoleResult:
    """
    Obtains information about single database role.

    ## Example Usage

    ```python
    import pulumi
    import pulumi_mssql as mssql

    master = mssql.get_database(name="master")
    example = mssql.get_database_role(name="public",
        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>')`. Defaults to ID of `master`.
    :param str name: Role name. Must follow [Regular Identifiers rules](https://docs.microsoft.com/en-us/sql/relational-databases/databases/database-identifiers#rules-for-regular-identifiers) and 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/getDatabaseRole:getDatabaseRole', __args__, opts=opts, typ=GetDatabaseRoleResult).value

    return AwaitableGetDatabaseRoleResult(
        database_id=__ret__.database_id,
        id=__ret__.id,
        members=__ret__.members,
        name=__ret__.name,
        owner_id=__ret__.owner_id)


@_utilities.lift_output_func(get_database_role)
def get_database_role_output(database_id: Optional[pulumi.Input[Optional[str]]] = None,
                             name: Optional[pulumi.Input[str]] = None,
                             opts: Optional[pulumi.InvokeOptions] = None) -> pulumi.Output[GetDatabaseRoleResult]:
    """
    Obtains information about single database role.

    ## Example Usage

    ```python
    import pulumi
    import pulumi_mssql as mssql

    master = mssql.get_database(name="master")
    example = mssql.get_database_role(name="public",
        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>')`. Defaults to ID of `master`.
    :param str name: Role name. Must follow [Regular Identifiers rules](https://docs.microsoft.com/en-us/sql/relational-databases/databases/database-identifiers#rules-for-regular-identifiers) and cannot be longer than 128 chars.
    """
    ...
