Class: ESP::ScanInterval
- Defined in:
- lib/esp/resources/scan_interval.rb
Constant Summary
Constants inherited from Resource
Class Method Summary collapse
-
.find(*arguments) ⇒ Object
Find a Scan Interval by id.
-
.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.
Instance Method Summary collapse
-
#external_account ⇒ Object
The external account the scan interval belongs to.
-
#service ⇒ Object
The service the scan interval belongs to.
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) = (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, ) if scope.is_a?(Numeric) || [:from].present? params = .fetch(:params, {}).with_indifferent_access external_account_id = params.delete(:external_account_id) for_external_account(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.for_external_account(54)
40 41 42 43 44 |
# File 'lib/esp/resources/scan_interval.rb', line 40 def self.for_external_account(external_account_id = nil) fail ArgumentError, "You must supply an external account id." unless external_account_id.present? from = "#{prefix}external_accounts/#{external_account_id}/scan_intervals.json" all(from: from) end |
Instance Method Details
#external_account ⇒ Object
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' |
#service ⇒ Object
The service the scan interval belongs to
9 |
# File 'lib/esp/resources/scan_interval.rb', line 9 belongs_to :service, class_name: 'ESP::Service' |