class MMS::Resource::Alert

Attributes

acknowledged_until[RW]
created[RW]
current_value[RW]
event_type_name[RW]
last_notified[RW]
name[RW]
resolved[RW]
status[RW]
type_name[RW]
updated[RW]

Public Class Methods

_find(client, group_id, id) click to toggle source

@param [MMS::Client] client @param [String] group_id @param [String] id @return [Hash]

# File lib/mms/resource/alert.rb, line 52
def self._find(client, group_id, id)
  client.get('/groups/' + group_id + '/alerts/' + id)
end
table_header() click to toggle source
# File lib/mms/resource/alert.rb, line 44
def self.table_header
  ['Status', 'Group', 'Type', 'Event name', 'Created', 'Updated', 'Resolved', 'Last notified', 'Value']
end

Public Instance Methods

ack(time, description) click to toggle source

@param [Time, Integer] time @param [String] description @return [TrueClass, FalseClass]

# 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
group() click to toggle source

@return [MMS::Resource::Group]

# File lib/mms/resource/alert.rb, line 16
def group
  MMS::Resource::Group.find(@client, @data['groupId'])
end
table_row() click to toggle source
# 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_section() click to toggle source
# 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

Private Instance Methods

_from_hash(data) click to toggle source

@param [Hash] data

# File lib/mms/resource/alert.rb, line 59
def _from_hash(data)
  @type_name = data['typeName']
  @event_type_name = data['eventTypeName']
  @status = data['status']
  @acknowledged_until = data['acknowledgedUntil']
  @created = data['created']
  @updated = data['updated']
  @resolved = data['resolved']
  @last_notified = data['lastNotified']
  @current_value = data['currentValue']
  @name = @type_name
end
_to_hash() click to toggle source
# File lib/mms/resource/alert.rb, line 72
def _to_hash
  @data
end