Class: ESP::Stat

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

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, where

Class Method Details

.findObject

Not Implemented. You cannot search for a Stat.



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

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) ⇒ 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.



40
41
42
43
44
# File 'lib/esp/resources/stat.rb', line 40

def self.for_report(report_id = nil)
  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")
end

.latest_for_teamsObject

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



47
48
49
50
# File 'lib/esp/resources/stat.rb', line 47

def self.latest_for_teams
  # call find_every directly since find is overriden/not implemented
  find_every(from: :latest_for_teams)
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'