Class: ESP::Report

Inherits:
Resource
  • Object
show all
Defined in:
lib/esp.rb,
lib/esp/resources/report.rb,
lib/esp/resources/reports/export/integration.rb

Defined Under Namespace

Modules: Export

Constant Summary

Constants inherited from Resource

ESP::Resource::PREDICATES

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

arrange_options, filters, find, make_pageable, #serializable_hash, where

Class Method Details

.create(arguments = {}) ⇒ Object

Enqueue a report to be run for the given team. Returns a Report object with a status of ‘queued’ and an id

Attribute

See API documentation for valid arguments

Periodically check the API

ESP::Report.find(<id>)

until status is ‘complete’.

If not successful, returns a Report object with the errors object populated.



36
37
38
39
40
41
# File 'lib/esp/resources/report.rb', line 36

def self.create(arguments = {})
  fail ArgumentError, "You must supply a team id." unless arguments.with_indifferent_access[:team_id].present?
  super
rescue ActiveResource::ResourceNotFound => error
  new(arguments).tap { |r| r.load_remote_errors(error, true) }
end

Instance Method Details

#alerts(arguments = {}) ⇒ Object

Returns a paginated collection of alerts for the report

Parameters

arguments | Not Required | An optional hash of search criteria to filter the returned collection

Valid Arguments

See API documentation for valid arguments

Example

report = ESP::Report.find(345)
alerts = report.alerts(status_eq: 'fail', signature_risk_level_in: ['High'])


57
58
59
# File 'lib/esp/resources/report.rb', line 57

def alerts(arguments = {})
  ESP::Alert.where(arguments.merge(report_id: id))
end

#destroyObject

Not Implemented. You cannot destroy a Report.



21
22
23
# File 'lib/esp/resources/report.rb', line 21

def destroy
  fail ESP::NotImplementedError
end

#organizationObject

The organization the report belongs to.



5
# File 'lib/esp/resources/report.rb', line 5

belongs_to :organization, class_name: 'ESP::Organization'

#statObject

Returns the stats for this report



62
63
64
# File 'lib/esp/resources/report.rb', line 62

def stat
  ESP::Stat.for_report(id)
end

#sub_organizationObject

The sub_organization the report belongs to.



9
# File 'lib/esp/resources/report.rb', line 9

belongs_to :sub_organization, class_name: 'ESP::SubOrganization'

#teamObject

The team the report belongs to.



13
# File 'lib/esp/resources/report.rb', line 13

belongs_to :team, class_name: 'ESP::Team'

#updateObject

Not Implemented. You cannot create or update a Report.



16
17
18
# File 'lib/esp/resources/report.rb', line 16

def update
  fail ESP::NotImplementedError
end