The document discusses Representational State Transfer (REST) and its implementation in the eZ Publish content management system. It begins with an overview of REST principles like giving resources IDs, linking resources, using standard HTTP methods, and communicating statelessly. It then covers how eZ Publish 5 is built on Symfony and includes REST APIs for content creation, retrieval, updating and deletion across the system. The document concludes with a demonstration of making REST API calls to retrieve content from eZ Publish and manipulate it.
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
A REST Layer on Top of the World - IPC13 Munich
1. #REST #ezpublish #symfony #IPC13 #CMS #SOA #UX
A REST Layer on Top
of The World
Nicolas Pastorino | eZ Systems
VP Community & Online Marketing
@jeanvoye | nicolas.pastorino@ez.no
Contents: Courtesy of Damien Pobel
6. about:me
eZ Publish Community since 2005
Lead Community + Marketing at eZ
Content Management, Open-source, Mountaineering
7. about:me
eZ Publish Community since 2005
Lead Community + Marketing at eZ
Content Management, Open-source, Mountaineering
@jeanvoye
http://bit.ly/nicolas-on-gplus
http://fr.linkedin.com/in/nicolaspastorino/
https://github.com/nfrp
12. REST?
Set of principles that define how Web standards,
such as HTTP and URIs, are supposed to be used.
Give every “thing” an ID
Link things together (“HATEOAS”)
Use standard methods
Resources with multiple representations
Communicate statelessly
h"p://www.infoq.com/ar4cles/rest-‐introduc4on
h"p://en.wikipedia.org/wiki/Representa4onal_State_Transfer
14. REST? (ctd)
Key goals of REST include:
Scalability of component interactions
Generality of interfaces
Independent deployment of components
Intermediary components to reduce latency,
enforce security and encapsulate legacy systems
h"p://www.infoq.com/ar4cles/rest-‐introduc4on
h"p://en.wikipedia.org/wiki/Representa4onal_State_Transfer
18. HTTP 1.1 Request - Anatomy
• HTTP verb / method : GET,POST,PUT,DELETE,
TRACE,OPTIONS,HEAD, ...
• ... or a custom verb: PATCH,COPY, ...
• Set of headers
19. HTTP 1.1 Request - Anatomy
• HTTP verb / method : GET,POST,PUT,DELETE,
TRACE,OPTIONS,HEAD, ...
• ... or a custom verb: PATCH,COPY, ...
• Set of headers
• A body in POST,PUT or custom verb requests
22. HTTP 1.1 Response - Anatomy
• Status code (by @stevelosh)
• 1XX: hold on
23. HTTP 1.1 Response - Anatomy
• Status code (by @stevelosh)
• 1XX: hold on
• 2XX: here you go
24. HTTP 1.1 Response - Anatomy
• Status code (by @stevelosh)
• 1XX: hold on
• 2XX: here you go
• 3XX: go away
25. HTTP 1.1 Response - Anatomy
• Status code (by @stevelosh)
• 1XX: hold on
• 2XX: here you go
• 3XX: go away
• 4XX: you f * * * * d up
26. HTTP 1.1 Response - Anatomy
• Status code (by @stevelosh)
• 1XX: hold on
• 2XX: here you go
• 3XX: go away
• 4XX: you f * * * * d up
• 5XX: I f * * * * d up
27. HTTP 1.1 Response - Anatomy
• Status code (by @stevelosh)
• 1XX: hold on
• 2XX: here you go
• 3XX: go away
• 4XX: you f * * * * d up
• 5XX: I f * * * * d up
• Set of headers
28. HTTP 1.1 Response - Anatomy
• Status code (by @stevelosh)
• 1XX: hold on
• 2XX: here you go
• 3XX: go away
• 4XX: you f * * * * d up
• 5XX: I f * * * * d up
• Set of headers
• A body depending on the response
39. REST API in eZ Publish
•
•
•
Read / Write
•
•
•
•
5.x
Support Basic Auth and Session Auth
Prefix /ezp/api/v2/
Allows to handle almost everything in the repository
(Content, Location, Types, ...)
XML or JSON support in input and output
Hypermedia as the Engine of Application State (HATEOAS)
Specifications: http://j.mp/ezpublish-rest-spec
44. Demo Synopsis
•
•
•
Navigate to http://cp2013.9.loc/ then to http://cp2013.9.loc/Blog
Add Blog post from http://cp2013.9.loc/ezdemo_site_admin/Blog (Content: http://phpconference.com/2013/en/sessions/rest-layer-top-world )
REST: Request REST Root:
•
•
•
Explain all parameters, then run.
REST: Show children of Content root
•
•
chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo/RestClient.html#RequestPlace:projectEndpoint/1
chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo/RestClient.html#RequestPlace:projectEndpoint/2
REST: Show Location/Content/ContentInfo for one child (“Blog”)
•
•
•
•
chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo/RestClient.html#RequestPlace:projectEndpoint/3
chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo/RestClient.html#RequestPlace:projectEndpoint/5
REST: Show children of one child (“Blog”)
•
•
•
•
chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo/RestClient.html#RequestPlace:projectEndpoint/4
Edit Content, then reload.
Show children: chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo/RestClient.html#RequestPlace:projectEndpoint/8
Delete the previously created blog post: curl -u "admin:publish" -X DELETE http://cp2013.9.loc/api/ezp/v2/content/objects/<objectId>
Refresh children list: Show children: chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo/RestClient.html#RequestPlace:projectEndpoint/8
REST: Create an Image object
•
•
Show ContentType (ContentClass) in back-office: http://cp2013.9.loc/ezdemo_site_admin/class/view/27
Create image from command line
•
•
$> cdipc13
•
•
Publish object: curl -u "admin:publish" -X PUBLISH http://cp2013.9.loc/api/ezp/v2/content/objects/<object Id>/versions/1
$> curl -u "admin:publish" -i -H "Accept: application/json" -H "Content-Type: application/vnd.ez.api.ContentCreate+json" -X POST -d
@createimage.json http://cp2013.9.loc/api/ezp/v2/content/objects
Show image in the back-office: http://cp2013.9.loc/ezdemo_site_admin/eZ-Systems-logo-created-with-the-REST-API
46. REST API for more than
service-to-service: UX example
47. REST API for more than
service-to-service: UX example
• API REST as provider for ajax calls - data
• Initial page load (JS code, generating an
interface) - then Ajax+REST for navigation, data
retrieval,
• Total separation of functional UX and data
retrieval + back-end business logic.
48. REST API for more than
service-to-service: UX example
49. REST API for more than
service-to-service: UX example
• Tools
• JS lib, REST client: https://github.com/
ezsystems/ez-js-rest-client
• Reproduction of the public PHP API: exposing
services
• Relying on HATEOS, but simplifying usage of it
50. REST API for more than
service-to-service: UX example
51. REST API for more than
service-to-service: UX example
• Why?
• Easy to discover the REST API structure from a client
• BC support: no URL hard-coding, painless clientside, all existing projects relying on the API need not
be modified,
• Simplifies cache management (HTTP): easy to know
exactly which resource is to be expired after a
change in content repository.
52.
53.
54.
55.
56. Demo Synopsis
•
•
•
•
Navigate to http://cp2013.9.loc/summercamp/rest-test
Open Console > Network > Filter with “XHR” only
Reload page, and clear console
Click on “Details” for “Blog”
•
Inspect request in console:
•
•
•
•
show URL
In “Preview” subtab: show response, focus on “Content.Section”
--> Show next request (back to “Headers” subtab): Section
•
•
•
•
show”Accept” header value,
show”Accept” header value,
show URL
In “Preview” subtab: show response, focus on “Section.name”
--> Show next request (back to “Headers” subtab): Owner
60. Slides available soon at
http://slideshare.net/jeanvoye
@jeanvoye
http://bit.ly/nicolas-on-gplus
http://fr.linkedin.com/in/nicolaspastorino/
https://github.com/nfrp
eZ Publish Community http://share.ez.no
eZ Publish 5 Community Project
http://share.ez.no/download
https://github.com/ezsystems/ezpublish-community
eZ Systems & eZ Publish Platform Enterprise Edition
http://ez.no