Commit c7998081 authored by Florian Fuchs's avatar Florian Fuchs

* Introduced a dict-like ``archivers`` property.

* Removed the list class's set_archiver method. 
* Updated docs.
* Updated vcr yaml data.
parent 55bdc9c3
......@@ -452,20 +452,8 @@ class _List:
Returns a dict of all available archivers, along with their
activation status.
"""
response, content = self._connection.call(
'lists/{0}/archivers'.format(self.list_id))
# Remove `http_etag` property.
content.pop('http_etag')
return content
def set_archiver(self, archiver_name, enabled):
"""
Updates the status of a single archiver.
"""
response, content = self._connection.call(
'lists/{0}/archivers'.format(self.list_id),
{archiver_name: enabled},
method='PATCH')
url = 'lists/{0}/archivers'.format(self.list_id)
return _ListArchivers(self._connection, url, self)
def add_owner(self, address):
self.add_role('owner', address)
......@@ -572,6 +560,45 @@ class _List:
'lists/{0}'.format(self.fqdn_listname), None, 'DELETE')
class _ListArchivers:
def __init__(self, connection, url, list_obj):
self._connection = connection
self._url = url
self._list_obj = list_obj
self._info = None
def __repr__(self):
self._get_info()
return '<Archivers on "{0}">'.format(self._list_obj.list_id)
def _get_info(self):
if self._info is None:
response, content = self._connection.call(self._url)
# Remove `http_etag` from dictionary.
content.pop('http_etag')
self._info = content
def __iter__(self):
self._get_info()
for archiver in self._info:
yield self._info[archiver]
def __getitem__(self, key):
self._get_info()
return self._info[key]
def __setitem__(self, key, value):
self._get_info()
self._info[key] = value
self._connection.call(self._url, self._info, method='PUT')
def keys(self):
self._get_info()
for key in self._info:
yield key
class _Member:
def __init__(self, connection, url):
......
j==================
===================
Mailman REST client
===================
......@@ -693,18 +693,38 @@ Archivers
=========
Each list object has an ``archivers`` attribute holding a dictionary which
contains the activation status of all available archivers.
Each list object has an ``archivers`` attribute.
>>> archivers = test_one.archivers
>>> print(archivers)
<Archivers on "test-one.example.com">
The activation status of each available archiver can be accessed like a
key in a dictionary.
>>> archivers = test_one.archivers
>>> archivers = test_one.archivers
>>> for archiver in sorted(archivers.keys()):
... print('{0}: {1}'.format(archiver, archivers[archiver]))
mail-archive: True
mhonarc: True
prototype: False
Each archiver's status can be changed with the ``set_archiver`` method.
>>> archivers['mail-archive']
True
>>> archivers['mhonarc']
True
>>> test_one.set_archiver('mhonarc', False)
>>> test_one.archivers['mhonarc']
They can also be set like items in dictionary.
>>> archivers['mail-archive'] = False
>>> archivers['mhonarc'] = False
So if we get a new ``archivers`` object from the API (by accessing the
list's archiver attribute again), we can see that the archiver stati
have now been set.
>>> archivers = test_one.archivers
>>> archivers['mail-archive']
False
>>> archivers['mhonarc']
False
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment