Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions mergin/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand Down