From cdabbb74c793bb4fe7d367472846a942bf44a375 Mon Sep 17 00:00:00 2001 From: unclebconnor Date: Fri, 4 Oct 2019 16:30:41 -0700 Subject: [PATCH 01/10] make query optional --- lib/dogapi/v1/monitor.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/dogapi/v1/monitor.rb b/lib/dogapi/v1/monitor.rb index 467f235c..dbdd4316 100644 --- a/lib/dogapi/v1/monitor.rb +++ b/lib/dogapi/v1/monitor.rb @@ -17,9 +17,10 @@ def monitor(type, query, options = {}) end def update_monitor(monitor_id, query, options) - body = { - 'query' => query, - }.merge options + body = {}.merge options + if query != nil + body = body.merge({'query' => query}) + end request(Net::HTTP::Put, "/api/#{API_VERSION}/monitor/#{monitor_id}", nil, body, true) end From b3176b5e30b5dfa7647fffe720d5fe5bdd475272 Mon Sep 17 00:00:00 2001 From: unclebconnor Date: Thu, 10 Oct 2019 17:46:16 -0700 Subject: [PATCH 02/10] updated query param as it is optional --- lib/dogapi/v1/monitor.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/dogapi/v1/monitor.rb b/lib/dogapi/v1/monitor.rb index dbdd4316..51b964c2 100644 --- a/lib/dogapi/v1/monitor.rb +++ b/lib/dogapi/v1/monitor.rb @@ -17,9 +17,10 @@ def monitor(type, query, options = {}) end def update_monitor(monitor_id, query, options) - body = {}.merge options + body = {}.merge options if query != nil - body = body.merge({'query' => query}) + body = {'query' => query}.merge body + warn '[DEPRECATION] query param is no longer required for update' end request(Net::HTTP::Put, "/api/#{API_VERSION}/monitor/#{monitor_id}", nil, body, true) From 8a540b2e1936cd020fba0904b9fe0da444ccdc79 Mon Sep 17 00:00:00 2001 From: unclebconnor Date: Thu, 10 Oct 2019 17:56:16 -0700 Subject: [PATCH 03/10] fix some linting errors --- lib/dogapi/v1/monitor.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/dogapi/v1/monitor.rb b/lib/dogapi/v1/monitor.rb index 51b964c2..430d2c44 100644 --- a/lib/dogapi/v1/monitor.rb +++ b/lib/dogapi/v1/monitor.rb @@ -17,9 +17,11 @@ def monitor(type, query, options = {}) end def update_monitor(monitor_id, query, options) - body = {}.merge options + body = {}.merge options if query != nil - body = {'query' => query}.merge body + body = { + 'query' => query + }.merge body warn '[DEPRECATION] query param is no longer required for update' end From 148cb57455233a2d11936818a19e7099791344da Mon Sep 17 00:00:00 2001 From: unclebconnor Date: Thu, 10 Oct 2019 18:00:12 -0700 Subject: [PATCH 04/10] better expression --- lib/dogapi/v1/monitor.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dogapi/v1/monitor.rb b/lib/dogapi/v1/monitor.rb index 430d2c44..be20cc1e 100644 --- a/lib/dogapi/v1/monitor.rb +++ b/lib/dogapi/v1/monitor.rb @@ -18,7 +18,7 @@ def monitor(type, query, options = {}) def update_monitor(monitor_id, query, options) body = {}.merge options - if query != nil + if !query.nil? body = { 'query' => query }.merge body From 123a98c148c39143167a092a88401650a4c21053 Mon Sep 17 00:00:00 2001 From: unclebconnor Date: Thu, 10 Oct 2019 18:13:09 -0700 Subject: [PATCH 05/10] new linting problem --- lib/dogapi/v1/monitor.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dogapi/v1/monitor.rb b/lib/dogapi/v1/monitor.rb index be20cc1e..2b5f79f5 100644 --- a/lib/dogapi/v1/monitor.rb +++ b/lib/dogapi/v1/monitor.rb @@ -18,7 +18,7 @@ def monitor(type, query, options = {}) def update_monitor(monitor_id, query, options) body = {}.merge options - if !query.nil? + unless query.nil? body = { 'query' => query }.merge body From fa5f7ea4acd32dbae6ee64a1b804ff2ea2421269 Mon Sep 17 00:00:00 2001 From: unclebconnor Date: Fri, 11 Oct 2019 10:02:57 -0700 Subject: [PATCH 06/10] updated version --- lib/dogapi/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dogapi/version.rb b/lib/dogapi/version.rb index 6295e730..f4838045 100644 --- a/lib/dogapi/version.rb +++ b/lib/dogapi/version.rb @@ -1,3 +1,3 @@ module Dogapi - VERSION = '1.36.0' + VERSION = '1.36.1' end From bf5d96530ba9f6057c87ba1775e94224a62f4936 Mon Sep 17 00:00:00 2001 From: unclebconnor Date: Wed, 16 Oct 2019 12:09:20 -0700 Subject: [PATCH 07/10] removed warn --- lib/dogapi/v1/monitor.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/dogapi/v1/monitor.rb b/lib/dogapi/v1/monitor.rb index 2b5f79f5..60992a92 100644 --- a/lib/dogapi/v1/monitor.rb +++ b/lib/dogapi/v1/monitor.rb @@ -22,7 +22,6 @@ def update_monitor(monitor_id, query, options) body = { 'query' => query }.merge body - warn '[DEPRECATION] query param is no longer required for update' end request(Net::HTTP::Put, "/api/#{API_VERSION}/monitor/#{monitor_id}", nil, body, true) From d1c2d2f77b7e7e8e22d8b4bb49901366382a2e52 Mon Sep 17 00:00:00 2001 From: unclebconnor Date: Wed, 16 Oct 2019 12:14:30 -0700 Subject: [PATCH 08/10] version bump --- lib/dogapi/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dogapi/version.rb b/lib/dogapi/version.rb index f4838045..f5e37e12 100644 --- a/lib/dogapi/version.rb +++ b/lib/dogapi/version.rb @@ -1,3 +1,3 @@ module Dogapi - VERSION = '1.36.1' + VERSION = '1.37.0' end From 7a1e9fb2ce5a29356cf953b24bea2996f92cbc59 Mon Sep 17 00:00:00 2001 From: unclebconnor Date: Thu, 17 Oct 2019 10:45:33 -0700 Subject: [PATCH 09/10] updated default params and warn message --- lib/dogapi/v1/monitor.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/dogapi/v1/monitor.rb b/lib/dogapi/v1/monitor.rb index 60992a92..ed61861a 100644 --- a/lib/dogapi/v1/monitor.rb +++ b/lib/dogapi/v1/monitor.rb @@ -16,13 +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) + def update_monitor(monitor_id, query = nil, options = {}) body = {}.merge options unless query.nil? body = { 'query' => query }.merge body end + 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' request(Net::HTTP::Put, "/api/#{API_VERSION}/monitor/#{monitor_id}", nil, body, true) end From b7632e9ebedf4fbc2c0665de650acfa15ae44e9a Mon Sep 17 00:00:00 2001 From: unclebconnor Date: Thu, 17 Oct 2019 10:49:59 -0700 Subject: [PATCH 10/10] oops put the warn in the wrong spot --- lib/dogapi/v1/monitor.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/dogapi/v1/monitor.rb b/lib/dogapi/v1/monitor.rb index ed61861a..6aaacc32 100644 --- a/lib/dogapi/v1/monitor.rb +++ b/lib/dogapi/v1/monitor.rb @@ -22,9 +22,9 @@ def update_monitor(monitor_id, query = nil, options = {}) body = { 'query' => query }.merge body - end - warn '[DEPRECATION] query param is not required anymore and should be set to nil.'\ + 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