class Sysdig::AlertNotification

Public Class Methods

dump_filter(h) click to toggle source
# File lib/sysdig/alert_notification.rb, line 14
def self.dump_filter(h)
  case h
  when Hash
    h.each_with_object([]) { |(k,v),r|
      r << "#{k} = #{Sysdig::AlertFilter.normalize_condition(v).inspect}"
    }.join(" and ")
  else h
  end
end
load_filter(s, _) click to toggle source

@arg v String like “container.name = 'deis-builder' and agent.tag.id = '8dbf0cfb-7b4b-42ea-b1f1-b742a5bdebf4'”

# File lib/sysdig/alert_notification.rb, line 4
def self.load_filter(s, _)
  case s
  when String
    s.split(" and ").
      map        { |c| c.split(" = ") }.
      inject({}) { |r,(k,v)| r.merge(k => Sysdig::AlertFilter.normalize_condition(v)) }
  else s
  end
end

Public Instance Methods

resolve!() click to toggle source
# File lib/sysdig/alert_notification.rb, line 52
def resolve!
  self.resolved = true
  self.save
end
save() click to toggle source

@todo get target information out of an alert notification

# File lib/sysdig/alert_notification.rb, line 37
def save
  params = {
    "alert"     => self.alert_id,
    "filter"    => self.class.dump_filter(self.filter),
    "resolved"  => self.resolved,
    "severity"  => self.severity,
    "state"     => self.state,
    "timestamp" => self.timestamp.to_i * 1_000_000,
  }

  data = service.update_alert_notification(self.identity, params).body.fetch("notification")

  merge_attributes(data)
end