diff --git a/mergin/client.py b/mergin/client.py index 69006bbe..5df33023 100644 --- a/mergin/client.py +++ b/mergin/client.py @@ -319,6 +319,7 @@ 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 + This can be removed once our SaaS server is upgraded to support workspaces """ try: @@ -331,6 +332,24 @@ def user_service(self): return response + def workspace_service(self, workspace_id): + """ + This Requests information about a workspace service from /workspace/{id}/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(f"/v1/workspace/{workspace_id}/service") + except ClientError as e: + self.log.debug(f"Unable to query for /workspace/{workspace_id}/service endpoint") + return + + response = json.loads(response.read()) + + return response + def server_type(self): """ Returns the deployment type of the server @@ -344,11 +363,13 @@ def server_type(self): try: resp = self.get("/config") config = json.load(resp) - if "user_workspaces_allowed" in config: - self._server_type = ServerType.EE - if "global_workspace" in config: + if config["server_type"] == "ce": self._server_type = ServerType.CE - except ClientError as e: + elif config["server_type"] == "ee": + self._server_type = ServerType.EE + elif config["server_type"] == "saas": + self._server_type = ServerType.SAAS + except (ClientError, KeyError): self._server_type = ServerType.OLD return self._server_type