Async API Reference
Async client for Mailman Core 3.1 API.
AsyncClient provides a thin Python API over Mailman Core’s HTTP API. It is currently is very early stages and supports on read operations. Some of the read operations might be missinng as well.
To start using the client, you need an async http library. httpx is officially supported one, but making some other client work with it is pretty easy.
>>> import httpx
>>> conn = httpx.AsyncClient()
>>> from mailmanclient.asynclient import AsyncClient
>>> client = AsyncClient(conn, 'http://localhost:8001/3.1',
... 'restadmin', 'restpass')
You will need an event loop to actually run the client. You can reuse your
existing one by calling await
on the client methods, or you can create a
new one using the standard library asyncio
module.
>>> import asyncio
>>> domains = asyncio.run(client.domains())
- class mailmanclient.asynclient.AsyncClient(client: HTTPClientProto, base_url: str, user: str, password: str)[source]
Provide an Idiomatic API for Mailman Core.
It requires an HTTP client instance as the first argument. You can use any client which has a
.request()
method and accepts named parametersurl
,path
,auth
,method
anddata
.data
is supposed to be a dictionary of parameters to be passed to the HTTP request and the rest are string parameters with their usual meaning.The parameters are based off on httpx python library.
- Parameters:
client – Http client object with an async request method.
base_url – Base URL to Core’s API.
user – Core admin username.
password – Core admin password.
- async find_members(list_id: str = None, subscriber: str = None, role: str = None, moderation_action: str = None, delivery_status: str = None, delivery_mode: str = None) List[Member] [source]
Find members.
/<api>/members/find
- Parameters:
list_id – Mailinglist id.
subscriber – Email or user_id or partial search string.
role – Membership role. One of ‘owner’, ‘member’, ‘nonmember’ or ‘moderator’.
moderation_action – One of the moderation action from ‘defer’, ‘accept’, ‘discard’, ‘reject’, ‘hold’.
delivery_status – Delivery status of the Member. It can be one among ‘enabled’, ‘by_user’, ‘by_moderator’ or ‘by_bounces’.
delivery_mode – Delivery mode of the member. It can be one between ‘plaintext_digests’, ‘mime_digests’, ‘regular’.
- async lists() List[MailingList] [source]
Get a list of MailingLists
/<api>/lists
- class mailmanclient.asyncobjects.domain.Domain(connection: ConnectionProto, data: ContentType)[source]
- async delete() Tuple[ResponseType, ContentType]
- async save() Tuple[ResponseType, ContentType]
- class mailmanclient.asyncobjects.mailinglist.MailingList(connection: ConnectionProto, data: ContentType)[source]
-
- async delete() Tuple[ResponseType, ContentType]
- async get_roster(role) List[Member] [source]
Get MailingList roster.
/<api>/lists/<listid>/roster/<role>
- async members() List[Member] [source]
Get Mailinglist members (subscribers.)
/<api>/lists/<listid>/roster/member
- async moderators() List[Member] [source]
Get Mailinglist moderators.
/<api>/lists/<listid>/roster/moderator
- async nonmember() List[Member] [source]
Get Mailinglist nonmembers.
/<api>/lists/<listid>/roster/nonmember
- async save() Tuple[ResponseType, ContentType]
- class mailmanclient.asyncobjects.member.Member(connection: ConnectionProto, data: ContentType)[source]
- async delete() Tuple[ResponseType, ContentType]
- async preferences()
- async save() Tuple[ResponseType, ContentType]
- class mailmanclient.asyncobjects.user.User(connection: ConnectionProto, data: ContentType)[source]
-
- async delete() Tuple[ResponseType, ContentType]
- async preferences()
- async save() Tuple[ResponseType, ContentType]