aboutsummaryrefslogtreecommitdiff
path: root/src/pgpmailman/rest/root.py
blob: b937fd3f5b130b6d5a4635c5bfaad99fc1824182 (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
40
"""
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 pgpmailman.rest.lists import AllEncryptedLists, AnEncryptedList
from pgpmailman.rest.users import AUser, AllUsers
from public import public


@public
class RESTRoot:
    @child()
    def lists(self, context, segments):
        if len(segments) == 0:
            return AllEncryptedLists(), []
        else:
            list_name = segments.pop(0)
            # WIP Check whether it's an encrypted list we know of here.
            return AnEncryptedList(list_name), segments

    @child()
    def users(self, context, segments):
        if len(segments) == 0:
            return AllUsers(), []
        else:
            uid = segments.pop(0)
            # WIP Check whether it's an encrypted user we know of here.
            return AUser(uid), segments