Class: Diplomat::Agent
- Inherits:
-
RestClient
- Object
- RestClient
- Diplomat::Agent
- Defined in:
- lib/diplomat/agent.rb
Overview
Agent API endpoint methods
Instance Method Summary collapse
-
#checks ⇒ OpenStruct
Get local agent checks.
-
#members ⇒ OpenStruct
Get cluster members (as seen by the agent).
-
#self ⇒ OpenStruct
Get agent configuration.
-
#services ⇒ OpenStruct
Get local agent services.
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 local agent checks
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/diplomat/agent.rb', line 27 def checks url = ['/v1/agent/checks'] # If the request fails, it's probably due to a bad path # so return a PathNotFound error. begin ret = @conn.get concat_url url rescue Faraday::ClientError raise Diplomat::PathNotFound end JSON.parse(ret.body).tap { |node| OpenStruct.new node } end |
#members ⇒ OpenStruct
Get cluster members (as seen by the agent)
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/diplomat/agent.rb', line 57 def members url = ['/v1/agent/members'] # If the request fails, it's probably due to a bad path # so return a PathNotFound error. begin ret = @conn.get concat_url url rescue Faraday::ClientError raise Diplomat::PathNotFound end JSON.parse(ret.body).map { |node| OpenStruct.new node } end |
#self ⇒ OpenStruct
Get agent configuration
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/diplomat/agent.rb', line 12 def self url = ['/v1/agent/self'] # If the request fails, it's probably due to a bad path # so return a PathNotFound error. begin ret = @conn.get concat_url url rescue Faraday::ClientError raise Diplomat::PathNotFound end JSON.parse(ret.body).tap { |node| OpenStruct.new node } end |
#services ⇒ OpenStruct
Get local agent services
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/diplomat/agent.rb', line 42 def services url = ['/v1/agent/services'] # If the request fails, it's probably due to a bad path # so return a PathNotFound error. begin ret = @conn.get concat_url url rescue Faraday::ClientError raise Diplomat::PathNotFound end JSON.parse(ret.body).tap { |node| OpenStruct.new node } end |