Class: Diplomat::Datacenter
- Inherits:
-
RestClient
- Object
- RestClient
- Diplomat::Datacenter
- Defined in:
- lib/diplomat/datacenter.rb
Overview
Methods for interacting with the Consul dataceneter API endpoint
Instance Method Summary collapse
-
#get(meta = nil, options = {}) ⇒ OpenStruct
Get an array of all avaliable datacenters accessible by the local consul agent.
Methods inherited from RestClient
access_method?, #concat_url, #configuration, #initialize, method_missing, respond_to?, respond_to_missing?, #use_named_parameter
Constructor Details
This class inherits a constructor from Diplomat::RestClient
Instance Method Details
#get(meta = nil, options = {}) ⇒ OpenStruct
Get an array of all avaliable datacenters accessible by the local consul agent
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/diplomat/datacenter.rb', line 12 def get( = nil, = {}) ret = send_get_request(@conn, ['/v1/catalog/datacenters'], ) if && ret.headers [:index] = ret.headers['x-consul-index'] if ret.headers['x-consul-index'] [:knownleader] = ret.headers['x-consul-knownleader'] if ret.headers['x-consul-knownleader'] [:lastcontact] = ret.headers['x-consul-lastcontact'] if ret.headers['x-consul-lastcontact'] end JSON.parse(ret.body) end |