aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Teichmann <daniel.teichmann@das-netzwerkteam.de>2023-02-21 12:09:17 +0100
committerDaniel Teichmann <daniel.teichmann@das-netzwerkteam.de>2023-02-21 12:47:51 +0100
commita38ec64a718917bd0998f7be6ce38e37a4af6b10 (patch)
tree78aaca2d3386c535f6809b8dc84516e8ce9cb305
parent692163a3282a6fc706f3e31e0884378b4bb0f464 (diff)
downloadRWA.Support.SessionService-a38ec64a718917bd0998f7be6ce38e37a4af6b10.tar.gz
RWA.Support.SessionService-a38ec64a718917bd0998f7be6ce38e37a4af6b10.tar.bz2
RWA.Support.SessionService-a38ec64a718917bd0998f7be6ce38e37a4af6b10.zip
(...)/service.py: Fix DBus input type declarations + Also provide 'status' field in response.
-rwxr-xr-xrwa/support/sessionservice/service.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/rwa/support/sessionservice/service.py b/rwa/support/sessionservice/service.py
index 33a679d..0d7ade1 100755
--- a/rwa/support/sessionservice/service.py
+++ b/rwa/support/sessionservice/service.py
@@ -99,7 +99,7 @@ class RWASupportSessionService(dbus.service.Object):
logging.debug(f"Is '{url}' an URL: {valid}")
return valid
- def _get_web_app_hosts(self) -> str:
+ def _get_web_app_hosts(self) -> list:
"""Get all registered RWA.Support.WebApp hosts.
Helper function: No D-Bus API.
@@ -109,7 +109,7 @@ class RWASupportSessionService(dbus.service.Object):
hosts = [
self._build_host_dict(key, value) for key, value in self.settings.web_app_hosts.items()
]
- return json.dumps(hosts)
+ return hosts
def _build_host_dict(self, host_uuid: str, host: dict) -> dict:
"""Include the host ID in the host dictionary."""
@@ -126,11 +126,12 @@ class RWASupportSessionService(dbus.service.Object):
::
- [{"url": "https://example.org", "uuid": <host_uuid>}, {"url": "http://127.0.0.1:8000", "uuid": <host_uuid>}]
+ {"status": "success", [{"url": "https://example.org", "uuid": <host_uuid>}, {"url": "http://127.0.0.1:8000", "uuid": <host_uuid>}]}
"""
logging.info("D-Bus method call: %s()", "get_web_app_hosts")
response = self._get_web_app_hosts()
+ response = json.dumps({"status": "success", "hosts": response})
logging.info('The response to D-Bus caller: "%s"', response)
return response
@@ -261,7 +262,7 @@ class RWASupportSessionService(dbus.service.Object):
return response
@dbus.service.method(
- "org.ArcticaProject.RWASupportSessionService", in_signature="i", out_signature="s"
+ "org.ArcticaProject.RWASupportSessionService", in_signature="s", out_signature="s"
)
def remove_web_app_host(self, host_uuid: str) -> str:
"""Remove a RWA.Support.WebApp host.
@@ -273,7 +274,7 @@ class RWASupportSessionService(dbus.service.Object):
::
- [{"url": "https://example.org", "uuid": <host_uuid>}, {"url": "http://127.0.0.1:8000", "uuid": <host_uuid>}]
+ {"status": "success", "host": {"url": "https://example.org", "alias": "<host_alias>", "uuid": <host_uuid>}}
"""
logging.info("D-Bus method call: %s(%s)", "remove_web_app_host", host_uuid)
@@ -291,11 +292,12 @@ class RWASupportSessionService(dbus.service.Object):
return json.dumps({"status": "error", "type": "host_not_found"})
response = self._get_web_app_hosts()
+ response = json.dumps({"status": "success", "hosts": response});
logging.info('The response to D-Bus caller: "%s"', response)
- return response
+ return response;
@dbus.service.method(
- "org.ArcticaProject.RWASupportSessionService", in_signature="i", out_signature="s"
+ "org.ArcticaProject.RWASupportSessionService", in_signature="s", out_signature="s"
)
def start(self, host_uuid: str) -> str:
"""Start a new remote session and register it in RWA.Support.WebApp.