class Hawkular::Alerts::Trigger

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”])

Attributes

actions[RW]
auto_disable[RW]
auto_enable[RW]
auto_resolve[RW]
auto_resolve_alerts[RW]
auto_resolve_match[RW]
conditions[R]
context[RW]
dampenings[R]
data_id_map[RW]
description[RW]
enabled[RW]
event_category[RW]
event_type[RW]
firing_match[RW]
group[RW]
id[RW]
member_of[RW]
name[RW]
severity[RW]
tags[RW]
tenant[RW]
type[RW]

Public Class Methods

new(trigger_hash) click to toggle source
    # File lib/hawkular/alerts/alerts_api.rb
391 def initialize(trigger_hash)
392   return if trigger_hash.nil?
393 
394   @_hash = trigger_hash
395   @conditions = []
396   @dampenings = []
397   @actions = []
398   @id = trigger_hash['id']
399   @name = trigger_hash['name']
400   @enabled = trigger_hash['enabled']
401   @severity = trigger_hash['severity']
402   @auto_resolve = trigger_hash['autoResolve']
403   @auto_resolve_alerts = trigger_hash['autoResolveAlerts']
404   @event_type = trigger_hash['eventType']
405   @event_category = trigger_hash['eventCategory']
406   @member_of = trigger_hash['memberOf']
407   @data_id_map = trigger_hash['dataIdMap']
408   @tenant = trigger_hash['tenantId']
409   @description = trigger_hash['description']
410   @auto_enable = trigger_hash['autoEnable']
411   @auto_disable = trigger_hash['autoDisable']
412   @context = trigger_hash['context']
413   @type = trigger_hash['type']
414   @tags = trigger_hash['tags']
415   @firing_match = trigger_hash['firingMatch']
416   @auto_resolve_match = trigger_hash['autoResolveMatch']
417   # acts = trigger_hash['actions']
418   # acts.each { |a| @actions.push(Action.new(a)) } unless acts.nil?
419 end

Public Instance Methods

to_h() click to toggle source
    # File lib/hawkular/alerts/alerts_api.rb
421 def to_h
422   trigger_hash = {}
423   to_camel = lambda do |x|
424     ret = x.to_s.split('_').collect(&:capitalize).join
425     ret[0, 1].downcase + ret[1..-1]
426   end
427   fields = %i[id name enabled severity auto_resolve auto_resolve_alerts
428               event_type event_category description auto_enable auto_disable
429               context type tags member_of data_id_map firing_match
430               auto_resolve_match]
431 
432   fields.each do |field|
433     camelized_field = to_camel.call(field)
434     field_value = __send__ field
435     trigger_hash[camelized_field] = field_value unless field_value.nil?
436   end
437 
438   trigger_hash['tenantId'] = @tenant unless @tenant.nil?
439   trigger_hash['actions'] = []
440   @actions.each { |d| trigger_hash['actions'].push d.to_h }
441 
442   trigger_hash
443 end