class Diplomat::Datacenter

Methods for interacting with the Consul dataceneter API endpoint

Public Instance Methods

get(meta = nil) click to toggle source

Get an array of all avaliable datacenters accessible by the local consul agent @param meta [Hash] output structure containing header information about the request (index) @return [OpenStruct] all datacenters avaliable to this consul agent

# File lib/diplomat/datacenter.rb, line 9
def get(meta = nil)
  url = ['/v1/catalog/datacenters']

  ret = @conn.get concat_url url

  if meta && ret.headers
    meta[:index] = ret.headers['x-consul-index']
    meta[:knownleader] = ret.headers['x-consul-knownleader']
    meta[:lastcontact] = ret.headers['x-consul-lastcontact']
  end
  JSON.parse(ret.body)
end