Class: Hawkular::Alerts::Alert

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/hawkular/alerts/alerts_api.rb

Overview

Representation of one alert. The name of the members are literally what they are in the JSON sent from the server and not 'rubyfied'. So 'alertId' and not 'alert_id' Check www.hawkular.org/docs/rest/rest-alerts.html#Alert for details

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(alert_hash) ⇒ Alert

Returns a new instance of Alert



546
547
548
549
# File 'lib/hawkular/alerts/alerts_api.rb', line 546

def initialize(alert_hash)
  super(alert_hash)
  @lifecycle = alert_hash['lifecycle']
end

Instance Attribute Details

#lifecycleObject

Returns the value of attribute lifecycle



544
545
546
# File 'lib/hawkular/alerts/alerts_api.rb', line 544

def lifecycle
  @lifecycle
end

Instance Method Details

#ack_byObject Also known as: ackBy



551
552
553
# File 'lib/hawkular/alerts/alerts_api.rb', line 551

def ack_by
  status_by('ACKNOWLEDGED')
end

#resolved_byObject Also known as: resolvedBy



555
556
557
# File 'lib/hawkular/alerts/alerts_api.rb', line 555

def resolved_by
  status_by('RESOLVED')
end

#status_by(status) ⇒ Object



559
560
561
562
# File 'lib/hawkular/alerts/alerts_api.rb', line 559

def status_by(status)
  a = @lifecycle.nil? ? [] : @lifecycle.select { |l| l['status'].eql? status }
  a.empty? ? nil : a.last['user']
end