Class: ESP::ScanInterval

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

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

.find(id) ⇒ ESP::ScanInterval .find(scope, options) ⇒ ESP::ScanInterval

Find a Scan Interval by id

call-seq -> super.find(id)

Overloads:

  • .find(id) ⇒ ESP::ScanInterval

    Parameters:

    • id (Integer, Numeric, #to_i)

      Required ID of the scan interval to retrieve.

  • .find(scope, options) ⇒ ESP::ScanInterval

    This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

    call-seq -> super.all(options)

    Parameters:

    • scope (Object)

      Example: :all

    • options (Hash)

      params: { external_account_id: Interger }

    Raises:

    • (ArgumentError)

      if no external_account_id is supplied.

Returns:



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/esp/resources/scan_interval.rb', line 26

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) ⇒ ActiveResource::PaginatedCollection<ESP::ScanInterval>

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

Examples:

alerts = ESP::ScanInterval.(54)

Parameters:

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

    Required ID of the external account to retrieve scan intervals for.

Returns:

Raises:

  • (ArgumentError)

    if no external_account_id is supplied.



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

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_accountESP::ExternalAccount

The external account the scan interval belongs to



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

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

#serviceESP::Service

The service the scan interval belongs to

Returns:



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

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