diff --git a/lib/api/infrastructure.js b/lib/api/infrastructure.js deleted file mode 100644 index 6352527..0000000 --- a/lib/api/infrastructure.js +++ /dev/null @@ -1,29 +0,0 @@ -var infrastructure_api = function(){ - -}; - -infrastructure_api.prototype.search = function(query, callback){ - this.request('GET', '/search', query, callback); -}; - -infrastructure_api.prototype.all_tags = function(){ - -}; - -infrastructure_api.prototype.host_tags = function(){ - -}; - -infrastructure_api.prototype.add_tags = function(){ - -}; - -infrastructure_api.prototype.change_tags = function(){ - -}; - -infrastructure_api.prototype.detach_tags = function(){ - -}; - -return module.exports = infrastructure_api; diff --git a/lib/api/tag.js b/lib/api/tag.js new file mode 100644 index 0000000..c0be542 --- /dev/null +++ b/lib/api/tag.js @@ -0,0 +1,65 @@ +var util = require('util'); +var v8type = require('v8type'); + +var tag_api = function(){}; + +tag_api.prototype.search = function(query, callback){ + this.request('GET', '/search', {query: {'q': query}}, callback); +}; + +tag_api.prototype.all_tags = function(source, callback){ + if(arguments.length < 2 && v8type.is(arguments[0], v8type.FUNCTION)){ + callback = arguments[0]; + source = undefined; + } + + params = { + query: { + source: source + } + }; + this.request('GET', '/tags/hosts', params, callback); +}; + +tag_api.prototype.host_tags = function(host, source, callback){ + if(arguments.length < 3 && v8type.is(arguments[1], v8type.FUNCTION)){ + callback = arguments[1]; + source = undefined; + } + + params = { + query: { + source: source, + } + }; + this.request('GET', util.format('/tags/hosts/%s', host), params, callback); +}; + +tag_api.prototype.host_tags_by_source = function(host, source, callback){ + if(arguments.length < 3 && v8type.is(arguments[1], v8type.FUNCTION)){ + callback = arguments[1]; + source = undefined; + } + + params = { + query: { + source: source, + by_source: true, + } + }; + this.request('GET', util.format('/tags/hosts/%s', host), params, callback); +}; + +tag_api.prototype.add_tags = function(){ + +}; + +tag_api.prototype.change_tags = function(){ + +}; + +tag_api.prototype.detach_tags = function(){ + +}; + +return module.exports = tag_api; diff --git a/lib/index.js b/lib/index.js index 2d0d6cb..dc3bbc5 100644 --- a/lib/index.js +++ b/lib/index.js @@ -4,7 +4,7 @@ var http_client = require('./http_client.js'); var alert_api = require('./api/alert.js'); var dash_api = require('./api/dash.js'); var event_api = require('./api/event.js'); -var infrastructure_api = require('./api/infrastructure.js'); +var tag_api = require('./api/tag.js'); var metric_api = require('./api/metric.js'); var dogapi = function(options){ @@ -16,7 +16,7 @@ extend(dogapi.prototype, alert_api.prototype, dash_api.prototype, event_api.prototype, - infrastructure_api.prototype, + tag_api.prototype, metric_api.prototype); return module.exports = dogapi;