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, cache_key, find, #from_hash, #invalidate_cache, #to_hash

Instance Attribute Details

#acknowledged_untilObject

Returns the value of attribute acknowledged_until.



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

def acknowledged_until
  @acknowledged_until
end

#createdObject

Returns the value of attribute created.



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

def created
  @created
end

#current_valueObject

Returns the value of attribute current_value.



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

def current_value
  @current_value
end

#event_type_nameObject

Returns the value of attribute event_type_name.



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

def event_type_name
  @event_type_name
end

#last_notifiedObject

Returns the value of attribute last_notified.



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

def last_notified
  @last_notified
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/mms/resource/alert.rb', line 3

def name
  @name
end

#resolvedObject

Returns the value of attribute resolved.



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

def resolved
  @resolved
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

#type_nameObject

Returns the value of attribute type_name.



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

def type_name
  @type_name
end

#updatedObject

Returns the value of attribute updated.



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

def updated
  @updated
end

Class Method Details

._find(client, group_id, id) ⇒ Hash

Parameters:

Returns:

  • (Hash)


52
53
54
# File 'lib/mms/resource/alert.rb', line 52

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

.table_headerObject



44
45
46
# File 'lib/mms/resource/alert.rb', line 44

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)


23
24
25
26
27
28
29
30
# File 'lib/mms/resource/alert.rb', line 23

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



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

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

#table_rowObject



32
33
34
# File 'lib/mms/resource/alert.rb', line 32

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

#table_sectionObject



36
37
38
39
40
41
42
# File 'lib/mms/resource/alert.rb', line 36

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