summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mailman/rest/docs/systemconf.rst4
-rw-r--r--src/mailman/rest/root.py12
-rw-r--r--src/mailman/rest/tests/test_systemconf.py4
3 files changed, 19 insertions, 1 deletions
diff --git a/src/mailman/rest/docs/systemconf.rst b/src/mailman/rest/docs/systemconf.rst
index 213929a42..a65b81ab8 100644
--- a/src/mailman/rest/docs/systemconf.rst
+++ b/src/mailman/rest/docs/systemconf.rst
@@ -8,6 +8,7 @@ get a list of all defined sections.
>>> dump_json('http://localhost:9001/3.0/system/configuration')
http_etag: ...
sections: ['antispam', 'archiver.mail_archive', 'archiver.master', ...
+ self_link: http://localhost:9001/3.0/system/configuration
You can also get all the values for a particular section, such as the
``[mailman]`` section...
@@ -25,6 +26,7 @@ You can also get all the values for a particular section, such as the
pending_request_life: 3d
post_hook:
pre_hook:
+ self_link: http://localhost:9001/3.0/system/configuration/mailman
sender_headers: from from_ reply-to sender
site_owner: noreply@example.com
@@ -36,6 +38,7 @@ You can also get all the values for a particular section, such as the
org_domain_data_url: https://publicsuffix.org/list/public_suffix_list.dat
resolver_lifetime: 5s
resolver_timeout: 3s
+ self_link: http://localhost:9001/3.0/system/configuration/dmarc
Dotted section names work too, for example, to get the French language
settings section.
@@ -45,3 +48,4 @@ settings section.
description: French
enabled: yes
http_etag: ...
+ self_link: http://localhost:9001/3.0/system/configuration/language.fr
diff --git a/src/mailman/rest/root.py b/src/mailman/rest/root.py
index 76cf2ba25..76289078b 100644
--- a/src/mailman/rest/root.py
+++ b/src/mailman/rest/root.py
@@ -89,7 +89,9 @@ class SystemConfiguration:
def on_get(self, request, response):
if self._section is None:
resource = dict(
- sections=sorted(section.name for section in config))
+ sections=sorted(section.name for section in config),
+ self_link=self.api.path_to('system/configuration'),
+ )
okay(response, etag(resource))
return
missing = object()
@@ -100,6 +102,14 @@ class SystemConfiguration:
# Sections don't have .keys(), .values(), or .items() but we can
# iterate over them.
resource = {key: section[key] for key in section}
+ # Add a `self_link` attribute to the resource. This is a little ugly
+ # because technically speaking we're mixing namespaces. We can't have
+ # a variable named `self_link` in any section, but also we can't have
+ # `http_etag` either, so unless we want to shove all these values into
+ # a sub dictionary (which we don't), we have to live with it.
+ self_link = self.api.path_to(
+ 'system/configuration/{}'.format(section.name))
+ resource['self_link'] = self_link
okay(response, etag(resource))
diff --git a/src/mailman/rest/tests/test_systemconf.py b/src/mailman/rest/tests/test_systemconf.py
index afa788719..f9fe9caa0 100644
--- a/src/mailman/rest/tests/test_systemconf.py
+++ b/src/mailman/rest/tests/test_systemconf.py
@@ -48,6 +48,7 @@ class TestSystemConfiguration(unittest.TestCase):
pending_request_life='3d',
post_hook='',
pre_hook='',
+ self_link='http://localhost:9001/3.0/system/configuration/mailman',
sender_headers='from from_ reply-to sender',
site_owner='noreply@example.com',
))
@@ -65,6 +66,7 @@ class TestSystemConfiguration(unittest.TestCase):
'https://publicsuffix.org/list/public_suffix_list.dat',
resolver_lifetime='5s',
resolver_timeout='3s',
+ self_link='http://localhost:9001/3.0/system/configuration/dmarc',
))
def test_dotted_section(self):
@@ -78,6 +80,8 @@ class TestSystemConfiguration(unittest.TestCase):
description='French',
charset='iso-8859-1',
enabled='yes',
+ self_link=('http://localhost:9001/3.0/system'
+ '/configuration/language.fr'),
))
def test_multiline(self):