Browse Source

Merge 9ddad29e18 into da2ddd0027

pull/2/merge
Colin Jones 12 years ago
parent
commit
2f72823eec
3 changed files with 56 additions and 3 deletions
  1. +47
    -0
      lib/api/snapshot.js
  2. +4
    -1
      lib/index.js
  3. +5
    -2
      package.json

+ 47
- 0
lib/api/snapshot.js View File

@ -0,0 +1,47 @@
var extend = require('extend');
var util = require('util');
var v8type = require('v8type');
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(!v8type.is(snapshot, v8type.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);
};
return module.exports = snapshot_api;

+ 4
- 1
lib/index.js View File

@ -8,6 +8,8 @@ var event_api = require('./api/event.js');
var tag_api = require('./api/tag.js'); var tag_api = require('./api/tag.js');
var metric_api = require('./api/metric.js'); var metric_api = require('./api/metric.js');
var search_api = require('./api/search.js'); var search_api = require('./api/search.js');
var snapshot_api = require('./api/snapshot.js');
var dogapi = function(options){ var dogapi = function(options){
http_client.call(this, options); http_client.call(this, options);
@ -21,6 +23,7 @@ extend(dogapi.prototype,
event_api.prototype, event_api.prototype,
tag_api.prototype, tag_api.prototype,
metric_api.prototype, metric_api.prototype,
search_api.prototype);
search_api.prototype,
snapshot_api.prototype);
return module.exports = dogapi; return module.exports = dogapi;

+ 5
- 2
package.json View File

@ -1,6 +1,6 @@
{ {
"name": "dogapi", "name": "dogapi",
"version": "0.1.2",
"version": "0.1.3",
"description": "Datadog API Node.JS Client", "description": "Datadog API Node.JS Client",
"main": "lib/index.js", "main": "lib/index.js",
"scripts": { "scripts": {
@ -8,7 +8,7 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git://github.com/brettlangdon/node-dogapi.git"
"url": "git://github.com/brettlangdon/node-dogapi"
}, },
"keywords": [ "keywords": [
"datadog", "datadog",
@ -19,6 +19,9 @@
"dog api" "dog api"
], ],
"author": "Brett Langdon <brett@blangdon.com> (http://brett.is)", "author": "Brett Langdon <brett@blangdon.com> (http://brett.is)",
"contributors":[
"colinjonesx (http://www.thetestpeople.com)"
],
"license": "MIT", "license": "MIT",
"readmeFilename": "README.md", "readmeFilename": "README.md",
"gitHead": "f388635a5ab4f4da25702dc0999385d437bdf2bc", "gitHead": "f388635a5ab4f4da25702dc0999385d437bdf2bc",


Loading…
Cancel
Save