Class: ESP::Stat

Inherits:
Resource
  • Object
show all
Includes:
StatTotals
Defined in:
lib/esp/resources/stat.rb

Constant Summary

Constants inherited from Resource

Resource::PREDICATES

Class Method Summary collapse

Instance Method Summary collapse

Methods included from StatTotals

#destroy, #save, #total, #total_suppressed

Methods inherited from Resource

arrange_options, filters, make_pageable, #serializable_hash

Class Method Details

.findObject

Not Implemented. You cannot search for a Stat.



31
32
33
# File 'lib/esp/resources/stat.rb', line 31

def self.find(*)
  fail ESP::NotImplementedError, 'Regular ARELlike methods are disabled.  Use either the ESP::Stat.for_report or ESP::Stat.latest_for_teams method.'
end

.for_report(report_id = nil, options = {}) ⇒ Object

Returns all the stats of all the alerts for a report identified by the report_id parameter. Said report contains all statistics for this alert triggered from signatures contained in all regions for the selected hour.

Parameters

report_id | Required | The ID of the report to retrieve stats for

options | Optional | A 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



59
60
61
62
63
# File 'lib/esp/resources/stat.rb', line 59

def self.for_report(report_id = nil, options = {}) # rubocop:disable Style/OptionHash
  fail ArgumentError, "You must supply a report id." unless report_id.present?
  # call find_one directly since find is overriden/not implemented
  find_one(from: "#{prefix}reports/#{report_id}/stats.json", params: options)
end

.latest_for_teamsObject

Returns all the stats for the most recent report of each team accessible by the given API key.



66
67
68
69
# File 'lib/esp/resources/stat.rb', line 66

def self.latest_for_teams
  # call find_every directly since find is overriden/not implemented
  find_every(from: :latest_for_teams)
end

.whereObject

Not Implemented. You cannot search for a Stat.



26
27
28
# File 'lib/esp/resources/stat.rb', line 26

def self.where(*)
  fail ESP::NotImplementedError
end

Instance Method Details

#custom_signaturesObject

The stats for each custom signature associated with this stat object.



23
# File 'lib/esp/resources/stat.rb', line 23

has_many :custom_signatures, class_name: 'ESP::StatCustomSignature'

#regionsObject

The stats for each region associated with this stat object.



11
# File 'lib/esp/resources/stat.rb', line 11

has_many :regions, class_name: 'ESP::StatRegion'

#reportObject

The report these stats are for.



7
# File 'lib/esp/resources/stat.rb', line 7

belongs_to :report, class_name: 'ESP::Report'

#servicesObject

The stats for each service associated with this stat object.



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

has_many :services, class_name: 'ESP::StatService'

#signaturesObject

The stats for each signature associated with this stat object.



19
# File 'lib/esp/resources/stat.rb', line 19

has_many :signatures, class_name: 'ESP::StatSignature'