Browse Source

Merge pull request #7 from dalehamel/snapshot-status

Add snapshot status
pull/11/head
Brett Langdon 11 years ago
parent
commit
06a010c6b0
1 changed files with 26 additions and 0 deletions
  1. +26
    -0
      lib/api/snapshot.js

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

@ -72,4 +72,30 @@ snapshot_api.prototype.add_snapshot_from_def = function(snapshot, callback){
this.request('GET', '/graph/snapshot', {query: snapshot}, callback); 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; return module.exports = snapshot_api;

Loading…
Cancel
Save