diff options
Diffstat (limited to 'src/mailman/rest')
| -rw-r--r-- | src/mailman/rest/docs/domains.txt | 43 | ||||
| -rw-r--r-- | src/mailman/rest/docs/lists.rst | 9 | ||||
| -rw-r--r-- | src/mailman/rest/domains.py | 7 | ||||
| -rw-r--r-- | src/mailman/rest/lists.py | 2 |
4 files changed, 54 insertions, 7 deletions
diff --git a/src/mailman/rest/docs/domains.txt b/src/mailman/rest/docs/domains.txt index 35546a56d..293d54c98 100644 --- a/src/mailman/rest/docs/domains.txt +++ b/src/mailman/rest/docs/domains.txt @@ -117,6 +117,49 @@ But we get a 404 for a non-existent domain. ... HTTPError: HTTP Error 404: 404 Not Found +You can also list mailing lists for a given domain by appending +`/lists` to the URL. + + >>> dump_json('http://localhost:9001/3.0/domains/example.com/lists') + http_etag: "..." + start: 0 + total_size: 0 + + >>> dump_json('http://localhost:9001/3.0/lists', { + ... 'fqdn_listname': 'test-domains@example.com', + ... }) + content-length: 0 + date: ... + location: http://localhost:9001/3.0/lists/test-domains@example.com + ... + + >>> dump_json('http://localhost:9001/3.0/domains/example.com/lists') + entry 0: + fqdn_listname: test-domains@example.com + http_etag: "..." + ... + self_link: http://localhost:9001/3.0/lists/test-domains@example.com + http_etag: "..." + start: 0 + total_size: 1 + + >>> dump_json('http://localhost:9001/3.0/domains/lists.example.net/lists') + http_etag: "..." + start: 0 + total_size: 0 + +Here are some poorly-formed URL's for testing purposes: + + >>> dump_json('http://localhost:9001/3.0/domains/example.com/lists/wrong') + Traceback (most recent call last): + ... + HTTPError: HTTP Error 400: 400 Bad Request + + >>> dump_json('http://localhost:9001/3.0/domains/example.com/wrong') + Traceback (most recent call last): + ... + HTTPError: HTTP Error 404: 404 Not Found + Creating new domains ==================== diff --git a/src/mailman/rest/docs/lists.rst b/src/mailman/rest/docs/lists.rst index a8b100a1b..f16daf00d 100644 --- a/src/mailman/rest/docs/lists.rst +++ b/src/mailman/rest/docs/lists.rst @@ -31,6 +31,7 @@ Create a mailing list in a domain and it's accessible via the API. total_size: 1 You can also query for lists from a particular domain. +:: >>> dump_json('http://localhost:9001/3.0/domains/example.com/lists') entry 0: @@ -44,10 +45,10 @@ You can also query for lists from a particular domain. start: 0 total_size: 1 - >>> dump_json('http://localhost:9001/3.0/domains/other.com/lists') - http_etag: "..." - start: 0 - total_size: 0 + >>> dump_json('http://localhost:9001/3.0/domains/no.example.org/lists') + Traceback (most recent call last): + ... + HTTPError: HTTP Error 404: 404 Not Found Creating lists via the API ========================== diff --git a/src/mailman/rest/domains.py b/src/mailman/rest/domains.py index 1f4077e0c..61cc28ca0 100644 --- a/src/mailman/rest/domains.py +++ b/src/mailman/rest/domains.py @@ -32,8 +32,8 @@ from zope.component import getUtility from mailman.interfaces.domain import ( BadDomainSpecificationError, IDomainManager) from mailman.rest.helpers import CollectionMixin, etag, no_content, path_to -from mailman.rest.validator import Validator from mailman.rest.lists import ListsForDomain +from mailman.rest.validator import Validator @@ -84,7 +84,10 @@ class ADomain(_DomainBase): def lists(self, request, segments): """/<api>/domains/<domain>/lists""" if len(segments) == 0: - return ListsForDomain(self._domain) + domain = getUtility(IDomainManager).get(self._domain) + if domain is None: + return http.not_found() + return ListsForDomain(domain) else: return http.bad_request() diff --git a/src/mailman/rest/lists.py b/src/mailman/rest/lists.py index 8e8242ee8..91a2d7ded 100644 --- a/src/mailman/rest/lists.py +++ b/src/mailman/rest/lists.py @@ -224,5 +224,5 @@ class ListsForDomain(_ListBase): def _get_collection(self, request): """See `CollectionMixin`.""" - return getUtility(IListManager).get_lists_for_domain(self._domain) + return list(self._domain.mailing_lists) |
