aistore.sdk.authn.user_manager

View as MarkdownOpen in Claude

Module Contents

Classes

NameDescription
UserManagerUserManager provides methods to manage users in the AuthN service.

Data

logger

API

class aistore.sdk.authn.user_manager.UserManager(
client: aistore.sdk.request_client.RequestClient
)

UserManager provides methods to manage users in the AuthN service.

Parameters:

client
RequestClient

The RequestClient used to make HTTP requests.

_role_manager
= RoleManager(client)
client
RequestClient

Returns the RequestClient instance used by this UserManager.

aistore.sdk.authn.user_manager.UserManager._get_roles_from_names(
role_names: typing.List[str]
) -> aistore.sdk.authn.types.RolesList

Helper function to convert a list of role names into a RolesList.

Parameters:

role_names
List[str]

List of role names to convert.

Returns: RolesList

The corresponding RolesList object.

Raises:

  • ValueError: If any role name is not found.
aistore.sdk.authn.user_manager.UserManager.create(
username: str,
roles: typing.List[str],
password: str
) -> aistore.sdk.authn.types.UserInfo

Create a new user in the AuthN Server.

Parameters:

username
str

The name or ID of the user to create.

password
str

The password for the user.

roles
List[str]

The list of names of roles to assign to the user.

Returns: UserInfo

The created user’s information.

Raises:

  • AISError: If the user creation request fails.
aistore.sdk.authn.user_manager.UserManager.delete(
username: str,
missing_ok: bool = False
) -> None

Delete an existing user from the AuthN Server.

Parameters:

username
str

The username of the user to delete.

missing_ok
boolDefaults to False

Ignore error if user does not exist. Defaults to False.

Raises:

  • ErrUserNotFound: If the user does not exist and missing_ok is False.
  • AISError: If the user deletion request fails.
aistore.sdk.authn.user_manager.UserManager.get(
username: str
) -> aistore.sdk.authn.types.UserInfo

Retrieve user information from the AuthN Server.

Parameters:

username
str

The username to retrieve.

Returns: UserInfo

The user’s information.

Raises:

  • AISError: If the user retrieval request fails.
aistore.sdk.authn.user_manager.UserManager.list() -> aistore.sdk.authn.types.UserMap

Get all users in the AuthN Server.

Returns: UserMap

A map of user IDs to their info in the AuthN Server.

Raises:

  • AISError: If the user list request fails.
aistore.sdk.authn.user_manager.UserManager.update(
username: str,
password: typing.Optional[str] = None,
roles: typing.Optional[typing.List[str]] = None
) -> aistore.sdk.authn.types.UserInfo

Update an existing user’s information in the AuthN Server.

Parameters:

username
str

The ID of the user to update.

password
strDefaults to None

The new password for the user.

roles
List[str]Defaults to None

The list of names of roles to assign to the user.

Returns: UserInfo

The updated user’s information.

Raises:

  • ValueError: If neither password nor roles are provided.
  • AISError: If the user update request fails.
aistore.sdk.authn.user_manager.logger = get_logger(__name__)