Class: Sysdig::UpdateUserNotifications

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

Instance Method Summary collapse

Instance Method Details

#mock(notification) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/sysdig/update_user_notifications.rb', line 10

def mock(notification)
  user_notification = Cistern::Hash.slice(Cistern::Hash.stringify_keys(notification), "sns", "email", "pagerDuty")

  schema = {
    "sns"       => %w[enabled topics],
    "email"     => %w[enabled recipients],
    "pagerDuty" => %w[enabled integrated resolveOnOk connectUrl],
  }

  sliced = schema.each_with_object({}) { |(type, keys), r|
    u = user_notification[type]

    if u
      r.merge!(type => Cistern::Hash.slice(u, *keys))
    end
  }

  service.response(
    :body => { "userNotification" => service.data[:user_notifications].merge!(sliced) },
  )
end

#real(notification) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/sysdig/update_user_notifications.rb', line 2

def real(notification)
  service.request(
    :method => :put,
    :path   => "/api/settings/notifications",
    :body   => { "userNotification" => notification },
  )
end