session: JMAP session discovery#
JMAP session establishment (RFC 8620 Section 2).
Fetches the Session object from /.well-known/jmap and extracts the information needed to make subsequent API calls.
- class calendaring_jmap.session.Session(api_url: str, account_id: str, state: str, account_capabilities: dict = <factory>, server_capabilities: dict = <factory>, upload_url: str | None = None, download_url: str | None = None, raw: dict = <factory>)[source]#
Bases:
objectParsed JMAP Session object (RFC 8620 Section 2).
- Variables:
api_url (str) – URL to POST method calls to.
account_id (str) – The accountId to use for calendar method calls. Chosen from
primaryAccountsif available, otherwise the first account advertising the calendars capability.state (str) – Current session state string.
account_capabilities (dict) – Capabilities dict for the chosen account.
server_capabilities (dict) – Server-level capabilities dict.
upload_url (str | None) – URI Template (RFC 8620 Section 6.1) for uploading a blob, or
Noneif the server omits it.download_url (str | None) – URI Template (RFC 8620 Section 6.2) for downloading a blob, or
Noneif the server omits it.raw (dict) – The full parsed Session JSON for anything not captured above.
- async calendaring_jmap.session.async_fetch_session(url: str, auth, timeout: int = 30) Session[source]#
Async variant of
fetch_session()using niquests.AsyncSession.- Parameters:
url – Full URL to the JMAP session endpoint.
auth – A niquests-compatible auth object.
- Returns:
Parsed
Sessionwithapi_urlandaccount_idset.- Raises:
JMAPAuthError – If the server returns HTTP 401 or 403.
JMAPCapabilityError – If no account advertises the calendars capability.
- calendaring_jmap.session.fetch_session(url: str, auth, timeout: int = 30) Session[source]#
Fetch and parse the JMAP Session object.
Performs a GET request to
url(expected to be/.well-known/jmapor equivalent), authenticates withauth, and returns a parsedSession.- Parameters:
url – Full URL to the JMAP session endpoint.
auth – A requests-compatible auth object (e.g. HTTPBasicAuth, HTTPBearerAuth).
- Returns:
Parsed
Sessionwithapi_urlandaccount_idset.- Raises:
JMAPAuthError – If the server returns HTTP 401 or 403.
JMAPCapabilityError – If no account advertises the calendars capability.
requests.HTTPError – For other non-2xx responses.