From 07358ed8e1c7e7399149f5972244fca90d5a73da Mon Sep 17 00:00:00 2001 From: unclebconnor <30842754+unclebconnor@users.noreply.github.com> Date: Fri, 18 Oct 2019 10:15:31 -0700 Subject: [PATCH] Bcon/make query optional monitor update (#192) * make query optional * updated query param as it is optional * fix some linting errors * better expression * new linting problem * updated version * removed warn * version bump * updated default params and warn message * oops put the warn in the wrong spot --- lib/dogapi/v1/monitor.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/dogapi/v1/monitor.rb b/lib/dogapi/v1/monitor.rb index 467f235c..6aaacc32 100644 --- a/lib/dogapi/v1/monitor.rb +++ b/lib/dogapi/v1/monitor.rb @@ -16,10 +16,15 @@ def monitor(type, query, options = {}) request(Net::HTTP::Post, "/api/#{API_VERSION}/monitor", nil, body, true) end - def update_monitor(monitor_id, query, options) - body = { - 'query' => query, - }.merge options + def update_monitor(monitor_id, query = nil, options = {}) + body = {}.merge options + unless query.nil? + body = { + 'query' => query + }.merge body + warn '[DEPRECATION] query param is not required anymore and should be set to nil.'\ + ' To update the query, set it in the options parameter instead' + end request(Net::HTTP::Put, "/api/#{API_VERSION}/monitor/#{monitor_id}", nil, body, true) end