User
Representing a Datatailr User.
This class provides methods to interact with the Datatailr User API. It allows you to create, update, delete, and manage users within the Datatailr platform.
Attributes:
| Name | Type | Description |
|---|---|---|
first_name |
str
|
The first name of the user. |
last_name |
str
|
The last name of the user. |
name |
str
|
The username of the user. |
email |
str
|
The email address of the user. |
user_id |
int
|
The unique identifier for the user. |
groups |
list
|
List of groups the user belongs to. |
is_system_user |
bool
|
Indicates if the user is a system user. |
Static Methods
signed_user() -> Optional['User']: Retrieve the currently signed-in user, if available. add(name: str, first_name: str = None, last_name: str = None, email: str = None, password: str = None, groups: list[str] = [], is_system_user: bool = False) -> 'User': Create a new user with the specified username, first name, last name, and email. get(name: str) -> 'User': Retrieve a user by their username. exists(name: str) -> bool: Check if a user exists by their username. ls() -> list: List all users available in the Datatailr platform. remove(name: str) -> None: Remove a user by their username.
Instance Methods
verify() -> None: Refresh the user information from the Datatailr API.
email
property
The email address of the user.
first_name
property
The first name of the user.
groups
property
List of group names the user belongs to.
is_system_user
property
Whether this user is a system (non-interactive) user.
last_name
property
The last name of the user.
name
property
The username.
user_id
property
The unique numeric identifier of the user.
__init__(name=None, id=None)
Create a User instance by fetching user data from the platform.
At least one of name or id must be provided. When both are given, name takes precedence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
The username to look up. |
None
|
id
|
int | None
|
The numeric user ID to look up. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither name nor id is provided. |
add(name, first_name, last_name, email, password, groups=None, is_system_user=False)
staticmethod
Create a new user on the Datatailr platform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The username for the new user. |
required |
first_name
|
str
|
The user's first name. |
required |
last_name
|
str
|
The user's last name. |
required |
email
|
str
|
The user's email address. |
required |
password
|
str
|
The login password. Ignored for system users. |
required |
groups
|
list[str] | None
|
Optional list of group names to add the user to. |
None
|
is_system_user
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
Optional['User']
|
The newly created User, or |
exists(name)
staticmethod
Check whether a user with the given username exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The username to look up. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
get(name_or_id)
staticmethod
Retrieve an existing user by username or numeric ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name_or_id
|
str | int
|
The username (str) or user ID (int). |
required |
Returns:
| Type | Description |
|---|---|
User
|
The matching User instance. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no user with the given name or ID exists. |
ls()
staticmethod
from datatailr import User User.ls() [User(name=root, first_name=Super User, last_name=, email=None, user_id=0, groups=[], is_system_user=True), ...]
remove(name)
staticmethod
Remove (delete) a user from the platform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The username of the user to remove. |
required |
signed_user()
staticmethod
Retrieve the currently signed-in (authenticated) user.
Returns:
| Type | Description |
|---|---|
User
|
The User instance of the currently authenticated user. |
Raises:
| Type | Description |
|---|---|
PermissionError
|
If no signed-in user is found. |
verify()
Verify the user's authentication signature with the platform.
This refreshes and validates the user's credentials against the Datatailr authentication service.