Class: ESP::Report

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

Defined Under Namespace

Modules: Export

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Dirty

#changed_attributes, #original_attributes, #original_attributes=

Methods included from LoadWithOriginalAttributes

#load

Class Method Details

.allActiveResource::PaginatedCollection<ESP::Report>

Return a paginated Report list



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

.create(arguments = {}) ⇒ ESP::Report

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

Periodically check the API

ESP::Report.find(<id>)

until status is ‘complete’.

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

Parameters:

Returns:

Raises:

  • (ArgumentError)

    if team_id: Integer is not supplied.



53
54
55
56
57
58
# File 'lib/esp/resources/report.rb', line 53

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

.find(id) ⇒ ESP::Report .find(id, options = {}) ⇒ ESP::Report

Find a Report by id

call-seq -> super.find(id, options = {})

Overloads:

  • .find(id, options = {}) ⇒ ESP::Report

    Parameters:

    • options (Hash) (defaults to: {})

      Optional hash of options.

      Valid Options

      include | The list of associated objects to return on the initial request.

      Valid Includable Associations

      See API documentation for valid arguments

Parameters:

  • id (Integer, Numeric, #to_i)

    Required ID of the report to retrieve.

Returns:



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

.where(clauses = {}) ⇒ ActiveResource::PaginatedCollection<ESP::Report>

Return a paginated Report list filtered by search parameters

call-seq -> super.where(clauses = {})

Parameters:

  • clauses (Hash) (defaults to: {})

    Hash of attributes with appended predicates to search, sort and include. See API documentation for valid arguments

Returns:



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

Instance Method Details

#alertsActiveResource::PaginatedCollection<ESP::Alert> #alerts(arguments = {}) ⇒ ActiveResource::PaginatedCollection<ESP::Alert>

Returns a paginated collection of alerts for the report

Examples:

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

Parameters:

  • arguments (Hash) (defaults to: {})

    An optional hash of search criteria to filter the returned collection. See API documentation for valid arguments.

Returns:



70
71
72
# File 'lib/esp/resources/report.rb', line 70

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

#destroyvoid

This method returns an undefined value.

Not Implemented. You cannot destroy a Report.



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

def destroy
  fail ESP::NotImplementedError
end

#external_accountESP::ExternalAccount

The external_account the report belongs to.



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

belongs_to :external_account, class_name: 'ESP::ExternalAccount'

#organizationESP::Organization

The organization the report belongs to.

Returns:



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

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

#statActiveResource::PaginatedCollection<ESP::Stat>

Returns the stats for this report



77
78
79
# File 'lib/esp/resources/report.rb', line 77

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

#sub_organizationESP::SubOrganization

The sub_organization the report belongs to.



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

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

#teamESP::Team

The team the report belongs to.

Returns:



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

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

#updatevoid

This method returns an undefined value.

Not Implemented. You cannot update a Report.



30
31
32
# File 'lib/esp/resources/report.rb', line 30

def update
  fail ESP::NotImplementedError
end