diff --git a/lib/api/host.js b/lib/api/host.js index e2e2bb2..7a88c93 100644 --- a/lib/api/host.js +++ b/lib/api/host.js @@ -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 = { diff --git a/lib/api/monitor.js b/lib/api/monitor.js index b7f4b5d..44bfcbd 100644 --- a/lib/api/monitor.js +++ b/lib/api/monitor.js @@ -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); } diff --git a/lib/client.js b/lib/client.js index 9a9839c..f5b5ebc 100644 --- a/lib/client.js +++ b/lib/client.js @@ -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,