This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
en:api_def [2017/01/23 17:55] admin [Alarms] |
en:api_def [2017/03/07 16:09] (current) admin [Alarms] |
||
---|---|---|---|
Line 13: | Line 13: | ||
The method to request or send data to NeMo is to send a JSON message containing the command and related parameters. The output will be a JSON message containing the response to the request. | The method to request or send data to NeMo is to send a JSON message containing the command and related parameters. The output will be a JSON message containing the response to the request. | ||
Users can send messages through two different channels: | Users can send messages through two different channels: | ||
- | - via HTTP using the script //**api.php**// | + | * via HTTP using the script //**api.php**// |
- | - via the NeMo message broker that use the AMQP protocol, through the queue "**nemoapi**" | + | * via the NeMo message broker that use the AMQP protocol, through the queue "**nemoapi**" |
To test the API messages there is the page apitest.php | To test the API messages there is the page apitest.php | ||
Line 89: | Line 89: | ||
These are the command to use in order to obtain information about alarms. | These are the command to use in order to obtain information about alarms. | ||
- | * alarmActive | + | * [[#alarmActive|alarmActive]] |
* [[#alarmGet|alarmGet]] | * [[#alarmGet|alarmGet]] | ||
+ | * [[#alarmMultiget|alarmMultiget]] | ||
+ | |||
+ | |||
+ | === alarmActive === | ||
+ | |||
+ | Get all active alarms. | ||
+ | |||
+ | Request: | ||
+ | |||
+ | <code> | ||
+ | { | ||
+ | "cmd": "alarmActive", | ||
+ | "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJ...." | ||
+ | "param": { } | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | Response: | ||
+ | |||
+ | <code> | ||
+ | { | ||
+ | "success": true, | ||
+ | "request": | ||
+ | { | ||
+ | "cmd": "alarmActive", | ||
+ | "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJ...." | ||
+ | "param": { } | ||
+ | }, | ||
+ | "response": { | ||
+ | "responseType": "full", //valid options: "full", "partial" | ||
+ | "data": [ | ||
+ | {....}, | ||
+ | {....} | ||
+ | ] | ||
+ | } | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | The "response" object contains the "responseType" field that specify if the content is complete (full) or partial. In case of "partial" response, only the first API_ALARM_MULTIGET_MAXEVENT alarms will be fully provided (if API_ALARM_MULTIGET_MAXEVENT is equal to 0 all messages will be provided in a single response); for the remaining alarms will be provided only the **eventId** field and the client have to call other **alarmGet** or **alarmMultiget** requests to obtain complete information. | ||
+ | The format for each event elements, is the same as that contained in the [[#alarmGet|alarmGet]] command. | ||
=== alarmGet === | === alarmGet === | ||
Request information about a single alarm. | Request information about a single alarm. | ||
+ | |||
+ | Request: | ||
<code> | <code> | ||
Line 106: | Line 148: | ||
</code> | </code> | ||
- | The response is in the form: | + | Response: |
<code> | <code> | ||
Line 147: | Line 189: | ||
} | } | ||
</code> | </code> | ||
+ | |||
+ | |||
+ | === alarmMultiget === | ||
+ | |||
+ | Request information about multiple alarms. | ||
+ | |||
+ | Request: | ||
+ | |||
+ | <code> | ||
+ | { | ||
+ | "cmd": "alarmMultiget", | ||
+ | "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJ...." | ||
+ | "param": { | ||
+ | "eventIds": [123,234,345,456,567,678,.....] | ||
+ | } | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | Response: | ||
+ | |||
+ | <code> | ||
+ | { | ||
+ | "success": true, | ||
+ | "request": | ||
+ | { | ||
+ | "cmd": "alarmMultiget", | ||
+ | "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJ...." | ||
+ | "param": { | ||
+ | "eventIds": [123,234,345,456,567,678,.....] | ||
+ | } | ||
+ | }, | ||
+ | "response": { | ||
+ | "responseType": "full", //valid options: "full", "partial" | ||
+ | "data": [ | ||
+ | {....}, | ||
+ | {....} | ||
+ | ] | ||
+ | } | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | The "response" object contains the "responseType" field that specify if the content is complete (full) or partial. In case of "partial" response, only the first API_ALARM_MULTIGET_MAXEVENT alarms will be fully provided (if API_ALARM_MULTIGET_MAXEVENT is equal to 0 all messages will be provided in a single response); for the remaining alarms will be provided only the **eventId** field and the client have to call other **alarmGet** or **alarmMultiget** requests to obtain complete information. | ||
+ | The format for each event elements, is the same as that contained in the [[#alarmGet|alarmGet]] command. | ||
+ | |||
+ | |||
+ | |||
+ | ==== Queue ==== | ||
+ | |||
+ | These are the command to use in order to manipulate queues. | ||
+ | |||
+ | * [[#queueLength|queueLength]] | ||
+ | * [[#queuePurge|queuePurge]] | ||
+ | |||
+ | |||
+ | === queueLength === | ||
+ | |||
+ | Request the number of message in a specific queue. | ||
+ | |||
+ | Request: | ||
+ | |||
+ | <code> | ||
+ | { | ||
+ | "cmd": "queueLength", | ||
+ | "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJ...." | ||
+ | "param": { | ||
+ | "queueName": "fooQueue" | ||
+ | } | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | Response: | ||
+ | |||
+ | <code> | ||
+ | { | ||
+ | "success": true, | ||
+ | "request": | ||
+ | { | ||
+ | "cmd": "queueLength", | ||
+ | "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJ...." | ||
+ | "param": { | ||
+ | "queueName": "fooQueue" | ||
+ | } | ||
+ | }, | ||
+ | "response": { | ||
+ | "length": 25 | ||
+ | } | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | |||
+ | === queuePurge === | ||
+ | |||
+ | Purge the specified queue. | ||
+ | |||
+ | Request: | ||
+ | |||
+ | <code> | ||
+ | { | ||
+ | "cmd": "queuePurge", | ||
+ | "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJ...." | ||
+ | "param": { | ||
+ | "queueName": "fooQueue" | ||
+ | } | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | Response: | ||
+ | |||
+ | <code> | ||
+ | { | ||
+ | "success": true, | ||
+ | "request": | ||
+ | { | ||
+ | "cmd": "queuePurge", | ||
+ | "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJ...." | ||
+ | "param": { | ||
+ | "queueName": "fooQueue" | ||
+ | } | ||
+ | }, | ||
+ | "response": {} | ||
+ | } | ||
+ | </code> | ||
+ |