Class: MMS::Resource::Alert

Inherits:
MMS::Resource show all
Defined in:
lib/mms/resource/alert.rb

Instance Attribute Summary collapse

Attributes inherited from MMS::Resource

#client, #data, #id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from MMS::Resource

#_load, find, #from_hash, #invalidate_cache, #set_client, #set_data, #to_hash

Instance Attribute Details

#acknowledged_untilObject

Returns the value of attribute acknowledged_until.



10
11
12
# File 'lib/mms/resource/alert.rb', line 10

def acknowledged_until
  @acknowledged_until
end

#createdObject

Returns the value of attribute created.



11
12
13
# File 'lib/mms/resource/alert.rb', line 11

def created
  @created
end

#current_valueObject

Returns the value of attribute current_value.



15
16
17
# File 'lib/mms/resource/alert.rb', line 15

def current_value
  @current_value
end

#event_type_nameObject

Returns the value of attribute event_type_name.



8
9
10
# File 'lib/mms/resource/alert.rb', line 8

def event_type_name
  @event_type_name
end

#last_notifiedObject

Returns the value of attribute last_notified.



14
15
16
# File 'lib/mms/resource/alert.rb', line 14

def last_notified
  @last_notified
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/mms/resource/alert.rb', line 5

def name
  @name
end

#resolvedObject

Returns the value of attribute resolved.



13
14
15
# File 'lib/mms/resource/alert.rb', line 13

def resolved
  @resolved
end

#statusObject

Returns the value of attribute status.



9
10
11
# File 'lib/mms/resource/alert.rb', line 9

def status
  @status
end

#type_nameObject

Returns the value of attribute type_name.



7
8
9
# File 'lib/mms/resource/alert.rb', line 7

def type_name
  @type_name
end

#updatedObject

Returns the value of attribute updated.



12
13
14
# File 'lib/mms/resource/alert.rb', line 12

def updated
  @updated
end

Class Method Details

._find(client, group_id, id) ⇒ Hash

Parameters:

Returns:

  • (Hash)


55
56
57
# File 'lib/mms/resource/alert.rb', line 55

def self._find(client, group_id, id)
  client.get('/groups/' + group_id + '/alerts/' + id)
end

.table_headerObject



47
48
49
# File 'lib/mms/resource/alert.rb', line 47

def self.table_header
  ['Status', 'Group', 'Type', 'Event name', 'Created', 'Updated', 'Resolved', 'Last notified', 'Value']
end

Instance Method Details

#ack(time, description) ⇒ TrueClass, FalseClass

Parameters:

  • time (Time, Integer)
  • description (String)

Returns:

  • (TrueClass, FalseClass)


26
27
28
29
30
31
32
33
# File 'lib/mms/resource/alert.rb', line 26

def ack(time, description)
  data = {
      :acknowledgedUntil => time.to_i,
      :acknowledgementComment => description
  }
  alert = @client.post '/groups/' + group.id + '/alerts/' + @id, data
  !alert.nil?
end

#groupMMS::Resource::Group



18
19
20
# File 'lib/mms/resource/alert.rb', line 18

def group
  MMS::Resource::Group.find(@client, @data['groupId'])
end

#table_rowObject



35
36
37
# File 'lib/mms/resource/alert.rb', line 35

def table_row
  [@status, group.name, @type_name, @event_type_name, @created, @updated, @resolved, @last_notified, JSON.dump(@current_value)]
end

#table_sectionObject



39
40
41
42
43
44
45
# File 'lib/mms/resource/alert.rb', line 39

def table_section
  rows = []
  rows << table_row
  rows << [{:value => "AlertId: #{@id}   GroupId: #{group.id}", :colspan => 9, :alignment => :left}]
  rows << :separator
  rows
end