aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/rest/root.py
blob: 286d9aeab119e86b18c886240e091c81cefcf002 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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