From e4c39ca6f7e535a7ee69d0540989bed585643ba8 Mon Sep 17 00:00:00 2001 From: alexcreek Date: Sun, 26 Feb 2017 23:36:31 -0500 Subject: [PATCH 1/4] pass hostname in the url instead of the POST body --- lib/api/host.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/api/host.js b/lib/api/host.js index e2e2bb2..2acb138 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,22 +28,22 @@ 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 *comment: unmute the given host, if it is not already unmuted *params: @@ -62,12 +63,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 = { From 25faaa879a49a68d1b73f3633c69d787dd9346c1 Mon Sep 17 00:00:00 2001 From: alexcreek Date: Sun, 26 Feb 2017 17:42:32 -0500 Subject: [PATCH 2/4] add params.body default to client.prototype.request --- lib/api/monitor.js | 7 +++++++ lib/client.js | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/api/monitor.js b/lib/api/monitor.js index b7f4b5d..44f4c9a 100644 --- a/lib/api/monitor.js +++ b/lib/api/monitor.js @@ -237,6 +237,8 @@ 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); } @@ -291,6 +293,11 @@ function unmute(monitorId, scope, callback){ params.body = { scope: scope }; +<<<<<<< HEAD +======= + } else { + params.body = ""; // create empty body +>>>>>>> 5243bf7... add params.body default to client.prototype.request } 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, From 995de8f7350549d208b97a4d0aa04003076e8743 Mon Sep 17 00:00:00 2001 From: alexcreek Date: Sun, 26 Feb 2017 17:41:50 -0500 Subject: [PATCH 3/4] add params.body default to mute() and unmute() --- lib/api/host.js | 1 - lib/api/monitor.js | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/api/host.js b/lib/api/host.js index 2acb138..7a88c93 100644 --- a/lib/api/host.js +++ b/lib/api/host.js @@ -43,7 +43,6 @@ function mute(hostname, options, callback){ client.request("POST", util.format("/host/%s/mute", hostname), params, callback); } - /*section: host *comment: unmute the given host, if it is not already unmuted *params: diff --git a/lib/api/monitor.js b/lib/api/monitor.js index 44f4c9a..b30a768 100644 --- a/lib/api/monitor.js +++ b/lib/api/monitor.js @@ -294,10 +294,15 @@ function unmute(monitorId, scope, callback){ scope: scope }; <<<<<<< HEAD +<<<<<<< HEAD ======= } else { params.body = ""; // create empty body >>>>>>> 5243bf7... add params.body default to client.prototype.request +======= + } else { + params.body = ""; +>>>>>>> 4818053... add params.body default to mute() and unmute() } client.request("POST", util.format("/monitor/%s/unmute", monitorId), params, callback); } From 2cf1f0d3968fde07cd0c5449cb1a92662033d13e Mon Sep 17 00:00:00 2001 From: alexcreek Date: Sat, 25 Feb 2017 01:44:37 -0500 Subject: [PATCH 4/4] add missing monitorID to mute() --- lib/api/monitor.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/api/monitor.js b/lib/api/monitor.js index b30a768..44bfcbd 100644 --- a/lib/api/monitor.js +++ b/lib/api/monitor.js @@ -240,7 +240,7 @@ function mute(monitorId, options, callback){ } 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 @@ -293,16 +293,8 @@ function unmute(monitorId, scope, callback){ params.body = { scope: scope }; -<<<<<<< HEAD -<<<<<<< HEAD -======= } else { params.body = ""; // create empty body ->>>>>>> 5243bf7... add params.body default to client.prototype.request -======= - } else { - params.body = ""; ->>>>>>> 4818053... add params.body default to mute() and unmute() } client.request("POST", util.format("/monitor/%s/unmute", monitorId), params, callback); }