|
|
|
@ -5,6 +5,20 @@ var v8type = require('v8type'); |
|
|
|
var alert_api = function(){}; |
|
|
|
|
|
|
|
alert_api.prototype.add_alert = function(alert, callback){ |
|
|
|
/* |
|
|
|
* alert_api.add_alert(alert, [callback]) |
|
|
|
* |
|
|
|
* add a new alert to datadog |
|
|
|
* |
|
|
|
* `alert` is an object containing: |
|
|
|
* query: *required*, the metric to query on |
|
|
|
* name: name of the alert |
|
|
|
* message: an optional message to include with the alert |
|
|
|
* silenced: whether the alert should notify by email and in the stream |
|
|
|
* |
|
|
|
* `callback` an optional function to get called with the results of the api call |
|
|
|
* callback(error, result, status_code) |
|
|
|
*/ |
|
|
|
if(!v8type.is(alert, v8type.OBJECT)){ |
|
|
|
throw new Error('`alert` parameter must be an object'); |
|
|
|
} |
|
|
|
@ -17,6 +31,21 @@ alert_api.prototype.add_alert = function(alert, callback){ |
|
|
|
}; |
|
|
|
|
|
|
|
alert_api.prototype.update_alert = function(alert_id, alert, callback){ |
|
|
|
/* |
|
|
|
* alert_api.update_alert(alert_id, alert, [callback]) |
|
|
|
* |
|
|
|
* update an existing alert |
|
|
|
* |
|
|
|
* `alert_id` the id of alert to update |
|
|
|
* `alert` is an object containing: |
|
|
|
* query: *required*, the metric to query on |
|
|
|
* name: name of the alert |
|
|
|
* message: an optional message to include with the alert |
|
|
|
* silenced: whether the alert should notify by email and in the stream |
|
|
|
* |
|
|
|
* `callback` an optional function to get called with the results of the api call |
|
|
|
* callback(error, result, status_code) |
|
|
|
*/ |
|
|
|
if(!v8type.is(alert, v8type.OBJECT)){ |
|
|
|
throw new Error('`alert` parameter must be an object'); |
|
|
|
} |
|
|
|
@ -29,22 +58,66 @@ alert_api.prototype.update_alert = function(alert_id, alert, callback){ |
|
|
|
}; |
|
|
|
|
|
|
|
alert_api.prototype.get_alert = function(alert_id, callback){ |
|
|
|
/* |
|
|
|
* alert_api.get_alert(alert_id, [callback]) |
|
|
|
* |
|
|
|
* get the details of an alert from the given id |
|
|
|
* |
|
|
|
* `alert_id` the id for the alert to get |
|
|
|
* |
|
|
|
* `callback` an optional function to call with the results |
|
|
|
* callback(error, result, status_code) |
|
|
|
*/ |
|
|
|
this.request('GET', util.format('/alert/%s', alert_id), callback) |
|
|
|
}; |
|
|
|
|
|
|
|
alert_api.prototype.delete_alert = function(){ |
|
|
|
alert_api.prototype.delete_alert = function(alert_id, callback){ |
|
|
|
/* |
|
|
|
* alert_api.delete_alert(alert_id, [callback]) |
|
|
|
* |
|
|
|
* delete the given alert from datadog |
|
|
|
* |
|
|
|
* `alert_id` the id for the alert to get |
|
|
|
* |
|
|
|
* `callback` an optional function to call with the results |
|
|
|
* callback(error, result, status_code) |
|
|
|
*/ |
|
|
|
this.request('DELETE', util.format('/alert/%s', alert_id), callback) |
|
|
|
}; |
|
|
|
|
|
|
|
alert_api.prototype.get_all_alerts = function(callback){ |
|
|
|
/* |
|
|
|
* alert_api.get_all_alerts([callback]) |
|
|
|
* |
|
|
|
* get the details of all alerts in datadog |
|
|
|
* |
|
|
|
* `callback` an optional function to call with the results |
|
|
|
* callback(error, result, status_code) |
|
|
|
*/ |
|
|
|
this.request('GET', '/alert', callback) |
|
|
|
}; |
|
|
|
|
|
|
|
alert_api.prototype.mute_alerts = function(callback){ |
|
|
|
/* |
|
|
|
* alert_api.mute_alerts([callback]) |
|
|
|
* |
|
|
|
* mute all alerts |
|
|
|
* |
|
|
|
* `callback` an optional function to call with the results |
|
|
|
* callback(error, result, status_code) |
|
|
|
*/ |
|
|
|
this.request('POST', '/mute_alerts', callback) |
|
|
|
}; |
|
|
|
|
|
|
|
alert_api.prototype.unmute_alerts = function(callback){ |
|
|
|
/* |
|
|
|
* alert_api.unmute_alerts([callback]) |
|
|
|
* |
|
|
|
* unmute all alerts |
|
|
|
* |
|
|
|
* `callback` an optional function to call with the results |
|
|
|
* callback(error, result, status_code) |
|
|
|
*/ |
|
|
|
this.request('POST', '/unmute_alerts', callback) |
|
|
|
}; |
|
|
|
|
|
|
|
|