Class: Hawkular::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/hawkular/hawkular_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Client

Returns a new instance of Client.



10
11
12
13
14
15
16
17
# File 'lib/hawkular/hawkular_client.rb', line 10

def initialize(hash)
  hash[:credentials] ||= {}
  hash[:options] ||= {}

  fail Hawkular::ArgumentError, 'no parameter ":entrypoint" given' if hash[:entrypoint].nil?

  @state = hash
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



29
30
31
32
# File 'lib/hawkular/hawkular_client.rb', line 29

def method_missing(name, *args, &block)
  super unless respond_to?(name)
  client_for_method(name).__send__(submethod_name_for(name), *args, &block)
end

Instance Method Details

#alertsObject



40
41
42
43
44
# File 'lib/hawkular/hawkular_client.rb', line 40

def alerts
  @alerts ||= Alerts::Client.new("#{@state[:entrypoint]}/hawkular/alerts",
                                 @state[:credentials],
                                 @state[:options])
end

#inventoryObject



34
35
36
37
38
# File 'lib/hawkular/hawkular_client.rb', line 34

def inventory
  @inventory ||= Inventory::Client.new("#{@state[:entrypoint]}/hawkular/inventory",
                                       @state[:credentials],
                                       @state[:options])
end

#operations(open_new = false) ⇒ Object

adds a way to explicitly open the new web socket connection (the default is to recycle it)

Parameters:

  • open_new (Boolean) (defaults to: false)

    if true, opens the new websocket connection



48
49
50
51
# File 'lib/hawkular/hawkular_client.rb', line 48

def operations(open_new = false)
  @operations = init_operations_client if open_new
  @operations ||= init_operations_client
end

#prometheusObject



59
60
61
62
63
# File 'lib/hawkular/hawkular_client.rb', line 59

def prometheus
  @prometheus ||= Prometheus::Client.new(@state[:entrypoint],
                                         @state[:credentials],
                                         @state[:options])
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
26
27
# File 'lib/hawkular/hawkular_client.rb', line 19

def respond_to_missing?(method_name, include_private = false)
  delegate_client = client_for_method(method_name)
  return super if delegate_client.nil?

  method = submethod_name_for(method_name)
  return super unless delegate_client.respond_to?(method)

  true
end

#tokensObject



53
54
55
56
57
# File 'lib/hawkular/hawkular_client.rb', line 53

def tokens
  @tokens ||= Token::Client.new(@state[:entrypoint],
                                @state[:credentials],
                                @state[:options])
end