async_client: Async JMAP calendar client#
Asynchronous JMAP client.
Mirrors JMAPClient with all public methods as coroutines.
Uses niquests’ AsyncSession for HTTP: the one part of calendaring-jmap with
no fallback to another HTTP library. See calendaring_jmap._http.
All response-parsing logic lives in _JMAPClientBase (client.py); each method here is a ~3-line async wrapper: get session, send request, delegate to parser.
- class calendaring_jmap.async_client.AsyncJMAPClient(url: str, username: str | None = None, password: str | None = None, auth=None, auth_type: str | None = None, timeout: int = 30)[source]#
Bases:
_JMAPClientBaseAsynchronous JMAP client for calendar operations.
The JMAP support is experimental, the API may change in minor-releases
Usage:
from calendaring_jmap import get_async_jmap_client async with get_async_jmap_client(url="https://jmap.example.com/.well-known/jmap", username="alice", password="secret") as client: calendars = await client.get_calendars()
- Parameters:
url – URL of the JMAP session endpoint (
/.well-known/jmap).username – Username for Basic auth.
password – Password for Basic auth, or bearer token if no username.
auth – A pre-built niquests-compatible auth object. Takes precedence over username/password if provided.
auth_type – Force a specific auth type:
"basic"or"bearer".timeout – HTTP request timeout in seconds.
- async aclose() None[source]#
Release the persistent HTTP session and its connection pool.
Only needed when the client was not used as an async context manager – the documented Quick Start builds one directly. Idempotent; the session is recreated on the next request.
- async create_event(calendar_id: str, ical_str: str) str[source]#
Create a calendar event from an iCalendar string.
- Parameters:
calendar_id – The JMAP calendar ID to create the event in.
ical_str – A VCALENDAR string representing the event.
- Returns:
The server-assigned JMAP event ID.
- Raises:
JMAPMethodError – If the server rejects the create request.
- async create_task(task_list_id: str, title: str, **kwargs) str[source]#
Create a task in a task list.
- Parameters:
task_list_id – The JMAP task list ID to create the task in.
title – Task title (maps to VTODO
SUMMARY).**kwargs – Optional JMAP Task fields using wire names:
description,due,start,timeZone,estimatedDuration,percentComplete,progress,priority.
- Returns:
The server-assigned JMAP task ID.
- Raises:
JMAPMethodError – If the server rejects the create request.
- async delete_event(event_id: str) None[source]#
Delete a calendar event.
- Parameters:
event_id – The JMAP event ID to delete.
- Raises:
JMAPMethodError – If the server rejects the delete.
- async delete_task(task_id: str) None[source]#
Delete a task.
- Parameters:
task_id – The JMAP task ID to delete.
- Raises:
JMAPMethodError – If the server rejects the delete.
- async get_calendars() list[JMAPCalendar[Literal[True]]][source]#
Fetch all calendars for the authenticated account.
- Returns:
List of
JMAPCalendarobjects.
- async get_event(event_id: str) JMAPCalendarObject[source]#
Fetch a calendar event as an iCalendar string.
- Parameters:
event_id – The JMAP event ID to retrieve.
- Returns:
A
JMAPCalendarObjectwrapping the raw JSCalendar dict.parentisNonesince noJMAPCalendaris available at the client level.- Raises:
JMAPMethodError – If the event is not found.
- async get_objects_by_sync_token(sync_token: str) tuple[list[JMAPCalendarObject], list[JMAPCalendarObject], list[str], str][source]#
Fetch events changed since a previous sync token.
Calls
CalendarEvent/changesto discover which events were created, modified, or destroyed sincesync_tokenwas issued. Created and modified events are returned asJMAPCalendarObjectinstances; destroyed events are returned as IDs (the objects no longer exist on the server).- Parameters:
sync_token – A state string previously returned by
get_sync_token()or by a prior call to this method.- Returns:
added: objects for newly created events (parentisNone).modified: objects for updated events (parentisNone).deleted: Event IDs that were destroyed.new_sync_token: Pass to the next call to this method assync_token.
- Return type:
A 4-tuple
(added, modified, deleted, new_sync_token)- Raises:
JMAPMethodError – If the server reports
hasMoreChanges: true.
- async get_sync_token() str[source]#
Return the current CalendarEvent state string for use as a sync token.
Calls
CalendarEvent/getwith an empty ID list — no event data is transferred, only thestatefield from the response.- Returns:
Opaque state string. Pass to
get_objects_by_sync_token()to retrieve only what changed since this point.
- async get_task(task_id: str) dict[source]#
Fetch a task by ID.
- Parameters:
task_id – The JMAP task ID to retrieve.
- Returns:
Raw JMAP Task dict as returned by the server.
- Raises:
JMAPMethodError – If the task is not found.
- async get_task_lists() list[dict][source]#
Fetch all task lists for the authenticated account.
- Returns:
List of raw JMAP TaskList dicts as returned by the server.
- async search_events(calendar_id: str | None = None, start: str | None = None, end: str | None = None, text: str | None = None) list[JMAPCalendarObject][source]#
Search for calendar events.
All parameters are optional; omitting all returns every event in the account. Results are fetched in a single batched JMAP request using a result reference from
CalendarEvent/queryintoCalendarEvent/get.- Parameters:
calendar_id – Limit results to this calendar.
start – Only events ending after this datetime (
YYYY-MM-DDTHH:MM:SS).end – Only events starting before this datetime (
YYYY-MM-DDTHH:MM:SS).text – Free-text search across title, description, locations, and participants.
- Returns:
List of
JMAPCalendarObjectinstances.parentisNoneon these objects; useJMAPCalendar.search()if you needparentset.