Home Wiki > openSUSE:SUSE Studio API
Sign up | Login

openSUSE:SUSE Studio API

tagline: From openSUSE

RESTful API

SUSE Studio features a RESTful API over HTTP which can be used to clone appliances, upload files, trigger and monitor builds and more. See the SUSE Studio API documentation for more details.

Authentication

In order to use the API you have to create an API key which will be used as the password for HTTP Basic Authentication. This can be done on the user page within SUSE Studio.

Libraries & Clients

There are a number of libraries and clients which use the SUSE Studio API:

Using the API with curl

All API functions can be used with curl. The following examples should give you an idea on how this is to be used.

Get the list of template sets

The available templates are grouped in template sets. The following command gets the list of template sets from Studio:

 curl -u <user>:<api_key> "http://susestudio.com/api/v1/user/template_sets" (example)

Usually you will pick one of the templates in the 'default' template set, which lists the default SUSE templates, and clone an appliance from it.

List your appliances

All appliances:

 curl -u <user>:<api_key> "http://susestudio.com/api/v1/user/appliances" (example)


A specific appliance:

 curl -u <user>:<api_key> "http://susestudio.com/api/v1/user/appliances/<id>" (example)


Clone an appliance

To create a new appliance pick a template from the template set and use its id with the following command (name and arch are optional parameters):

 curl -u <user>:<api_key> -XPOST "http://susestudio.com/api/v1/user/appliances?clone_from=14774&name=My%20Server&arch=x86_64"

Manage overlay files

List the files of an appliance:

 curl -u <user>:<api_key> "http://susestudio.com/api/v1/user/files?appliance_id=<id>" (example)


Upload a file:

 curl -u <user>:<api_key> -XPOST -F "file=@/path/to/your/file" "http://susestudio.com/api/v1/user/files?appliance_id=<id>" (example)

Optionally, you can specify the filename, path, owner, group or permissions, here.


Build your appliance

Trigger a build of an appliance:

 curl -u <user>:<api_key> -XPOST "http://susestudio.com/api/v1/user/running_builds?appliance_id=<id>"

Monitor build progress:

 curl -u <user>:<api_key> "http://susestudio.com/api/v1/user/running_builds?appliance_id=<id>" (example)

RESTful API

SUSE Studio features a RESTful API over HTTP which can be used to clone appliances, upload files, trigger and monitor builds and more. See the SUSE Studio API documentation for more details.

URL Encoding

Not all the characters are allowed into an URL (http://tools.ietf.org/html/rfc1738). This is a problem for example if you try to add the gcc-c++ package into your appliance as "+" is not allowed. So, the following will not work:

curl -u user:secret -XPOST http://susestudio.com/api/v1/user/appliances/263276/cmd/add_package?name=gcc-c++


However, some characters can be encoded. See http://www.w3schools.com/tags/ref_urlencode.asp .

So, in our example, you should :

curl -u  user:secret -XPOST http://susestudio.com/api/v1/user/appliances/263276/cmd/add_package?name=gcc-c%2B%2B