Comparing version 0.1.3 to 0.1.4
var util = require('util'); | ||
var v8type = require('v8type'); | ||
@@ -22,8 +21,8 @@ | ||
*/ | ||
if(!v8type.is(alert, v8type.OBJECT)){ | ||
throw new Error('`alert` parameter must be an object'); | ||
if(typeof alert != 'object'){ | ||
throw new Error('`alert` parameter must be an object'); | ||
} | ||
if(!alert['query']){ | ||
throw new Error('`alert["query"]` is required'); | ||
throw new Error('`alert["query"]` is required'); | ||
} | ||
@@ -50,8 +49,8 @@ | ||
*/ | ||
if(!v8type.is(alert, v8type.OBJECT)){ | ||
throw new Error('`alert` parameter must be an object'); | ||
if(typeof alert != 'object'){ | ||
throw new Error('`alert` parameter must be an object'); | ||
} | ||
if(!alert['query']){ | ||
throw new Error('`alert["query"]` is required'); | ||
throw new Error('`alert["query"]` is required'); | ||
} | ||
@@ -73,3 +72,3 @@ | ||
*/ | ||
this.request('GET', util.format('/alert/%s', alert_id), callback) | ||
this.request('GET', util.format('/alert/%s', alert_id), callback); | ||
}; | ||
@@ -88,3 +87,3 @@ | ||
*/ | ||
this.request('DELETE', util.format('/alert/%s', alert_id), callback) | ||
this.request('DELETE', util.format('/alert/%s', alert_id), callback); | ||
}; | ||
@@ -101,3 +100,3 @@ | ||
*/ | ||
this.request('GET', '/alert', callback) | ||
this.request('GET', '/alert', callback); | ||
}; | ||
@@ -114,3 +113,3 @@ | ||
*/ | ||
this.request('POST', '/mute_alerts', callback) | ||
this.request('POST', '/mute_alerts', callback); | ||
}; | ||
@@ -127,5 +126,5 @@ | ||
*/ | ||
this.request('POST', '/unmute_alerts', callback) | ||
this.request('POST', '/unmute_alerts', callback); | ||
}; | ||
return module.exports = alert_api; |
var util = require('util'); | ||
var v8type = require('v8type'); | ||
var validate_dashboard = function(dashboard){ | ||
if(!v8type.of(dashboard, v8type.OBJECT)){ | ||
throw new Error('`dashboard` parameter must be an object'); | ||
if(typeof dashboard != 'object'){ | ||
throw new Error('`dashboard` parameter must be an object'); | ||
} | ||
if(!v8type.of(dashboard['title'], v8type.STRING)){ | ||
throw new Error('`dashboard["title"]` must be a string'); | ||
if(dashboard['title'] != 'string'){ | ||
throw new Error('`dashboard["title"]` must be a string'); | ||
} | ||
if(!v8type.of(dashboard['description'], v8type.STRING)){ | ||
throw new Error('`dashboard["description"]` must be a string'); | ||
if(typeof dashboard['description'] != 'string'){ | ||
throw new Error('`dashboard["description"]` must be a string'); | ||
} | ||
if(!v8type.of(dashboard['graphs'], v8type.ARRAY)){ | ||
throw new Error('`dashboard["graphs"]` must be an array'); | ||
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)); | ||
} | ||
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)); | ||
} | ||
} | ||
} | ||
}; | ||
@@ -43,3 +42,3 @@ var dash_api = function(){}; | ||
*/ | ||
this.request('GET', util.format('/dash/%s', dash_id), callback) | ||
this.request('GET', util.format('/dash/%s', dash_id), callback); | ||
}; | ||
@@ -56,3 +55,3 @@ | ||
*/ | ||
this.request('GET', '/dash', callback) | ||
this.request('GET', '/dash', callback); | ||
}; | ||
@@ -103,5 +102,5 @@ | ||
*/ | ||
this.request('DELETE', util.format('/dash/%s', dash_id), callback) | ||
this.request('DELETE', util.format('/dash/%s', dash_id), callback); | ||
}; | ||
return module.exports = dash_api; |
var extend = require('extend'); | ||
var util = require('util'); | ||
var v8type = require('v8type'); | ||
@@ -27,7 +26,7 @@ | ||
if(arguments.length < 2){ | ||
throw new Error('parameters `start` and `end` are required'); | ||
throw new Error('parameters `start` and `end` are required'); | ||
} | ||
query = { | ||
start: parseInt(start), | ||
end: parseInt(end), | ||
start: parseInt(start), | ||
end: parseInt(end), | ||
}; | ||
@@ -38,5 +37,5 @@ | ||
// we want to push callback back | ||
if(arguments.length == 3 && v8type.is(arguments[2], v8type.FUNCTION)){ | ||
callback = arguments[2]; | ||
filter = {}; | ||
if(arguments.length == 3 && typeof arguments[2] == 'function'){ | ||
callback = arguments[2]; | ||
filter = {}; | ||
} | ||
@@ -47,13 +46,13 @@ | ||
if(filter['priority'] && ['low', 'normal'].indexOf(filter['priority'].toLowerCase()) >= 0){ | ||
query['priority'] = filter['priority'].toLowerCase(); | ||
query['priority'] = filter['priority'].toLowerCase(); | ||
} | ||
if(filter['sources'] && v8type.is(filter['sources'], v8type.ARRAY)){ | ||
query['sources'] = filter['sources'].join(); | ||
if(filter['sources'] && typeof filter['sources'] == 'object'){ | ||
query['sources'] = filter['sources'].join(); | ||
} | ||
if(filter['tags'] && v8type.is(filter['tags'], v8type.ARRAY)){ | ||
query['tags'] = filter['tags'].join(); | ||
if(filter['tags'] && typeof filter['tags'] == 'object'){ | ||
query['tags'] = filter['tags'].join(); | ||
} | ||
params = { | ||
query: query, | ||
query: query, | ||
}; | ||
@@ -74,8 +73,8 @@ this.request('GET', '/events', params, callback); | ||
*/ | ||
if(arguments.length < 3 && v8type.is(arguments[1], v8type.FUNCTION)){ | ||
callback = arguments[1]; | ||
filter = {}; | ||
if(arguments.length < 3 && typeof arguments[1] == 'function'){ | ||
callback = arguments[1]; | ||
filter = {}; | ||
} | ||
if(!v8type.is(filter, v8type.OBJECT)){ | ||
throw new Error('`filter` parameter must be an object'); | ||
if(typeof filter != 'object'){ | ||
throw new Error('`filter` parameter must be an object'); | ||
} | ||
@@ -86,5 +85,5 @@ | ||
setInterval(function(){ | ||
var start = last_run; | ||
var end = last_run = new Date().getTime() / 1000; | ||
self.stream(start, end, filter, callback); | ||
var start = last_run; | ||
last_run = new Date().getTime() / 1000; | ||
self.stream(start, last_run, filter, callback); | ||
}, interval * 1000); | ||
@@ -105,3 +104,3 @@ | ||
if(!event_id){ | ||
throw new Error('`event_id` parameter is required'); | ||
throw new Error('`event_id` parameter is required'); | ||
} | ||
@@ -133,26 +132,26 @@ | ||
*/ | ||
if(!v8type.is(event, v8type.OBJECT)){ | ||
throw new Error('`event` parameter must be an object'); | ||
if(typeof event != 'object'){ | ||
throw new Error('`event` parameter must be an object'); | ||
} | ||
if(!event['title']){ | ||
throw new Error('`title` property of `event` parameter is required'); | ||
throw new Error('`title` property of `event` parameter is required'); | ||
} | ||
if(!event['text']){ | ||
throw new Error('`text` property of `event` parameter is required'); | ||
throw new Error('`text` property of `event` parameter is required'); | ||
} | ||
if(!event['date_happened']){ | ||
event['date_happened'] = (new Date().getTime()) / 1000; | ||
event['date_happened'] = (new Date().getTime()) / 1000; | ||
} | ||
if(event['priority']){ | ||
if(['normal', 'low'].indexOf(event['priority'].toLowerCase()) == -1){ | ||
event['priority'] = undefined; | ||
} | ||
if(['normal', 'low'].indexOf(event['priority'].toLowerCase()) == -1){ | ||
event['priority'] = undefined; | ||
} | ||
} | ||
if(event['tags']){ | ||
event['tags'] = event['tags'].join(); | ||
event['tags'] = event['tags'].join(); | ||
} | ||
@@ -177,8 +176,8 @@ | ||
*/ | ||
if(!v8type.is(comment, v8type.OBJECT)){ | ||
throw new Error('`comment` parameter must be an object'); | ||
if(typeof comment != 'object'){ | ||
throw new Error('`comment` parameter must be an object'); | ||
} | ||
if(!comment['message']){ | ||
throw new Error('`message` property of `comment` paramter is required'); | ||
throw new Error('`message` property of `comment` paramter is required'); | ||
} | ||
@@ -203,4 +202,4 @@ | ||
*/ | ||
if(!v8type.is(comment, v8type.OBJECT)){ | ||
throw new Error('`comment` parameter must be an object'); | ||
if(typeof comment != 'object'){ | ||
throw new Error('`comment` parameter must be an object'); | ||
} | ||
@@ -207,0 +206,0 @@ |
@@ -1,4 +0,1 @@ | ||
var v8type = require('v8type'); | ||
var metric_api = function(){}; | ||
@@ -23,3 +20,3 @@ | ||
var metrics = { | ||
'series': [metric] | ||
'series': [metric] | ||
}; | ||
@@ -41,19 +38,19 @@ this.add_metrics(metrics, callback); | ||
*/ | ||
if(!v8type.is(metrics, v8type.OBJECT)){ | ||
throw new Error('`metrics` parameter must be an object'); | ||
if(typeof metrics != 'object'){ | ||
throw new Error('`metrics` parameter must be an object'); | ||
} | ||
if(!metrics['series'] || !v8type.is(metrics['series'], v8type.ARRAY)){ | ||
throw new Error('`metrics["series"]` parameter must be an array'); | ||
if(!metrics['series'] || typeof metrics['series'] != 'object'){ | ||
throw new Error('`metrics["series"]` parameter must be an array'); | ||
} | ||
for(var i in metrics['series']){ | ||
var metric = metrics['series'][i]; | ||
if(!metric['metric']){ | ||
throw new Error('metric["metric"] is required'); | ||
} | ||
var metric = metrics['series'][i]; | ||
if(!metric['metric']){ | ||
throw new Error('metric["metric"] is required'); | ||
} | ||
if(!metric['points'] || !v8type.is(metric['points'], v8type.ARRAY)){ | ||
throw new Error('metric["points"] must be an array'); | ||
} | ||
if(!metric['points'] || typeof metric['points'] != 'object'){ | ||
throw new Error('metric["points"] must be an array'); | ||
} | ||
} | ||
@@ -60,0 +57,0 @@ |
var util = require('util'); | ||
var v8type = require('v8type'); | ||
var validate_screenboard = function(screenboard){ | ||
if(!v8type.of(screenboard, v8type.OBJECT)){ | ||
if(typeof screenboard != 'object'){ | ||
throw new Error('`screenboard` parameter must be an object'); | ||
} | ||
if(!v8type.of(screenboard['board_title'], v8type.STRING)){ | ||
if(typeof screenboard['board_title'] != 'string'){ | ||
throw new Error('`screenboard["board_title"]` must be a string'); | ||
} | ||
if(screenboard['width'] != undefined && !v8type.of(screenboard['width'], v8type.NUMBER)){ | ||
if(screenboard['width'] != undefined && typeof screenboard['width'] != 'number'){ | ||
throw new Error('`screenboard["width"]` must be a number'); | ||
} | ||
if(screenboard['height'] != undefined && !v8type.of(screenboard['height'], v8type.NUMBER)){ | ||
if(screenboard['height'] != undefined && typeof screenboard['height'] != 'number'){ | ||
throw new Error('`screenboard["height"]` must be a number'); | ||
} | ||
if(!v8type.of(screenboard['widgets'], v8type.ARRAY)){ | ||
if(typeof screenboard['widgets'] != 'object'){ | ||
throw new Error('`screenboard["widgets"]` must be an array'); | ||
@@ -42,3 +41,3 @@ } | ||
} | ||
} | ||
}; | ||
@@ -57,3 +56,3 @@ var screen_api = function(){}; | ||
*/ | ||
this.request('GET', util.format('/screen/%s', screen_id), callback) | ||
this.request('GET', util.format('/screen/%s', screen_id), callback); | ||
}; | ||
@@ -70,3 +69,3 @@ | ||
*/ | ||
this.request('GET', '/screen', callback) | ||
this.request('GET', '/screen', callback); | ||
}; | ||
@@ -117,5 +116,5 @@ | ||
*/ | ||
this.request('DELETE', util.format('/screen/%s', screen_id), callback) | ||
this.request('DELETE', util.format('/screen/%s', screen_id), callback); | ||
}; | ||
return module.exports = screen_api; |
var extend = require('extend'); | ||
var util = require('util'); | ||
var v8type = require('v8type'); | ||
@@ -25,3 +24,3 @@ | ||
*/ | ||
if(!v8type.is(snapshot, v8type.OBJECT)){ | ||
if(typeof snapshot != 'object'){ | ||
throw new Error('`snapshot` parameter must be an object'); | ||
@@ -28,0 +27,0 @@ } |
var util = require('util'); | ||
var v8type = require('v8type'); | ||
@@ -17,11 +16,11 @@ var tag_api = function(){}; | ||
*/ | ||
if(arguments.length < 2 && v8type.is(arguments[0], v8type.FUNCTION)){ | ||
callback = arguments[0]; | ||
source = undefined; | ||
if(arguments.length < 2 && typeof arguments[0] == 'function'){ | ||
callback = arguments[0]; | ||
source = undefined; | ||
} | ||
params = { | ||
query: { | ||
source: source | ||
} | ||
query: { | ||
source: source | ||
} | ||
}; | ||
@@ -42,11 +41,11 @@ this.request('GET', '/tags/hosts', params, callback); | ||
*/ | ||
if(arguments.length < 3 && v8type.is(arguments[1], v8type.FUNCTION)){ | ||
callback = arguments[1]; | ||
source = undefined; | ||
if(arguments.length < 3 && typeof arguments[1] == 'function'){ | ||
callback = arguments[1]; | ||
source = undefined; | ||
} | ||
params = { | ||
query: { | ||
source: source, | ||
} | ||
query: { | ||
source: source, | ||
} | ||
}; | ||
@@ -67,12 +66,12 @@ this.request('GET', util.format('/tags/hosts/%s', host), params, callback); | ||
*/ | ||
if(arguments.length < 3 && v8type.is(arguments[1], v8type.FUNCTION)){ | ||
callback = arguments[1]; | ||
source = undefined; | ||
if(arguments.length < 3 && typeof arguments[1] == 'function'){ | ||
callback = arguments[1]; | ||
source = undefined; | ||
} | ||
params = { | ||
query: { | ||
source: source, | ||
by_source: true, | ||
} | ||
query: { | ||
source: source, | ||
by_source: true, | ||
} | ||
}; | ||
@@ -94,18 +93,18 @@ this.request('GET', util.format('/tags/hosts/%s', host), params, callback); | ||
*/ | ||
if(!v8type.is(tags, v8type.ARRAY)){ | ||
throw new Error('`tags` parameter must be an array'); | ||
if(typeof tags != 'object'){ | ||
throw new Error('`tags` parameter must be an array'); | ||
} | ||
if(arguments.length < 4 && v8type.is(arguments[2], v8type.FUNCTION)){ | ||
callback = arguments[2]; | ||
source = undefined; | ||
if(arguments.length < 4 && typeof arguments[2] == 'function'){ | ||
callback = arguments[2]; | ||
source = undefined; | ||
} | ||
params = { | ||
query: { | ||
source: source, | ||
}, | ||
body: { | ||
tags: tags, | ||
} | ||
query: { | ||
source: source, | ||
}, | ||
body: { | ||
tags: tags, | ||
} | ||
}; | ||
@@ -128,18 +127,18 @@ | ||
*/ | ||
if(!v8type.is(tags, v8type.ARRAY)){ | ||
throw new Error('`tags` parameter must be an array'); | ||
if(typeof tags != 'object'){ | ||
throw new Error('`tags` parameter must be an array'); | ||
} | ||
if(arguments.length < 4 && v8type.is(arguments[2], v8type.FUNCTION)){ | ||
callback = arguments[2]; | ||
source = undefined; | ||
if(arguments.length < 4 && typeof arguments[2] == 'function'){ | ||
callback = arguments[2]; | ||
source = undefined; | ||
} | ||
params = { | ||
query: { | ||
source: source, | ||
}, | ||
body: { | ||
tags: tags, | ||
} | ||
query: { | ||
source: source, | ||
}, | ||
body: { | ||
tags: tags, | ||
} | ||
}; | ||
@@ -161,11 +160,11 @@ | ||
*/ | ||
if(arguments.length < 3 && v8type.is(arguments[1], v8type.FUNCTION)){ | ||
callback = arguments[1]; | ||
source = undefined; | ||
if(arguments.length < 3 && typeof arguments[1] == 'function'){ | ||
callback = arguments[1]; | ||
source = undefined; | ||
} | ||
params = { | ||
query: { | ||
source: source, | ||
}, | ||
query: { | ||
source: source, | ||
}, | ||
}; | ||
@@ -172,0 +171,0 @@ |
@@ -5,3 +5,2 @@ var extend = require('extend'); | ||
var util = require('util'); | ||
var v8type = require('v8type'); | ||
@@ -35,3 +34,3 @@ | ||
if(!this.api_key){ | ||
throw new Error('`api_key` is not present, either provide `api_key` in `options` or use environment variable `DD_API_KEY`'); | ||
throw new Error('`api_key` is not present, either provide `api_key` in `options` or use environment variable `DD_API_KEY`'); | ||
} | ||
@@ -41,3 +40,3 @@ | ||
if(!this.api_key){ | ||
throw new Error('`app_key` is not present, either provide `app_key` in `options` or use environment variable `DD_APP_KEY`'); | ||
throw new Error('`app_key` is not present, either provide `app_key` in `options` or use environment variable `DD_APP_KEY`'); | ||
} | ||
@@ -47,3 +46,3 @@ | ||
if(!this.api_version){ | ||
this.api_version = 'v1'; | ||
this.api_version = 'v1'; | ||
} | ||
@@ -53,3 +52,3 @@ | ||
if(!this.api_host){ | ||
this.api_host = 'app.datadoghq.com'; | ||
this.api_host = 'app.datadoghq.com'; | ||
} | ||
@@ -76,65 +75,65 @@ | ||
*/ | ||
if(arguments.length == 3 && v8type.is(arguments[2], v8type.FUNCTION)){ | ||
callback = arguments[2]; | ||
params = {}; | ||
if(arguments.length == 3 && typeof arguments[2] == 'function'){ | ||
callback = arguments[2]; | ||
params = {}; | ||
} | ||
params = params || {}; | ||
var body = v8type.is(params['body'], v8type.OBJECT)? JSON.stringify(params['body']) : params['body']; | ||
var body = (typeof params['body'] == 'object')? JSON.stringify(params['body']) : params['body']; | ||
var query = { | ||
'api_key': this.api_key, | ||
'application_key': this.app_key, | ||
'api_key': this.api_key, | ||
'application_key': this.app_key, | ||
}; | ||
if(v8type.is(params['query'], v8type.OBJECT)){ | ||
extend(query, params['query']); | ||
if(typeof params['query'] == 'object'){ | ||
extend(query, params['query']); | ||
} | ||
path = url.format({ | ||
'pathname': util.format('/api/%s%s', this.api_version, path), | ||
'query': query, | ||
'pathname': util.format('/api/%s%s', this.api_version, path), | ||
'query': query, | ||
}); | ||
var http_options = { | ||
hostname: this.api_host, | ||
port: 443, | ||
method: method.toUpperCase(), | ||
path: path, | ||
hostname: this.api_host, | ||
port: 443, | ||
method: method.toUpperCase(), | ||
path: path, | ||
}; | ||
if(['POST', 'PUT'].indexOf(http_options['method']) >= 0){ | ||
http_options['headers'] = { | ||
'Content-Type': 'application/json', | ||
'Content-Length': body.length, | ||
}; | ||
http_options['headers'] = { | ||
'Content-Type': 'application/json', | ||
'Content-Length': body.length, | ||
}; | ||
} | ||
var req = https.request(http_options, function(res){ | ||
res.on('error', function(err){ | ||
if(v8type.is(callback, v8type.FUNCTION)){ | ||
callback(err, null, res.statusCode); | ||
} | ||
}); | ||
res.on('error', function(err){ | ||
if(typeof callback == 'function'){ | ||
callback(err, null, res.statusCode); | ||
} | ||
}); | ||
var data = ''; | ||
res.on('data', function(chunk){ | ||
data += chunk; | ||
}); | ||
var data = ''; | ||
res.on('data', function(chunk){ | ||
data += chunk; | ||
}); | ||
res.on('end', function(){ | ||
error = null; | ||
try{ data = JSON.parse(data); }catch(e){} | ||
if(data['errors']){ | ||
error = data['errors']; | ||
data = null; | ||
} | ||
res.on('end', function(){ | ||
error = null; | ||
try{ data = JSON.parse(data); }catch(e){} | ||
if(data['errors']){ | ||
error = data['errors']; | ||
data = null; | ||
} | ||
if(v8type.is(callback, v8type.FUNCTION)){ | ||
callback(error, data, res.statusCode); | ||
} | ||
}); | ||
if(typeof callback == 'function'){ | ||
callback(error, data, res.statusCode); | ||
} | ||
}); | ||
}); | ||
if(['POST', 'PUT'].indexOf(http_options['method']) >= 0){ | ||
req.write(body); | ||
req.write(body); | ||
} | ||
@@ -141,0 +140,0 @@ req.end() |
{ | ||
"name": "dogapi", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Datadog API Node.JS Client", | ||
@@ -29,5 +29,4 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"extend": "~1.1.3", | ||
"v8type": "~0.1.0" | ||
"extend": "~1.1.3" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
39460
1
4
883
- Removedv8type@~0.1.0
- Removedv8type@0.1.0(transitive)