class Diplomat::Agent

Agent API endpoint methods @see www.consul.io/docs/agent/http/agent.html

Public Instance Methods

checks() click to toggle source

Get local agent checks @return [OpenStruct] all agent checks

# 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() click to toggle source

Get cluster members (as seen by the agent) @return [OpenStruct] all members

# 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() click to toggle source

Get agent configuration @return [OpenStruct] all data associated with the node

# 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() click to toggle source

Get local agent services @return [OpenStruct] all agent services

# 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