SlideShare a Scribd company logo
1 of 39
REpresentational State
Transfer
GET https://PUG.at.dp.ua/representational-state-transfer HTTP/1.1
Dmytro Krasun, TonicForHealth, Kyiv
Agenda
1. REST ideas.
2. REST and HTTP.
3. Symfony and HTTP.
Hype cycle
REST and RPC
rest in peace
REST API
Idea
How often you cry about refactoring?
REpresentational State Transfer
Is about changing resource state through transferring resource representations.
Key concepts:
Resources and resource representations;
URI;
HATEOAS.
Resources and resource representations
“The key abstraction of information in REST is a resource. Any information that
can be named can be a resource: a document or image, a temporal service (e.g.
"today's weather in Los Angeles"), a collection of other resources, a non-virtual
object (e.g. a person), and so on. In other words, any concept that might be the
target of an author's hypertext reference must fit within the definition of a resource.
A resource is a conceptual mapping to a set of entities, not the entity that
corresponds to the mapping at any particular point in time.” - Roy Fielding’s
dissertation.
Resource and resource representations
Account ($1 500) is resource, but:
<ul class=”account”><li class=”currency”>USD</li><li class=”balance”>1500</li></ul>;
{“balance”: 1500};
{“balance”: 1500, “currency”: “USD”};
<account><balance currency=”USD”>1500</balance></account>;
<account currency=”USD” balance=”1500” />
Are different Account (read as resource) representations.
Uniform Resource Identifier
Uniform? Yes, not unique.
Resource can have more than one URI.
Examples: “james.bond”, “j.bond”, “007-company”.
URL (Uniform Resource Locator) as URI in HTTP:
Can be used as URI;
Valid URLs’: “http://james.bond”, “http://j.bond”, “ftp://zero-zero-
seven.com/docs.txt”.
“RESTful” URL
1. http://example.com/users/1?delete
2. http://example.com/delete-users/1
3. http://example.com/?userId=1&action=delete
4. http://example.com/getData?userId=1
5. http://example.com/users/1
6. http://example.com/user/1
What is really URL?
What is really URL?
Hypermedia as the Engine of Application State
Client interacts with an application entirely through hypermedia provided
dynamically.
Resource state machines.
Hypermedia as the Engine of Application State
It’s important
- Reliability (no need to store information about client which can be corrupted
or lost);
- Performance (cache);
- Scalability;
- Simplicity of interfaces;
- Ability to evolve and adapt to new requirements (WWW as example).
Implementation
HTTP as “framework”
HTTP verbs (POST, GET, DELETE and so on) for resource manipulations;
URL as URI for resource;
Request and response bodies for resource representations;
Status codes;
Headers (for more precise control):
Caching;
Authentication and authorization;
Versioning (E-Tag);
Transfer resource state
Early stage adopters
It’s very hard to implement REST in the right way.
Some of closest implementations: Github API, Amazon S3 REST API, JIRA
REST API.
Github API (https://developer.github.com/v3/repos/forks/):
HATEOAS (links to other resources);
Right granularity (POST /repos/:owner/:repo/forks);
Right status codes (202 Accepted for POST /repos/:owner/:repo/forks).
Standards
1. HTTP, URI, URI Template, JSON, XML, HTML and friends;
2. HAL - http://stateless.co/hal_specification.html;
3. Siren - https://github.com/kevinswiber/siren.
Resource modeling
is key problem.*
* There is no silver bullet :( **
** That’s why we earn money, because of thinking, so :)
1. I want to deposit money to account
We have account and account balance. Possible representation:
GET /accounts/{accountId}
{“account”: {“balance”: 1500, “currency”: “USD”}}
1. I want to deposit money to account
PUT /accounts/{accountId}
{“balance”: 1500, “currency”: “USD”}
Hmmm…
It’s better to PATCH /accounts/{accountId}
[{“op”: “replace”, “path”: “/balance”, “value”: 1500}]
1. I want to deposit money to account
Yes, it’s better to create transaction. Transaction is also resource.
POST /accounts/usd/transactions (Hey! why not
“/accounts/{accountId}/transactions”?
{“amount”: “1500”}
So now:
1. We can get the state of current transaction: GET /accounts/1/transactions/23
-> {“status”: “pending”}.
2. We have natural log of account operations.
2. I want to copy something (account, ad campaign
and so on)
Copy & paste pattern: I can GET it, and POST it.
2. I want to copy something (account, ad campaign
and so on)
Amazon S3 solution:
http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectCOPY.html
2. I want to copy something
We have resource copying process or resource copier. And we can send resource
representation to it.
{
“title”: “some ad campaign”,
“_links”: {“copy”: “http://somesite.org/campaigns/1/copy”}
}
POST:
1. /campaigns/{campaignId}/copiers, /campaigns/{surveyId}/campaigns
2. /campaign-copier with {“surveyId”: 1}
3. I want to sort something
Easy-peasy!
POST /ad-campaigns/{campaignId}/sortings
{“previousCampaignId”: 42}
Because you need to satisfy too many conditions.
4. I want to update one field in very big resource
It’s better to have 5-7 small resources which easier to update and control, than
something big.
OK! We can solve it:
PUT /ad-campaign/1/meta
{ “title”: “new title”, … and other fields}
Symfony speaks HTTP
REST ~ HTTP ~ Symfony
Resources
Entity or set of entities, e. g. “Ad
Campaign” entity in marketing
application;
Service or set of services, e. g.
“Copier” service, which can
copy anything;
Any operation on a resource be
modeled as “process”
resource.
Any business entity or business
process can be modeled as
resource.
Resource
representations
Resource representation handlers
HATEOAS (https://github.com/willdurand/Hateoas)
HATEOAS
Links
1. REST bundle documentation (https://bitbucket.org/tonicforhealth/server-
bundle-rest-
bundle/src/master/Resources/doc/index.md?at=master&fileviewer=file-view-
default).
2. “REST in Practice, Hypermedia and Systems Architecture“ by Jim Webber,
Savas Parastatidis, Ian Robinson
(http://shop.oreilly.com/product/9780596805838.do).
3. “REST API Design - Resource Modeling”
(https://www.thoughtworks.com/insights/blog/rest-api-design-resource-
modeling).

More Related Content

What's hot

The Rest Architectural Style
The Rest Architectural StyleThe Rest Architectural Style
The Rest Architectural StyleRobert Wilson
 
Representational State Transfer (REST) and HATEOAS
Representational State Transfer (REST) and HATEOASRepresentational State Transfer (REST) and HATEOAS
Representational State Transfer (REST) and HATEOASGuy K. Kloss
 
HATEOAS: The Confusing Bit from REST
HATEOAS: The Confusing Bit from RESTHATEOAS: The Confusing Bit from REST
HATEOAS: The Confusing Bit from RESTelliando dias
 
Resource Oriented Architectures
Resource Oriented ArchitecturesResource Oriented Architectures
Resource Oriented ArchitecturesGabriele Lana
 
Representational State Transfer (REST)
Representational State Transfer (REST)Representational State Transfer (REST)
Representational State Transfer (REST)David Krmpotic
 
Representational State Transfer (REST)
Representational State Transfer (REST)Representational State Transfer (REST)
Representational State Transfer (REST)Abhay Ananda Shukla
 
REST and Resource Oriented Architecture - okcDG March 2008
REST and Resource Oriented Architecture - okcDG March 2008REST and Resource Oriented Architecture - okcDG March 2008
REST and Resource Oriented Architecture - okcDG March 2008Ryan Hoegg
 
REST - Representational state transfer
REST - Representational state transferREST - Representational state transfer
REST - Representational state transferTricode (part of Dept)
 
Five Inconvenient Truths about REST
Five Inconvenient Truths about RESTFive Inconvenient Truths about REST
Five Inconvenient Truths about RESTFilip Van Laenen
 
Design Beautiful REST + JSON APIs
Design Beautiful REST + JSON APIsDesign Beautiful REST + JSON APIs
Design Beautiful REST + JSON APIsStormpath
 
Resource-Oriented Architecture (ROA) and REST
Resource-Oriented Architecture (ROA) and RESTResource-Oriented Architecture (ROA) and REST
Resource-Oriented Architecture (ROA) and RESTIASA
 
REST and RESTful Web Services
REST and RESTful Web ServicesREST and RESTful Web Services
REST and RESTful Web ServicesKasun Madusanke
 
REpresentational State Transfer
REpresentational State TransferREpresentational State Transfer
REpresentational State TransferVladimir Tsukur
 

What's hot (20)

The Rest Architectural Style
The Rest Architectural StyleThe Rest Architectural Style
The Rest Architectural Style
 
Representational State Transfer (REST) and HATEOAS
Representational State Transfer (REST) and HATEOASRepresentational State Transfer (REST) and HATEOAS
Representational State Transfer (REST) and HATEOAS
 
HATEOAS: The Confusing Bit from REST
HATEOAS: The Confusing Bit from RESTHATEOAS: The Confusing Bit from REST
HATEOAS: The Confusing Bit from REST
 
Resource Oriented Architectures
Resource Oriented ArchitecturesResource Oriented Architectures
Resource Oriented Architectures
 
Representational State Transfer (REST)
Representational State Transfer (REST)Representational State Transfer (REST)
Representational State Transfer (REST)
 
Representational State Transfer (REST)
Representational State Transfer (REST)Representational State Transfer (REST)
Representational State Transfer (REST)
 
REST API Design
REST API DesignREST API Design
REST API Design
 
REST and Resource Oriented Architecture - okcDG March 2008
REST and Resource Oriented Architecture - okcDG March 2008REST and Resource Oriented Architecture - okcDG March 2008
REST and Resource Oriented Architecture - okcDG March 2008
 
REST - Representational state transfer
REST - Representational state transferREST - Representational state transfer
REST - Representational state transfer
 
Five Inconvenient Truths about REST
Five Inconvenient Truths about RESTFive Inconvenient Truths about REST
Five Inconvenient Truths about REST
 
Design Beautiful REST + JSON APIs
Design Beautiful REST + JSON APIsDesign Beautiful REST + JSON APIs
Design Beautiful REST + JSON APIs
 
Elasticsearch
ElasticsearchElasticsearch
Elasticsearch
 
Take a REST!
Take a REST!Take a REST!
Take a REST!
 
Resource-Oriented Architecture (ROA) and REST
Resource-Oriented Architecture (ROA) and RESTResource-Oriented Architecture (ROA) and REST
Resource-Oriented Architecture (ROA) and REST
 
Rest web services
Rest web servicesRest web services
Rest web services
 
REST and RESTful Web Services
REST and RESTful Web ServicesREST and RESTful Web Services
REST and RESTful Web Services
 
Restful web services ppt
Restful web services pptRestful web services ppt
Restful web services ppt
 
JSON and REST
JSON and RESTJSON and REST
JSON and REST
 
The Glory of Rest
The Glory of RestThe Glory of Rest
The Glory of Rest
 
REpresentational State Transfer
REpresentational State TransferREpresentational State Transfer
REpresentational State Transfer
 

Similar to Дмитрий Красун: Сегодня вы уйдете с новым представлением о REST

Creating Restful Web Services with restish
Creating Restful Web Services with restishCreating Restful Web Services with restish
Creating Restful Web Services with restishGrig Gheorghiu
 
REST Architecture with use case and example
REST Architecture with use case and exampleREST Architecture with use case and example
REST Architecture with use case and exampleShailesh singh
 
REST Architecture with use case and example
REST Architecture with use case and exampleREST Architecture with use case and example
REST Architecture with use case and exampleShailesh singh
 
[2015/2016] The REST architectural style
[2015/2016] The REST architectural style[2015/2016] The REST architectural style
[2015/2016] The REST architectural styleIvano Malavolta
 
Together Cheerfully to Walk with Hypermedia
Together Cheerfully to Walk with HypermediaTogether Cheerfully to Walk with Hypermedia
Together Cheerfully to Walk with HypermediaVladimir Tsukur
 
JAX-RS. Developing RESTful APIs with Java
JAX-RS. Developing RESTful APIs with JavaJAX-RS. Developing RESTful APIs with Java
JAX-RS. Developing RESTful APIs with JavaJerry Kurian
 
Building RESTful applications using Spring MVC
Building RESTful applications using Spring MVCBuilding RESTful applications using Spring MVC
Building RESTful applications using Spring MVCIndicThreads
 
Restful Fundamentals
Restful FundamentalsRestful Fundamentals
Restful FundamentalsSuresh Madhra
 
Restful Fundamentals
Restful FundamentalsRestful Fundamentals
Restful FundamentalsSuresh Madhra
 
Reactive Hypermedia
Reactive HypermediaReactive Hypermedia
Reactive HypermediaKevin Swiber
 
Introduction to REST and Hypermedia
Introduction to REST and HypermediaIntroduction to REST and Hypermedia
Introduction to REST and HypermediaNordic APIs
 

Similar to Дмитрий Красун: Сегодня вы уйдете с новым представлением о REST (20)

Creating Restful Web Services with restish
Creating Restful Web Services with restishCreating Restful Web Services with restish
Creating Restful Web Services with restish
 
REST Architecture with use case and example
REST Architecture with use case and exampleREST Architecture with use case and example
REST Architecture with use case and example
 
REST Architecture with use case and example
REST Architecture with use case and exampleREST Architecture with use case and example
REST Architecture with use case and example
 
Best Practices in Api Design
Best Practices in Api DesignBest Practices in Api Design
Best Practices in Api Design
 
Introduction To REST
Introduction To RESTIntroduction To REST
Introduction To REST
 
[2015/2016] The REST architectural style
[2015/2016] The REST architectural style[2015/2016] The REST architectural style
[2015/2016] The REST architectural style
 
Together Cheerfully to Walk with Hypermedia
Together Cheerfully to Walk with HypermediaTogether Cheerfully to Walk with Hypermedia
Together Cheerfully to Walk with Hypermedia
 
ReSTful API Final
ReSTful API FinalReSTful API Final
ReSTful API Final
 
JAX-RS. Developing RESTful APIs with Java
JAX-RS. Developing RESTful APIs with JavaJAX-RS. Developing RESTful APIs with Java
JAX-RS. Developing RESTful APIs with Java
 
SFDC REST API
SFDC REST APISFDC REST API
SFDC REST API
 
Building RESTful applications using Spring MVC
Building RESTful applications using Spring MVCBuilding RESTful applications using Spring MVC
Building RESTful applications using Spring MVC
 
Restful Fundamentals
Restful FundamentalsRestful Fundamentals
Restful Fundamentals
 
Restful Fundamentals
Restful FundamentalsRestful Fundamentals
Restful Fundamentals
 
RESTing with JAX-RS
RESTing with JAX-RSRESTing with JAX-RS
RESTing with JAX-RS
 
REST Basics
REST BasicsREST Basics
REST Basics
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Switch to Backend 2023
 
Reactive Hypermedia
Reactive HypermediaReactive Hypermedia
Reactive Hypermedia
 
Introduction to REST and Hypermedia
Introduction to REST and HypermediaIntroduction to REST and Hypermedia
Introduction to REST and Hypermedia
 
Modified REST Presentation
Modified REST PresentationModified REST Presentation
Modified REST Presentation
 
Rest
Rest Rest
Rest
 

More from Oleg Poludnenko

Александр Трищенко: PHP 7 Evolution
Александр Трищенко: PHP 7 EvolutionАлександр Трищенко: PHP 7 Evolution
Александр Трищенко: PHP 7 EvolutionOleg Poludnenko
 
Иван Стеценко: ЯП Zephir. Панацея или лечение?
Иван Стеценко: ЯП Zephir. Панацея или лечение?Иван Стеценко: ЯП Zephir. Панацея или лечение?
Иван Стеценко: ЯП Zephir. Панацея или лечение?Oleg Poludnenko
 
Александр Трищенко: Phalcon framework
Александр Трищенко: Phalcon frameworkАлександр Трищенко: Phalcon framework
Александр Трищенко: Phalcon frameworkOleg Poludnenko
 
Алексей Иванкин: Highload + PHP
Алексей Иванкин: Highload + PHPАлексей Иванкин: Highload + PHP
Алексей Иванкин: Highload + PHPOleg Poludnenko
 
Антон Довгоброд: Highload и очереди задач на примере PHP + Gearman + Yii2
Антон Довгоброд: Highload и очереди задач на примере PHP + Gearman + Yii2Антон Довгоброд: Highload и очереди задач на примере PHP + Gearman + Yii2
Антон Довгоброд: Highload и очереди задач на примере PHP + Gearman + Yii2Oleg Poludnenko
 
Алексей Рыстенко: Highload и микросервисы
Алексей Рыстенко: Highload и микросервисыАлексей Рыстенко: Highload и микросервисы
Алексей Рыстенко: Highload и микросервисыOleg Poludnenko
 
Алексей Плеханов: Новинки Laravel 5
Алексей Плеханов: Новинки Laravel 5Алексей Плеханов: Новинки Laravel 5
Алексей Плеханов: Новинки Laravel 5Oleg Poludnenko
 
Макс Волошин: Php + shell = ♥
Макс Волошин: Php + shell = ♥Макс Волошин: Php + shell = ♥
Макс Волошин: Php + shell = ♥Oleg Poludnenko
 
Дмитрий Тарасов: Google App Engine & PHP SDK
Дмитрий Тарасов: Google App Engine & PHP SDKДмитрий Тарасов: Google App Engine & PHP SDK
Дмитрий Тарасов: Google App Engine & PHP SDKOleg Poludnenko
 
Алексей Рыстенко: Continuous Integration
Алексей Рыстенко: Continuous IntegrationАлексей Рыстенко: Continuous Integration
Алексей Рыстенко: Continuous IntegrationOleg Poludnenko
 
Илья Андриенко: Вёрстка в проекте глазами “неверстальщика”
Илья Андриенко: Вёрстка в проекте глазами  “неверстальщика”Илья Андриенко: Вёрстка в проекте глазами  “неверстальщика”
Илья Андриенко: Вёрстка в проекте глазами “неверстальщика”Oleg Poludnenko
 
Алексей Плеханов: 25 причин попробовать Laravel
Алексей Плеханов: 25 причин попробовать LaravelАлексей Плеханов: 25 причин попробовать Laravel
Алексей Плеханов: 25 причин попробовать LaravelOleg Poludnenko
 

More from Oleg Poludnenko (12)

Александр Трищенко: PHP 7 Evolution
Александр Трищенко: PHP 7 EvolutionАлександр Трищенко: PHP 7 Evolution
Александр Трищенко: PHP 7 Evolution
 
Иван Стеценко: ЯП Zephir. Панацея или лечение?
Иван Стеценко: ЯП Zephir. Панацея или лечение?Иван Стеценко: ЯП Zephir. Панацея или лечение?
Иван Стеценко: ЯП Zephir. Панацея или лечение?
 
Александр Трищенко: Phalcon framework
Александр Трищенко: Phalcon frameworkАлександр Трищенко: Phalcon framework
Александр Трищенко: Phalcon framework
 
Алексей Иванкин: Highload + PHP
Алексей Иванкин: Highload + PHPАлексей Иванкин: Highload + PHP
Алексей Иванкин: Highload + PHP
 
Антон Довгоброд: Highload и очереди задач на примере PHP + Gearman + Yii2
Антон Довгоброд: Highload и очереди задач на примере PHP + Gearman + Yii2Антон Довгоброд: Highload и очереди задач на примере PHP + Gearman + Yii2
Антон Довгоброд: Highload и очереди задач на примере PHP + Gearman + Yii2
 
Алексей Рыстенко: Highload и микросервисы
Алексей Рыстенко: Highload и микросервисыАлексей Рыстенко: Highload и микросервисы
Алексей Рыстенко: Highload и микросервисы
 
Алексей Плеханов: Новинки Laravel 5
Алексей Плеханов: Новинки Laravel 5Алексей Плеханов: Новинки Laravel 5
Алексей Плеханов: Новинки Laravel 5
 
Макс Волошин: Php + shell = ♥
Макс Волошин: Php + shell = ♥Макс Волошин: Php + shell = ♥
Макс Волошин: Php + shell = ♥
 
Дмитрий Тарасов: Google App Engine & PHP SDK
Дмитрий Тарасов: Google App Engine & PHP SDKДмитрий Тарасов: Google App Engine & PHP SDK
Дмитрий Тарасов: Google App Engine & PHP SDK
 
Алексей Рыстенко: Continuous Integration
Алексей Рыстенко: Continuous IntegrationАлексей Рыстенко: Continuous Integration
Алексей Рыстенко: Continuous Integration
 
Илья Андриенко: Вёрстка в проекте глазами “неверстальщика”
Илья Андриенко: Вёрстка в проекте глазами  “неверстальщика”Илья Андриенко: Вёрстка в проекте глазами  “неверстальщика”
Илья Андриенко: Вёрстка в проекте глазами “неверстальщика”
 
Алексей Плеханов: 25 причин попробовать Laravel
Алексей Плеханов: 25 причин попробовать LaravelАлексей Плеханов: 25 причин попробовать Laravel
Алексей Плеханов: 25 причин попробовать Laravel
 

Recently uploaded

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 

Recently uploaded (20)

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 

Дмитрий Красун: Сегодня вы уйдете с новым представлением о REST

  • 2. Agenda 1. REST ideas. 2. REST and HTTP. 3. Symfony and HTTP.
  • 8. How often you cry about refactoring?
  • 9. REpresentational State Transfer Is about changing resource state through transferring resource representations. Key concepts: Resources and resource representations; URI; HATEOAS.
  • 10. Resources and resource representations “The key abstraction of information in REST is a resource. Any information that can be named can be a resource: a document or image, a temporal service (e.g. "today's weather in Los Angeles"), a collection of other resources, a non-virtual object (e.g. a person), and so on. In other words, any concept that might be the target of an author's hypertext reference must fit within the definition of a resource. A resource is a conceptual mapping to a set of entities, not the entity that corresponds to the mapping at any particular point in time.” - Roy Fielding’s dissertation.
  • 11. Resource and resource representations Account ($1 500) is resource, but: <ul class=”account”><li class=”currency”>USD</li><li class=”balance”>1500</li></ul>; {“balance”: 1500}; {“balance”: 1500, “currency”: “USD”}; <account><balance currency=”USD”>1500</balance></account>; <account currency=”USD” balance=”1500” /> Are different Account (read as resource) representations.
  • 12. Uniform Resource Identifier Uniform? Yes, not unique. Resource can have more than one URI. Examples: “james.bond”, “j.bond”, “007-company”. URL (Uniform Resource Locator) as URI in HTTP: Can be used as URI; Valid URLs’: “http://james.bond”, “http://j.bond”, “ftp://zero-zero- seven.com/docs.txt”.
  • 13. “RESTful” URL 1. http://example.com/users/1?delete 2. http://example.com/delete-users/1 3. http://example.com/?userId=1&action=delete 4. http://example.com/getData?userId=1 5. http://example.com/users/1 6. http://example.com/user/1
  • 16. Hypermedia as the Engine of Application State Client interacts with an application entirely through hypermedia provided dynamically. Resource state machines.
  • 17. Hypermedia as the Engine of Application State
  • 18. It’s important - Reliability (no need to store information about client which can be corrupted or lost); - Performance (cache); - Scalability; - Simplicity of interfaces; - Ability to evolve and adapt to new requirements (WWW as example).
  • 20. HTTP as “framework” HTTP verbs (POST, GET, DELETE and so on) for resource manipulations; URL as URI for resource; Request and response bodies for resource representations; Status codes; Headers (for more precise control): Caching; Authentication and authorization; Versioning (E-Tag);
  • 22. Early stage adopters It’s very hard to implement REST in the right way. Some of closest implementations: Github API, Amazon S3 REST API, JIRA REST API. Github API (https://developer.github.com/v3/repos/forks/): HATEOAS (links to other resources); Right granularity (POST /repos/:owner/:repo/forks); Right status codes (202 Accepted for POST /repos/:owner/:repo/forks).
  • 23. Standards 1. HTTP, URI, URI Template, JSON, XML, HTML and friends; 2. HAL - http://stateless.co/hal_specification.html; 3. Siren - https://github.com/kevinswiber/siren.
  • 24. Resource modeling is key problem.* * There is no silver bullet :( ** ** That’s why we earn money, because of thinking, so :)
  • 25. 1. I want to deposit money to account We have account and account balance. Possible representation: GET /accounts/{accountId} {“account”: {“balance”: 1500, “currency”: “USD”}}
  • 26. 1. I want to deposit money to account PUT /accounts/{accountId} {“balance”: 1500, “currency”: “USD”} Hmmm… It’s better to PATCH /accounts/{accountId} [{“op”: “replace”, “path”: “/balance”, “value”: 1500}]
  • 27. 1. I want to deposit money to account Yes, it’s better to create transaction. Transaction is also resource. POST /accounts/usd/transactions (Hey! why not “/accounts/{accountId}/transactions”? {“amount”: “1500”} So now: 1. We can get the state of current transaction: GET /accounts/1/transactions/23 -> {“status”: “pending”}. 2. We have natural log of account operations.
  • 28. 2. I want to copy something (account, ad campaign and so on) Copy & paste pattern: I can GET it, and POST it.
  • 29. 2. I want to copy something (account, ad campaign and so on) Amazon S3 solution: http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectCOPY.html
  • 30. 2. I want to copy something We have resource copying process or resource copier. And we can send resource representation to it. { “title”: “some ad campaign”, “_links”: {“copy”: “http://somesite.org/campaigns/1/copy”} } POST: 1. /campaigns/{campaignId}/copiers, /campaigns/{surveyId}/campaigns 2. /campaign-copier with {“surveyId”: 1}
  • 31. 3. I want to sort something Easy-peasy! POST /ad-campaigns/{campaignId}/sortings {“previousCampaignId”: 42} Because you need to satisfy too many conditions.
  • 32. 4. I want to update one field in very big resource It’s better to have 5-7 small resources which easier to update and control, than something big. OK! We can solve it: PUT /ad-campaign/1/meta { “title”: “new title”, … and other fields}
  • 33. Symfony speaks HTTP REST ~ HTTP ~ Symfony
  • 34. Resources Entity or set of entities, e. g. “Ad Campaign” entity in marketing application; Service or set of services, e. g. “Copier” service, which can copy anything; Any operation on a resource be modeled as “process” resource. Any business entity or business process can be modeled as resource.
  • 39. Links 1. REST bundle documentation (https://bitbucket.org/tonicforhealth/server- bundle-rest- bundle/src/master/Resources/doc/index.md?at=master&fileviewer=file-view- default). 2. “REST in Practice, Hypermedia and Systems Architecture“ by Jim Webber, Savas Parastatidis, Ian Robinson (http://shop.oreilly.com/product/9780596805838.do). 3. “REST API Design - Resource Modeling” (https://www.thoughtworks.com/insights/blog/rest-api-design-resource- modeling).