SlideShare une entreprise Scribd logo
1  sur  60
Télécharger pour lire hors ligne
#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
about:eZ
about:eZ
Enterprise Open-source since 1999
Creators of eZ Publish Platform
Global
Business: http://ez.no | Community: http://share.ez.no
about:eZ
Enterprise Open-source since 1999
Creators of eZ Publish Platform
Global
Business: http://ez.no | Community: http://share.ez.no
@eZSystems
http://google.com/+ezsystems
http://linkedin.com/company/16738
https://github.com/ezsystems
about:me
about:me
eZ Publish Community since 2005
Lead Community + Marketing at eZ
Content Management, Open-source, Mountaineering
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
T

O

D

A

Y
Y

REST

A

eZ Publish

D

REST in eZ Publish

O

DEMO

T

REST for UX
REST

5
REST?

h"p://www.infoq.com/ar4cles/rest-­‐introduc4on
h"p://en.wikipedia.org/wiki/Representa4onal_State_Transfer
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
REST? (ctd)

h"p://www.infoq.com/ar4cles/rest-­‐introduc4on
h"p://en.wikipedia.org/wiki/Representa4onal_State_Transfer
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
HTTP 1.1 Request - Anatomy
HTTP 1.1 Request - Anatomy
• HTTP verb / method : GET,POST,PUT,DELETE,
TRACE,OPTIONS,HEAD, ...
HTTP 1.1 Request - Anatomy
• HTTP verb / method : GET,POST,PUT,DELETE,
TRACE,OPTIONS,HEAD, ...

• ... or a custom verb: PATCH,COPY, ...
HTTP 1.1 Request - Anatomy
• HTTP verb / method : GET,POST,PUT,DELETE,
TRACE,OPTIONS,HEAD, ...

• ... or a custom verb: PATCH,COPY, ...
• Set of headers
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
HTTP 1.1 Response - Anatomy
HTTP 1.1 Response - Anatomy
• Status code (by @stevelosh)
HTTP 1.1 Response - Anatomy
• Status code (by @stevelosh)
• 1XX: hold on
HTTP 1.1 Response - Anatomy
• Status code (by @stevelosh)
• 1XX: hold on
• 2XX: here you go
HTTP 1.1 Response - Anatomy
• Status code (by @stevelosh)
• 1XX: hold on
• 2XX: here you go
• 3XX: go away
HTTP 1.1 Response - Anatomy
• Status code (by @stevelosh)
• 1XX: hold on
• 2XX: here you go
• 3XX: go away
• 4XX: you f * * * * d up
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
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
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
eZ Publish

10
Standard
Symfony2 App.
(=app)
Standard
Symfony2 App.
(=app)

+

eZ Publish
bundles
(PHP & REST APIs
+ Legacy)

vendor/
ezsystems/
ezpublish-kernel
Standard
Symfony2 App.
(=app)

+

eZ Publish
bundles
(PHP & REST APIs
+ Legacy)

vendor/
ezsystems/
ezpublish-kernel

+

Full-blown
Back-office
THIS is eZ Publish 5
Standard
Symfony2 App.
(=app)

+

eZ Publish
bundles
(PHP & REST APIs
+ Legacy)

vendor/
ezsystems/
ezpublish-kernel

+

Full-blown
Back-office
REST in eZ Publish

12
REST API in eZ Publish

4.x
REST API in eZ Publish

• eZ Publish 4.x has a REST API
• Prefix /ezp/api/v1/
• Read only
• Very limited scope / incomplete

4.x
REST API in eZ Publish

5.x
REST API in eZ Publish

5.x
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
A REST Layer on top of
a world of Content
A REST Layer on top of
a world of Content
A REST Layer on top of
a world of Content

o/
DEMO

16
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
REST for UX

18
REST API for more than
service-to-service: UX example
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.
REST API for more than
service-to-service: UX example
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
REST API for more than
service-to-service: UX example
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.
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
Wrap-up

24
T

O

D

A

Y
Y

REST

A

eZ Publish

D

REST in eZ Publish

O

DEMO

T

REST for UX
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

Contenu connexe

Similaire à A REST Layer on Top of the World - IPC13 Munich

Atmosphere 2014: Let's build a solid base for a scale. - Krzysztof Debski
Atmosphere 2014: Let's build a solid base for a scale. - Krzysztof DebskiAtmosphere 2014: Let's build a solid base for a scale. - Krzysztof Debski
Atmosphere 2014: Let's build a solid base for a scale. - Krzysztof Debski
PROIDEA
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
Joseph Scott
 
AtmosphereConf - Let's build a solid base for a scale
AtmosphereConf - Let's build a solid base for a scaleAtmosphereConf - Let's build a solid base for a scale
AtmosphereConf - Let's build a solid base for a scale
Krzysztof Debski
 
XFLTReaT: A New Dimension in Tunneling (Shakacon 2017)
XFLTReaT: A New Dimension in Tunneling (Shakacon 2017)XFLTReaT: A New Dimension in Tunneling (Shakacon 2017)
XFLTReaT: A New Dimension in Tunneling (Shakacon 2017)
Balazs Bucsay
 

Similaire à A REST Layer on Top of the World - IPC13 Munich (20)

JSON REST API for WordPress
JSON REST API for WordPressJSON REST API for WordPress
JSON REST API for WordPress
 
Free The Enterprise With Ruby & Master Your Own Domain
Free The Enterprise With Ruby & Master Your Own DomainFree The Enterprise With Ruby & Master Your Own Domain
Free The Enterprise With Ruby & Master Your Own Domain
 
Using eZ Platform in an API Era
Using eZ Platform in an API EraUsing eZ Platform in an API Era
Using eZ Platform in an API Era
 
Atmosphere 2014: Let's build a solid base for a scale. - Krzysztof Debski
Atmosphere 2014: Let's build a solid base for a scale. - Krzysztof DebskiAtmosphere 2014: Let's build a solid base for a scale. - Krzysztof Debski
Atmosphere 2014: Let's build a solid base for a scale. - Krzysztof Debski
 
Designing a beautiful REST json api
Designing a beautiful REST json apiDesigning a beautiful REST json api
Designing a beautiful REST json api
 
Scaling with swagger
Scaling with swaggerScaling with swagger
Scaling with swagger
 
Beyond 'Set it and Forget it': Proactively managing your EZproxy server
Beyond 'Set it and Forget it': Proactively managing your EZproxy serverBeyond 'Set it and Forget it': Proactively managing your EZproxy server
Beyond 'Set it and Forget it': Proactively managing your EZproxy server
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
 
JSON REST API for WordPress
JSON REST API for WordPressJSON REST API for WordPress
JSON REST API for WordPress
 
AtmosphereConf - Let's build a solid base for a scale
AtmosphereConf - Let's build a solid base for a scaleAtmosphereConf - Let's build a solid base for a scale
AtmosphereConf - Let's build a solid base for a scale
 
Mastering composer
Mastering composerMastering composer
Mastering composer
 
UCLA HACKU'11
UCLA HACKU'11UCLA HACKU'11
UCLA HACKU'11
 
05 integrate redis
05 integrate redis05 integrate redis
05 integrate redis
 
NullMQ @ PDX
NullMQ @ PDXNullMQ @ PDX
NullMQ @ PDX
 
Kubernetes and AWS Lambda can play nicely together
Kubernetes and AWS Lambda can play nicely togetherKubernetes and AWS Lambda can play nicely together
Kubernetes and AWS Lambda can play nicely together
 
Unleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ PlatformUnleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ Platform
 
Server Side Swift
Server Side SwiftServer Side Swift
Server Side Swift
 
HTMX: Web 1.0 with the benefits of Web 2.0 without the grift of Web 3.0
HTMX: Web 1.0 with the benefits of Web 2.0 without the grift of Web 3.0HTMX: Web 1.0 with the benefits of Web 2.0 without the grift of Web 3.0
HTMX: Web 1.0 with the benefits of Web 2.0 without the grift of Web 3.0
 
XFLTReaT: A New Dimension in Tunneling (Shakacon 2017)
XFLTReaT: A New Dimension in Tunneling (Shakacon 2017)XFLTReaT: A New Dimension in Tunneling (Shakacon 2017)
XFLTReaT: A New Dimension in Tunneling (Shakacon 2017)
 
Introduction to NodeJS with LOLCats
Introduction to NodeJS with LOLCatsIntroduction to NodeJS with LOLCats
Introduction to NodeJS with LOLCats
 

Plus de Nicolas Pastorino

Plus de Nicolas Pastorino (8)

Symfony et eZ Publish: embarquement immédiat - talk at Symfony Live Paris
Symfony et eZ Publish: embarquement immédiat - talk at Symfony Live ParisSymfony et eZ Publish: embarquement immédiat - talk at Symfony Live Paris
Symfony et eZ Publish: embarquement immédiat - talk at Symfony Live Paris
 
Nicolas Pastorino - Distribution de contenu scalable, le multicanal avec REST...
Nicolas Pastorino - Distribution de contenu scalable, le multicanal avec REST...Nicolas Pastorino - Distribution de contenu scalable, le multicanal avec REST...
Nicolas Pastorino - Distribution de contenu scalable, le multicanal avec REST...
 
Nicolas Pastorino - The Open-source roar in the eZ Community
Nicolas Pastorino - The Open-source roar in the eZ CommunityNicolas Pastorino - The Open-source roar in the eZ Community
Nicolas Pastorino - The Open-source roar in the eZ Community
 
Nicolas Pastorino - REST + recommendation, consume the right content, anywher...
Nicolas Pastorino - REST + recommendation, consume the right content, anywher...Nicolas Pastorino - REST + recommendation, consume the right content, anywher...
Nicolas Pastorino - REST + recommendation, consume the right content, anywher...
 
Nicolas Pastorino - eZ Community - Innovation and Open-source inside
Nicolas Pastorino - eZ Community - Innovation and Open-source insideNicolas Pastorino - eZ Community - Innovation and Open-source inside
Nicolas Pastorino - eZ Community - Innovation and Open-source inside
 
IPCse11 Nicolas Pastorino Launching content in mobility with REST and eZ Publish
IPCse11 Nicolas Pastorino Launching content in mobility with REST and eZ PublishIPCse11 Nicolas Pastorino Launching content in mobility with REST and eZ Publish
IPCse11 Nicolas Pastorino Launching content in mobility with REST and eZ Publish
 
Nicolas Pastorino - Launching Content in mobility with REST and eZ Publish
Nicolas Pastorino - Launching Content in mobility with REST and eZ PublishNicolas Pastorino - Launching Content in mobility with REST and eZ Publish
Nicolas Pastorino - Launching Content in mobility with REST and eZ Publish
 
Nicolas Pastorino - Launching content in mobility with REST & eZ Publish
Nicolas Pastorino - Launching content in mobility with REST & eZ PublishNicolas Pastorino - Launching content in mobility with REST & eZ Publish
Nicolas Pastorino - Launching content in mobility with REST & eZ Publish
 

Dernier

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+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
  • 3. about:eZ Enterprise Open-source since 1999 Creators of eZ Publish Platform Global Business: http://ez.no | Community: http://share.ez.no
  • 4. about:eZ Enterprise Open-source since 1999 Creators of eZ Publish Platform Global Business: http://ez.no | Community: http://share.ez.no @eZSystems http://google.com/+ezsystems http://linkedin.com/company/16738 https://github.com/ezsystems
  • 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
  • 9. Y REST A eZ Publish D REST in eZ Publish O DEMO T REST for UX
  • 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
  • 15. HTTP 1.1 Request - Anatomy
  • 16. HTTP 1.1 Request - Anatomy • HTTP verb / method : GET,POST,PUT,DELETE, TRACE,OPTIONS,HEAD, ...
  • 17. HTTP 1.1 Request - Anatomy • HTTP verb / method : GET,POST,PUT,DELETE, TRACE,OPTIONS,HEAD, ... • ... or a custom verb: PATCH,COPY, ...
  • 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
  • 20. HTTP 1.1 Response - Anatomy
  • 21. HTTP 1.1 Response - Anatomy • Status code (by @stevelosh)
  • 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
  • 31. Standard Symfony2 App. (=app) + eZ Publish bundles (PHP & REST APIs + Legacy) vendor/ ezsystems/ ezpublish-kernel
  • 32. Standard Symfony2 App. (=app) + eZ Publish bundles (PHP & REST APIs + Legacy) vendor/ ezsystems/ ezpublish-kernel + Full-blown Back-office
  • 33. THIS is eZ Publish 5 Standard Symfony2 App. (=app) + eZ Publish bundles (PHP & REST APIs + Legacy) vendor/ ezsystems/ ezpublish-kernel + Full-blown Back-office
  • 34. REST in eZ Publish 12
  • 35. REST API in eZ Publish 4.x
  • 36. REST API in eZ Publish • eZ Publish 4.x has a REST API • Prefix /ezp/api/v1/ • Read only • Very limited scope / incomplete 4.x
  • 37. REST API in eZ Publish 5.x
  • 38. REST API in eZ Publish 5.x
  • 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
  • 40. A REST Layer on top of a world of Content
  • 41. A REST Layer on top of a world of Content
  • 42. A REST Layer on top of a world of Content o/
  • 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
  • 59. Y REST A eZ Publish D REST in eZ Publish O DEMO T REST for UX
  • 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