projectal.entities.user
1from projectal import api 2from projectal.entity import Entity 3from projectal.linkers import * 4 5 6class User(Entity, AccessPolicyLinker, PermissionLinker, NoteLinker, TagLinker): 7 """ 8 Implementation of the [User](https://projectal.com/docs/latest/#tag/User) API. 9 """ 10 11 _path = "user" 12 _name = "user" 13 _links = [AccessPolicyLinker, PermissionLinker, NoteLinker, TagLinker] 14 15 def register(self): 16 url = "/api/user/registration/{}".format(self["uuId"]) 17 return api.post(url) 18 19 def set_password(self, password, token_id): 20 url = "/auth/register/password" 21 payload = {"password": password, "confirm": password, "tokenId": token_id} 22 api.post(url, payload=payload) 23 return True 24 25 @classmethod 26 def current_user_permissions(cls): 27 """ 28 Get the authenticated user's permissions as a list. 29 """ 30 return api.get("/api/user/permission")["permissions"] 31 32 def link_permission(self, permissions): 33 self.__permission(self, permissions, "add") 34 35 def unlink_permission(self, permissions): 36 self.__permission(self, permissions, "delete") 37 38 @classmethod 39 def __permission(cls, from_user, to_permissions, operation): 40 if isinstance(to_permissions, dict): 41 to_permissions = [to_permissions] 42 43 url = "/api/user/permission/{}".format(operation) 44 payload = [{"uuId": from_user["uuId"], "permissionList": to_permissions}] 45 api.post(url, payload=payload) 46 return True 47 48 @classmethod 49 def current_user_details(cls): 50 """Get some details about the authenticated user.""" 51 return api.get("/api/user/details") 52 53 @classmethod 54 def get_permissions(cls, user): 55 """Get the permissions assigned to a specific User entity.""" 56 url = "/api/user/get/{}/permissions".format(user["uuId"]) 57 return api.get(url)["data"]
class
User(projectal.entity.Entity, projectal.linkers.AccessPolicyLinker, projectal.linkers.PermissionLinker, projectal.linkers.NoteLinker, projectal.linkers.TagLinker):
7class User(Entity, AccessPolicyLinker, PermissionLinker, NoteLinker, TagLinker): 8 """ 9 Implementation of the [User](https://projectal.com/docs/latest/#tag/User) API. 10 """ 11 12 _path = "user" 13 _name = "user" 14 _links = [AccessPolicyLinker, PermissionLinker, NoteLinker, TagLinker] 15 16 def register(self): 17 url = "/api/user/registration/{}".format(self["uuId"]) 18 return api.post(url) 19 20 def set_password(self, password, token_id): 21 url = "/auth/register/password" 22 payload = {"password": password, "confirm": password, "tokenId": token_id} 23 api.post(url, payload=payload) 24 return True 25 26 @classmethod 27 def current_user_permissions(cls): 28 """ 29 Get the authenticated user's permissions as a list. 30 """ 31 return api.get("/api/user/permission")["permissions"] 32 33 def link_permission(self, permissions): 34 self.__permission(self, permissions, "add") 35 36 def unlink_permission(self, permissions): 37 self.__permission(self, permissions, "delete") 38 39 @classmethod 40 def __permission(cls, from_user, to_permissions, operation): 41 if isinstance(to_permissions, dict): 42 to_permissions = [to_permissions] 43 44 url = "/api/user/permission/{}".format(operation) 45 payload = [{"uuId": from_user["uuId"], "permissionList": to_permissions}] 46 api.post(url, payload=payload) 47 return True 48 49 @classmethod 50 def current_user_details(cls): 51 """Get some details about the authenticated user.""" 52 return api.get("/api/user/details") 53 54 @classmethod 55 def get_permissions(cls, user): 56 """Get the permissions assigned to a specific User entity.""" 57 url = "/api/user/get/{}/permissions".format(user["uuId"]) 58 return api.get(url)["data"]
Implementation of the User API.
@classmethod
def
current_user_permissions(cls):
26 @classmethod 27 def current_user_permissions(cls): 28 """ 29 Get the authenticated user's permissions as a list. 30 """ 31 return api.get("/api/user/permission")["permissions"]
Get the authenticated user's permissions as a list.
@classmethod
def
current_user_details(cls):
49 @classmethod 50 def current_user_details(cls): 51 """Get some details about the authenticated user.""" 52 return api.get("/api/user/details")
Get some details about the authenticated user.
@classmethod
def
get_permissions(cls, user):
54 @classmethod 55 def get_permissions(cls, user): 56 """Get the permissions assigned to a specific User entity.""" 57 url = "/api/user/get/{}/permissions".format(user["uuId"]) 58 return api.get(url)["data"]
Get the permissions assigned to a specific User entity.
Inherited Members
- projectal.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