Class: Hawkular::Alerts::Trigger
- Inherits:
-
Object
- Object
- Hawkular::Alerts::Trigger
- Defined in:
- lib/hawkular/alerts/alerts_api.rb
Overview
Representation of one Trigger (22 known properties: “enabled”, “autoResolveMatch”, “name”, “memberOf”, “autoEnable”, “firingMatch”, “tags”, “id”, “source”, “tenantId”, “eventText”, “context”, “eventType”, “autoResolveAlerts”, “dataIdMap”, “eventCategory”, “autoDisable”, “type”, “description”, “severity”, “autoResolve”, “actions”])
Defined Under Namespace
Classes: Action, Condition, Dampening, GroupConditionsInfo, GroupMemberInfo
Instance Attribute Summary collapse
-
#actions ⇒ Object
Returns the value of attribute actions.
-
#auto_disable ⇒ Object
Returns the value of attribute auto_disable.
-
#auto_enable ⇒ Object
Returns the value of attribute auto_enable.
-
#auto_resolve ⇒ Object
Returns the value of attribute auto_resolve.
-
#auto_resolve_alerts ⇒ Object
Returns the value of attribute auto_resolve_alerts.
-
#auto_resolve_match ⇒ Object
Returns the value of attribute auto_resolve_match.
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
-
#context ⇒ Object
Returns the value of attribute context.
-
#dampenings ⇒ Object
readonly
Returns the value of attribute dampenings.
-
#data_id_map ⇒ Object
Returns the value of attribute data_id_map.
-
#description ⇒ Object
Returns the value of attribute description.
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#event_category ⇒ Object
Returns the value of attribute event_category.
-
#event_type ⇒ Object
Returns the value of attribute event_type.
-
#firing_match ⇒ Object
Returns the value of attribute firing_match.
-
#group ⇒ Object
Returns the value of attribute group.
-
#id ⇒ Object
Returns the value of attribute id.
-
#member_of ⇒ Object
Returns the value of attribute member_of.
-
#name ⇒ Object
Returns the value of attribute name.
-
#severity ⇒ Object
Returns the value of attribute severity.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#tenant ⇒ Object
Returns the value of attribute tenant.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(trigger_hash) ⇒ Trigger
constructor
A new instance of Trigger.
- #to_h ⇒ Object
Constructor Details
#initialize(trigger_hash) ⇒ Trigger
Returns a new instance of Trigger.
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 391 def initialize(trigger_hash) return if trigger_hash.nil? @_hash = trigger_hash @conditions = [] @dampenings = [] @actions = [] @id = trigger_hash['id'] @name = trigger_hash['name'] @enabled = trigger_hash['enabled'] @severity = trigger_hash['severity'] @auto_resolve = trigger_hash['autoResolve'] @auto_resolve_alerts = trigger_hash['autoResolveAlerts'] @event_type = trigger_hash['eventType'] @event_category = trigger_hash['eventCategory'] @member_of = trigger_hash['memberOf'] @data_id_map = trigger_hash['dataIdMap'] @tenant = trigger_hash['tenantId'] @description = trigger_hash['description'] @auto_enable = trigger_hash['autoEnable'] @auto_disable = trigger_hash['autoDisable'] @context = trigger_hash['context'] @type = trigger_hash['type'] @tags = trigger_hash['tags'] @firing_match = trigger_hash['firingMatch'] @auto_resolve_match = trigger_hash['autoResolveMatch'] # acts = trigger_hash['actions'] # acts.each { |a| @actions.push(Action.new(a)) } unless acts.nil? end |
Instance Attribute Details
#actions ⇒ Object
Returns the value of attribute actions.
385 386 387 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 385 def actions @actions end |
#auto_disable ⇒ Object
Returns the value of attribute auto_disable.
385 386 387 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 385 def auto_disable @auto_disable end |
#auto_enable ⇒ Object
Returns the value of attribute auto_enable.
385 386 387 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 385 def auto_enable @auto_enable end |
#auto_resolve ⇒ Object
Returns the value of attribute auto_resolve.
386 387 388 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 386 def auto_resolve @auto_resolve end |
#auto_resolve_alerts ⇒ Object
Returns the value of attribute auto_resolve_alerts.
386 387 388 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 386 def auto_resolve_alerts @auto_resolve_alerts end |
#auto_resolve_match ⇒ Object
Returns the value of attribute auto_resolve_match.
389 390 391 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 389 def auto_resolve_match @auto_resolve_match end |
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
388 389 390 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 388 def conditions @conditions end |
#context ⇒ Object
Returns the value of attribute context.
385 386 387 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 385 def context @context end |
#dampenings ⇒ Object (readonly)
Returns the value of attribute dampenings.
388 389 390 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 388 def dampenings @dampenings end |
#data_id_map ⇒ Object
Returns the value of attribute data_id_map.
387 388 389 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 387 def data_id_map @data_id_map end |
#description ⇒ Object
Returns the value of attribute description.
387 388 389 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 387 def description @description end |
#enabled ⇒ Object
Returns the value of attribute enabled.
389 390 391 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 389 def enabled @enabled end |
#event_category ⇒ Object
Returns the value of attribute event_category.
387 388 389 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 387 def event_category @event_category end |
#event_type ⇒ Object
Returns the value of attribute event_type.
387 388 389 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 387 def event_type @event_type end |
#firing_match ⇒ Object
Returns the value of attribute firing_match.
389 390 391 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 389 def firing_match @firing_match end |
#group ⇒ Object
Returns the value of attribute group.
387 388 389 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 387 def group @group end |
#id ⇒ Object
Returns the value of attribute id.
385 386 387 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 385 def id @id end |
#member_of ⇒ Object
Returns the value of attribute member_of.
387 388 389 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 387 def member_of @member_of end |
#name ⇒ Object
Returns the value of attribute name.
385 386 387 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 385 def name @name end |
#severity ⇒ Object
Returns the value of attribute severity.
387 388 389 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 387 def severity @severity end |
#tags ⇒ Object
Returns the value of attribute tags.
386 387 388 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 386 def @tags end |
#tenant ⇒ Object
Returns the value of attribute tenant.
387 388 389 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 387 def tenant @tenant end |
#type ⇒ Object
Returns the value of attribute type.
386 387 388 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 386 def type @type end |
Instance Method Details
#to_h ⇒ Object
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 421 def to_h trigger_hash = {} to_camel = lambda do |x| ret = x.to_s.split('_').collect(&:capitalize).join ret[0, 1].downcase + ret[1..-1] end fields = %i[id name enabled severity auto_resolve auto_resolve_alerts event_type event_category description auto_enable auto_disable context type tags member_of data_id_map firing_match auto_resolve_match] fields.each do |field| camelized_field = to_camel.call(field) field_value = __send__ field trigger_hash[camelized_field] = field_value unless field_value.nil? end trigger_hash['tenantId'] = @tenant unless @tenant.nil? trigger_hash['actions'] = [] @actions.each { |d| trigger_hash['actions'].push d.to_h } trigger_hash end |