class ESP::Signature

Public Instance Methods

destroy() click to toggle source

Not Implemented. You cannot destroy a Signature.

@return [void]

# File lib/esp/resources/signature.rb, line 18
def destroy
  fail ESP::NotImplementedError
end
run(arguments = {}) click to toggle source

Run this signature. Returns a collection of alerts. If not successful, returns a Signature object with the errors object populated.

@param arguments [Hash] Required hash of run arguments.

===== Valid Arguments

See {API documentation}[http://api-docs.evident.io?ruby#signature-run] for valid arguments

@return [ActiveResource::PaginatedCollection<ESP::Alert>, self] @example

signature = ESP::Signature.find(3)
alerts = signature.run(external_account_id: 3, region: 'us_east_1')
# File lib/esp/resources/signature.rb, line 51
def run(arguments = {})
  arguments = arguments.with_indifferent_access
  attributes['external_account_id'] ||= arguments[:external_account_id]
  attributes['region'] ||= arguments[:region]

  response = connection.post("#{self.class.prefix}signatures/#{id}/run.json", to_json)
  ESP::Alert.send(:instantiate_collection, self.class.format.decode(response.body))
rescue ActiveResource::BadRequest, ActiveResource::ResourceInvalid, ActiveResource::ResourceNotFound => error
  load_remote_errors(error, true)
  self.code = error.response.code
  self
end
run!(arguments = {}) click to toggle source

Run this signature. Returns a collection of alerts. Throws an error if not successful.

@param (see run) @return [ActiveResource::PaginatedCollection<ESP::Alert>] @raise [ActiveResource::ResourceInvalid] if not successful. @example

signature = ESP::Signature.find(3)
alerts = signature.run!(external_account_id: 3, region: 'us_east_1')
# File lib/esp/resources/signature.rb, line 32
def run!(arguments = {})
  result = run(arguments)
  return result if result.is_a?(ActiveResource::Collection)
  result.message = result.errors.full_messages.join(' ')
  fail(ActiveResource::ResourceInvalid.new(result)) # rubocop:disable Style/RaiseArgs
end
save() click to toggle source

Not Implemented. You cannot create or update a Signature.

@return [void]

# File lib/esp/resources/signature.rb, line 11
def save
  fail ESP::NotImplementedError
end
suppress(arguments = {}) click to toggle source

Create a suppression for this signature.

@param arguments [Hash] Required hash of signature suppression attributes.

===== Valid Arguments

See {API documentation}[http://api-docs.evident.io?ruby#suppression-create] for valid arguments

@return [ESP::Suppression::Signature] @example

suppress(regions: ['us_east_1'], external_account_ids: [5], reason: 'My very good reason for creating this suppression')
# File lib/esp/resources/signature.rb, line 73
def suppress(arguments = {})
  arguments = arguments.with_indifferent_access
  ESP::Suppression::Signature.create(signature_ids: [id], regions: Array(arguments[:regions]), external_account_ids: Array(arguments[:external_account_ids]), reason: arguments[:reason])
end