# 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__ = [
    'GetServerRoleResult',
    'AwaitableGetServerRoleResult',
    'get_server_role',
    'get_server_role_output',
]

@pulumi.output_type
class GetServerRoleResult:
    """
    A collection of values returned by getServerRole.
    """
    def __init__(__self__, id=None, members=None, name=None, owner_id=None):
        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
    def id(self) -> str:
        """
        Role principal ID. Either `name` or `id` must be provided.
        """
        return pulumi.get(self, "id")

    @property
    @pulumi.getter
    def members(self) -> Sequence['outputs.GetServerRoleMemberResult']:
        """
        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. Either `name` or `id` must be provided.
        """
        return pulumi.get(self, "name")

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


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


def get_server_role(id: Optional[str] = None,
                    name: Optional[str] = None,
                    opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetServerRoleResult:
    """
    Obtains information about single server role.

    ## Example Usage

    ```python
    import pulumi
    import pulumi_mssql as mssql

    by_name = mssql.get_server_role(name="example")
    by_id = mssql.get_server_role(id="8")
    ```


    :param str id: Role principal ID. Either `name` or `id` must be provided.
    :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. Either `name` or `id` must be provided.
    """
    __args__ = dict()
    __args__['id'] = id
    __args__['name'] = name
    opts = pulumi.InvokeOptions.merge(_utilities.get_invoke_opts_defaults(), opts)
    __ret__ = pulumi.runtime.invoke('mssql:index/getServerRole:getServerRole', __args__, opts=opts, typ=GetServerRoleResult).value

    return AwaitableGetServerRoleResult(
        id=pulumi.get(__ret__, 'id'),
        members=pulumi.get(__ret__, 'members'),
        name=pulumi.get(__ret__, 'name'),
        owner_id=pulumi.get(__ret__, 'owner_id'))


@_utilities.lift_output_func(get_server_role)
def get_server_role_output(id: Optional[pulumi.Input[Optional[str]]] = None,
                           name: Optional[pulumi.Input[Optional[str]]] = None,
                           opts: Optional[pulumi.InvokeOptions] = None) -> pulumi.Output[GetServerRoleResult]:
    """
    Obtains information about single server role.

    ## Example Usage

    ```python
    import pulumi
    import pulumi_mssql as mssql

    by_name = mssql.get_server_role(name="example")
    by_id = mssql.get_server_role(id="8")
    ```


    :param str id: Role principal ID. Either `name` or `id` must be provided.
    :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. Either `name` or `id` must be provided.
    """
    ...
