Class: Hawkular::Alerts::Alert
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Hawkular::Alerts::Alert
- 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
-
#lifecycle ⇒ Object
Returns the value of attribute lifecycle.
Instance Method Summary collapse
- #ack_by ⇒ Object (also: #ackBy)
-
#initialize(alert_hash) ⇒ Alert
constructor
A new instance of Alert.
- #resolved_by ⇒ Object (also: #resolvedBy)
- #status_by(status) ⇒ Object
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
#lifecycle ⇒ Object
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_by ⇒ Object Also known as: ackBy
590 591 592 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 590 def ack_by status_by('ACKNOWLEDGED') end |
#resolved_by ⇒ Object 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 |