projectal.entities.user
View Source
from projectal import api from projectal.entity import Entity from projectal.linkers import * class User(Entity, AccessPolicyLinker, PermissionLinker, NoteLinker, TagLinker): """ Implementation of the [User](https://projectal.com/docs/latest/#tag/User) API. """ _path = 'user' _name = 'user' _links = [AccessPolicyLinker, PermissionLinker, NoteLinker, TagLinker] def register(self): url = '/api/user/registration/{}'.format(self['uuId']) return api.post(url) def set_password(self, password, token_id): url = '/auth/register/password' payload = { 'password': password, 'confirm': password, 'tokenId': token_id } api.post(url, payload=payload) return True @classmethod def current_user_permissions(cls): """ Get the authenticated user's permissions as a list. """ return api.get('/api/user/permissions')['permissions'] def link_permission(self, permissions): self.__permission(self, permissions, 'add') def unlink_permission(self, permissions): self.__permission(self, permissions, 'delete') @classmethod def __permission(cls, from_user, to_permissions, operation): if isinstance(to_permissions, dict): to_permissions = [to_permissions] url = '/api/user/permission/{}'.format(operation) payload = [{ 'uuId': from_user['uuId'], 'permissionList': to_permissions }] api.post(url, payload=payload) return True @classmethod def current_user_details(cls): """Get some details about the authenticated user.""" return api.get('/api/user/details') @classmethod def get_permissions(cls, user): """Get the permissions assigned to a specific User entity.""" url = '/api/user/get/{}/permissions'.format(user['uuId']) return api.get(url)['data']
#  
class
User(projectal.entity.Entity, projectal.linkers.AccessPolicyLinker, projectal.linkers.PermissionLinker, projectal.linkers.NoteLinker, projectal.linkers.TagLinker):
View Source
class User(Entity, AccessPolicyLinker, PermissionLinker, NoteLinker, TagLinker): """ Implementation of the [User](https://projectal.com/docs/latest/#tag/User) API. """ _path = 'user' _name = 'user' _links = [AccessPolicyLinker, PermissionLinker, NoteLinker, TagLinker] def register(self): url = '/api/user/registration/{}'.format(self['uuId']) return api.post(url) def set_password(self, password, token_id): url = '/auth/register/password' payload = { 'password': password, 'confirm': password, 'tokenId': token_id } api.post(url, payload=payload) return True @classmethod def current_user_permissions(cls): """ Get the authenticated user's permissions as a list. """ return api.get('/api/user/permissions')['permissions'] def link_permission(self, permissions): self.__permission(self, permissions, 'add') def unlink_permission(self, permissions): self.__permission(self, permissions, 'delete') @classmethod def __permission(cls, from_user, to_permissions, operation): if isinstance(to_permissions, dict): to_permissions = [to_permissions] url = '/api/user/permission/{}'.format(operation) payload = [{ 'uuId': from_user['uuId'], 'permissionList': to_permissions }] api.post(url, payload=payload) return True @classmethod def current_user_details(cls): """Get some details about the authenticated user.""" return api.get('/api/user/details') @classmethod def get_permissions(cls, user): """Get the permissions assigned to a specific User entity.""" url = '/api/user/get/{}/permissions'.format(user['uuId']) return api.get(url)['data']
Implementation of the User API.
View Source
def register(self): url = '/api/user/registration/{}'.format(self['uuId']) return api.post(url)
View Source
def set_password(self, password, token_id): url = '/auth/register/password' payload = { 'password': password, 'confirm': password, 'tokenId': token_id } api.post(url, payload=payload) return True
View Source
@classmethod def current_user_permissions(cls): """ Get the authenticated user's permissions as a list. """ return api.get('/api/user/permissions')['permissions']
Get the authenticated user's permissions as a list.
View Source
def link_permission(self, permissions): self.__permission(self, permissions, 'add')
View Source
def unlink_permission(self, permissions): self.__permission(self, permissions, 'delete')
View Source
@classmethod def current_user_details(cls): """Get some details about the authenticated user.""" return api.get('/api/user/details')
Get some details about the authenticated user.
View Source
@classmethod def get_permissions(cls, user): """Get the permissions assigned to a specific User entity.""" url = '/api/user/get/{}/permissions'.format(user['uuId']) return api.get(url)['data']
Get the permissions assigned to a specific User entity.
Inherited Members
- projectal.entity.Entity
- Entity
- get
- update
- delete
- history
- create
- save
- clone
- list
- match
- match_startswith
- match_endswith
- match_one
- match_startswith_one
- match_endswith_one
- search
- query
- profile_get
- profile_set
- changes
- set_readonly
- get_link_definitions
- entity_name
- builtins.dict
- setdefault
- pop
- popitem
- keys
- items
- values
- fromkeys
- clear
- copy