class documentation

class Client: (source)

View In Hierarchy

Access the Mailman REST API root.
Parameters
baseurlThe base url to access the Mailman 3 REST API.
nameThe Basic Auth user name. If given, the password must also be given.
passwordThe Basic Auth password. If given the name must also be given.
request​_hooksCallable hooks to process request parameters before being sent to Core's API.
Method __init__ Initialize client access to the REST API.
Method __repr__ Undocumented
Method add​_hooks Add a hook to process connections to Mailman's API.
Method create​_domain Create a new Domain.
Method create​_user Create a new User.
Method delete​_domain Delete a Domain.
Method delete​_list Delete a MailingList.
Method find​_lists Given a subscriber and a role, return all the list they are subscribed to with given role.
Method find​_users Find users with query string matching display name and emails.
Method find​_users​_page Same as find_users but allows for pagination.
Method get​_address Given an Email Address, return the Address object.
Method get​_bans​_page Get a list of all the bans with pagination.
Method get​_domain Get Domain by its mail_host.
Method get​_list Get a MailingList object.
Method get​_list​_page Get a list of all MailingList with pagination.
Method get​_lists Get a list of all the MailingLists.
Method get​_member Get the Member object for a given MailingList and Subsciber's Email Address.
Method get​_member​_page Return a paginated list of Members.
Method get​_nonmember Get the Member object for a given MailingList and Non-member's Email.
Method get​_templates​_page Get paginated site-context templates.
Method get​_user Given an Email Address, return the User it belongs to.
Method get​_user​_page Get all the users with pagination.
Method set​_template Set template in site-context.
Property bans Get a list of all the bans.
Property chains Get a list of all the Chains.
Property configuration Get the system configuration.
Property domains Get a list of all Domains.
Property lists Get a list of all MailingLists.
Property members Get a list of all the Members.
Property pipelines Get a list of all Pipelines.
Property preferences Get all default system Preferences.
Property queues Get a list of all Queues.
Property styles All the default styles in Mailman Core.
Property system Get the basic system information.
Property templates Get all site-context templates.
Property users Get all the users.
Instance Variable _connection Undocumented
def __init__(self, baseurl, name=None, password=None, request_hooks=None): (source)
Initialize client access to the REST API.
def __repr__(self): (source)

Undocumented

def add_hooks(self, request_hooks): (source)

Add a hook to process connections to Mailman's API.

Hooks are callables that are passed in the parameters of HTTP call made to Mailman Core' RESt API and are expected to return the same number of parameters back. This can be useful to manipulate parameters and update them, or simply log each call to API.

from mailmanclient.client import Client
client = Client('http://localhost:8001/3.1', <user>, <password>)

def sample_hook(params):
    print(f'Request params are {params}')
    return params

client.add_hook([sample_hook])
Parameters
request​_hooksA list of callables that take in a dictionary of parameters. params is the list of request parameters before the request is made.
def create_domain(self, mail_host, base_url=MISSING, description=None, owner=None, alias_domain=None): (source)
Create a new Domain.
Parameters
mail​_hostUndocumented
base​_urlUndocumented
descriptionUndocumented
ownerUndocumented
alias​_domainUndocumented
str mail​_hostThe Mail host for the new domain. If you want foo@bar.com" as the address for your MailingList, use "bar.com" here.
str descriptionA brief description for this Domain.
str ownerEmail address for the owner of this list.
str alias​_domainAlias domain.
Returns
DomainThe created Domain.
def create_user(self, email, password, display_name=''): (source)
Create a new User.
Parameters
emailUndocumented
passwordUndocumented
display​_nameUndocumented
str emailEmail address for the new user.
str passwordPassword for the new user.
str display​_nameAn optional name for the new user.
Returns
UserThe created user instance.
def delete_domain(self, mail_host): (source)
Delete a Domain.
Parameters
mail​_hostUndocumented
str mail​_hostThe Mail host for the domain you want to delete.
def delete_list(self, fqdn_listname): (source)
Delete a MailingList.
Parameters
fqdn​_listnameUndocumented
str fqdn​_listnameFully qualified name of the MailingList.
def find_lists(self, subscriber, role=None, count=50, page=1, mail_host=None): (source)

Given a subscriber and a role, return all the list they are subscribed to with given role.

If no role is specified all the related mailing lists are returned without duplicates, even though there can potentially be multiple memberships of a user in a single mailing list.

Parameters
subscriberUndocumented
roleUndocumented
countUndocumented
pageUndocumented
mail​_hostUndocumented
str subscriberThe address of the subscriber.
str roleowner, moderator or subscriber.
int countNumber of entries per-page (defaults to 50).
int pageThe page number to return (defaults to 1).
str mail​_hostDomain to filter results by.
Returns
List[MailingList]A filtered list of mailing lists with given filters.
def find_users(self, query): (source)
Find users with query string matching display name and emails.
Parameters
queryUndocumented
str queryThe string to search for. The search string is case insensitive as core doens't care about the case.
int countNumber of entries per-page (defaults to 50).
int pageThe page number to return (defaults to 1).
def find_users_page(self, query, count, page): (source)
Same as find_users but allows for pagination.
Parameters
queryUndocumented
countUndocumented
pageUndocumented
str queryThe string to search for. The search string is case insensitive as core doens't care about the case.
int countNumber of entries per-page (defaults to 50).
int pageThe page number to return (defaults to 1).
def get_address(self, address): (source)
Given an Email Address, return the Address object.
Parameters
addressUndocumented
str addressEmail address.
Returns
AddressThe Address object for given email address.
def get_bans_page(self, count=50, page=1): (source)
Get a list of all the bans with pagination.
Parameters
countUndocumented
pageUndocumented
int countNumber of entries per-page (defaults to 50).
int pageThe page number to return (defaults to 1).
Returns
Page of BannedAddressPaginated list of banned addresses.
def get_domain(self, mail_host, web_host=MISSING): (source)
Get Domain by its mail_host.
def get_list(self, fqdn_listname): (source)
Get a MailingList object.
Parameters
fqdn​_listnameUndocumented
str fqdn​_listnameFully qualified name of the MailingList.
Returns
MailingListThe mailing list object of the given fqdn_listname.
def get_list_page(self, count=50, page=1, advertised=None, mail_host=None): (source)
Get a list of all MailingList with pagination.
Parameters
countNumber of entries per-page (defaults to 50).
pageThe page number to return (defaults to 1).
advertisedIf marked True, returns all MailingLists including the ones that aren't advertised.
mail​_hostDomain to filter results by.
def get_lists(self, advertised=False): (source)
Get a list of all the MailingLists.
Parameters
advertised:boolIf marked True, returns all MailingLists including the ones that aren't advertised.
Returns
List(MailingList)A list of mailing lists.
def get_member(self, fqdn_listname, subscriber_address): (source)
Get the Member object for a given MailingList and Subsciber's Email Address.
Parameters
fqdn​_listnameUndocumented
subscriber​_addressUndocumented
str fqdn​_listnameFully qualified address for the MailingList.
str subscriber​_addressEmail Address for the subscriber.
Returns
MemberA member of a list.
def get_member_page(self, count=50, page=1): (source)
Return a paginated list of Members.
Parameters
countUndocumented
pageUndocumented
int countNumber of items to return.
int pageThe page number.
Returns
Page of Member.Paginated lists of members.
def get_nonmember(self, fqdn_listname, nonmember_address): (source)
Get the Member object for a given MailingList and Non-member's Email.
Parameters
fqdn​_listnameUndocumented
nonmember​_addressUndocumented
str fqdn​_listnameFully qualified address for the MailingList.
str subscriber​_addressEmail Address for the non-member.
Returns
MemberA member of a list.
def get_templates_page(self, count=25, page=1): (source)
Get paginated site-context templates.
Returns
Page of TemplatePaginated list of templates of site context.
def get_user(self, address): (source)
Given an Email Address, return the User it belongs to.
Parameters
addressUndocumented
str addressEmail Address of the User.
Returns
UserThe user instance that owns the address.
def get_user_page(self, count=50, page=1): (source)
Get all the users with pagination.
Parameters
countUndocumented
pageUndocumented
int countNumber of entries per-page (defaults to 50).
int pageThe page number to return (defaults to 1).
Returns
Page of UserPaginated list of users on Mailman.
def set_template(self, template_name, url, username=None, password=None): (source)
Set template in site-context.
Parameters
template​_nameUndocumented
urlUndocumented
usernameUndocumented
passwordUndocumented
str template​_nameThe template to set.
str urlThe URL to fetch the template from.
str usernameUsername for access to the template.
str passwordPassword for the username to access templates.
@property
bans: Bans = (source)
Get a list of all the bans.
Returns
A list of all the bans.
@property
chains: List = (source)
Get a list of all the Chains.
Returns
A list of all the chains in Core.
@property
configuration: Dict[str, Configuration] = (source)
Get the system configuration.
Returns
All the system configuration.
@property
domains: List[Domain] = (source)
Get a list of all Domains.
Returns
All the domains on the system.
@property
lists: list(MailingList) = (source)
Get a list of all MailingLists.
Returns
All the mailing lists.
@property
members: List[Member] = (source)
Get a list of all the Members.
Returns
All the list memebrs.
@property
pipelines: List = (source)
Get a list of all Pipelines.
Returns
A list of all the pipelines in Core.
@property
preferences: Preferences = (source)
Get all default system Preferences.
Returns
System preferences.
@property
queues: List = (source)
Get a list of all Queues.
Returns
A list of all the queues in Core.
@property
styles: Styles = (source)
All the default styles in Mailman Core.
Returns
All the styles in Core.
@property
system: Dict[str, str] = (source)
Get the basic system information.
Returns
System information about Mailman Core
@property
templates: TemplateList = (source)
Get all site-context templates.
Returns
List of templates for the site context.
@property
users: List[User] = (source)
Get all the users.
Returns
All the users in Mailman Core.
_connection = (source)

Undocumented