class Diplomat::Datacenter

Methods for interacting with the Consul dataceneter API endpoint

Public Instance Methods

get(meta = nil, options = {}) 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) @param options [Hash] options parameter hash @return [OpenStruct] all datacenters avaliable to this consul agent

# File lib/diplomat/datacenter.rb, line 10
def get(meta = nil, options = {})
  ret = send_get_request(@conn, ['/v1/catalog/datacenters'], options)

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