@@ -2,7 +2,7 @@ var http = require('http');
22var https = require ( 'https' ) ;
33var ID = 'TempoDB: ' ;
44
5- var TempoDBClient = exports . TempoDBClient =
5+ var TempoDBClient = exports . TempoDBClient =
66 function ( key , secret , options ) {
77 /*
88 options
@@ -12,7 +12,7 @@ var TempoDBClient = exports.TempoDBClient =
1212 version (string)
1313 */
1414 options = options || { } ;
15-
15+
1616 const HOST = 'api.tempo-db.com' ,
1717 PORT = 443 ,
1818 VERSION = 'v1' ,
@@ -42,6 +42,9 @@ TempoDBClient.prototype.call = function(method, path, body, callback) {
4242 json_body = JSON . stringify ( body ) ;
4343 this . headers [ 'Content-Length' ] = json_body . length ;
4444 }
45+ else {
46+ this . headers [ 'Content-Length' ] = 0
47+ }
4548
4649 var options = {
4750 host : this . hostname ,
@@ -57,7 +60,7 @@ TempoDBClient.prototype.call = function(method, path, body, callback) {
5760 //the listener that handles the response chunks
5861 res . addListener ( 'data' , function ( chunk ) {
5962 data += chunk . toString ( ) ;
60- } ) ;
63+ } ) ;
6164
6265 res . addListener ( 'end' , function ( ) {
6366 result = '' ;
@@ -107,7 +110,7 @@ TempoDBClient.prototype.get_series = function(options, callback) {
107110 */
108111 options = options || { } ;
109112 query_string = '?' + EncodeQueryData ( options ) ;
110-
113+
111114 return this . call ( 'GET' , '/series/' + query_string , null , callback ) ;
112115}
113116
@@ -212,6 +215,28 @@ TempoDBClient.prototype.increment_bulk = function(ts, data, callback) {
212215 return this . call ( 'POST' , '/increment/' , body , callback ) ;
213216}
214217
218+ TempoDBClient . prototype . delete_id = function ( series_id , start , end , callback ) {
219+ var options = {
220+ start : ISODateString ( start ) ,
221+ end : ISODateString ( end )
222+ }
223+ var query_string = '?' + EncodeQueryData ( options ) ;
224+
225+ return this . call ( 'DELETE' , '/series/id/' + series_id + '/data/' + query_string , null , callback ) ;
226+ }
227+
228+ TempoDBClient . prototype . delete_key = function ( series_key , start , end , callback ) {
229+ var options = {
230+ start : ISODateString ( start ) ,
231+ end : ISODateString ( end )
232+ }
233+
234+ var query_string = '?' + EncodeQueryData ( options ) ;
235+
236+ return this . call ( 'DELETE' , '/series/key/' + series_key + '/data/' + query_string , null , callback ) ;
237+ }
238+
239+
215240var EncodeQueryData = function ( data ) {
216241 var ret = [ ] ;
217242 for ( var key in data ) {
0 commit comments