Skip to content

miracle2k/jmap-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jmap-python

This Python library intends to implement JMAP as a set of generic primitives which are helpful in writing JMAP servers, as well as clients.

It's a work in progress, and far from complete, but is far enough along that you might find it useful.

Modules

In particular, it currently consists of the following parts:

  1. It implements the JMAP data types as light-weight Python models, and supports serializing/deserializing them to and from JSON, including proper validation according to the spec.

  2. It provides an execution engine to process a JMAP request, including handling resolving JSON pointers and references to previous results.

  3. It implements some of the controllers necessary for a server in a SansIO fashion, that is, without being based on any particular web framework.

    Want to write a JMAP server using Flask? Wrap the generic request handlers provided by this library within Flask views.

Using the models

from jmap.protocol.models import MailboxGetArgs, JMapRequest

# Parse the arguments a client might send for a `Mailbox/get` request: 
# https://jmap.io/spec-mail.html#mailbox/get
MailboxGetArgs.from_client({
    "account_id": 1,
    "ids": ["mailbox-1", "mailbox-2"]
})


# Parse a whole request structure:
JMapRequest.from_client({
    "using": [],
    "methodCalls": [["Core/echo", {"test": 42}, 1]]
})

Handling a request

TBD: Show the executor system.

Using the server views

TBD. The generic server helpers.

About

A JMAP library in Python.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages