Class: Notifu::Model::Event

Inherits:
Object show all
Includes:
Util
Defined in:
lib/notifu/model/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

action_log, log, option

Constructor Details

#initialize(args) ⇒ Event

Returns a new instance of Event.


28
29
30
31
32
33
34
35
36
37
# File 'lib/notifu/model/event.rb', line 28

def initialize args
  payload = args.first
  payload.each { |name, value| instance_variable_set("@#{name}", value) }
  @time_last_notified = Hash.new.to_json.to_s
  @time_created = self.time_last_event
  @aspiring_code = self.code
  @occurrences_trigger ||= 1
  @refresh ||= nil
  @unsilence ||= true
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action


17
18
19
# File 'lib/notifu/model/event.rb', line 17

def action
  @action
end

#addressObject (readonly)

Returns the value of attribute address


8
9
10
# File 'lib/notifu/model/event.rb', line 8

def address
  @address
end

#api_endpointObject (readonly)

Returns the value of attribute api_endpoint


22
23
24
# File 'lib/notifu/model/event.rb', line 22

def api_endpoint
  @api_endpoint
end

#aspiring_codeObject (readonly)

Returns the value of attribute aspiring_code


19
20
21
# File 'lib/notifu/model/event.rb', line 19

def aspiring_code
  @aspiring_code
end

#codeObject (readonly)

Returns the value of attribute code


18
19
20
# File 'lib/notifu/model/event.rb', line 18

def code
  @code
end

#datacenterObject (readonly)

Returns the value of attribute datacenter


6
7
8
# File 'lib/notifu/model/event.rb', line 6

def datacenter
  @datacenter
end

#durationObject (readonly)

Returns the value of attribute duration


23
24
25
# File 'lib/notifu/model/event.rb', line 23

def duration
  @duration
end

#hostObject (readonly)

Returns the value of attribute host


7
8
9
# File 'lib/notifu/model/event.rb', line 7

def host
  @host
end

#intervalObject (readonly)

Returns the value of attribute interval


12
13
14
# File 'lib/notifu/model/event.rb', line 12

def interval
  @interval
end

#messageObject (readonly)

Returns the value of attribute message


20
21
22
# File 'lib/notifu/model/event.rb', line 20

def message
  @message
end

#notifu_idObject (readonly)

Returns the value of attribute notifu_id


5
6
7
# File 'lib/notifu/model/event.rb', line 5

def notifu_id
  @notifu_id
end

#occurrences_countObject (readonly)

Returns the value of attribute occurrences_count


11
12
13
# File 'lib/notifu/model/event.rb', line 11

def occurrences_count
  @occurrences_count
end

#occurrences_triggerObject (readonly)

Returns the value of attribute occurrences_trigger


10
11
12
# File 'lib/notifu/model/event.rb', line 10

def occurrences_trigger
  @occurrences_trigger
end

#playbookObject (readonly)

Returns the value of attribute playbook


21
22
23
# File 'lib/notifu/model/event.rb', line 21

def playbook
  @playbook
end

#process_resultObject

Returns the value of attribute process_result


26
27
28
# File 'lib/notifu/model/event.rb', line 26

def process_result
  @process_result
end

#refreshObject (readonly)

Returns the value of attribute refresh


25
26
27
# File 'lib/notifu/model/event.rb', line 25

def refresh
  @refresh
end

#serviceObject (readonly)

Returns the value of attribute service


9
10
11
# File 'lib/notifu/model/event.rb', line 9

def service
  @service
end

#sgsObject (readonly)

Returns the value of attribute sgs


16
17
18
# File 'lib/notifu/model/event.rb', line 16

def sgs
  @sgs
end

#time_createdObject (readonly)

Returns the value of attribute time_created


15
16
17
# File 'lib/notifu/model/event.rb', line 15

def time_created
  @time_created
end

#time_last_eventObject (readonly)

Returns the value of attribute time_last_event


13
14
15
# File 'lib/notifu/model/event.rb', line 13

def time_last_event
  @time_last_event
end

#time_last_notifiedObject (readonly)

Returns the value of attribute time_last_notified


14
15
16
# File 'lib/notifu/model/event.rb', line 14

def time_last_notified
  @time_last_notified
end

#unsilenceObject (readonly)

Returns the value of attribute unsilence


24
25
26
# File 'lib/notifu/model/event.rb', line 24

def unsilence
  @unsilence
end

Instance Method Details

#dataObject


43
44
45
# File 'lib/notifu/model/event.rb', line 43

def data
  @data ||= Hash[ instance_variables.map { |var| [var.to_s.sub(/^@/,""), instance_variable_get(var)] } ]
end

#group_slaObject


39
40
41
# File 'lib/notifu/model/event.rb', line 39

def group_sla
  self.sgs.map { |gs| Hash[:group, gs.split(':')[0], :sla, gs.split(':')[1]] }
end

#update_process_result!(obj) ⇒ Object


47
48
49
50
# File 'lib/notifu/model/event.rb', line 47

def update_process_result!(obj)
  self.process_result ||= JSON.generate(Array.new)
  self.process_result = JSON.generate(JSON.parse(self.process_result) + [ obj ])
end