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



585
586
587
588
# File 'lib/hawkular/alerts/alerts_api.rb', line 585

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

Instance Attribute Details

#lifecycleObject

Returns the value of attribute lifecycle



583
584
585
# File 'lib/hawkular/alerts/alerts_api.rb', line 583

def lifecycle
  @lifecycle
end

Instance Method Details

#ack_byObject Also known as: ackBy



590
591
592
# File 'lib/hawkular/alerts/alerts_api.rb', line 590

def ack_by
  status_by('ACKNOWLEDGED')
end

#resolved_byObject Also known as: resolvedBy



594
595
596
# File 'lib/hawkular/alerts/alerts_api.rb', line 594

def resolved_by
  status_by('RESOLVED')
end

#status_by(status) ⇒ Object



598
599
600
601
# File 'lib/hawkular/alerts/alerts_api.rb', line 598

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