Class: Zenoss::Events::Event

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/zenoss/events/event.rb

Direct Known Subclasses

ZEvent

Instance Method Summary collapse

Constructor Details

#initialize(zenoss, zhash) ⇒ Event

Initialize this object from a Hash returned via the JSON api @param zenoss the current instance we are connecting with @param zhash a hash of values used to create this Event instance



28
29
30
31
32
33
# File 'lib/zenoss/events/event.rb', line 28

def initialize(zenoss,zhash)
  @zenoss = zenoss
  super zhash
  self.firstTime &&= convert_time(self.firstTime)
  self.lastTime &&= convert_time(self.lastTime)
end

Instance Method Details

#acknowledgeObject



59
60
# File 'lib/zenoss/events/event.rb', line 59

def acknowledge
end

#convert_time(time) ⇒ Object

Converts a string or float to a Time object Zenoss version 4 emits the time format as a string Zenoss version 6 emits the time as a float @return



39
40
41
42
43
44
45
# File 'lib/zenoss/events/event.rb', line 39

def convert_time(time)
  if time.is_a?(String)
    Time.parse(time)
  else
    Time.at(time)
  end
end

#detail(history = false) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/zenoss/events/event.rb', line 47

def detail(history = false)
  data = {
    :evid => self.evid,
    :history => history,
  }
  resp = @zenoss.json_request('EventsRouter', 'detail', [data])
  resp['event'].first.each_pair do |k,v|
    self.new_ostruct_member(k)
    @table[k.to_sym] = v
  end
end