Using the API with curl

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

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> "https://susestudio.com/api/v2/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> "https://susestudio.com/api/v2/user/appliances"

Example

A specific appliance:

   curl -u <user>:<api_key> "https://susestudio.com/api/v2/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 "https://susestudio.com/api/v2/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> "https://susestudio.com/api/v2/user/files?appliance_id=<id>"

Example

Upload a file:

   curl -u <user>:<api_key> -XPOST -F "file=@/path/to/your/file" "https://susestudio.com/api/v2/user/files?appliance_id=<id>"

Example

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

Build your appliance

Trigger a build of an appliance:

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

Monitor build progress:

   curl -u <user>:<api_key> "https://susestudio.com/api/v2/user/running_builds?appliance_id=<id>"

Example

URL Encoding

Not all characters are allowed in 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 https://susestudio.com/api/v2/user/appliances/263276/cmd/add_package?name=gcc-c++

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

In our example, use the following command:

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