Разработка restful api with all bells and whistles

Click here to load reader

Post on 02-Jul-2015

4.444 views

Category:

Technology

0 download

Embed Size (px)

TRANSCRIPT

  • 1. 1

2. 2 RESTful API with all the bells and whistles 3. 3 . , , , . 20+ . 10+ . 7+ . 4. 4 . , , , . 20+ . 10+ . 7+ . 5. 5 . , , , . 20+ . 10+ . 7+ . 6. 6 . , , , . 20+ . 10+ . 7+ . 7. 7 Yandex Disk APIs WebDAV , RESTful API , WebDAV 8. 8 Yandex Disk APIs WebDAV , RESTful API , WebDAV 9. 9 10. 10 API API 11. 11 API API 12. 12 API API 13. 13 RESTful API Hypermedia API Self-descriptive & Machine-readable API 14. 14 RESTful API Hypermedia API Self-descriptive & Machine-readable API 15. 15 RESTful API Hypermedia API Self-descriptive & Machine-readable API 16. 16 REST? 17. 17 - , , 18. 18 - , , 19. 19 Stateless 20. 20 Stateless 21. 21 Stateless 22. 22 , 23. 23 , 24. 24 RESTful API 25. 25 26. 26 URL API : resources operations 27. 27 URL API : resources operations 28. 28 URL API : resources operations 29. 29 URL API : resources operations 30. 30 URL 31. 31 URL URL /disk URL /disk / resources /disk / operations URL + = URL /disk / resources ? path={path} /disk / operations ? id={id} /pets / kittens / {name} 32. 32 URL URL /disk URL /disk / resources /disk / operations URL + = URL /disk / resources ? path={path} /disk / operations ? id={id} /pets / kittens / {name} 33. 33 URL URL /disk URL /disk / resources /disk / operations URL + = URL /disk / resources ? path={path} /disk / operations ? id={id} /pets / kittens / {name} 34. 34 URL URL /disk URL /disk / resources /disk / operations URL + = URL /disk / resources ? path={path} /disk / operations ? id={id} /pets / kittens / {name} 35. 35 HTTP- CRUD-: GET, POST, PUT, DELETE 36. 36 HTTP- GET . , : GET /disk/resources?path={path} GET /disk/operations?id={id} GET, PUT, DELETE . , : PUT /disk/resources?path={path} DELETE /disk/resources?path={path} POST . , OPTIONS 37. 37 HTTP- GET . , : GET /disk/resources?path={path} GET /disk/operations?id={id} GET, PUT, DELETE . , : PUT /disk/resources?path={path} DELETE /disk/resources?path={path} POST . , OPTIONS 38. 38 HTTP- GET . , : GET /disk/resources?path={path} GET /disk/operations?id={id} GET, PUT, DELETE . , : PUT /disk/resources?path={path} DELETE /disk/resources?path={path} POST . , OPTIONS 39. 39 HTTP- GET . , : GET /disk/resources?path={path} GET /disk/operations?id={id} GET, PUT, DELETE . , : PUT /disk/resources?path={path} DELETE /disk/resources?path={path} POST . , OPTIONS 40. 40 CRUD 41. 41 CRUD POST, , ! Ad Hoc-! POST /disk/resources/ copy ? path={path}&from={from} POST /disk/resources/ move ? path={path}&from={from} 42. 42 CRUD POST, , ! Ad Hoc-! POST /disk/resources/ copy ? path={path}&from={from} POST /disk/resources/ move ? path={path}&from={from} 43. 43 CRUD POST, , ! Ad Hoc-! POST /disk/resources/ copy ? path={path}&from={from} POST /disk/resources/ move ? path={path}&from={from} 44. 44 The Bells And Whistles RESTful API 45. 45 Hypermedia API , . Hypermedia as the Engine of Application State hypermedia-, . URL 46. 46 Hypermedia API , . Hypermedia as the Engine of Application State hypermedia-, . URL 47. 47 Hypermedia API , . Hypermedia as the Engine of Application State hypermedia-, . URL 48. 48 Hypermedia API Collection+JSON HAL DocJSON JSON API JSON Hyperschema 49. 49 Hypertext Application Language draft RFC- API MIME-type: application/hal+json HAL , 50. 50 Hypertext Application Language draft RFC- API MIME-type: application/hal+json HAL , 51. 51 API # print folder { name: foo, path: disk:/foo, type: dir } # URL = 'https://cloud-api.yandex.net/v1/disk/resources' query = {} query['path'] = folder['path'] query['permanently'] = True qs = urlencode(query) url = URL + '?' + qs request('DELETE', url) 52. 52 Hypermedia API # HAL- print folder { "_links": { "delete": { "href": "https://cloud- api.yandex.net/v1/disk/resources?path=disk%3A%2Ffoo&permanently=True", "method": "DELETE" }, }, name: foo, path: disk:/foo, type: dir } # action = folder[_links][delete] request(action[method], action[href]) 53. 53 Self-describing & Machine-readable REST API RAML WADL JSON Schema + JSON HyperSchema Swagger IO Docs Apiary Blueprints 54. 54 Swagger API JSON 55. 55 Swagger API 56. 56 Swagger Swagger- SDK open source UI API 57. 57 tech.yandex.ru/disk/poligon 58. 58 59. 59 API 60. 60 API 61. 61 API 62. 62 REST API 63. 63 REST API RFC 2616 Ad Hoc- HTTP API hypermedia- HAL http://stateless.co/hal_specification.html API Swagger https://helloreverb.com/developers/swagger 64. 64 REST API RFC 2616 Ad Hoc- HTTP API hypermedia- HAL http://stateless.co/hal_specification.html API Swagger https://helloreverb.com/developers/swagger 65. 65 REST API RFC 2616 Ad Hoc- HTTP API hypermedia- HAL http://stateless.co/hal_specification.html API Swagger https://helloreverb.com/developers/swagger 66. 66 REST API RFC 2616 Ad Hoc- HTTP API hypermedia- HAL http://stateless.co/hal_specification.html API Swagger https://helloreverb.com/developers/swagger 67. 67 REST API RFC 2616 Ad Hoc- HTTP API hypermedia- HAL http://stateless.co/hal_specification.html API Swagger https://helloreverb.com/developers/swagger 68. 68 REST API RFC 2616 Ad Hoc- HTTP API hypermedia- HAL http://stateless.co/hal_specification.html API Swagger https://helloreverb.com/developers/swagger 69. 69 API user-related 70. 70 ! 71. 71 back-end REST API . : : tech.yandex.ru/disk/poligon clubs.ya.ru/apidisk/