Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

REST API v3 proposal #35

Open
Open
@Danita

Description

@Danita

Hi! I'm developing a REST web client to use with ElasticInbox and two important things I've noticed with the current API implementation are:

  • Resources url do not follow REST standard accepted practices, which makes it really convoluted to employ REST libraries that expect that a resource would be accesible at /resource/{id}, a collection of them in /resources/, and nested resources in resource/{id}/children/ as many REST implementations do.
  • Responses do not follow commonly used JSON response formats, which forces us to do conversions before and after read/write.

I would love to help in the format of patches or pull requests, but I don't know a word of Java. Instead here is what I propose for the next API revision, and I hope some fellow collaborators with help with the code 😄

Labels

Get all labels
GET /{domain}/{user}/mailbox/labels/

Get one label
GET /{domain}/{user}/mailbox/labels/{label_id}

Create label
POST /{domain}/{user}/mailbox/labels/

Edit label
PUT /{domain}/{user}/mailbox/labels/{label_id}

Delete label
DELETE /{domain}/{user}/mailbox/labels/{label_id}

Messages

Get all messages
GET /{domain}/{user}/mailbox/messages/

Get one message (parsed)
GET /{domain}/{user}/mailbox/messages/{message_id}

Get one message (raw)
GET /{domain}/{user}/mailbox/messages/{message_id}?format=raw

Get one message (blob uri)
GET /{domain}/{user}/mailbox/messages/{message_id}?format=blob_uri

Get all messages in label
GET /{domain}/{user}/mailbox/labels/{label_id}/messages/

Get message part by part id or content id
GET /{domain}/{user}/mailbox/messages/{message_id}/parts/{part_id} (part_id format determines response)

Create message
POST /{domain}/{user}/mailbox/messages/

Edit message (also modifying labels and markers)
PUT /{domain}/{user}/mailbox/messages/{message_id}

Delete message
DELETE /{domain}/{user}/mailbox/messages/{message_id}

Mailbox

Purge deleted messages in mailbox
PUT /{domain}/{user}/mailbox/messages/purge

Update label counters
PUT /{domain}/{user}/mailbox/labels/refresh (not sure of verb)

Batch

Bulk operations could be handled at the resource level (PUT /mailbox/messages/{message_id},{message_id}... for edit, DELETE /mailbox/messages/{message_id},{message_id}... to delete) or via a dedicated url when the number of resources is too big to handle as part of the request url (PUT /mailbox/batch/messages/, DELETE /mailbox/batch/messages/) so the id collection to affect could be sent as part of the request body.

Miscelaneous

Data representation

All collections should be represented as an array of javascript primitives (strings, objects, other arrays):

[
    {
        "id" : 0
        "name" : "all"
    },
    {
        "id" : 1
        "name" : "inbox"
    },
    {
        "id" : 2
        "name" : "drafts"
    }
]

Domains and users

I'm not really sure of using /rest/v2/{domain}/{user}/ as a way to address either of them. I think that a structure like the following could also provide a RESTful way to handle CRUD for user and domain resources:

/rest/v2/domains/{domain}/accounts/{user}

Thus:

GET /rest/v2/domains/ (get all domains for this ElasticInbox instance)
POST /rest/v2/domains/ (create a new domain)
GET /rest/v2/domains/{domain} (get info for a specific domain)
GET /rest/v2/domains/{domain}/users/ (list users for a domain)
POST /rest/v2/domains/{domain}/users/ (create a new user for this domain)
GET /rest/v2/domains/{domain}/users/{user} (get info for this user)

...and so on. Thoughts?

Reference: http://shop.oreilly.com/product/9780596801694.do

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions