diff options
| author | Barry Warsaw | 2011-04-19 12:41:17 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2011-04-19 12:41:17 -0400 |
| commit | b6b5825bf19e6fb9c5f13ffe2558c1a3531b8b85 (patch) | |
| tree | 981f78b59c682b122c9b9479e4421d95a32b0247 | |
| parent | c0c2ae64dd48f95a57669395c315e84c992fc332 (diff) | |
| download | mailman-b6b5825bf19e6fb9c5f13ffe2558c1a3531b8b85.tar.gz mailman-b6b5825bf19e6fb9c5f13ffe2558c1a3531b8b85.tar.zst mailman-b6b5825bf19e6fb9c5f13ffe2558c1a3531b8b85.zip | |
| -rw-r--r-- | src/mailman/rest/docs/domains.txt | 21 | ||||
| -rw-r--r-- | src/mailman/rest/domains.py | 12 |
2 files changed, 32 insertions, 1 deletions
diff --git a/src/mailman/rest/docs/domains.txt b/src/mailman/rest/docs/domains.txt index 29592fadb..35546a56d 100644 --- a/src/mailman/rest/docs/domains.txt +++ b/src/mailman/rest/docs/domains.txt @@ -186,4 +186,25 @@ address. >>> transaction.abort() +Deleting domains +================ + +Domains can also be deleted via the API. + + >>> dump_json('http://localhost:9001/3.0/domains/lists.example.com', + ... method='DELETE') + content-length: 0 + date: ... + server: ... + status: 204 + +It is an error to delete a domain twice. + + >>> dump_json('http://localhost:9001/3.0/domains/lists.example.com', + ... method='DELETE') + Traceback (most recent call last): + ... + HTTPError: HTTP Error 404: 404 Not Found + + .. _Domains: ../../model/docs/domains.html diff --git a/src/mailman/rest/domains.py b/src/mailman/rest/domains.py index edb72af61..780380270 100644 --- a/src/mailman/rest/domains.py +++ b/src/mailman/rest/domains.py @@ -31,7 +31,7 @@ from zope.component import getUtility from mailman.interfaces.domain import ( BadDomainSpecificationError, IDomainManager) -from mailman.rest.helpers import CollectionMixin, etag, path_to +from mailman.rest.helpers import CollectionMixin, etag, no_content, path_to from mailman.rest.validator import Validator @@ -69,6 +69,16 @@ class ADomain(_DomainBase): return http.not_found() return http.ok([], self._resource_as_json(domain)) + @resource.DELETE() + def delete(self, request): + """Delete the domain.""" + try: + getUtility(IDomainManager).remove(self._domain) + except KeyError: + # The domain does not exist. + return http.not_found() + return no_content() + class AllDomains(_DomainBase): """The domains.""" |
