Monday, December 07, 2009

OGCE Gadget Container REST API

Notes by Gerald Guo, the developer of the gadget container. We are developing a REST API for the gadget container that allows you to work with it programmatically.  The following example shows how to add a gadget to a layout using curl.  If you prefer, a tool like the Firefox plugin Poster can be used.

Curl example:
1) Authentication
    curl -H Connection:keep-alive -d "screenname=testuser&password=testuser"
-v -k -o output.txt -c cookies
https://gf13.ucs.indiana.edu:7443/ishindig-webapp/signin

2) Add a new gadget (Calender gadget)

First, create a file named "gadget.json" with following content:
{ "gadgetname":"Embedded Calendar",
"gadgetspecsrc":"https://gf13.ucs.indiana.edu:7443/gadgets-repo/EmbeddedCale
ndar.xml"}

Then execute this command:
curl -d @gadget.json -H Content-Type:application/json -H
Connection:keep-alive -v -k -c cookies -b cookies
'https://gf13.ucs.indiana.edu:7443/ishindig-webapp/rest/users/@self/layouts/
index/0/tabs/index/0/columns/index/2/gadgets/index/-1'

In the long POST URL, position (consisting of tuple
gadget index>) of the new gadget is specified.
    layouts/index/0  : this specifies the layout the gadget will be added to
    tabs/index/0     : this specifies the tab the gadget will be added to
    columns/index/2  : this specifies the column the gadget will be added to
    gadgets/index/-1 : this specifies position of the gadget within
containing column. -1 means appending.

Then you can log in OGCE gadget container via web interface
(https://gf13.ucs.indiana.edu:7443/ishindig-webapp/www/sign.jsp) to check
whether it has been added. 


This feature is currently only available in the SVN trunk.  It is not part of the SC09 tagged release.

No comments: