From e078533344aadd6a751da35f582e15fc9cec3c8a Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Thu, 14 Dec 2023 19:23:17 -0700 Subject: [PATCH] fix: Add endpoints to receive data of profiles --- tm_admin/tmserver.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tm_admin/tmserver.py b/tm_admin/tmserver.py index 407de042..55e77a92 100755 --- a/tm_admin/tmserver.py +++ b/tm_admin/tmserver.py @@ -82,6 +82,7 @@ def doRequest(self, request, context): out = "" action = protobuf_to_dict(request) + # These requests get data from the database if action['cmd'] == Command.GET_USER: print(f"USER {action}") if action['id'] != 0: @@ -104,7 +105,15 @@ def doRequest(self, request, context): else: out = teams.getAllUsers() elif action['cmd'] == Command.GET_PROJECT: - log.error("PROJECTS unimplemented!") + if action['id'] != 0: + if len(action['name']) > 0: + # print(f"BY NAME {action}") + out = projectsDB.getByName(action['name']) + else: + # print(f" BY ID {action}") + out = projectsDB.getByID(action['id']) + else: + out = projectsDB.getAllUsers() elif action['cmd'] == Command.GET_TEAM: if action['id'] != 0: if len(action['name']) > 0: @@ -115,7 +124,18 @@ def doRequest(self, request, context): out = teamsDB.getByID(action['id']) else: out = teams.getAllUsers() - + # These requests receive a data packet for the database + elif action['cmd'] == Command.SEND_USER: + out = users.CreateTable() + log.error("SEND USER unimplemented!") + elif action['cmd'] == Command.SEND_PROJECT: + log.error("SEND PROJECT unimplemented!") + elif action['cmd'] == Command.SEND_TEAM: + log.error("SEND TEAM unimplemented!") + elif action['cmd'] == Command.SEND_ORGANIZATION: + log.error("SEND ORGANIZATION implemented!") + + # Send the result result = serialize_to_protobuf(error, tm_admin.services_pb2.tmresponse) if type(out) == dict(): for key, value in entry.items():