UsersClient
Client for managing users in the Datagrok platform. Provides methods to retrieve, update, list, block, and unblock users, as well as to get information about the current authenticated user.
Examples
Get user by login
>>> from datagrok_api import DatagrokClient
>>> from datagrok_api.models import Func, Script, ScriptLanguage, DataQuery
>>> grok = DatagrokClient(base_url="https://public.datagrok.ai/api", api_key="Bearer <your-token>")
>>> john_doe = grok.users.get("johndoe")
>>> print(john_doe.first_name)
... John
Get current authenticated user
>>> me = grok.users.current()
Methods
__init__()
get()
Get detailed information about a specific user.
Parameters
| Name | Type | Description |
|---|---|---|
| id | str | ID or login of the user to retrieve |
Returns
| Type | Description |
|---|---|
| User | User instance with detailed information |
save()
Save or update User.
Parameters
| Name | Type | Description |
|---|---|---|
| user | User | The user to save or update |
Returns
| Type | Description |
|---|---|
| User | The saved user instance |
current()
Returns the current authenticated user.
Returns
| Type | Description |
|---|---|
| User | User instance representing the current user |
list()
List users from Datagrok with optional filtering and inclusion of related data.
Parameters
| Name | Type | Description |
|---|---|---|
| smart_filter | Optional[str] | Optional smart search filter to apply |
| include_group | bool | Whether to include personal group in the results |
Returns
| Type | Description |
|---|---|
| List[User] | List of User instances matching the criteria |
block()
Block a user from accessing the Datagrok platform.
Parameters
| Name | Type | Description |
|---|---|---|
| user | User | The user to block. |
unblock()
Unblock a previously blocked user.
Parameters
| Name | Type | Description |
|---|---|---|
| user | User | The user to unblock. |