Auth, Users, and Groups Client Methods#
This page lists all relevant methods for Dioptra Authentication, User management, and Group management that are available via the Python Client.
Contents
Requirements#
Install Dioptra - an installation and deployment of Dioptra must be available
Set Up the Python Client - the Python client must be configured and initialized
Authentication Methods#
After importing and initializing the client, these methods can be executed via client.auth.METHOD_NAME().
Login#
Logout#
Users - General Methods#
These methods relate to general user management and retrieval. They can be executed via client.users.METHOD_NAME().
Get All Users#
- UsersCollectionClient.get(index: int = 0, page_length: int = 10, search: str | None = None) dioptra.client.users.T[source]#
Get a list of Dioptra users.
- Parameters
index – The paging index. Optional, defaults to 0.
page_length – The maximum number of users to return in the paged response. Optional, defaults to 10.
search – Search for users using the Dioptra API’s query language. Optional, defaults to None.
- Returns
The response from the Dioptra API.
Create User#
- UsersCollectionClient.create(username: str, email: str, password: str) dioptra.client.users.T[source]#
Creates a Dioptra user.
- Parameters
username – The username of the new user.
email – The email address of the new user.
password – The password to set for the new user.
- Returns
The response from the Dioptra API.
Get User by ID#
Change User Password by ID#
- UsersCollectionClient.change_password_by_id(user_id: str | int, old_password: str, new_password: str) dioptra.client.users.T[source]#
Change the password of the user matching the provided id.
This primary use case for using this over change_current_user_password is if your password has expired and you need to update it before you can log in.
- Parameters
user_id – The user id, an integer.
old_password – The user’s current password. The password change will fail if this is incorrect.
new_password – The new password to set for the user.
- Returns
The response from the Dioptra API.
Users - Current User Methods#
These methods interact specifically with the currently authenticated user session (the user logged in via the client).
Get Current User#
Modify Current User#
- UsersCollectionClient.modify_current_user(username: str, email: str) dioptra.client.users.T[source]#
Modify details about the currently logged-in user.
- Parameters
username – The new username for the currently logged-in user.
email – The new email address for the currently logged-in user.
- Returns
The response from the Dioptra API.
Change Current User Password#
- UsersCollectionClient.change_current_user_password(old_password: str, new_password: str) dioptra.client.users.T[source]#
Change the currently logged-in user’s password.
- Parameters
old_password – The currently logged-in user’s current password. The password change will fail if this is incorrect.
new_password – The new password to set for the currently logged-in user.
- Returns
The response from the Dioptra API.
Delete Current User#
Groups Methods#
These methods relate to group management and retrieval. They can be executed via client.groups.METHOD_NAME().
Important
Groups are only partially implemented in Dioptra currently. All users are created under a single “Public” group. At this time, the creation of custom groups is not yet supported.
Get All Groups#
- GroupsCollectionClient.get(index: int = 0, page_length: int = 10, search: str | None = None) dioptra.client.groups.T[source]#
Get a list of groups.
- Parameters
index – The paging index. Optional, defaults to 0.
page_length – The maximum number of groups to return in the paged response. Optional, defaults to 10.
search – Search for groups using the Dioptra API’s query language. Optional, defaults to None.
- Returns
The response from the Dioptra API.