aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/rest/root.py
diff options
context:
space:
mode:
authorJ08nY2017-06-09 17:41:24 +0200
committerJ08nY2017-06-09 17:41:24 +0200
commitb932ba4a32f208aa934bad8b4039e8c871b6715f (patch)
treec93f1277353928446dccaa4e16845fe9a83372b5 /src/mailman_pgp/rest/root.py
parent25487795779c05ff8e97680550948443924b98c0 (diff)
downloadmailman-pgp-b932ba4a32f208aa934bad8b4039e8c871b6715f.tar.gz
mailman-pgp-b932ba4a32f208aa934bad8b4039e8c871b6715f.tar.zst
mailman-pgp-b932ba4a32f208aa934bad8b4039e8c871b6715f.zip
Diffstat (limited to 'src/mailman_pgp/rest/root.py')
-rw-r--r--src/mailman_pgp/rest/root.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/mailman_pgp/rest/root.py b/src/mailman_pgp/rest/root.py
new file mode 100644
index 0000000..286d9ae
--- /dev/null
+++ b/src/mailman_pgp/rest/root.py
@@ -0,0 +1,39 @@
+"""
+REST root.
+
+
+/lists/ -> List all known encrypted lists.
+/lists/<list_id>/ ->
+/lists/<list_id>/key -> GET list_public_key
+/lists/<list_id>/archive/key -> GET/POST list_archive_public_key
+
+/users/ -> List all known users of encrypted lists.
+/users/<uid>/ ->
+/users/<uid>/key -> GET/POST user_public_key
+
+"""
+
+from mailman.rest.helpers import child
+from public import public
+
+from mailman_pgp.rest.lists import AllEncryptedLists, AnEncryptedList
+from mailman_pgp.rest.users import AllUsers, AUser
+
+
+@public
+class RESTRoot:
+ @child()
+ def lists(self, context, segments):
+ if len(segments) == 0:
+ return AllEncryptedLists(), []
+ else:
+ list_id = segments.pop(0)
+ return AnEncryptedList(list_id), segments
+
+ @child()
+ def users(self, context, segments):
+ if len(segments) == 0:
+ return AllUsers(), []
+ else:
+ uid = segments.pop(0)
+ return AUser(uid), segments