Class: Hawkular::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Client

Returns a new instance of Client



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

def initialize(hash)
  hash[:credentials] ||= {}
  hash[:options] ||= {}
  fail '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



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

def method_missing(name, *args, &block)
  delegate_client = case name
                    when /^inventory_/ then inventory
                    when /^metrics_/ then metrics
                    when /^alerts_/ then alerts
                    when /^operations_/ then operations
                    when /^tokens_/ then tokens
                    else
                      fail "unknown method prefix `#{name}`, allowed prefixes:"\
  '`inventory_`, `metrics_`,`alerts_`,`operations_`, `tokens_`'
                    end
  method = name.to_s.sub(/^[^_]+_/, '')
  delegate_client.__send__(method, *args, &block)
end

Instance Attribute Details

#alertsObject (readonly)

Returns the value of attribute alerts



10
11
12
# File 'lib/hawkular/hawkular_client.rb', line 10

def alerts
  @alerts
end

#inventoryObject (readonly)

Returns the value of attribute inventory



10
11
12
# File 'lib/hawkular/hawkular_client.rb', line 10

def inventory
  @inventory
end

#metricsObject (readonly)

Returns the value of attribute metrics



10
11
12
# File 'lib/hawkular/hawkular_client.rb', line 10

def metrics
  @metrics
end

#operations(open_new = false) ⇒ Object (readonly)

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



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

def operations
  @operations
end

#stateObject (readonly)

Returns the value of attribute state



10
11
12
# File 'lib/hawkular/hawkular_client.rb', line 10

def state
  @state
end

#tokensObject (readonly)

Returns the value of attribute tokens



10
11
12
# File 'lib/hawkular/hawkular_client.rb', line 10

def tokens
  @tokens
end