Class: ESP::Signature

Inherits:
Resource show all
Defined in:
lib/esp/resources/signature.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

.allActiveResource::PaginatedCollection<ESP::Signature>

Return a paginated Signature list



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

.find(id) ⇒ ESP::Signature .find(id, options = {}) ⇒ ESP::Signature

Find a Signature by id

call-seq -> super.find(id, options = {})

Overloads:

  • .find(id, options = {}) ⇒ ESP::Signature

    Parameters:

    • 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

Parameters:

  • id (Integer, Numeric, #to_i)

    Required ID of the signature to retrieve.

Returns:



# File 'lib/esp/resources/signature.rb', line 89

.where(clauses = {}) ⇒ ActiveResource::PaginatedCollection<ESP::Signature>

Return a paginated Signature list filtered by search parameters

call-seq -> super.where(clauses = {})

Parameters:

  • clauses (Hash) (defaults to: {})

    A hash of attributes with appended predicates to search, sort and include.

    Valid Clauses

    See API documentation for valid arguments

Returns:



# File 'lib/esp/resources/signature.rb', line 78

Instance Method Details

#destroyvoid

This method returns an undefined value.

Not Implemented. You cannot destroy a Signature.



18
19
20
# File 'lib/esp/resources/signature.rb', line 18

def destroy
  fail ESP::NotImplementedError
end

#run(arguments = {}) ⇒ ActiveResource::PaginatedCollection<ESP::Alert>, self

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

Examples:

signature = ESP::Signature.find(3)
alerts = signature.run(external_account_id: 3, region: 'us_east_1')

Parameters:

  • arguments (Hash) (defaults to: {})

    Required hash of run arguments.

    Valid Arguments

    See API documentation for valid arguments

Returns:



51
52
53
54
55
56
57
58
59
60
61
62
# 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 = {}) ⇒ ActiveResource::PaginatedCollection<ESP::Alert>

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

Examples:

signature = ESP::Signature.find(3)
alerts = signature.run!(external_account_id: 3, region: 'us_east_1')

Parameters:

  • arguments (Hash) (defaults to: {})

    Required hash of run arguments.

    Valid Arguments

    See API documentation for valid arguments

Returns:

Raises:

  • (ActiveResource::ResourceInvalid)

    if not successful.



32
33
34
35
36
37
# 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

#savevoid

This method returns an undefined value.

Not Implemented. You cannot create or update a Signature.



11
12
13
# File 'lib/esp/resources/signature.rb', line 11

def save
  fail ESP::NotImplementedError
end

#serviceESP::Service

The service this signature belongs to.

Returns:



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

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

#suppress(arguments = {}) ⇒ ESP::Suppression::Signature

Create a suppression for this signature.

Examples:

suppress(regions: ['us_east_1'], external_account_ids: [5], reason: 'My very good reason for creating this suppression')

Parameters:

  • arguments (Hash) (defaults to: {})

    Required hash of signature suppression attributes.

    Valid Arguments

    See API documentation for valid arguments

Returns:



73
74
75
76
# 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