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.

Requirements#

Authentication Methods#

After importing and initializing the client, these methods can be executed via client.auth.METHOD_NAME().

Login#

AuthCollectionClient.login(username: str, password: str) dioptra.client.auth.T[source]#

Send a login request to the Dioptra API.

Parameters
  • username – The username of the user.

  • password – The password of the user.

Returns

The response from the Dioptra API.

Logout#

AuthCollectionClient.logout(everywhere: bool = False) dioptra.client.auth.T[source]#

Send a logout request to the Dioptra API.

Parameters

everywhere – If True, log out from all sessions.

Returns

The response from the Dioptra API.

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#

UsersCollectionClient.get_by_id(user_id: str | int) dioptra.client.users.T[source]#

Get the user matching the provided id.

Parameters

user_id – The user id, an integer.

Returns

The response from the Dioptra API.

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#

UsersCollectionClient.get_current() dioptra.client.users.T[source]#

Get details about the currently logged-in user.

Returns

The response from the Dioptra API.

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#

UsersCollectionClient.delete_current_user(password: str) dioptra.client.users.T[source]#

Delete the currently logged-in user.

Parameters

password – The password of the currently logged-in user. The deletion will fail if this is incorrect.

Returns

The response from the Dioptra API.

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.

Get Group by ID#

GroupsCollectionClient.get_by_id(group_id: str | int) dioptra.client.groups.T[source]#

Get the group matching the provided id.

Parameters

group_id – The group id, an integer.

Returns

The response from the Dioptra API.

See Also#