| @ -1,123 +0,0 @@ | |||||
| var util = require('util'); | |||||
| 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(typeof alert != 'object'){ | |||||
| throw new Error('`alert` parameter must be an object'); | |||||
| } | |||||
| if(!alert['query']){ | |||||
| throw new Error('`alert["query"]` is required'); | |||||
| } | |||||
| this.request('POST', '/alert', {body: 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(typeof alert != 'object'){ | |||||
| throw new Error('`alert` parameter must be an object'); | |||||
| } | |||||
| if(!alert['query']){ | |||||
| throw new Error('`alert["query"]` is required'); | |||||
| } | |||||
| this.request('PUT', util.format('/alert/%s', alert_id), {body: 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_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); | |||||
| }; | |||||
| return module.exports = alert_api; | |||||
| @ -1,103 +0,0 @@ | |||||
| var util = require('util'); | |||||
| var validate_dashboard = function(dashboard){ | |||||
| if(typeof dashboard != 'object'){ | |||||
| throw new Error('`dashboard` parameter must be an object'); | |||||
| } | |||||
| if(dashboard['title'] != 'string'){ | |||||
| throw new Error('`dashboard["title"]` must be a string'); | |||||
| } | |||||
| if(typeof dashboard['description'] != 'string'){ | |||||
| throw new Error('`dashboard["description"]` must be a string'); | |||||
| } | |||||
| if(typeof dashboard['graphs'] != 'object'){ | |||||
| throw new Error('`dashboard["graphs"]` must be an array'); | |||||
| } | |||||
| for(var i in dashboard['graphs']){ | |||||
| if(!dashboard['graphs'][i]['title']){ | |||||
| throw new Error(util.format('`dashboard["graphs"][%s]["title"]` is missing', i)); | |||||
| } | |||||
| if(!dashboard['graphs'][i]['definition']){ | |||||
| throw new Error(util.format('`dashboard["graphs"][%s]["definition"]` is missing', i)); | |||||
| } | |||||
| } | |||||
| }; | |||||
| var dash_api = function(){}; | |||||
| dash_api.prototype.get_dashboard = function(dash_id, callback){ | |||||
| /* | |||||
| * dash_api.get_dashboard(dash_id, [callback]) | |||||
| * | |||||
| * method to get a single dashboard information | |||||
| * | |||||
| * `dash_id` is the id of the dashboard to get information for | |||||
| * `callback` is an optional function to call with the results of the api call | |||||
| * callback(error, results, status_code) | |||||
| */ | |||||
| this.request('GET', util.format('/dash/%s', dash_id), callback); | |||||
| }; | |||||
| dash_api.prototype.get_all_dashboards = function(callback){ | |||||
| /* | |||||
| * dash_api.get_all_dashboards([callback]) | |||||
| * | |||||
| * method to retrieve all dashboards in datadog | |||||
| * | |||||
| * `callback` is an optional function to call with the results of the api call | |||||
| * callback(error, result, status_code) | |||||
| */ | |||||
| this.request('GET', '/dash', callback); | |||||
| }; | |||||
| dash_api.prototype.create_dashboard = function(dashboard, callback){ | |||||
| /* | |||||
| * dash_api.create_dashboard(dashboard, [callback]) | |||||
| * | |||||
| * method used to create a new dashboard in datadog | |||||
| * | |||||
| * `dashboard` is the definition for the dashboard | |||||
| * please see (http://docs.datadoghq.com/api/) for more information | |||||
| * | |||||
| * `callback` is an optional function to call with the results of the api call | |||||
| * callback(error, result, status_code) | |||||
| */ | |||||
| validate_dashboard(dashboard); | |||||
| this.request('POST', '/dash', {body: dashboard}, callback); | |||||
| }; | |||||
| dash_api.prototype.update_dashboard = function(dash_id, dashboard, callback){ | |||||
| /* | |||||
| * dash_api.update_dashboard(dash_id, dashboard, [callback]) | |||||
| * | |||||
| * method used to update the dashboard with the provided `dash_id` | |||||
| * | |||||
| * `dash_id` the id of the dashboard to update | |||||
| * `dashboard` is a definition for the datadog dashboard | |||||
| * please see (http://docs.datadoghq.com/api/) for more information | |||||
| * | |||||
| * `callback` an optional function to call with the results of the api call | |||||
| * callback(error, result, status_code) | |||||
| */ | |||||
| validate_dashboard(dashboard); | |||||
| this.request('PUT', util.format('/dash/%s', dash_id), {body: dashbboard}, callback); | |||||
| }; | |||||
| dash_api.prototype.delete_dashboard = function(dash_id, callback){ | |||||
| /* | |||||
| * dash_api.delete_dashboard(dash_id, [callback]) | |||||
| * | |||||
| * method to remove a dashboard from datadog | |||||
| * | |||||
| * `dash_id` the id for the dashboard to remove | |||||
| * `callback` an optional function to call with the results of the api call | |||||
| * callback(error, result, status_code) | |||||
| */ | |||||
| this.request('DELETE', util.format('/dash/%s', dash_id), callback); | |||||
| }; | |||||
| return module.exports = dash_api; | |||||
| @ -1,102 +0,0 @@ | |||||
| var util = require('util'); | |||||
| var downtime_api = function(){}; | |||||
| downtime_api.prototype.schedule_downtime = function(scope, options, callback){ | |||||
| /* | |||||
| * downtime_api.schedule_downtime(scope, [options], [callback]) | |||||
| * | |||||
| * method to schedule a new downtime | |||||
| * | |||||
| * `scope` the scope to schedule downtime for | |||||
| * `options` optional `start` `end` and `message` paramaters | |||||
| * `callback` is an optional function to call with the results of the api call | |||||
| * callback(error, results, status_code) | |||||
| */ | |||||
| if(typeof scope !== 'string'){ | |||||
| throw new Error('scope parameter must be a string'); | |||||
| } | |||||
| if(typeof options === 'function'){ | |||||
| callback = options; | |||||
| options = {}; | |||||
| } | |||||
| options.scope = scope; | |||||
| this.request('POST', '/downtime', {body: options}, callback); | |||||
| }; | |||||
| downtime_api.prototype.update_downtime = function(downtime_id, options, callback){ | |||||
| /* | |||||
| * downtime_api.update_downtime(downtime_id, [options], [callback]) | |||||
| * | |||||
| * method to update an existing downtime | |||||
| * | |||||
| * `downtime_id` the id of the downtime | |||||
| * `options` optional `scope` `start` `end` and `message` paramaters | |||||
| * `callback` is an optional function to call with the results of the api call | |||||
| * callback(error, results, status_code) | |||||
| */ | |||||
| if(typeof options === 'function'){ | |||||
| callback = options; | |||||
| options = {}; | |||||
| } | |||||
| this.request('PUT', util.format('/downtime/%s', downtime_id), {body: options}, callback); | |||||
| }; | |||||
| downtime_api.prototype.get_downtime = function(downtime_id, callback){ | |||||
| /* | |||||
| * downtime_api.get_downtime(downtime_id, [callback]) | |||||
| * | |||||
| * method to get an existing downtime | |||||
| * | |||||
| * `downtime_id` the id of the downtime | |||||
| * `callback` is an optional function to call with the results of the api call | |||||
| * callback(error, results, status_code) | |||||
| */ | |||||
| this.request('GET', util.format('/downtime/%s', downtime_id), callback); | |||||
| }; | |||||
| downtime_api.prototype.cancel_downtime = function(downtime_id, callback){ | |||||
| /* | |||||
| * downtime_api.cancel_downtime(downtime_id, [callback]) | |||||
| * | |||||
| * method to cancel an existing downtime | |||||
| * | |||||
| * `downtime_id` the id of the downtime | |||||
| * `callback` is an optional function to call with the results of the api call | |||||
| * callback(error, results, status_code) | |||||
| */ | |||||
| this.request('DELETE', util.format('/downtime/%s', downtime_id), callback); | |||||
| }; | |||||
| downtime_api.prototype.get_all_downtimes = function(current_only, callback){ | |||||
| /* | |||||
| * downtime_api.get_all_downtimes(downtime_id, [current_only], [callback]) | |||||
| * | |||||
| * method to get all downtimes | |||||
| * | |||||
| * `downtime_id` the id of the downtime | |||||
| * `current_only` whether or not to get the current downtime only | |||||
| * `callback` is an optional function to call with the results of the api call | |||||
| * callback(error, results, status_code) | |||||
| */ | |||||
| if(typeof current_only === 'function'){ | |||||
| callback = current_only; | |||||
| current_only = false; | |||||
| } | |||||
| query = {}; | |||||
| if(current_only){ | |||||
| query.current_only = true; | |||||
| } | |||||
| this.request('GET', '/downtime', {query: query}, callback); | |||||
| }; | |||||
| return module.exports = downtime_api; | |||||
| @ -1,116 +0,0 @@ | |||||
| var util = require('util'); | |||||
| var validate_screenboard = function(screenboard){ | |||||
| if(typeof screenboard != 'object'){ | |||||
| throw new Error('`screenboard` parameter must be an object'); | |||||
| } | |||||
| if(typeof screenboard['board_title'] != 'string'){ | |||||
| throw new Error('`screenboard["board_title"]` must be a string'); | |||||
| } | |||||
| if(screenboard['width'] != undefined && typeof screenboard['width'] != 'number'){ | |||||
| throw new Error('`screenboard["width"]` must be a number'); | |||||
| } | |||||
| if(screenboard['height'] != undefined && typeof screenboard['height'] != 'number'){ | |||||
| throw new Error('`screenboard["height"]` must be a number'); | |||||
| } | |||||
| if(typeof screenboard['widgets'] != 'object'){ | |||||
| throw new Error('`screenboard["widgets"]` must be an array'); | |||||
| } | |||||
| for(var i in screenboard['widgets']){ | |||||
| if(!screenboard['widgets'][i]['type']){ | |||||
| throw new Error(util.format('`screenboard["widgets"][%s]["type"]` is missing', i)); | |||||
| } | |||||
| if(!screenboard['widgets'][i]['width']){ | |||||
| throw new Error(util.format('`screenboard["widgets"][%s]["width"]` is missing', i)); | |||||
| } | |||||
| if(!screenboard['widgets'][i]['height']){ | |||||
| throw new Error(util.format('`screenboard["widgets"][%s]["height"]` is missing', i)); | |||||
| } | |||||
| if(!screenboard['widgets'][i]['x']){ | |||||
| throw new Error(util.format('`screenboard["widgets"][%s]["x"]` is missing', i)); | |||||
| } | |||||
| if(!screenboard['widgets'][i]['y']){ | |||||
| throw new Error(util.format('`screenboard["widgets"][%s]["y"]` is missing', i)); | |||||
| } | |||||
| } | |||||
| }; | |||||
| var screen_api = function(){}; | |||||
| screen_api.prototype.get_screenboard = function(screen_id, callback){ | |||||
| /* | |||||
| * screen_api.get_screenboard(screen_id, [callback]) | |||||
| * | |||||
| * method to get a single screenboard information | |||||
| * | |||||
| * `screen_id` is the id of the screenboard to get information for | |||||
| * `callback` is an optional function to call with the results of the api call | |||||
| * callback(error, results, status_code) | |||||
| */ | |||||
| this.request('GET', util.format('/screen/%s', screen_id), callback); | |||||
| }; | |||||
| screen_api.prototype.get_all_screenboards = function(callback){ | |||||
| /* | |||||
| * screen_api.get_all_screenboards([callback]) | |||||
| * | |||||
| * method to retrieve all screenboards in datadog | |||||
| * | |||||
| * `callback` is an optional function to call with the results of the api call | |||||
| * callback(error, result, status_code) | |||||
| */ | |||||
| this.request('GET', '/screen', callback); | |||||
| }; | |||||
| screen_api.prototype.create_screenboard = function(screenboard, callback){ | |||||
| /* | |||||
| * screen_api.create_screenboard(screenboard, [callback]) | |||||
| * | |||||
| * method used to create a new screenboard in datadog | |||||
| * | |||||
| * `screenboard` is the definition for the screenboard | |||||
| * please see (http://docs.datadoghq.com/api/) for more information | |||||
| * | |||||
| * `callback` is an optional function to call with the results of the api call | |||||
| * callback(error, result, status_code) | |||||
| */ | |||||
| validate_screenboard(screenboard); | |||||
| this.request('POST', '/screen', {body: screenboard}, callback); | |||||
| }; | |||||
| screen_api.prototype.update_screenboard = function(screen_id, screenboard, callback){ | |||||
| /* | |||||
| * screen_api.update_screenboard(screen_id, screenboard, [callback]) | |||||
| * | |||||
| * method used to update the screenboard with the provided `screen_id` | |||||
| * | |||||
| * `screen_id` the id of the screenboard to update | |||||
| * `screenboard` is a definition for the datadog screenboard | |||||
| * please see (http://docs.datadoghq.com/api/) for more information | |||||
| * | |||||
| * `callback` an optional function to call with the results of the api call | |||||
| * callback(error, result, status_code) | |||||
| */ | |||||
| validate_screenboard(screenboard); | |||||
| this.request('PUT', util.format('/screen/%s', screen_id), {body: screenboard}, callback); | |||||
| }; | |||||
| screen_api.prototype.delete_screenboard = function(screen_id, callback){ | |||||
| /* | |||||
| * screen_api.delete_screenboard(screen_id, [callback]) | |||||
| * | |||||
| * method to remove a screenboard from datadog | |||||
| * | |||||
| * `screen_id` the id for the screenboard to remove | |||||
| * `callback` an optional function to call with the results of the api call | |||||
| * callback(error, result, status_code) | |||||
| */ | |||||
| this.request('DELETE', util.format('/screen/%s', screen_id), callback); | |||||
| }; | |||||
| return module.exports = screen_api; | |||||
| @ -1,16 +0,0 @@ | |||||
| var search_api = function(){}; | |||||
| search_api.prototype.search = function(query, callback){ | |||||
| /* | |||||
| * search_api.search(query, [callback]) | |||||
| * | |||||
| * method used to query the api for `metrics` or `hosts` | |||||
| * | |||||
| * `query` the query to use to search the datadog service | |||||
| * | |||||
| * `callback` an optional function called with the results of the search | |||||
| * callback(error, result, status_code) | |||||
| */ | |||||
| this.request('GET', '/search', {query: {'q': query}}, callback); | |||||
| }; | |||||
| return module.exports = search_api; | |||||
| @ -1,101 +0,0 @@ | |||||
| var extend = require('extend'); | |||||
| var util = require('util'); | |||||
| var snapshot_api = function(){}; | |||||
| snapshot_api.prototype.add_snapshot = function(snapshot, callback){ | |||||
| /* | |||||
| * snapshot_api.add_snapshot(snapshot, [callback]) | |||||
| * | |||||
| * method used to add a new snapshot to datadog | |||||
| * | |||||
| * `snapshot` is an object containing any of the following: | |||||
| * metric_query: *required*, The metric query. | |||||
| * start: *required*, int, Start of the query.(POSIX timestamp) | |||||
| * end: *required*, int, End of the query.(POSIX timestamp) | |||||
| * event_query: A query that will add event bands to the graph. | |||||
| * | |||||
| * `callback` is an optional function for the result | |||||
| * callback(error, result, status_code) | |||||
| */ | |||||
| if(typeof snapshot != 'object'){ | |||||
| throw new Error('`snapshot` parameter must be an object'); | |||||
| } | |||||
| if(!snapshot['metric_query']){ | |||||
| throw new Error('`metric_query` property of `snapshot` parameter is required'); | |||||
| } | |||||
| if(!snapshot['start']){ | |||||
| throw new Error('`start` property of `snapshot` parameter is required'); | |||||
| } | |||||
| if(!snapshot['end']){ | |||||
| throw new Error('`end` property of `snapshot` parameter is required'); | |||||
| } | |||||
| this.request('GET', '/graph/snapshot', {query: snapshot}, callback); | |||||
| }; | |||||
| snapshot_api.prototype.add_snapshot_from_def = function(snapshot, callback){ | |||||
| /* | |||||
| * snapshot_api.add_snapshot_from_def(snapshot, [callback]) | |||||
| * | |||||
| * method used to add a new snapshot to datadog based on a graph definition | |||||
| * https://github.com/DataDog/dogapi/commit/583f13d7bd8de5a86daa2ff53f2d7cf6570e7ab2 | |||||
| * feature is not currently documented (at time of writing), but very useful. | |||||
| * | |||||
| * `snapshot` is an object containing any of the following: | |||||
| * graph_def: *required*, JSON string dump of an existing graph definition | |||||
| * start: *required*, int, Start of the query.(POSIX timestamp) | |||||
| * end: *required*, int, End of the query.(POSIX timestamp) | |||||
| * | |||||
| * `callback` is an optional function for the result | |||||
| * callback(error, result, status_code) | |||||
| */ | |||||
| if(typeof snapshot != 'object'){ | |||||
| throw new Error('`snapshot` parameter must be an object'); | |||||
| } | |||||
| if(!snapshot['graph_def']){ | |||||
| throw new Error('`graph_def` property of `snapshot` parameter is required'); | |||||
| } | |||||
| if(!snapshot['start']){ | |||||
| throw new Error('`start` property of `snapshot` parameter is required'); | |||||
| } | |||||
| if(!snapshot['end']){ | |||||
| throw new Error('`end` property of `snapshot` parameter is required'); | |||||
| } | |||||
| this.request('GET', '/graph/snapshot', {query: snapshot}, callback); | |||||
| }; | |||||
| snapshot_api.prototype.snapshot_status = function(snapshot_url, callback){ | |||||
| /* | |||||
| * snapshot_api.add_snapshot(snapshot_url, [callback]) | |||||
| * | |||||
| * method used to check the status of a datadog snapshot. | |||||
| * https://github.com/DataDog/dogapi/blob/master/src/dogapi/http/snapshot.py#L64 | |||||
| * Snapshot URLs are returned right away, but may be empty if the query or graph is complicated. | |||||
| * Result will be a json payload, with 403 for incomplete, or 200 for complete. | |||||
| * Examples: | |||||
| * * {"status_code":403} - incomplete (still processing, image is empty) | |||||
| * * {"status_code":200} - image is rendered and ready | |||||
| * | |||||
| * `snapshot_url` is a string containing URL returned from a call to add_snapshot or add_snapshot_from_def | |||||
| * | |||||
| * `callback` is an optional function for the result | |||||
| * callback(error, result, status_code) | |||||
| */ | |||||
| if(typeof snapshot_url != 'string'){ | |||||
| throw new Error('`snapshot_url` parameter must be a string'); | |||||
| } | |||||
| url = snapshot_url.split('/snapshot/view/')[1].split('.png')[0] | |||||
| this.request('GET', '/graph/snapshot_status/'+url, {}, callback); | |||||
| }; | |||||
| return module.exports = snapshot_api; | |||||