# coding=utf-8
# *** WARNING: this file was generated by pulumi-language-python. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***

import builtins as _builtins
import warnings
import sys
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union, overload
if sys.version_info >= (3, 11):
    from typing import NotRequired, TypedDict, TypeAlias
else:
    from typing_extensions import NotRequired, TypedDict, TypeAlias
from . import _utilities
from . import outputs
from ._inputs import *

__all__ = [
    'GetUsersResult',
    'AwaitableGetUsersResult',
    'get_users',
    'get_users_output',
]

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

    @_builtins.property
    @pulumi.getter(name="extraAttributes")
    def extra_attributes(self) -> Optional[_builtins.str]:
        return pulumi.get(self, "extra_attributes")

    @_builtins.property
    @pulumi.getter
    def filter(self) -> Optional[_builtins.str]:
        return pulumi.get(self, "filter")

    @_builtins.property
    @pulumi.getter
    def id(self) -> _builtins.str:
        """
        The provider-assigned unique ID for this managed resource.
        """
        return pulumi.get(self, "id")

    @_builtins.property
    @pulumi.getter
    def users(self) -> Sequence['outputs.GetUsersUserResult']:
        """
        A list of users matching the specified criteria. Each user has the following attributes:
        """
        return pulumi.get(self, "users")


class AwaitableGetUsersResult(GetUsersResult):
    # pylint: disable=using-constant-test
    def __await__(self):
        if False:
            yield self
        return GetUsersResult(
            extra_attributes=self.extra_attributes,
            filter=self.filter,
            id=self.id,
            users=self.users)


def get_users(extra_attributes: Optional[_builtins.str] = None,
              filter: Optional[_builtins.str] = None,
              users: Optional[Sequence[Union['GetUsersUserArgs', 'GetUsersUserArgsDict']]] = None,
              opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetUsersResult:
    """
    Retrieves information about multiple User resources.

    > This data source works with both the account-level and workspace-level provider.

    ## Example Usage

    Adding a subset of users to a group

    ```python
    import pulumi
    import pulumi_databricks as databricks

    company_users = databricks.get_users(filter="userName co \\"@domain.org\\"")
    data_users_group = databricks.Group("data_users_group", display_name="Data Users")
    add_users_to_group = []
    for range in [{"key": k, "value": v} for [k, v] in enumerate({user.id: user for user in company_users.users})]:
        add_users_to_group.append(databricks.GroupMember(f"add_users_to_group-{range['key']}",
            group_id=data_users_group.id,
            member_id=%!v(PANIC=Format method: runtime error: index out of range [-1])))
    ```

    ## Related Resources

    The following resources are used in the same context:

    - **databricks_user**: Resource to manage individual users in Databricks.
    - **databricks_group**: Resource to manage groups in Databricks.
    - **databricks_group_member**: Resource to manage group memberships by adding users to groups.
    - **databricks_permissions**: Resource to manage access control in the Databricks workspace.
    - **databricks_current_user**: Data source to retrieve information about the user or service principal that is calling the Databricks REST API.


    :param _builtins.str extra_attributes: A comma-separated list of additional user attributes to include in the results. By default, the data source returns the following attributes: `id`, `userName`, `displayName`, and `externalId`. Use this argument to request additional attributes as needed. The list of all available attributes can be found in the [API reference](https://docs.databricks.com/api/workspace/users/list).
    :param _builtins.str filter: Query by which the results have to be filtered. If not specified, all users will be returned. Supported operators are equals (`eq`), contains (`co`), starts with (`sw`), and not equals (`ne`). Additionally, simple expressions can be formed using logical operators `and` and `or`.
           
           **Examples:**
           - User whose `displayName` equals "john":
    :param Sequence[Union['GetUsersUserArgs', 'GetUsersUserArgsDict']] users: A list of users matching the specified criteria. Each user has the following attributes:
    """
    __args__ = dict()
    __args__['extraAttributes'] = extra_attributes
    __args__['filter'] = filter
    __args__['users'] = users
    opts = pulumi.InvokeOptions.merge(_utilities.get_invoke_opts_defaults(), opts)
    __ret__ = pulumi.runtime.invoke('databricks:index/getUsers:getUsers', __args__, opts=opts, typ=GetUsersResult).value

    return AwaitableGetUsersResult(
        extra_attributes=pulumi.get(__ret__, 'extra_attributes'),
        filter=pulumi.get(__ret__, 'filter'),
        id=pulumi.get(__ret__, 'id'),
        users=pulumi.get(__ret__, 'users'))
def get_users_output(extra_attributes: Optional[pulumi.Input[Optional[_builtins.str]]] = None,
                     filter: Optional[pulumi.Input[Optional[_builtins.str]]] = None,
                     users: Optional[pulumi.Input[Optional[Sequence[Union['GetUsersUserArgs', 'GetUsersUserArgsDict']]]]] = None,
                     opts: Optional[Union[pulumi.InvokeOptions, pulumi.InvokeOutputOptions]] = None) -> pulumi.Output[GetUsersResult]:
    """
    Retrieves information about multiple User resources.

    > This data source works with both the account-level and workspace-level provider.

    ## Example Usage

    Adding a subset of users to a group

    ```python
    import pulumi
    import pulumi_databricks as databricks

    company_users = databricks.get_users(filter="userName co \\"@domain.org\\"")
    data_users_group = databricks.Group("data_users_group", display_name="Data Users")
    add_users_to_group = []
    for range in [{"key": k, "value": v} for [k, v] in enumerate({user.id: user for user in company_users.users})]:
        add_users_to_group.append(databricks.GroupMember(f"add_users_to_group-{range['key']}",
            group_id=data_users_group.id,
            member_id=%!v(PANIC=Format method: runtime error: index out of range [-1])))
    ```

    ## Related Resources

    The following resources are used in the same context:

    - **databricks_user**: Resource to manage individual users in Databricks.
    - **databricks_group**: Resource to manage groups in Databricks.
    - **databricks_group_member**: Resource to manage group memberships by adding users to groups.
    - **databricks_permissions**: Resource to manage access control in the Databricks workspace.
    - **databricks_current_user**: Data source to retrieve information about the user or service principal that is calling the Databricks REST API.


    :param _builtins.str extra_attributes: A comma-separated list of additional user attributes to include in the results. By default, the data source returns the following attributes: `id`, `userName`, `displayName`, and `externalId`. Use this argument to request additional attributes as needed. The list of all available attributes can be found in the [API reference](https://docs.databricks.com/api/workspace/users/list).
    :param _builtins.str filter: Query by which the results have to be filtered. If not specified, all users will be returned. Supported operators are equals (`eq`), contains (`co`), starts with (`sw`), and not equals (`ne`). Additionally, simple expressions can be formed using logical operators `and` and `or`.
           
           **Examples:**
           - User whose `displayName` equals "john":
    :param Sequence[Union['GetUsersUserArgs', 'GetUsersUserArgsDict']] users: A list of users matching the specified criteria. Each user has the following attributes:
    """
    __args__ = dict()
    __args__['extraAttributes'] = extra_attributes
    __args__['filter'] = filter
    __args__['users'] = users
    opts = pulumi.InvokeOutputOptions.merge(_utilities.get_invoke_opts_defaults(), opts)
    __ret__ = pulumi.runtime.invoke_output('databricks:index/getUsers:getUsers', __args__, opts=opts, typ=GetUsersResult)
    return __ret__.apply(lambda __response__: GetUsersResult(
        extra_attributes=pulumi.get(__response__, 'extra_attributes'),
        filter=pulumi.get(__response__, 'filter'),
        id=pulumi.get(__response__, 'id'),
        users=pulumi.get(__response__, 'users')))
