Class: Sysdig::GetAlertNotifications

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

Instance Method Summary collapse

Instance Method Details

#mock(from, to) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/sysdig/get_alert_notifications.rb', line 15

def mock(from, to)
  from_i, to_i = timestamps(from, to)

  notifications = service.data[:alert_notifications].values.select { |an|
    an["timestamp"] >= from_i && an["timestamp"] <= to_i
  }

  service.response(
    :body => { "notifications" => notifications },
  )
end

#real(from, to) ⇒ Object



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

def real(from, to)
  from_i, to_i = timestamps(from, to)

  service.request(
    :path   => "/api/notifications",
    :params => {"from" => from_i, "to" => to_i},
  )
end

#timestamps(*args) ⇒ Object



11
12
13
# File 'lib/sysdig/get_alert_notifications.rb', line 11

def timestamps(*args)
  args.map { |a| a.to_i * 1_000_000 }
end