Class: Diplomat::Check
- Inherits:
-
RestClient
- Object
- RestClient
- Diplomat::Check
- Defined in:
- lib/diplomat/check.rb
Overview
Methods for interacting with the Consul check API endpoint
Instance Method Summary collapse
-
#checks ⇒ OpenStruct
Get registered checks.
-
#deregister(check_id) ⇒ Integer
Deregister a check.
-
#fail(check_id) ⇒ Integer
Warn a check.
-
#pass(check_id) ⇒ Integer
Pass a check.
-
#register_script(check_id, name, notes, script, interval) ⇒ Integer
Register a check.
-
#register_ttl(check_id, name, notes, ttl) ⇒ Boolean
Register a TTL check.
-
#warn(check_id) ⇒ Integer
Warn a check.
Methods inherited from RestClient
access_method?, #concat_url, #initialize, method_missing, respond_to?, respond_to_missing?, #use_named_parameter
Constructor Details
This class inherits a constructor from Diplomat::RestClient
Instance Method Details
#checks ⇒ OpenStruct
Get registered checks
9 10 11 12 |
# File 'lib/diplomat/check.rb', line 9 def checks ret = @conn.get '/v1/agent/checks' JSON.parse(ret.body) end |
#deregister(check_id) ⇒ Integer
Deregister a check
52 53 54 55 |
# File 'lib/diplomat/check.rb', line 52 def deregister(check_id) ret = @conn.get "/v1/agent/check/deregister/#{check_id}" ret.status == 200 end |
#fail(check_id) ⇒ Integer
Warn a check
76 77 78 79 |
# File 'lib/diplomat/check.rb', line 76 def fail(check_id) ret = @conn.get "/v1/agent/check/fail/#{check_id}" ret.status == 200 end |
#pass(check_id) ⇒ Integer
Pass a check
60 61 62 63 |
# File 'lib/diplomat/check.rb', line 60 def pass(check_id) ret = @conn.get "/v1/agent/check/pass/#{check_id}" ret.status == 200 end |
#register_script(check_id, name, notes, script, interval) ⇒ Integer
Register a check
23 24 25 26 27 28 29 30 31 |
# File 'lib/diplomat/check.rb', line 23 def register_script(check_id, name, notes, script, interval) ret = @conn.put do |req| req.url '/v1/agent/check/register' req.body = JSON.generate( 'ID' => check_id, 'Name' => name, 'Notes' => notes, 'Script' => script, 'Interval' => interval ) end ret.status == 200 end |
#register_ttl(check_id, name, notes, ttl) ⇒ Boolean
Register a TTL check
39 40 41 42 43 44 45 46 47 |
# File 'lib/diplomat/check.rb', line 39 def register_ttl(check_id, name, notes, ttl) ret = @conn.put do |req| req.url '/v1/agent/check/register' req.body = JSON.generate( 'ID' => check_id, 'Name' => name, 'Notes' => notes, 'TTL' => ttl ) end ret.status == 200 end |
#warn(check_id) ⇒ Integer
Warn a check
68 69 70 71 |
# File 'lib/diplomat/check.rb', line 68 def warn(check_id) ret = @conn.get "/v1/agent/check/warn/#{check_id}" ret.status == 200 end |