Skip to content

Commit

Permalink
Merge pull request #127 from DataDog/validate_monitor
Browse files Browse the repository at this point in the history
Add validate endpoint to dogapi-rb
  • Loading branch information
degemer authored May 1, 2017
2 parents cdbf553 + cb76c71 commit 9492b93
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/dogapi/facade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions lib/dogapi/v1/monitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions spec/integration/monitor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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, [],
Expand Down

0 comments on commit 9492b93

Please sign in to comment.