summaryrefslogtreecommitdiff
path: root/src/mailman/rest/domains.py
diff options
context:
space:
mode:
authorBarry Warsaw2016-07-16 15:44:07 -0400
committerBarry Warsaw2016-07-16 15:44:07 -0400
commitdbde6231ec897379ed38ed4cd015b8ab20ed5fa1 (patch)
tree1226d06a238314262a1d04d0bbf9c4dc0b72c309 /src/mailman/rest/domains.py
parent3387791beb7112dbe07664041f117fdcc20df53d (diff)
downloadmailman-dbde6231ec897379ed38ed4cd015b8ab20ed5fa1.tar.gz
mailman-dbde6231ec897379ed38ed4cd015b8ab20ed5fa1.tar.zst
mailman-dbde6231ec897379ed38ed4cd015b8ab20ed5fa1.zip
Diffstat (limited to 'src/mailman/rest/domains.py')
-rw-r--r--src/mailman/rest/domains.py25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/mailman/rest/domains.py b/src/mailman/rest/domains.py
index 62e05b82f..7f54e8905 100644
--- a/src/mailman/rest/domains.py
+++ b/src/mailman/rest/domains.py
@@ -24,6 +24,7 @@ from mailman.rest.helpers import (
BadRequest, CollectionMixin, NotFound, bad_request, child, created, etag,
no_content, not_found, okay)
from mailman.rest.lists import ListsForDomain
+from mailman.rest.uris import ADomainURI, AllDomainURIs
from mailman.rest.users import OwnersForDomain
from mailman.rest.validator import Validator, list_of_strings_validator
from zope.component import getUtility
@@ -35,11 +36,9 @@ class _DomainBase(CollectionMixin):
def _resource_as_dict(self, domain):
"""See `CollectionMixin`."""
return dict(
- base_url=domain.base_url,
description=domain.description,
mail_host=domain.mail_host,
self_link=self.api.path_to('domains/{}'.format(domain.mail_host)),
- url_host=domain.url_host,
)
def _get_collection(self, request):
@@ -94,6 +93,24 @@ class ADomain(_DomainBase):
else:
return NotFound(), []
+ @child()
+ def uris(self, context, segments):
+ """Return the template URIs of the domain.
+
+ These are only available after API 3.0.
+ """
+ domain = getUtility(IDomainManager).get(self._domain)
+ if domain is None or self.api.version_info < (3, 1):
+ return NotFound(), []
+ if len(segments) == 0:
+ return AllDomainURIs(domain)
+ if len(segments) > 1:
+ return BadRequest(), []
+ template = segments[0]
+ if template not in AllDomainURIs.URIs:
+ return NotFound(), []
+ return ADomainURI(domain, template), []
+
@public
class AllDomains(_DomainBase):
@@ -105,10 +122,8 @@ class AllDomains(_DomainBase):
try:
validator = Validator(mail_host=str,
description=str,
- base_url=str,
owner=list_of_strings_validator,
- _optional=(
- 'description', 'base_url', 'owner'))
+ _optional=('description', 'owner'))
values = validator(request)
# For consistency, owners are passed in as multiple `owner` keys,
# but .add() requires an `owners` keyword. Match impedence.