summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mailman/rest/docs/domains.txt21
-rw-r--r--src/mailman/rest/domains.py12
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."""