-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from mozilla-services/documentation-improvements
Documentation improvements
- Loading branch information
Showing
8 changed files
with
687 additions
and
624 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,104 @@ | ||
Working with collections | ||
======================== | ||
|
||
.. _collections: | ||
|
||
Collections are always linked to a `bucket <buckets>`_. | ||
Collections | ||
########### | ||
|
||
A collection belongs to a bucket and stores records. | ||
|
||
A collection is a mapping with the following attributes: | ||
|
||
.. note:: | ||
* ``permissions``: (*optional*) the :term:`ACLs <ACL>` for the collection object | ||
|
||
By default users have a bucket that is used for their own data. | ||
|
||
Application can use this default bucket with the ``~`` shortcut. | ||
.. .. note:: | ||
|
||
ie: ``/buckets/~/collections/contacts`` will be the current user contacts. | ||
.. By default users have a bucket that is used for their own data. | ||
.. Application can use this default bucket with the ``~`` shortcut. | ||
.. ie: ``/buckets/~/collections/contacts`` will be the current user contacts. | ||
/buckets/<bucket_id>/collections/<collection_id> | ||
================================================ | ||
PUT /buckets/<bucket_id>/collections/<collection_id> | ||
==================================================== | ||
|
||
**Requires authentication** | ||
|
||
End-point for the collection of records: | ||
Creates or replaces a collection object. | ||
|
||
.. code-block:: http | ||
* Create record | ||
* Fetch, sort and filter records | ||
$ http PUT http://localhost:8888/v1/buckets/blog/collections/articles --auth "admin:" | ||
HTTP/1.1 200 OK | ||
Access-Control-Expose-Headers: Backoff, Retry-After, Alert | ||
Content-Length: 47 | ||
Content-Type: application/json; charset=UTF-8 | ||
Date: Wed, 10 Jun 2015 13:10:30 GMT | ||
Server: waitress | ||
{ | ||
"id": "articles", | ||
"last_modified": 1433941830569, | ||
"permissions": { | ||
"write": [ | ||
"fxa:af3e077eb9f5444a949ad65aa86e82ff" | ||
] | ||
} | ||
} | ||
.. note:: | ||
|
||
A collection is considered empty by default. In other words, no error will | ||
be thrown if the collection id is unknown. | ||
In order to create only if does not exist yet, a ``If-None-Match: *`` | ||
request header can be provided. A ``412 Precondition Failed`` error response | ||
will be returned if the record already exists. | ||
|
||
|
||
GET /buckets/<bucket_id>/collections/<collection_id> | ||
==================================================== | ||
|
||
**Requires authentication** | ||
|
||
Returns the collection object. | ||
|
||
.. code-block:: http | ||
$ http GET http://localhost:8888/v1/buckets/blog/collections/articles --auth "admin:" | ||
HTTP/1.1 200 OK | ||
Access-Control-Expose-Headers: Backoff, Retry-After, Alert, Last-Modified, ETag | ||
Content-Length: 47 | ||
Content-Type: application/json; charset=UTF-8 | ||
Date: Wed, 10 Jun 2015 13:11:25 GMT | ||
Last-Modified: 1433941885974 | ||
Server: waitress | ||
See `cliquet resource documentation | ||
<http://cliquet.readthedocs.org/en/latest/api/resource.html#get-resource>`_ | ||
for more details on available operations. | ||
{ | ||
"id": "articles", | ||
"last_modified": 1433941830569, | ||
"permissions": { | ||
"write": [ | ||
"fxa:af3e077eb9f5444a949ad65aa86e82ff" | ||
] | ||
} | ||
} | ||
/buckets/<bucket_id>/collections/<collection_id>/records/<record_id> | ||
==================================================================== | ||
DELETE /buckets/<bucket_id>/collections/<collection_id> | ||
======================================================= | ||
|
||
**Requires authentication** | ||
|
||
End-point for a single record of the collection: | ||
Deletes a specific collection, and **everything under it**. | ||
|
||
* Fetch | ||
* Modify | ||
* Replace | ||
* Delete | ||
.. code-block:: http | ||
$ http DELETE http://localhost:8888/v1/buckets/blog/collections/articles --auth "admin:" | ||
HTTP/1.1 200 OK | ||
Access-Control-Expose-Headers: Backoff, Retry-After, Alert | ||
Content-Length: 62 | ||
Content-Type: application/json; charset=UTF-8 | ||
Date: Wed, 10 Jun 2015 13:13:55 GMT | ||
Server: waitress | ||
See `cliquet record documentation <http://cliquet.readthedocs.org/en/latest/api/resource.html#get-resource-id>`_ | ||
for more details on available operations. | ||
{ | ||
"deleted": true, | ||
"id": "articles", | ||
"last_modified": 1433942035743 | ||
} |
Oops, something went wrong.