Browse Source

Merge pull request #54 from alexcreek/fix_mute_pr

Fix mute/unmute for hosts and monitors
pull/55/head
Brett Langdon 9 years ago
committed by GitHub
parent
commit
b2dd998ac8
3 changed files with 14 additions and 15 deletions
  1. +8
    -12
      lib/api/host.js
  2. +5
    -1
      lib/api/monitor.js
  3. +1
    -2
      lib/client.js

+ 8
- 12
lib/api/host.js View File

@ -1,4 +1,5 @@
var client = require("../client");
var util = require("util");
/*section: host
*comment: mute the given host, if it is not already muted
@ -27,20 +28,19 @@ function mute(hostname, options, callback){
callback = options;
options = {};
}
var params = {
body: {
hostname: hostname
}
};
var params = {};
if(typeof options === "object"){
params.body = {}; // create body property
if(options.end){
params.body.end = parseInt(options.end);
}
if(options.override){
params.body.override = options.override;
}
} else {
params.body = ""; // create empty body
}
client.request("POST", "/host", params, callback);
client.request("POST", util.format("/host/%s/mute", hostname), params, callback);
}
/*section: host
@ -62,12 +62,8 @@ function mute(hostname, options, callback){
* ```
*/
function unmute(hostname, callback){
var params = {
body: {
hostname: hostname
}
};
client.request("POST", "/host", params, callback);
var params = {body: ""}; // create empty body
client.request("POST", util.format("/host/%s/unmute", hostname), params, callback);
}
module.exports = {


+ 5
- 1
lib/api/monitor.js View File

@ -237,8 +237,10 @@ function mute(monitorId, options, callback){
if(options.end){
params.body.end = parseInt(options.end);
}
} else {
params.body = ""; // create empty body
}
client.request("POST", util.format("/monitor/%s/mute"), params, callback);
client.request("POST", util.format("/monitor/%s/mute", monitorId), params, callback);
}
/*section: monitor
@ -291,6 +293,8 @@ function unmute(monitorId, scope, callback){
params.body = {
scope: scope
};
} else {
params.body = ""; // create empty body
}
client.request("POST", util.format("/monitor/%s/unmute", monitorId), params, callback);
}


+ 1
- 2
lib/client.js View File

@ -49,10 +49,9 @@ var client = function(){
client.prototype.request = function(method, path, params, callback){
if(arguments.length === 3 && typeof arguments[2] === "function"){
callback = arguments[2];
params = {};
params = {body: ''}; // create params with empty body property
}
params = params || {};
var body = (typeof params["body"] === "object") ? json.stringify(params["body"]) : params["body"];
var query = {
"api_key": this.api_key,


Loading…
Cancel
Save