Class: Diplomat::Nodes

Inherits:
RestClient show all
Defined in:
lib/diplomat/nodes.rb

Overview

Methods for interacting with the Consul nodes API endpoint

Instance Method Summary collapse

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

#getOpenStruct

Deprecated.

Please use Diplomat::Node instead.

Get all nodes

Returns:

  • (OpenStruct)

    all data associated with the nodes in catalog



10
11
12
13
# File 'lib/diplomat/nodes.rb', line 10

def get
  ret = @conn.get '/v1/catalog/nodes'
  JSON.parse(ret.body)
end

#get_all(options = nil) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/diplomat/nodes.rb', line 15

def get_all(options = nil)
  url = ['/v1/catalog/nodes']
  url << use_named_parameter('dc', options[:dc]) if options && options[:dc]

  ret = @conn.get concat_url url
  JSON.parse(ret.body).map { |service| OpenStruct.new service }
rescue Faraday::ClientError
  raise Diplomat::PathNotFound
end