Sha256: 638a9b3328940a3e2ae3f1598b189b60ef2a84a6c48813cb874ede96e446eb7b

Contents?: true

Size: 1.54 KB

Versions: 2

Compression:

Stored size: 1.54 KB

Contents

class Sysdig::UpdateAlertNotification < Sysdig::Request
  def self.params
    %w[alert condition entities filter resolved severity state timespan timestamp]
  end

  def slice(notification)
    Cistern::Hash.slice(notification, *Cistern::Hash.stringify_keys(self.class.params))
  end

  # "notification"=>
  # {"timestamp"=>1445878320000000,
  #  "severity"=>2,
  #  "filter"=>
  # "container.name = 'deis-builder' and agent.tag.id = '8dbf0cfb-7b4b-42ea-b1f1-b742a5bdebf4'",
  #   "timespan"=>60000000,
  #   "condition"=>"timeAvg(uptime) = 0",
  #   "entities"=>
  # [{"filter"=>
  #   "container.name = 'deis-builder' and agent.tag.id = '8dbf0cfb-7b4b-42ea-b1f1-b742a5bdebf4'",
  #     "target"=>
  #   {"id"=>"group@agent_tag_id-8dbf0cfb-7b4b-42ea-b1f1-b742a5bdebf4",
  #    "type"=>"GROUP",
  #    "subTarget"=>[{"metric"=>"container.name", "value"=>"deis-builder"}]},
  #   "metricValues"=>
  #   [{"metric"=>"uptime", "aggregation"=>"timeAvg", "value"=>0}]}],
  # "state"=>"ACTIVE",
  # "resolved"=>true,
  # "alert"=>"31586"}}
  def real(notification_id, notification)
    service.request(
      :method => :put,
      :path   => File.join("/api/notifications", notification_id.to_s),
      :body   => { "notification" => self.slice(notification) },
    )
  end

  def mock(notification_id, notification)
    update_notification   = self.slice(notification)
    existing_notification = service.data[:alert_notifications].fetch(notification_id)

    service.response(
      :body => { "notification" => existing_notification.merge!(update_notification) },
    )
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sysdig-0.3.1 lib/sysdig/update_alert_notification.rb
sysdig-0.3.0 lib/sysdig/update_alert_notification.rb