Class: Sysdig::UpdateAlertNotification

Inherits:
Request
  • Object
show all
Defined in:
lib/sysdig/update_alert_notification.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.paramsObject



2
3
4
# File 'lib/sysdig/update_alert_notification.rb', line 2

def self.params
  %w[alert condition entities filter resolved severity state timespan timestamp]
end

Instance Method Details

#mock(notification_id, notification) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/sysdig/update_alert_notification.rb', line 37

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

#real(notification_id, notification) ⇒ Object

“notification”=>

"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"=>
["aggregation"=>"timeAvg", "value"=>0]}],

“state”=>“ACTIVE”, “resolved”=>true, “alert”=>“31586”}}



29
30
31
32
33
34
35
# File 'lib/sysdig/update_alert_notification.rb', line 29

def real(notification_id, notification)
  service.request(
    :method => :put,
    :path   => File.join("/api/notifications", notification_id.to_s),
    :body   => { "notification" => self.slice(notification) },
  )
end

#slice(notification) ⇒ Object



6
7
8
# File 'lib/sysdig/update_alert_notification.rb', line 6

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