Notifications utils
Notification
The notification object is the main object for managing notifications.
notification.addEmailNotification(emailConfig)
Sends an email notification to defined recipients.
Returns: void
This function takes as parameter an object with the following fields:
| Property | Type | Default | Mandatory | Description |
|---|---|---|---|---|
| jsRecipients | List | Yes | Array of recipients to send email. This param has same format as defined in easy mode | |
| notificationName | String | Yes | Name of notification that will be received in subject field | |
| notificationBody | String | Yes | Mustache template with email’s body | |
| ruleName | String | Yes | Name of rule that launch email request | |
| mailParameters | Object | No | Json object with key-value pairs that will be replaces in mustache evaluation |
Example of use:
The example send email to example@recipient.es with highTemperature notification.
notification.addTrapNotification(trapConfig)
Sends an SNMP trap notification to defined recipients.
This function takes as parameter an object with the following fields:
| Property | Type | Default | Mandatory | Description |
|---|---|---|---|---|
| jsRecipients | List | Yes | Array of recipients (<ip>:<port>) to send trap. This param has same format as defined in easy mode |
|
| jsVariables | Object | Yes | Map of variables. Each pair defines OID variable and sent value for this OID | |
| notificationName | String | Yes | Name of notification | |
| trapOID | String | Yes | OID of trap | |
| enterpriseOID | String | Yes | OID of enterprise | |
| ruleName | String | Yes | Name of rule |
Example of use:
The example send trap to 25.35.98.5:8585 with highTemperature notification.
notification.sendHttp(httpConfig)
Sends an HTTP request notification to a specified URL.
Returns: void
This function takes as parameter an object with the following fields:
| Property | Type | Default | Mandatory | Description |
|---|---|---|---|---|
| url | String | Yes | URL to which the HTTP request will be sent | |
| method | String | Yes | HTTP method to be used for the request | |
| headers | Object | No | Key-value pairs representing HTTP headers | |
| queryParams | Object | No | Key-value pairs representing query parameters | |
| body | String | No | Body of the HTTP request |
Example of use:
The example sends http request to http://myService/request with highTemperature notification.