Apache Brooklyn exposes a powerful REST API, allowing it to be scripted from bash or integrated with other systems.
For many commands, the REST call follows the same structure as the web console URL
scheme, but with the
# at the start of the path removed; for instance the catalog
cluster in the web console is displayed at:
And in the REST API it is accessed at:
A full reference for the REST API is automatically generated by the server at runtime. It can be found in the Brooklyn web console, under the Script tab.
Here we include some of the most common REST examples and other advice for working with the REST API.
For command-line access, we recommend
curl, with tips below.
For navigating in a browser we recommend getting a plugin for working with REST; these are available for most browsers and make it easier to authenticate, set headers, and see JSON responses.
For manipulating JSON responses on the command-line,
jq from stedolan’s github
is very useful, and available in most package repositories, including
brew on Mac.
Common REST Examples
Here are some useful snippets:
Deploy an application from
curl http://localhost:8081/v1/applications --data-binary @__FILE__
Get details of a task with ID
idis returned by the above, optionally piped to
Get the value of sensor
app1(note you can use either the entity’s ID or its name)
Get all sensor values (using the pseudo-sensor
Invoke an effector
e1, with argument
hi(note if no arguments, you must specify
-d ""; for multiple args, just use multiple
-dentries, or a JSON file with
curl http://localhost:8081/v1/applications/app1/entities/e1/effectors/eff -d arg1=hi
Add an item to the catalog from
curl http://localhost:8081/v1/catalog --data-binary @__FILE__
Curl Cheat Sheet
- if authentication is required, use
- to see detailed output, including headers, code, and errors, use
- where the request is not a simple HTTP GET, use
- to pass key-value data to a post, use
- where you are posting from a file
--data-binary @__FILE__(implies a POST) or
-T __FILE__ -X POST
- to add a header, use
-H "key: value", for example
-H "Brooklyn-Allow-Non-Master-Access: true"
- to specify that a specific content-type is being uploaded, use
-H "Content-Type: application/json"(or
- to specify the content-type required for the result, use
-H "Accept: application/json"(or
application/yaml, or for sensor values,