Browse Source

move search method into it's own script

pull/2/merge
Brett Langdon 13 years ago
parent
commit
b64a203ceb
3 changed files with 59 additions and 7 deletions
  1. +6
    -0
      lib/api/search.js
  2. +50
    -6
      lib/api/tag.js
  3. +3
    -1
      lib/index.js

+ 6
- 0
lib/api/search.js View File

@ -0,0 +1,6 @@
var search_api = function(){};
search_api.prototype.search = function(query, callback){
this.request('GET', '/search', {query: {'q': query}}, callback);
};
return module.exports = search_api;

+ 50
- 6
lib/api/tag.js View File

@ -3,9 +3,6 @@ var v8type = require('v8type');
var tag_api = function(){}; 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){ tag_api.prototype.all_tags = function(source, callback){
if(arguments.length < 2 && v8type.is(arguments[0], v8type.FUNCTION)){ if(arguments.length < 2 && v8type.is(arguments[0], v8type.FUNCTION)){
@ -50,16 +47,63 @@ tag_api.prototype.host_tags_by_source = function(host, source, callback){
this.request('GET', util.format('/tags/hosts/%s', host), params, callback); this.request('GET', util.format('/tags/hosts/%s', host), params, callback);
}; };
tag_api.prototype.add_tags = function(){
tag_api.prototype.add_tags = function(host, tags, source, callback){
if(!v8type.is(tags, v8type.ARRAY)){
throw new Error('`tags` parameter must be an array');
}
if(arguments.length < 4 && v8type.is(arguments[2], v8type.FUNCTION)){
callback = arguments[2];
source = undefined;
}
params = {
query: {
source: source,
},
body: {
tags: tags,
}
};
this.request('POST', util.format('/tags/hosts/%s', host), params, callback);
}; };
tag_api.prototype.change_tags = function(){
tag_api.prototype.update_tags = function(host, tags, source, callback){
if(!v8type.is(tags, v8type.ARRAY)){
throw new Error('`tags` parameter must be an array');
}
if(arguments.length < 4 && v8type.is(arguments[2], v8type.FUNCTION)){
callback = arguments[2];
source = undefined;
}
params = {
query: {
source: source,
},
body: {
tags: tags,
}
};
this.request('PUT', util.format('/tags/hosts/%s', host), params, callback);
}; };
tag_api.prototype.detach_tags = function(){
tag_api.prototype.detach_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('DELETE', util.format('/tags/hosts/%s', host), params, callback);
}; };
return module.exports = tag_api; return module.exports = tag_api;

+ 3
- 1
lib/index.js View File

@ -6,6 +6,7 @@ var dash_api = require('./api/dash.js');
var event_api = require('./api/event.js'); 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 dogapi = function(options){ var dogapi = function(options){
http_client.call(this, options); http_client.call(this, options);
@ -17,6 +18,7 @@ extend(dogapi.prototype,
dash_api.prototype, dash_api.prototype,
event_api.prototype, event_api.prototype,
tag_api.prototype, tag_api.prototype,
metric_api.prototype);
metric_api.prototype,
search_api.prototype);
return module.exports = dogapi; return module.exports = dogapi;

Loading…
Cancel
Save