class Client: (source)
Access the Mailman REST API root.
Parameters | |
baseurl | The base url to access the Mailman 3 REST API. |
name | The Basic Auth user name. If given, the password must
also be given. |
password | The Basic Auth password. If given the name must
also be given. |
request | Callable 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 |
Add a hook to process connections to Mailman's API. |
Method | create |
Create a new Domain. |
Method | create |
Create a new User. |
Method | delete |
Delete a Domain. |
Method | delete |
Delete a MailingList. |
Method | find |
Given a subscriber and a role, return all the list they are subscribed to with given role. |
Method | find |
Find users with query string matching display name and emails. |
Method | find |
Same as find_users but allows for pagination. |
Method | get |
Given an Email Address, return the Address object. |
Method | get |
Get a list of all the bans with pagination. |
Method | get |
Get Domain by its mail_host. |
Method | get |
Get a MailingList object. |
Method | get |
Get a list of all MailingList with pagination. |
Method | get |
Get a list of all the MailingLists. |
Method | get |
Get the Member object for a given MailingList and Subsciber's Email Address. |
Method | get |
Return a paginated list of Members. |
Method | get |
Get the Member object for a given MailingList and Non-member's Email. |
Method | get |
Get paginated site-context templates. |
Method | get |
Given an Email Address, return the User it belongs to. |
Method | get |
Get all the users with pagination. |
Method | set |
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 |
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 | A list of callables that take in a dictionary of parameters. params is the list of request parameters before the request is made. |
Create a new Domain.
Parameters | |
mail | Undocumented |
base | Undocumented |
description | Undocumented |
owner | Undocumented |
alias | Undocumented |
str mail | The Mail host for the new domain. If you want foo@bar.com" as the address for your MailingList, use "bar.com" here. |
str description | A brief description for this Domain. |
str owner | Email address for the owner of this list. |
str alias | Alias domain. |
Returns | |
Domain | The created Domain. |
Create a new User.
Parameters | |
Undocumented | |
password | Undocumented |
display | Undocumented |
str email | Email address for the new user. |
str password | Password for the new user. |
str display | An optional name for the new user. |
Returns | |
User | The created user instance. |
Delete a Domain.
Parameters | |
mail | Undocumented |
str mail | The Mail host for the domain you want to delete. |
Delete a MailingList.
Parameters | |
fqdn | Undocumented |
str fqdn | Fully qualified name of the MailingList. |
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 | |
subscriber | Undocumented |
role | Undocumented |
count | Undocumented |
page | Undocumented |
mail | Undocumented |
str subscriber | The address of the subscriber. |
str role | owner, moderator or subscriber. |
int count | Number of entries per-page (defaults to 50). |
int page | The page number to return (defaults to 1). |
str mail | Domain to filter results by. |
Returns | |
List[ MailingList ] | A filtered list of mailing lists with given filters. |
Find users with query string matching display name and emails.
Parameters | |
query | Undocumented |
str query | The string to search for. The search string is case insensitive as core doens't care about the case. |
int count | Number of entries per-page (defaults to 50). |
int page | The page number to return (defaults to 1). |
Same as find_users
but allows for pagination.
Parameters | |
query | Undocumented |
count | Undocumented |
page | Undocumented |
str query | The string to search for. The search string is case insensitive as core doens't care about the case. |
int count | Number of entries per-page (defaults to 50). |
int page | The page number to return (defaults to 1). |
Given an Email Address, return the Address object.
Parameters | |
address | Undocumented |
str address | Email address. |
Returns | |
Address | The Address object for given email address. |
Get a list of all the bans with pagination.
Parameters | |
count | Undocumented |
page | Undocumented |
int count | Number of entries per-page (defaults to 50). |
int page | The page number to return (defaults to 1). |
Returns | |
Page of BannedAddress | Paginated list of banned addresses. |
Get a MailingList object.
Parameters | |
fqdn | Undocumented |
str fqdn | Fully qualified name of the MailingList. |
Returns | |
MailingList | The mailing list object of the given fqdn_listname. |
Get a list of all MailingList with pagination.
Parameters | |
count | Number of entries per-page (defaults to 50). |
page | The page number to return (defaults to 1). |
advertised | If marked True, returns all MailingLists including the ones that aren't advertised. |
mail | Domain to filter results by. |
Get a list of all the MailingLists.
Parameters | |
advertised:bool | If marked True, returns all MailingLists including the ones that aren't advertised. |
Returns | |
List( MailingList ) | A list of mailing lists. |
Get the Member object for a given MailingList and Subsciber's Email Address.
Parameters | |
fqdn | Undocumented |
subscriber | Undocumented |
str fqdn | Fully qualified address for the MailingList. |
str subscriber | Email Address for the subscriber. |
Returns | |
Member | A member of a list. |
Get the Member object for a given MailingList and Non-member's Email.
Parameters | |
fqdn | Undocumented |
nonmember | Undocumented |
str fqdn | Fully qualified address for the MailingList. |
str subscriber | Email Address for the non-member. |
Returns | |
Member | A member of a list. |
Given an Email Address, return the User it belongs to.
Parameters | |
address | Undocumented |
str address | Email Address of the User. |
Returns | |
User | The user instance that owns the address. |
Set template in site-context.
Parameters | |
template | Undocumented |
url | Undocumented |
username | Undocumented |
password | Undocumented |
str template | The template to set. |
str url | The URL to fetch the template from. |
str username | Username for access to the template. |
str password | Password for the username to access templates. |