NAO Cloud can be configured to send a POST request whenever resources of a certain type are modified, or triggered (applicable for alerts only). Modification includes creation, update and deletion of a resource of those types.
The Resource notifiers can be accessed via the Overview/Actions/Resource notifiers menu of a NAO Cloud site. On this page you will be able to create new notifiers, as well as list all existing notifiers for the current site.
When creating a notifier, along with the resource types that will trigger the request and the events that should trigger requests you will be able to set the URL to which the POST request will be made, as well as additional custom parameters that should be sent along with the notification parameters.
The POST request that will be sent will have the following format :
POST post_url HTTP/1.1
Content-Type: application/json
{
"resource_id": 1,
"resource_type": "Region",
"action": "Update",
"time": "2016-11-07T11:00:00Z"
}
Any custom parameter that was set in the notifier will be added to the previous parameters.
NAO Cloud expects in return a 200
response code. If it receives a different response code, the notification will be marked as not sent and will be stored for future sending.
Notifications that couldn’t be sent can be accessed in two different ways, on the NAO Cloud site or using the NAO Cloud API.
Pending notifications can be accessed by accessing a notifier’s configuration page. Note that in the Resource Notifiers index page a badge will appear to indicate the number of notifications that could not be sent. On the notifier’s page, a table of all unsent notifications and their informations can be seen at the bottom. From there you can either delete the notifications or re-send them.
Using the API, there are several end-points that can be used to retrieve informations of the notifier and its pending notifications. First, a notifier can be accessed using the following endpoint:
GET /api/v2/sites/{site_id}/notifiers/{id}
Along with the notifier’s attributes such as the post_url
and post_params
, there is a nb_pending_notifications
attribute that indicates the number of pending notifications. The notifications can then be accessed using the following endpoint:
GET /api/v2/sites/{site_id}/notifiers/{notifier_id}/notifications
Each notification can then be individually accessed using their endpoint
GET /api/v2/sites/{site_id}/notifiers/{notifier_id}/notifications/{id}
To mark the notification as read and remove it from the list, you then need to destroy it using its DELETE
endpoint :
DELETE /api/v2/sites/{site_id}/notifiers/{notifier_id}/notifications/{id}