# 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__ = [
    'GetServerPermissionsResult',
    'AwaitableGetServerPermissionsResult',
    'get_server_permissions',
    'get_server_permissions_output',
]

@pulumi.output_type
class GetServerPermissionsResult:
    """
    A collection of values returned by getServerPermissions.
    """
    def __init__(__self__, id=None, permissions=None, principal_id=None):
        if id and not isinstance(id, str):
            raise TypeError("Expected argument 'id' to be a str")
        pulumi.set(__self__, "id", id)
        if permissions and not isinstance(permissions, list):
            raise TypeError("Expected argument 'permissions' to be a list")
        pulumi.set(__self__, "permissions", permissions)
        if principal_id and not isinstance(principal_id, str):
            raise TypeError("Expected argument 'principal_id' to be a str")
        pulumi.set(__self__, "principal_id", principal_id)

    @property
    @pulumi.getter
    def id(self) -> str:
        """
        Equals to `principal_id`.
        """
        return pulumi.get(self, "id")

    @property
    @pulumi.getter
    def permissions(self) -> Sequence['outputs.GetServerPermissionsPermissionResult']:
        """
        Set of permissions granted to the principal
        """
        return pulumi.get(self, "permissions")

    @property
    @pulumi.getter(name="principalId")
    def principal_id(self) -> str:
        """
        ID of the principal who will be granted `permission`. Can be retrieved using `ServerRole` or `SqlLogin`.
        """
        return pulumi.get(self, "principal_id")


class AwaitableGetServerPermissionsResult(GetServerPermissionsResult):
    # pylint: disable=using-constant-test
    def __await__(self):
        if False:
            yield self
        return GetServerPermissionsResult(
            id=self.id,
            permissions=self.permissions,
            principal_id=self.principal_id)


def get_server_permissions(principal_id: Optional[str] = None,
                           opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetServerPermissionsResult:
    """
    Returns all permissions grated to given principal

    ## Example Usage

    ```python
    import pulumi
    import pulumi_mssql as mssql

    example_sql_login = mssql.get_sql_login(name="example_login")
    example_server_permissions = mssql.get_server_permissions(principal_id=example_sql_login.principal_id)
    pulumi.export("permissions", example_server_permissions.permissions)
    ```


    :param str principal_id: ID of the principal who will be granted `permission`. Can be retrieved using `ServerRole` or `SqlLogin`.
    """
    __args__ = dict()
    __args__['principalId'] = principal_id
    opts = pulumi.InvokeOptions.merge(_utilities.get_invoke_opts_defaults(), opts)
    __ret__ = pulumi.runtime.invoke('mssql:index/getServerPermissions:getServerPermissions', __args__, opts=opts, typ=GetServerPermissionsResult).value

    return AwaitableGetServerPermissionsResult(
        id=pulumi.get(__ret__, 'id'),
        permissions=pulumi.get(__ret__, 'permissions'),
        principal_id=pulumi.get(__ret__, 'principal_id'))


@_utilities.lift_output_func(get_server_permissions)
def get_server_permissions_output(principal_id: Optional[pulumi.Input[str]] = None,
                                  opts: Optional[pulumi.InvokeOptions] = None) -> pulumi.Output[GetServerPermissionsResult]:
    """
    Returns all permissions grated to given principal

    ## Example Usage

    ```python
    import pulumi
    import pulumi_mssql as mssql

    example_sql_login = mssql.get_sql_login(name="example_login")
    example_server_permissions = mssql.get_server_permissions(principal_id=example_sql_login.principal_id)
    pulumi.export("permissions", example_server_permissions.permissions)
    ```


    :param str principal_id: ID of the principal who will be granted `permission`. Can be retrieved using `ServerRole` or `SqlLogin`.
    """
    ...
