/
Access Right Service (python)
NOTE: Trivore ID Documentation has moved to https://trivoreid.com
The content on this site IS OUT OF DATE!
This space has been archived!
Please go ahead to the new site!
Access Right Service (python)
List of all options:
Get list of all builtin permissions or a single permission.
Get list of all builtin roles
Create, read, update and delete a custom role
Getting access right objects
from trivoreid.models.access_right import Permission, BuiltInRole, CustomRole
from trivoreid.utils.criteria import Filter
# get list with all builtin permissions (Permission objects).
permissions = api.access_right_service.get_all_permissions()
# get a single permission
permission api.access_right_service.get_permission('permissionId')
# get list with all builtin roles (BuiltInRole objects).
builtin_roles = api.access_right_service.get_all_builtin_roles()
# get first five custom roles belonging to namespace 'examplecode'
f = Filter(Filter.EQUAL, 'nsCode', 'examplecode')
page = api.target_service.get_all(f, start_index=0, count=5)
Managing access right objects
# create new custom role
role = CustomRole()
role.nsCode = 'examplecode'
role.name = 'EXAMPLE_ROLE'
role.memberOf = ['groupId1', 'groupId2']
# the function returns custom role object with the generated id
role = api.access_right_service.create_custom_role(role)
# update custom role
role.name = 'MODIFIED_NAME'
api.access_right_service.update_custom_role(role)
# get custom role
role = api.access_right_service.get_custom_role(role.id)
# delete custom role
api.access_right_service.delete_custom_role(role.id)