Sha256: 3158c044b893742c1123bdc0723e13428681d6fb16b5b86a35754be0897ebebf

Contents?: true

Size: 728 Bytes

Versions: 4

Compression:

Stored size: 728 Bytes

Contents

class Sysdig::CreateAlert < Sysdig::Request
  def self.params
    %w[condition createdOn description enabled filter modifiedOn name notify segmentBy segmentCondition severity timespan type version]
  end

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

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

  def mock(alert)
    alert_id = service.serial_id
    body = self.class.slice(alert).merge!("id" => alert_id)

    service.data[:alerts][alert_id] = body

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sysdig-0.3.1 lib/sysdig/create_alert.rb
sysdig-0.3.0 lib/sysdig/create_alert.rb
sysdig-0.2.4 lib/sysdig/create_alert.rb
sysdig-0.2.3 lib/sysdig/create_alert.rb