Users
get_user(user_id)
async
get_user_by_username(username)
async
Get information about a user by username.
This is a convenience method for searching for a user by username and then getting the full user information with its ID.
See:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username |
str
|
The username of the user to get information about |
required |
Returns:
Type | Description |
---|---|
UserResp
|
Information about the user. |
create_user(user)
async
Create a new user. Can only be used when the authentication mode is for local DB, when self registration is disabled.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user |
UserCreationReq
|
The user to create |
required |
Returns:
Type | Description |
---|---|
str
|
The location of the created user |
update_user(user_id, user)
async
Update a user's profile.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user_id |
int
|
The ID of the user to update |
required |
user |
UserProfile
|
The user profile to update |
required |
delete_user(user_id, missing_ok=None)
async
get_users(query=None, sort=None, page=1, page_size=10, limit=None)
async
Get all users.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query |
Optional[str]
|
Query string to filter the users. Supported query patterns are:
The value of range and list can be:
All of these query patterns should be put in the query string
and separated by |
None
|
sort |
Optional[str]
|
Comma-separated string of fields to sort by.
Prefix with |
None
|
page |
int
|
The page number to retrieve |
1
|
page_size |
int
|
The number of users to retrieve per page |
10
|
limit |
Optional[int]
|
The maximum number of users to retrieve. |
None
|
Returns:
Type | Description |
---|---|
List[UserResp]
|
A list of users. |
search_users_by_username(username, page=1, page_size=100, limit=None, **kwargs)
async
set_user_admin(user_id, is_admin)
async
set_user_password(user_id, new_password, old_password=None)
async
Set a user's password. Admin users can change any user's password. Non-admin users can only change their own password.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user_id |
int
|
The ID of the user to set the password for |
required |
new_password |
str
|
The new password to set for the user |
required |
old_password |
str
|
The old password for the user, not required if API user is admin. |
None
|
Raises:
Type | Description |
---|---|
BadRequest
|
Raised for any of the following reasons:
|
set_user_cli_secret(user_id, secret)
async
Set the CLI secret for a user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user_id |
int
|
The ID of the user to set the secret for |
required |
secret |
str
|
The secret to set for the user |
required |
Raises:
Type | Description |
---|---|
BadRequest
|
Invalid user ID. Or user is not onboarded via OIDC authentication. Or the secret does not meet the standard. (This is a Harbor API implementation detail.) |
get_current_user()
async
Get information about the current user.
Returns:
Type | Description |
---|---|
UserResp
|
Information about the current user. |
get_current_user_permissions(scope=None, relative=False)
async
Get current user permissions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scope |
Optional[str]
|
The scope for the permission |
None
|
relative |
bool
|
Display resource paths relative to the scope.
Has no effect if |
False
|
Returns:
Type | Description |
---|---|
List[Permission]
|
A list of Permission objects for the current user. |