aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/rest/root.py
diff options
context:
space:
mode:
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