diff --git a/README.md b/README.md index 7116c16..8dfc444 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,9 @@ NOTE: This is a 3rd party gem and not an official product from Pingdom. check.last_response_time #=> 200 (ms) check.status #=> "up" + check.paused(true) + check.status #=> "paused" + result = check.results.first(:probes => [1,2,3], :status => [:up, :down]) #=> # result.status #=> :up diff --git a/lib/pingdom/check.rb b/lib/pingdom/check.rb index a787fd5..880f21e 100644 --- a/lib/pingdom/check.rb +++ b/lib/pingdom/check.rb @@ -17,6 +17,10 @@ def results(options = {}) @client.results(id, options) end + def paused(bool) + @client.paused(id, bool) + end + def summary @client.summary(id) end diff --git a/lib/pingdom/client.rb b/lib/pingdom/client.rb index 2481d5e..3e6760b 100644 --- a/lib/pingdom/client.rb +++ b/lib/pingdom/client.rb @@ -41,6 +41,12 @@ def get(uri, params = {}, &block) response end + def put(uri, params = {}, data, &block) + response = @connection.put(@connection.build_url(uri, prepare_params(params)), data, "App-Key" => @options[:key], &block) + update_limits!(response.headers['req-limit-short'], response.headers['req-limit-long']) + response + end + def update_limits!(short, long) @limit ||= {} @limit[:short] = parse_limit(short) @@ -63,6 +69,7 @@ def test!(options = {}) def checks(options = {}) Check.parse(self, get("checks", options)) end + def check(id) Check.parse(self, get("checks/#{id}")).first end @@ -73,6 +80,10 @@ def results(id, options = {}) Result.parse(self, get("results/#{id}", options)) end + def paused(id, bool) + Check.parse(self, put("checks/#{id}", {'paused'=>bool.to_s})) + end + def probes(options = {}) Probe.parse(self, get("probes", options)) end