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
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
#lifecycle ⇒ Object
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_by ⇒ Object Also known as: ackBy
551 552 553 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 551 def ack_by status_by('ACKNOWLEDGED') end |
#resolved_by ⇒ Object 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 |