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
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 355 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
349 350 351 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 349 def actions @actions end |
#auto_disable ⇒ Object
Returns the value of attribute auto_disable
349 350 351 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 349 def auto_disable @auto_disable end |
#auto_enable ⇒ Object
Returns the value of attribute auto_enable
349 350 351 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 349 def auto_enable @auto_enable end |
#auto_resolve ⇒ Object
Returns the value of attribute auto_resolve
350 351 352 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 350 def auto_resolve @auto_resolve end |
#auto_resolve_alerts ⇒ Object
Returns the value of attribute auto_resolve_alerts
350 351 352 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 350 def auto_resolve_alerts @auto_resolve_alerts end |
#auto_resolve_match ⇒ Object
Returns the value of attribute auto_resolve_match
353 354 355 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 353 def auto_resolve_match @auto_resolve_match end |
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions
352 353 354 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 352 def conditions @conditions end |
#context ⇒ Object
Returns the value of attribute context
349 350 351 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 349 def context @context end |
#dampenings ⇒ Object (readonly)
Returns the value of attribute dampenings
352 353 354 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 352 def dampenings @dampenings end |
#data_id_map ⇒ Object
Returns the value of attribute data_id_map
351 352 353 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 351 def data_id_map @data_id_map end |
#description ⇒ Object
Returns the value of attribute description
351 352 353 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 351 def description @description end |
#enabled ⇒ Object
Returns the value of attribute enabled
353 354 355 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 353 def enabled @enabled end |
#event_category ⇒ Object
Returns the value of attribute event_category
351 352 353 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 351 def event_category @event_category end |
#event_type ⇒ Object
Returns the value of attribute event_type
351 352 353 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 351 def event_type @event_type end |
#firing_match ⇒ Object
Returns the value of attribute firing_match
353 354 355 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 353 def firing_match @firing_match end |
#group ⇒ Object
Returns the value of attribute group
351 352 353 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 351 def group @group end |
#id ⇒ Object
Returns the value of attribute id
349 350 351 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 349 def id @id end |
#member_of ⇒ Object
Returns the value of attribute member_of
351 352 353 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 351 def member_of @member_of end |
#name ⇒ Object
Returns the value of attribute name
349 350 351 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 349 def name @name end |
#severity ⇒ Object
Returns the value of attribute severity
351 352 353 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 351 def severity @severity end |
#tags ⇒ Object
Returns the value of attribute tags
350 351 352 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 350 def @tags end |
#tenant ⇒ Object
Returns the value of attribute tenant
351 352 353 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 351 def tenant @tenant end |
#type ⇒ Object
Returns the value of attribute type
350 351 352 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 350 def type @type end |
Instance Method Details
#to_h ⇒ Object
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 |
# File 'lib/hawkular/alerts/alerts_api.rb', line 385 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 = [: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 |