Class: Sysdig::CreateAlert

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.paramsObject



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

def self.params
  %w[name description enabled filter type condition timespan severity notify segmentBy segmentCondition groupCondition groupBy groupAggregations]
end

Instance Method Details

#mock(alert) ⇒ Object



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

def mock(alert)
  alert_id = service.serial_id
  body     = Cistern::Hash.slice(Cistern::Hash.stringify_keys(alert), *self.class.params)

  service.data[:alerts][alert_id] = body.merge!("id" => alert_id)

  service.response(
    :status => 201,
    :body   => {"alert" => body},
  )
end

#real(alert) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/sysdig/create_alert.rb', line 6

def real(alert)
  service.request(
    :method => :post,
    :path   => "/api/alerts",
    :body   => { "alert" => alert },
  )
end