Hi,
That Swagger.JS approach looks very cool and simple for accessing the API!
The sensor info is retrieved under the given entity. For the top-level
application's sensors, the application is also an entity so the app id
matches the entity id (e.g.
http://localhost:8081/v1/applications/fGc8HGHM/entities/fGc8HGHM/sensors).
Unfortunately applicationTree doesn't give links to the details of each
application/entity shown in the tree. You need to look under the
specific application.
As a general note, there are four easy ways to discover the API:
* Use the web-console to navigate to the info you want, and then note
the URL.
For example, run `brooklyn launch` and deploy an entity. In the
"applications" view, entity and click on the sensors tab. The URL
will look something like:
http://localhost:8081/#v1/applications/fGc8HGHM/entities/RfaEjNGd/sensors
Strip out the "#" and you'll get the required REST call for
retrieving all sensor info of a given entity (e.g.
http://localhost:8081/v1/applications/fGc8HGHM/entities/RfaEjNGd/sensors)
* Follow the links returned in the REST calls (e.g.
http://localhost:8081/#v1/applications gives links to the
applications, which gives links to the entities in that application,
etc)
* Browse the REST api docs (i.e. run `brooklyn launch`, navigate to
the "Script->REST API" tab).
Under "Entity Sensors" it shows the URL format.
* Browse the open-source code at
https://github.com/apache/incubator-brooklyn/tree/master/usage/rest-api/src/main/java/brooklyn/rest/api,
looking at the swagger annotations on the methods for the
corresponding URLs.
Aled
On 25/09/2014 08:41, Adrián Nieto wrote:
Hello, I'm currently developing a sample of a monitoring dashboard fed
with Brooklyn's Sensors for the SeaClouds project. In order to connect
to the backend, I'm using Swagger.JS
Getting the list of deployed applications and their entities is pretty
straightforward:
var API = new SwaggerApi({
basePath: BROOKLYN_ENDPOINT,
discoveryUrl: BROOKLYN_ENDPOINT + "/v1/apidoc",
success: refreshUI,
fail: checkBackendStatus
})
After calling the success function, the application list can be
retrieved by using for example
"API.Applications.applicationTree(params,success,fail)"
However, I'm not able to find anything related with the sensor
information, because it only provides the following subAPIs:
"Activities, Applications, Catalog, Entities, Locations, Scripting,
Server, Usage and Version".
The remaining subAPIs (API Documentation, Access Control, Entity Config,
Entity Effectors, Entity Policies, Entity Policy Config, Entity Sensors)
are missing. Probably it will be due the whitespaces in the name.
Anyone could point me in the right direction? Maybe i should fill a JIRA
Issue?
Thank you very much.