summary refs log tree commit diff
path: root/synapse/rest/client/v2_alpha
diff options
context:
space:
mode:
authorDavid Baker <dbkr@users.noreply.github.com>2016-07-21 13:41:42 +0100
committerGitHub <noreply@github.com>2016-07-21 13:41:42 +0100
commit2c28e25bdae253aa31ec61ac7672f15e2b053963 (patch)
treea23e906f2d2400496b835f4b687e5649aec9c29d /synapse/rest/client/v2_alpha
parentMerge pull request #942 from matrix-org/rav/fix_register_deviceid (diff)
parentFix PEP8 errors (diff)
downloadsynapse-2c28e25bdae253aa31ec61ac7672f15e2b053963.tar.xz
Merge pull request #943 from matrix-org/rav/get_device_api
Implement GET /device/{deviceId}
Diffstat (limited to 'synapse/rest/client/v2_alpha')
-rw-r--r--synapse/rest/client/v2_alpha/devices.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/synapse/rest/client/v2_alpha/devices.py b/synapse/rest/client/v2_alpha/devices.py
index 5cf8bd1afa..8b9ab4f674 100644
--- a/synapse/rest/client/v2_alpha/devices.py
+++ b/synapse/rest/client/v2_alpha/devices.py
@@ -47,5 +47,30 @@ class DevicesRestServlet(RestServlet):
         defer.returnValue((200, {"devices": devices}))
 
 
+class DeviceRestServlet(RestServlet):
+    PATTERNS = client_v2_patterns("/devices/(?P<device_id>[^/]*)$",
+                                  releases=[], v2_alpha=False)
+
+    def __init__(self, hs):
+        """
+        Args:
+            hs (synapse.server.HomeServer): server
+        """
+        super(DeviceRestServlet, self).__init__()
+        self.hs = hs
+        self.auth = hs.get_auth()
+        self.device_handler = hs.get_device_handler()
+
+    @defer.inlineCallbacks
+    def on_GET(self, request, device_id):
+        requester = yield self.auth.get_user_by_req(request)
+        device = yield self.device_handler.get_device(
+            requester.user.to_string(),
+            device_id,
+        )
+        defer.returnValue((200, device))
+
+
 def register_servlets(hs, http_server):
     DevicesRestServlet(hs).register(http_server)
+    DeviceRestServlet(hs).register(http_server)