Skip to content

Commit

Permalink
Merge branch 'master' into barcelona-mocks
Browse files Browse the repository at this point in the history
Conflicts:
	src/plone/restapi/tests/test_documentation.py
  • Loading branch information
lukasgraf committed May 16, 2016
2 parents 78c905c + 7fa90f4 commit f9e2916
Show file tree
Hide file tree
Showing 54 changed files with 560 additions and 1,811 deletions.
10 changes: 10 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ Further Reading

.. _`REST in Practice: Hypermedia and Systems Architecture (Webber, Parastatidis, Robinson)`: http://www.amazon.com/gp/product/0596805829

Standards
=========

- JSON-LD: http://www.w3.org/TR/json-ld/
- JSON Schema: http://json-schema.org/
- Schema.org: http://schema.org/
- Hydra: http://www.w3.org/ns/hydra/spec/latest/core/
- Collection+JSON: http://amundsen.com/media-types/collection/
- Siren: https://github.com/kevinswiber/siren

License
=======

Expand Down
6 changes: 5 additions & 1 deletion base.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ develop = .
sources-dir = extras
auto-checkout =
# plone.rest
sphinxcontrib-osexample

[instance]
recipe = plone.recipe.zope2instance
Expand Down Expand Up @@ -70,7 +71,9 @@ interpreter = ${buildout:directory}/bin/${sphinx-python:interpreter}

[sphinx-python]
recipe = zc.recipe.egg
eggs = sphinxcontrib-httpdomain
eggs =
sphinxcontrib-httpdomain
sphinxcontrib-osexample
interpreter = sphinxPython

[deploy-to-heroku]
Expand All @@ -83,3 +86,4 @@ mode = 755

[sources]
plone.rest = git git://github.com/plone/plone.rest.git pushurl=git@github.com:plone/plone.rest.git branch=master
sphinxcontrib-osexample = git https://github.com/svx/sphinxcontrib-osexample.git branch=plone
1 change: 0 additions & 1 deletion docs/source/_json/collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ HTTP 200 OK
content-type: application/json

{
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
"@id": "http://localhost:55001/plone/collection",
"@type": "Collection",
"UID": "d0c89bc77f874ce1aad5720921d875c0",
Expand Down
1 change: 0 additions & 1 deletion docs/source/_json/document.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ HTTP 200 OK
content-type: application/json

{
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
"@id": "http://localhost:55001/plone/front-page",
"@type": "Document",
"UID": "1f699ffa110e45afb1ba502f75f7ec33",
Expand Down
1 change: 0 additions & 1 deletion docs/source/_json/event.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ HTTP 200 OK
content-type: application/json

{
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
"@id": "http://localhost:55001/plone/event",
"@type": "Event",
"UID": "846d632bc0854c5aa6d3dcae171ed2db",
Expand Down
1 change: 0 additions & 1 deletion docs/source/_json/file.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ HTTP 200 OK
content-type: application/json

{
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
"@id": "http://localhost:55001/plone/file",
"@type": "File",
"UID": "9b6a4eadb9074dde97d86171bb332ae9",
Expand Down
1 change: 0 additions & 1 deletion docs/source/_json/folder.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ HTTP 200 OK
content-type: application/json

{
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
"@id": "http://localhost:55001/plone/folder",
"@type": "Folder",
"UID": "fc7881c46d61452db4177bc059d9dcb5",
Expand Down
1 change: 0 additions & 1 deletion docs/source/_json/image.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ HTTP 200 OK
content-type: application/json

{
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
"@id": "http://localhost:55001/plone/image",
"@type": "Image",
"UID": "2166e81a0c224fe3b62e197c7fdc9c3e",
Expand Down
1 change: 0 additions & 1 deletion docs/source/_json/link.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ HTTP 200 OK
content-type: application/json

{
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
"@id": "http://localhost:55001/plone/link",
"@type": "Link",
"UID": "6ff48d27762143a0ae8d63cee73d9fc2",
Expand Down
1 change: 0 additions & 1 deletion docs/source/_json/newsitem.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ HTTP 200 OK
content-type: application/json

{
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
"@id": "http://localhost:55001/plone/newsitem",
"@type": "News Item",
"UID": "80c2a074cb4240d08c9a129e3a834c74",
Expand Down
8 changes: 7 additions & 1 deletion docs/source/_json/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ HTTP 200 OK
content-type: application/json

{
"items_count": 1,
"items_count": 2,
"member": [
{
"@id": "http://localhost:55001/plone/front-page",
"@type": "Document",
"description": "Congratulations! You have successfully installed Plone.",
"title": "Welcome to Plone"
},
{
"@id": "http://localhost:55001/plone/robot-test-folder",
"@type": "Folder",
"description": "",
"title": "Test Folder"
}
]
}
7 changes: 6 additions & 1 deletion docs/source/_json/siteroot.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ HTTP 200 OK
content-type: application/json

{
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
"@id": "http://localhost:55001/plone",
"@type": "Plone Site",
"member": [
{
"@id": "http://localhost:55001/plone/robot-test-folder",
"@type": "Folder",
"description": "",
"title": "Test Folder"
},
{
"@id": "http://localhost:55001/plone/front-page",
"@type": "Document",
Expand Down
27 changes: 27 additions & 0 deletions docs/source/_json/workflow_get.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
GET /plone/front-page/workflow
Accept: application/json

HTTP 200 OK
content-type: application/json

{
"history": [
{
"action": null,
"actor": "test_user_1_",
"comments": "",
"review_state": "private",
"time": "2016-05-16T13:42:42+00:00"
}
],
"transitions": [
{
"@id": "http://localhost:55001/plone/front-page/workflow/publish",
"title": "Publish"
},
{
"@id": "http://localhost:55001/plone/front-page/workflow/submit",
"title": "Submit for publication"
}
]
}
13 changes: 13 additions & 0 deletions docs/source/_json/workflow_post.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
POST /plone/front-page/workflow/publish
Accept: application/json

HTTP 200 OK
content-type: application/json

{
"action": "publish",
"actor": "admin",
"comments": "",
"review_state": "published",
"time": "2016-05-16T13:42:42+00:00"
}
40 changes: 40 additions & 0 deletions docs/source/authentication.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
==============
Authentication
==============

``plone.restapi`` uses Plone PAS for Authentication.

That means that any authentication method supported by an installed PAS Plugin
should work, assuming it's an authentication method that makes sense to use
with an API.

For example, to authenticate using HTTP basic auth, you'd set an
``Authorization`` header:

.. code::
GET /Plone HTTP/1.1
Authorization: Basic Zm9vYmFyOmZvb2Jhcgo=
Accept: application/json
HTTP client libraries usually contain helper functions to produce a proper
``Authorization`` header for you based on given credentials.

Using the ``requests`` library, you'd set up a session with basic auth like
this:

.. code:: python
import requests
session = requests.Session()
session.auth = ('username', 'password')
session.headers.update({'Accept': 'application/json'})
response = session.get(url)
Or the same example using ``curl``:

.. code:: python
curl -u username:password -H 'Accept:application/json' $URL

0 comments on commit f9e2916

Please sign in to comment.