From 7abe04e5edb67926273461779fa67b8e3340285c Mon Sep 17 00:00:00 2001 From: Isaac Sadaqah Date: Sat, 29 Apr 2017 00:51:39 -0400 Subject: [PATCH 1/2] Add validate endpoint to dogapi-rb --- lib/dogapi/v1/monitor.rb | 9 +++++++++ spec/integration/monitor_spec.rb | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/lib/dogapi/v1/monitor.rb b/lib/dogapi/v1/monitor.rb index e98d38fe..61a74dc3 100644 --- a/lib/dogapi/v1/monitor.rb +++ b/lib/dogapi/v1/monitor.rb @@ -53,6 +53,15 @@ def get_all_monitors(options = {}) request(Net::HTTP::Get, "/api/#{API_VERSION}/monitor", extra_params, nil, false) end + def monitor_validate(type, query, options = {}) + body = { + 'type' => type, + 'query' => query, + }.merge options + + request(Net::HTTP::Post, "/api/#{API_VERSION}/monitor/validate", nil, body, true) + end + def mute_monitors request(Net::HTTP::Post, "/api/#{API_VERSION}/monitor/mute_all", nil, nil, false) end diff --git a/spec/integration/monitor_spec.rb b/spec/integration/monitor_spec.rb index 0306ce83..ccd18562 100644 --- a/spec/integration/monitor_spec.rb +++ b/spec/integration/monitor_spec.rb @@ -38,6 +38,12 @@ :get, '/monitor', group_states: %w(custom all), tags: ['test', 'key:value'], name: 'test' end + describe '#validate_monitor' do + it_behaves_like 'an api method with options', + :monitor, [MONITOR_TYPE, MONITOR_QUERY], + :post, '/monitor', 'type' => MONITOR_TYPE, 'query' => MONITOR_QUERY + end + describe '#mute_monitors' do it_behaves_like 'an api method', :mute_monitors, [], From cb76c7131c3918938416c2c2b1c1b739fc23b017 Mon Sep 17 00:00:00 2001 From: Isaac Sadaqah Date: Mon, 1 May 2017 16:42:04 -0400 Subject: [PATCH 2/2] Add monitor validate to facade.rb --- lib/dogapi/facade.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/dogapi/facade.rb b/lib/dogapi/facade.rb index 3ebf35f1..6bd77873 100644 --- a/lib/dogapi/facade.rb +++ b/lib/dogapi/facade.rb @@ -408,6 +408,10 @@ def get_all_monitors(options= {}) @monitor_svc.get_all_monitors(options) end + def monitor_validate(type, query, options= {}) + @monitor_svc.monitor_validate(type, query, options) + end + def mute_monitors() @monitor_svc.mute_monitors() end