vantage6.client.subclients.store.role.StoreRoleSubClient

class StoreRoleSubClient(parent)

Bases: SubClient

Subclient for the roles from the algorithm store.

__init__(parent)

Methods

__init__(parent)

create(name, description, rules)

Create a new role

delete(role_id)

Delete an existing role

edit(role_id[, name, description, rules])

Edit an existing role

list([name, description, user, page, per_page])

List algorithms

create(name, description, rules)

Create a new role

Parameters:
  • name (str) – Name of the role.

  • description (str) – Description of the role.

  • rules (list[int]) – List of rule IDs associated with the role.

Returns:

The created role.

Return type:

dict

delete(role_id)

Delete an existing role

Parameters:

role_id (int) – ID of the role to delete.

Return type:

None

edit(role_id, name=None, description=None, rules=None)

Edit an existing role

Parameters:
  • role_id (int) – ID of the role to edit.

  • name (str, optional) – New name of the role.

  • description (str, optional) – New description of the role.

  • rules (list[int], optional) – New list of rule IDs associated with the role. CAUTION! This will not add rules but replace them. If you remove rules from your own role you lose access. By default None

Returns:

The updated role.

Return type:

dict

list(name=None, description=None, user=None, page=1, per_page=10)

List algorithms

Parameters:
  • name (str, optional) – Filter by name (with LIKE operator).

  • description (str, optional) – Filter by description (with LIKE operator).

  • user (int, optional) – Filter by user id.

  • field (str, optional) – Which data field to keep in the result. For instance, “field=’name’” will only return the name of the roles. Default is None.

  • fields (list[str], optional) – Which data fields to keep in the result. For instance, “fields=[‘name’, ‘id’]” will only return the name and id of the roles. Default is None.

  • filter (tuple, optional) – Filter the result on key-value pairs. For instance, “filter_=(‘name’, ‘my_name’)” will only return the roles with the name ‘my_name’. Default is None.

  • filters (list[tuple], optional) – Filter the result on multiple key-value pairs. For instance, “filters=[(‘name’, ‘my_name’), (‘id’, 1)]” will only return the roles with the name ‘my_name’ and id 1. Default is None.

  • page (int, optional) – Page number for pagination (default=1)

  • per_page (int, optional) – Number of items per page (default=10)

Returns:

List of roles

Return type:

list[dict]