connect.users
connect.users
User resources.
Classes
Name | Description |
---|---|
User | |
Users | Users resource. |
User
connect.users.User(self, /, params, **kwargs)
Attributes
Name | Description |
---|---|
content |
Classes
Name | Description |
---|---|
UpdateUser | Update user request. |
UpdateUser
connect.users.User.UpdateUser()
Update user request.
Attributes
Name | Description |
---|---|
first_name | |
last_name | |
user_role | |
username |
Methods
Name | Description |
---|---|
lock | Lock the user account. |
unlock | Unlock the user account. |
update | Update the user’s attributes. |
lock
connect.users.User.lock(force=False)
Lock the user account.
You cannot unlock your own account unless you have administrative privileges. Once an account is locked, only an admin can unlock it.
Parameters
Name | Type | Description | Default |
---|---|---|---|
force | bool | If True , overrides lock protection allowing a user to lock their own account. Default is False . |
False |
Returns
Name | Type | Description |
---|---|---|
None |
Examples
Lock another user’s account:
>>> user.lock()
Attempt to lock your own account (will raise RuntimeError
unless force
is set to True
):
>>> user.lock(force=True)
unlock
connect.users.User.unlock()
Unlock the user account.
This method unlocks the specified user’s account. You must have administrative privileges to unlock accounts other than your own.
Returns
Name | Type | Description |
---|---|---|
None |
Examples
Unlock a user’s account:
>>> user.unlock()
update
connect.users.User.update(**kwargs)
Update the user’s attributes.
Parameters
Name | Type | Description | Default |
---|---|---|---|
(str, not required ) |
The new email address for the user. Default is None . |
required | |
username | (str, not required ) |
The new username for the user. Default is None . |
required |
first_name | (str, not required ) |
The new first name for the user. Default is None . |
required |
last_name | (str, not required ) |
The new last name for the user. Default is None . |
required |
user_role | (Literal['administrator', 'publisher', 'viewer'], not required ) |
The new role for the user. Options are 'administrator' , 'publisher' , 'viewer' . Default is None . |
required |
Returns
Name | Type | Description |
---|---|---|
None |
Examples
Update the user’s email and role:
>>> user.update(email="newemail@example.com", user_role="publisher")
Update the user’s first and last name:
>>> user.update(first_name="Jane", last_name="Smith")
Users
connect.users.Users(self, params)
Users resource.
Classes
Name | Description |
---|---|
CreateUser | Create user request. |
FindUser | Find user request. |
CreateUser
connect.users.Users.CreateUser()
Create user request.
Attributes
Name | Description |
---|---|
first_name | |
last_name | |
password | |
unique_id | |
user_must_set_password | |
user_role | |
username |
FindUser
connect.users.Users.FindUser()
Find user request.
Attributes
Name | Description |
---|---|
account_status | |
prefix | |
user_role |
Methods
Name | Description |
---|---|
count | Return the total number of users. |
create | Create a new user with the specified attributes. |
find | Find users matching the specified conditions. |
find_one | Find a user matching the specified conditions. |
get | Retrieve a user by their unique identifier (guid). |
count
connect.users.Users.count()
Return the total number of users.
Returns
Name | Type | Description |
---|---|---|
int |
create
connect.users.Users.create(**attributes)
Create a new user with the specified attributes.
Applies when server setting ‘Authentication.Provider’ is set to ‘ldap’, ‘oauth2’, ‘pam’, ‘password’, ‘proxy’, or ‘saml’.
Parameters
Name | Type | Description | Default |
---|---|---|---|
username | (str, required ) |
The user’s desired username. | required |
password | (str, not required ) |
Applies when server setting ‘Authentication.Provider=“password”’. Cannot be set when user_must_set_password is True . |
required |
user_must_set_password | (bool, not required ) |
If True , the user is prompted to set their password on first login. When False , the password parameter is used. Default is False . Applies when server setting ‘Authentication.Provider=“password”’. |
required |
(str, not required ) |
The user’s email address. | required | |
first_name | (str, not required ) |
The user’s first name. | required |
last_name | (str, not required ) |
The user’s last name. | required |
user_role | (Literal['administrator', 'publisher', 'viewer'], not required ) |
The user role. Options are 'administrator' , 'publisher' , 'viewer' . Falls back to server setting ‘Authorization.DefaultUserRole’. |
required |
unique_id | str, maybe required | Required when server is configured with SAML or OAuth2 (non-Google) authentication. Applies when server setting ProxyAuth.UniqueIdHeader is set. |
required |
Returns
Name | Type | Description |
---|---|---|
User | The newly created user. |
Examples
Create a user with a predefined password:
>>> user = client.create(
="jdoe",
... username="jdoe@example.com",
... email="John",
... first_name="Doe",
... last_name="s3cur3p@ssword",
... password="viewer",
... user_role ... )
Create a user who must set their own password:
>>> user = client.create(
="jdoe",
... username="jdoe@example.com",
... email="John",
... first_name="Doe",
... last_name=True,
... user_must_set_password="viewer",
... user_role ... )
find
connect.users.Users.find(**conditions)
Find users matching the specified conditions.
Parameters
Name | Type | Description | Default |
---|---|---|---|
prefix | (str, not required ) |
Filter users by prefix (username, first name, or last name). The filter is case-insensitive. | required |
user_role | (Literal['administrator', 'publisher', 'viewer'], not required ) |
Filter by user role. Options are 'administrator' , 'publisher' , 'viewer' . Use '\|' to represent logical OR (e.g., 'viewer\|publisher' ). |
required |
account_status | (Literal['locked', 'licensed', 'inactive'], not required ) |
Filter by account status. Options are 'locked' , 'licensed' , 'inactive' . Use '\|' to represent logical OR. For example, 'locked\|licensed' includes users who are either locked or licensed. |
required |
Returns
Name | Type | Description |
---|---|---|
List[User] | A list of users matching the specified conditions. |
Examples
Find all users with a username, first name, or last name starting with ‘jo’:
>>> users = client.find(prefix="jo")
Find all users who are either viewers or publishers:
>>> users = client.find(user_role="viewer|publisher")
Find all users who are locked or licensed:
>>> users = client.find(account_status="locked|licensed")
find_one
connect.users.Users.find_one(**conditions)
Find a user matching the specified conditions.
Parameters
Name | Type | Description | Default |
---|---|---|---|
prefix | str | Filter users by prefix (username, first name, or last name). The filter is case-insensitive. Default is None . |
required |
user_role | Literal['administrator', 'publisher', 'viewer'] | Filter by user role. Options are 'administrator' , 'publisher' , 'viewer' . Use '\|' to represent logical OR (e.g., 'viewer\|publisher' ). Default is None . |
required |
account_status | Literal['locked', 'licensed', 'inactive'] | Filter by account status. Options are 'locked' , 'licensed' , 'inactive' . Use '\|' to represent logical OR. For example, 'locked\|licensed' includes users who are either locked or licensed. Default is None . |
required |
Returns
Name | Type | Description |
---|---|---|
User or None | The first user matching the specified conditions, or None if no user is found. |
Examples
Find a user with a username, first name, or last name starting with ‘jo’:
>>> user = client.find_one(prefix="jo")
Find a user who is either a viewer or publisher:
>>> user = client.find_one(user_role="viewer|publisher")
Find a user who is locked or licensed:
>>> user = client.find_one(account_status="locked|licensed")
get
connect.users.Users.get(uid)
Retrieve a user by their unique identifier (guid).
Parameters
Name | Type | Description | Default |
---|---|---|---|
uid | str | The unique identifier (guid) of the user to retrieve. | required |
Returns
Name | Type | Description |
---|---|---|
User |
Examples
>>> user = client.get("123e4567-e89b-12d3-a456-426614174000")