services stanford 2012

Download Services Stanford 2012

If you can't read please download the document

Upload: yuriy-gerasimov

Post on 16-Apr-2017

1.414 views

Category:

Technology


0 download

TRANSCRIPT

Drupal ServicesYuriy Gerasimovemail: [email protected]

twitter: ygerasimov

d.o.: http://drupal.org/user/257311

Presentation plan

What is Services for?

Building REST interface with Services

Resources out-of-box.

Services API

Future of Services

Architechture

Services

Move from RPC style to REST

RESTGET safe method (only to retrieve)

PUT and DELETE are idempotent methods (multiple calls should have same result)

Services 3.x

resource oriented (CRUD = create, retrieve, update, delete, index)

Content Type

different formatters (php, json, jsonp, xml, ...)

separate endpoints (exportable to features)

authentication

Content Type

Request: URL, headers, body

Content-type: application/x-www-form-urlencodedkey1=value1&key2=value2&key3[0]=a&key3[1]=b&key3[2]=c

Content-type: application/json{"key1":"value1","key2":"value2","key3":["a","b","c"]}

Routing

Picture from WSCCI proposal http://groups.drupal.org/node/226479

REST with Services

Create POST http://host/rest/node.json

Retrieve GET http://host/rest/node/5.json

Update PUT http://host/rest/node/5.json

Delete DELETE http://host/rest/node/5.json

Index GET http://host.com/rest/node.json

REST with Services

Action POST http://host/rest/user/login.json

Targeted Action

POST http://host/rest/node/5/vote.json

Relation GET http://host/rest/node/5/files.json

Services 3.x resources

Node resource

Taxonomy vocabulary resource (getTree)

Taxonomy term resource (selectNodes)

User resource (login, logout, register)

Comment resource (loadNodeComments, countAll, countNew)

System resource (no CRUD) (connect, get_variable, set_variable)

Services 3.x resources

File resource (CRUD) (nodeFiles)

Services 3.x hook_services_resources

Services 3.x hook_services_resources

Services 3.x REST server formatters

http:////.

Standard: php, json, jsonp, xml, yaml, bencode (see RESTServerViewBuiltIn)

Build REST interface

Implement CRUD functionality.

Use actions, relationships resource/node/X/comments

Use aliases if needed.

Write tests

For public GET calls you can use Views + Views Datasource

WSCCI

Use Symfony components

Context (HttpFoundation)

Rounting (HttpKernel)

Lazy loading

Tools & Resources

Poster https://addons.mozilla.org/en-US/firefox/addon/2691

Services Handbook http://drupal.org/handbook/modules/services

Tests

A future of Services http://goodold.se/blog/tech/future-services-3x

Groups http://groups.drupal.org/services

WSCCI http://groups.drupal.org/wscci

Questions

Yuriy Gerasimovemail: [email protected]/irc: ygerasimovd.o.: http://drupal.org/user/257311

/ 1