Class: ESP::Stat

Inherits:
Resource show all
Defined in:
lib/esp/resources/stat.rb

'total' rollup methods collapse

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

.createvoid

This method returns an undefined value.

Not Implemented. You cannot create a Stat.



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

.findvoid

This method returns an undefined value.

Not Implemented. You cannot search for a Stat.



45
46
47
# File 'lib/esp/resources/stat.rb', line 45

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 = {}) ⇒ ActiveResource::PaginatedCollection<ESP::Stat>

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

Parameters:

  • report_id (Integer, Numeric) (defaults to: nil)

    Required ID of the report to retrieve stats for.

  • 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

Returns:

Raises:

  • (ArgumentError)

    if no report_id is supplied.



79
80
81
82
83
# File 'lib/esp/resources/stat.rb', line 79

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_teamsActiveResource::PaginatedCollection<ESP::Stat>

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



88
89
90
91
# File 'lib/esp/resources/stat.rb', line 88

def self.latest_for_teams
  # call find_every directly since find is overriden/not implemented
  where(from: "#{prefix}stats/latest_for_teams")
end

.where(attrs) ⇒ void

This method returns an undefined value.

Not Implemented. You cannot search for a Stat.



33
34
35
36
37
38
39
40
# File 'lib/esp/resources/stat.rb', line 33

def self.where(attrs)
  # when calling `latest_for_teams.next_page` it will come into here
  if attrs[:from].to_s.include?('latest_for_teams')
    super
  else
    fail ESP::NotImplementedError
  end
end

Instance Method Details

#custom_signaturesActiveResource::PaginatedCollection<ESP::StatCustomSignature>

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



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

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

#destroyvoid

This method returns an undefined value.

Not Implemented. You cannot delete a Stat.



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

#regionsActiveResource::PaginatedCollection<ESP::StatRegion>

The stats for each region associated with this stat object.



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

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

#reportESP::Report

The report these stats are for.

Returns:



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

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

#savevoid

This method returns an undefined value.

Not Implemented. You cannot create or update a Stat.



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

#servicesActiveResource::PaginatedCollection<ESP::StatService>

The stats for each service associated with this stat object.



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

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

#signaturesActiveResource::PaginatedCollection<ESP::StatSignature>

The stats for each signature associated with this stat object.



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

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

#totalObject



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

#total_errorObject



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

#total_failObject



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

#total_infoObject



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

#total_new_1dObject



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

#total_new_1d_errorObject



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

#total_new_1d_failObject



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

#total_new_1d_infoObject



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

#total_new_1d_passObject



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

#total_new_1d_warnObject



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

#total_new_1hObject



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

#total_new_1h_errorObject



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

#total_new_1h_failObject



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

#total_new_1h_infoObject



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

#total_new_1h_passObject



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

#total_new_1h_warnObject



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

#total_new_1wObject



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

#total_new_1w_errorObject



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

#total_new_1w_failObject



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

#total_new_1w_infoObject



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

#total_new_1w_passObject



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

#total_new_1w_warnObject



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

#total_oldObject



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

#total_old_errorObject



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

#total_old_failObject



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

#total_old_infoObject



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

#total_old_passObject



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

#total_old_warnObject



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

#total_passObject



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

#total_suppressedObject



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

#total_suppressed_errorObject



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

#total_suppressed_failObject



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

#total_suppressed_passObject



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

#total_suppressed_warnObject



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

#total_warnObject



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