Class: ESP::ScanInterval

Inherits:
Resource
  • Object
show all
Defined in:
lib/esp/resources/scan_interval.rb

Constant Summary

Constants inherited from Resource

Resource::PREDICATES

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

arrange_options, filters, make_pageable, #serializable_hash, where

Class Method Details

.find(*arguments) ⇒ Object

Find a Scan Interval by id

Parameter

id | Required | The ID of the scan interval to retrieve

:call-seq:

find(id)


19
20
21
22
23
24
25
26
27
28
29
# File 'lib/esp/resources/scan_interval.rb', line 19

def self.find(*arguments)
  scope = arguments.slice!(0)
  options = (arguments.slice!(0) || {}).with_indifferent_access
  # If the first option is a number, we are looking for a specific object.
  # Otherwise `all` calls this with either nil, or a hash of arguments, and we need
  # to use our custom finder to use the correct URL
  return super(scope, options) if scope.is_a?(Numeric) || options[:from].present?
  params = options.fetch(:params, {}).with_indifferent_access
   = params.delete(:external_account_id)
  ()
end

.for_external_account(external_account_id = nil) ⇒ Object

Returns a collection of scan_intervals for the given external_account_id Convenience method to use instead of ::find since a external_account_id is required to return alerts.

Parameters

external_account_id | Required | The ID of the external account to retrieve scan intervals for

Example

alerts = ESP::ScanInterval.(54)


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

def self.( = nil)
  fail ArgumentError, "You must supply an external account id." unless .present?
  from = "#{prefix}external_accounts/#{}/scan_intervals.json"
  all(from: from)
end

Instance Method Details

#external_accountObject

The external account the scan interval belongs to



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

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

#serviceObject

The service the scan interval belongs to



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

belongs_to :service, class_name: 'ESP::Service'