From d02c71d3845ba019c53ae3734a68aa7589d1a3eb Mon Sep 17 00:00:00 2001 From: tomasMizera Date: Thu, 11 Nov 2021 14:26:52 +0100 Subject: [PATCH] add call to /user/service endpoint --- mergin/client.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/mergin/client.py b/mergin/client.py index 8095047e..8b31ea1d 100644 --- a/mergin/client.py +++ b/mergin/client.py @@ -306,6 +306,23 @@ def username(self): return None # not authenticated return self._user_info["username"] + def user_service(self): + """ + Requests information about user from /user/service endpoint if such exists in self.url server. + + Returns response from server as JSON dict or None if endpoint is not found + """ + + try: + response = self.get("/v1/user/service") + except ClientError as e: + self.log.debug("Unable to query for /user/service endpoint") + return + + response = json.loads(response.read()) + + return response + def create_project(self, project_name, is_public=False, namespace=None): """ Create new project repository in user namespace on Mergin server.