Services/Sync/Server/Archived/0.3/API: Difference between revisions

From MozillaWiki
< Services‎ | Sync‎ | Server‎ | Archived
Jump to navigation Jump to search
No edit summary
Line 16: Line 16:
| 64
| 64
| An identifying string. For a user, the id must be unique for a WBO within a collection, though objects in different collections may have the same ID.
| An identifying string. For a user, the id must be unique for a WBO within a collection, though objects in different collections may have the same ID.
|- valign="top"
| tag
| none
| 32
| An optional tag to allow segmentation of data within collections.
|- valign="top"
|- valign="top"
| parentid
| parentid
Line 52: Line 47:
{
{
"id": "B1549145-55CB-4A6B-9526-70D370821BB5",
"id": "B1549145-55CB-4A6B-9526-70D370821BB5",
"tag": "",
"parentid": "88C3865F-05A6-4E5C-8867-0FAC9AE264FC",
"parentid": "88C3865F-05A6-4E5C-8867-0FAC9AE264FC",
"modified": "2454725.98283",
"modified": "2454725.98283",
Line 113: Line 107:
| parentid
| parentid
| Returns the objects in the collection that are the children of the parent id given.
| Returns the objects in the collection that are the children of the parent id given.
|- valign="top"
| type
| Returns only objects in the collection that have been annotated with the type given.
|- valign="top"
|- valign="top"
| modified
| modified

Revision as of 18:24, 16 October 2008

Weave 0.3 API

Release Date: TBD

Weave Basic Object (WBO)

A Weave Basic Object is the generic wrapper around all items passed into and out of the Weave server. The Weave Basic Object has the following fields:

Parameter Default Max Description
id required 64 An identifying string. For a user, the id must be unique for a WBO within a collection, though objects in different collections may have the same ID.
parentid none 64 The id of a parent object in the same collection. This allows for the creation of hierarchical structures (such as folders).
modified time submitted 16 The last-modified date, in Julian date format.
encryption none 256 The URL of a Weave Encryption Record (WER) that defines how the payload is encrypted. No URL means that the payload is being sent unencrypted.
encoding utf-8 16 The character set of the decrypted payload.
payload none The (possibly encrypted) JSON structure encapsualting the data of the record. This structure is defined separately for each WBO type.

Sample:

{
	"id": "B1549145-55CB-4A6B-9526-70D370821BB5",
	"parentid": "88C3865F-05A6-4E5C-8867-0FAC9AE264FC",
	"modified": "2454725.98283",
	"encrytpion": "http://server/prefix/version/user/crypto-meta/B1549145-55CB-4A6B-9526-70D370821BB5",
	"encoding": "shift-JIS",
	"payload": "a89sdmawo58aqlva.8vj2w9fmq2af8vamva98fgqamff..."
}

URL Semantics

Term Description
server The name of the Weave server.
prefix Any added path prefix that defines the Weave namespace on that server.
version The Weave API version.
user The userid of the Weave user.
collection A defined grouping of objects into a set. All basic objects will be a member of one collection, and it will be the access point for those objects.
id The Weave Basic Object id.

A WBO will always be accessible at the following URL. All URLs will have REST semantics:

https://server/prefix/version/user/collection/id

GET: Retrieve the object.
PUT: Add/update the object.
DELETE: Delete the object.

Batch processing can be done with:

https://server/prefix/version/user/collection

GET: Returns a list of ids associated with the collection.
POST: Takes an array of WBOs and adds/updates them within the collection. Identical to doing a set of PUTs over /id urls.
DELETE: Deletes all objects in this collection.

Optional GET parameters:

Term Description
wbo The json objects/array of json objects to be POSTed
parentid Returns the objects in the collection that are the children of the parent id given.
modified Returns only objects in the collection that have been modified since the date given, ordered by earliest timestamp.
full If defined, returns the full objects, rather than a group of ids.
limit Caps the number of objects that will be returned.
offset Skips the first n objects, for use with the limit parameter

Response Codes

200 OK -- Returned on a successful request. Note that this does not guarantee that the server has done anything - deleting a nonexistent object will return a 200.

400 Bad Request -- Will be returned if there was an error in the client's request, such as malformed JSON, a protocol/content mismatch or a missing required field. The response will contain json data that may provide hints as to the problem.

401 Unauthorized -- Username and password do not allow access to the requested URL

404 Not Found -- Returned if the user does not exist.

503 Service Unavailable -- An internal error (storage failure). Please try back again later.

Payloads

Payloads are a hash with a required "type" key that defines the object type of the payload. Other keys will be required based on this type.

Here are some defined Payload Structures:

Bookmarks

(needs defining)

History

(needs defining)

Private Key

Public Key payloads must be unencrypted. Note that the key itself is still passphrase protected.

Parameter Default Description
key_data required The private key, passphrase encrypted.
public_key required The URI to the public key associated with this private key.

Sample

  "payload": 
  {
    "type: "private_key",
    "key_data": "nviuwc023nd210o3idn120x283cm...",
    "public_key": "A24349145-5AB-2YX-9526"
  }


Public Key

Public Key objects must be unencrypted.

Parameter Default Description
key_data required The public key
private_key required The URI to the private key associated with this private key.

Sample

  "payload": 
  {
    "type: "public_key",
    "key_data": "nviuwc023nd210o3idn120x283cm...",
    "private_key": "B24349145-5AB-2YX-9526"
  }

Cryptometa

Cryptometa objects (type: "cryptometa") must be unencrypted.

Parameter Default Description
algorithm required A hash, containing a "name" key and associated value, and any additional data required for the algorithm, such as "salt" or "iv".
keyring empty A hash in which the keys are URLs to publickey WERs and the values are the encryption string used with that key to encrypt this record. The keys may be fully qualified URLs, or relative to the id level (thus, just the id is acceptable)

Sample

  "payload": 
  {
    "type: "cryptometa",
    "algorithm": 
    {
      "name": "aes-256-cbc",
      "salt": "234imasd9f8w23m7",
      "iv": "2w3kmv9821maz985"
    }
    "keyring": 
    {
	  "B24349145-5AB-2YX-9526": "m29f2mnvwiecvnw0ev...",
    }
  }