7. Cloud API: RESTful Web Services REST = Representational State Transfer Conforming to the REST constraints is often referred to as being ‘RESTful’ Roy Fielding Doctoral Dissertation “Roy Fielding "Architectural Styles and the Design of Network-based Software Architectures” year 2000 http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm “Adddressability is the idea that every object and resource in your system is reachable through a unique identifier……..URIs” Scheme://host:port/path?queryString#fragment http://example.com/customers?lastName=Burke&zipcode=02115 With REST over HTTP you do not have to worry about vendor interoperability you can focus on understanding the data format of the server and application interoperability . …. Bill Burke
8. Cloud API: CURL REST-esting with cURL curl -i -H "Accept: application/json" -X POST -d "firstName=james" http://192.168.0.165/persons/person Where i – show response headers H – pass request headers to the resource X – pass a HTTP method name d – pass in parameters enclosed in quotes; multiple parameters are separated by ‘&’The above command posts the first name “james” to the persons resource. Assuming the server creates a new person resource with first name of James, I also tell the server to return a json representation of the newly created resource. Good Examples http://blogs.plexibus.com/2009/01/15/rest-esting-with-curl/
9. Cloud API - API Authentication Figure on page 7: API Authentication from Cloud Servers Developer Guide 10/15/09 GET /v1.0 HTTP/1.1 Host: auth.api.rackspacecloud.com X-Auth-User: jdoe X-Auth-Key: a86850deb2742ec3cb41518e26aa2d89 Curl implementation of the above Authentication Request curl -i -H "X-Auth-Key: a86850deb2742ec3cb41518e26aa2d89 " -H "X-Auth-User: jdoe" https://auth.api.rackspacecloud.com/v1.0 Rackspace Response HTTP/1.1 204 No Content Date: Sat, 27 Feb 2010 06:28:49 GMT Server: Apache/2.2.3 (Mosso Engineering) X-Storage-Token: 6ce9397a-4164-44ba-bbd4-e1b6c9a6abc1 X-Storage-Url: https://storage5.clouddrive.com/v1/MossoCloudFS_8c1e3b35-d250-4a6d-aa5a-35399b039b1d X-Server-Management-Url: https://servers.api.rackspacecloud.com/v1.0/437001 X-CDN-Management-Url: https://cdn.clouddrive.com/v1/MossoCloudFS_8c1e3b35-d250-4a6d-aa5a-35399b039b1d X-Auth-Token: 6ce9397a-4164-44ba-bbd4-e1b6c9a6abc1 Content-Length: 0 Connection: close Content-Type: application/octet-stream
10. Cloud API - API Version Figure on page 15: API Version GET HTTP/1.1 Host: servers.api.rackspacecloud.com/ curl -i -H "Accept: application/xml" -H "X-Auth-Token: 6ce9397a-4164-44ba-bbd4-e1b6c9a6abc1" -X GET "https://servers.api.rackspacecloud.com/" HTTP/1.1 200 OK Server: Apache-Coyote/1.1 vary: Accept, Accept-Encoding Last-Modified: Thu, 25 Feb 2010 22:40:13 GMT Content-Type: application/xml Content-Length: 161 Date: Sat, 27 Feb 2010 05:42:06 GMT X-Varnish: 168976310Age: 0 Via: 1.1 varnishConnection: close <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <versions xmlns="http://docs.rackspacecloud.com/servers/api"> <version status="BETA" id="v1.0"/> </versions>
11. Cloud API - API Version Figure on page 20: List Servers curl -i -H "Accept: application/xml" -H "X-Auth-Token: 6ce9397a-4164-44ba-bbd4-e1b6c9a6abc1" -X GET https://servers.api.rackspacecloud.com/v1.0/437001/servers/detail > apiServerListDetails.xml
17. References http://www.productionscale.com/home/2009/8/2/using-curl-to-access-the-rackspace-cloud-api.html http://blogs.plexibus.com/2009/01/15/rest-esting-with-curl/ http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm https://manage.rackspacecloud.com/APIAccess.do http://en.wikipedia.org/wiki/REST http://oreilly.com/catalog/9780596529260/ http://www.oreillynet.com/pub/wlg/3005 http://15timez.blogspot.com/2010/03/virtual-world-therecom-to-close.html I was recently talking with Jeff Barr, creator of syndic8 and now Amazon's chief web services evangelist. He let drop an interesting tidbit. Amazon has both SOAP and REST interfaces to their web services, and 85% of their usage is of the REST interface. Despite all of the corporate hype over the SOAP stack, this is pretty compelling evidence that developers like the simpler REST approach. (I know there are many more complex applications where SOAP is better, but I've always liked technologies that have low barriers to entry and grassroots adoption, and simple XML over HTTP approach seems to have that winning combination.) ….. REST vs. SOAP Tim O’Reilly Apr 03, 2003 With REST over HTTP you do not have to worry about vendor interoperability you can focus on understanding the data format of the server and application interoperability . …. Bill Burke