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:
-
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.
At least one of name or id must be provided. When both are given, name takes precedence.
Parameters:
-
(namestr | None, default:None) –The username to look up.
-
(idint | None, default:None) –The numeric user ID to look up.
-
(first_namestr | None, default:None) –The first name of the user.
-
(last_namestr | None, default:None) –The last name of the user.
-
(emailstr | None, default:None) –The email address of the user.
-
(groupslist[str] | None, default:None) –The list of groups the user belongs to.
-
(is_system_userbool, default:False) –Whether the user is a system user.
Raises:
-
ValueError–If neither name nor id is provided.
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.
add
staticmethod
Create a new user on the Datatailr platform.
Parameters:
-
(namestr) –The username for the new user.
-
(first_namestr) –The user's first name.
-
(last_namestr) –The user's last name.
-
(emailstr) –The user's email address.
-
(passwordstr) –The login password. Ignored for system users.
-
(groupslist[str] | None, default:None) –Optional list of group names to add the user to.
-
(is_system_userbool, default:False) –If
True, create a non-interactive system user.
Returns:
-
'User' | None–The newly created User, or
Noneif the operation failed.
Raises:
-
Warning–If a password is provided for a system user.
Notes
Passwords are ignored for system users.
exists
staticmethod
Check whether a user with the given username exists.
Parameters:
-
(namestr) –The username to look up.
Returns:
-
bool–Trueif the user exists,Falseotherwise.
from_dict
classmethod
Construct a User instance from a dictionary.
get
staticmethod
Retrieve an existing user by username or numeric ID.
Parameters:
-
(name_or_idstr | int) –The username (str) or user ID (int).
Returns:
-
User–The matching User instance.
Raises:
-
ValueError–If no user with the given name or ID exists.
ls
staticmethod
List all users available in the Datatailr platform.
Parameters:
-
(filterstr | None, default:None) –A filter expression to apply to the users.
Examples:
>>> from datatailr import User
>>> User.ls()
[...User(name=root, first_name=Super User, last_name=, email=, user_id=0, groups=[''], is_system_user=True), ...]
Returns:
-
list–A list of User instances.
remove
staticmethod
Remove (delete) a user from the platform.
Parameters:
-
(namestr) –The username of the user to remove.
signed_user
staticmethod
Retrieve the currently signed-in (authenticated) user.
Returns:
-
User–The User instance of the currently authenticated user.
Raises:
-
PermissionError–If no signed-in user is found.
to_cookie
Return a cookie string for the user.
verify
Verify the user's authentication signature with the platform.
This refreshes and validates the user's credentials against the Datatailr authentication service.