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 16:58] 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 === | ||
- | 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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.These are the command to use in order to obtain information about alarms. | + | Request information about a single alarm. |
+ | |||
+ | Request: | ||
+ | |||
+ | <code> | ||
+ | { | ||
+ | "cmd": "alarmGet", | ||
+ | "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJ...." | ||
+ | "param": { | ||
+ | "eventId": 123 | ||
+ | } | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | Response: | ||
+ | |||
+ | <code> | ||
+ | { | ||
+ | "success": true, | ||
+ | "request": | ||
+ | { | ||
+ | "cmd": "alarmGet", | ||
+ | "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJ...." | ||
+ | "param": { | ||
+ | "eventId": 123 | ||
+ | } | ||
+ | }, | ||
+ | "response": | ||
+ | { | ||
+ | eventId: 12345, | ||
+ | type: 1, | ||
+ | typeString: “Threshold”, | ||
+ | deviceId: 1234, | ||
+ | deviceName: “NODE0101”, | ||
+ | entityId: 12345, | ||
+ | thresholdId: 12345, | ||
+ | description: “DOWN Interface Gi0/1/1.2” | ||
+ | status: 10, | ||
+ | statusString: “Active”, | ||
+ | level: 5, | ||
+ | levelString: “Critical”, | ||
+ | start: 1472577290, | ||
+ | restart: 1472577290, | ||
+ | end: 0, | ||
+ | elementInfo: { | ||
+ | ifIndex: 23, | ||
+ | ifDescr: “GigabitEthernet0/1/1.2”, | ||
+ | ifName: “Gi0/1/1.2”, | ||
+ | ifType: “Ethernet”, | ||
+ | ifAlias: “”, | ||
+ | .... | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </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> |