Class: ESP::Suppression

Inherits:
Resource show all
Defined in:
lib/esp/resources/suppression.rb,
lib/esp/resources/suppression/region.rb,
lib/esp/resources/suppression/signature.rb,
lib/esp/resources/suppression/unique_identifier.rb

Defined Under Namespace

Classes: Region, Signature, UniqueIdentifier

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::Suppression>

Return a paginated Suppression list



# File 'lib/esp/resources/suppression.rb', line 134

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

Find a Suppression by id

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

Parameters:

  • id (Integer, Numeric, #to_i)

    Required ID of the suppression to retrieve.

  • 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

Returns:



# File 'lib/esp/resources/suppression.rb', line 118

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

Return a paginated Suppression 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/suppression.rb', line 107

Instance Method Details

#created_byESP::User

The user who created the suppression.

Returns:



15
# File 'lib/esp/resources/suppression.rb', line 15

belongs_to :created_by, class_name: 'ESP::User'

#custom_signaturesActiveResource::PaginatedCollection<ESP::CustomSignature>

The custom signatures being suppressed.



50
51
52
53
54
55
# File 'lib/esp/resources/suppression.rb', line 50

def custom_signatures
  # When custom_signatures come back in an include, the method still gets called, to return the object from the attributes.
  return attributes['custom_signatures'] if attributes['custom_signatures'].present?
  return [] unless respond_to? :custom_signature_ids
  ESP::CustomSignature.where(id_in: custom_signature_ids)
end

#deactivateNet::HTTPSuccess, false

Deactivate the current suppression instance. The current object will be updated with the new status if successful. If not successful, populates its errors object.

Once deactivated the suppression cannot be reactivated.

Returns:

  • (Net::HTTPSuccess, false)


97
98
99
100
101
102
103
104
105
# File 'lib/esp/resources/suppression.rb', line 97

def deactivate
  patch(:deactivate).tap do |response|
    load_attributes_from_response(response)
  end
rescue ActiveResource::BadRequest, ActiveResource::ResourceInvalid, ActiveResource::UnauthorizedAccess, ActiveResource::ForbiddenAccess => error
  load_remote_errors(error, true)
  self.code = error.response.code
  false
end

#deactivate!void

This method returns an undefined value.

Deactivate the current suppression instance. The current object will be updated with the new status if successful. Throws an error if not successful.

Once deactivated the suppression cannot be reactivated.

Raises:

  • (ActiveResource::ResourceInvalid)

    if unsuccessful.



85
86
87
88
89
# File 'lib/esp/resources/suppression.rb', line 85

def deactivate!
  return self if deactivate
  self.message = errors.full_messages.join(' ')
  fail(ActiveResource::ResourceInvalid.new(self)) # rubocop:disable Style/RaiseArgs
end

#destroyvoid

This method returns an undefined value.

Not Implemented. You cannot destroy a Suppression.



74
75
76
# File 'lib/esp/resources/suppression.rb', line 74

def destroy
  fail ESP::NotImplementedError
end

#external_accountsActiveResource::PaginatedCollection<ESP::ExternalAccount>

The external accounts affected by this suppression.



30
31
32
33
34
35
# File 'lib/esp/resources/suppression.rb', line 30

def external_accounts
  # When external_accounts come back in an include, the method still gets called, to return the object from the attributes.
  return attributes['external_accounts'] if attributes['external_accounts'].present?
  return [] unless respond_to? :external_account_ids
  ESP::ExternalAccount.where(id_in: )
end

#organizationESP::Organization

The organization this sub organization belongs to.

Returns:



10
# File 'lib/esp/resources/suppression.rb', line 10

belongs_to :organization, class_name: 'ESP::Organization'

#regionsActiveResource::PaginatedCollection<ESP::Region>

The regions affected by this suppression.



20
21
22
23
24
25
# File 'lib/esp/resources/suppression.rb', line 20

def regions
  # When regions come back in an include, the method still gets called, to return the object from the attributes.
  return attributes['regions'] if attributes['regions'].present?
  return [] unless respond_to? :region_ids
  ESP::Region.where(id_in: region_ids)
end

#savevoid

This method returns an undefined value.

Not Implemented. You cannot create or update a Suppression.



67
68
69
# File 'lib/esp/resources/suppression.rb', line 67

def save
  fail ESP::NotImplementedError
end

#signaturesActiveResource::PaginatedCollection<ESP::Signature>

The signatures being suppressed.



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

def signatures
  # When signatures come back in an include, the method still gets called, to return the object from the attributes.
  return attributes['signatures'] if attributes['signatures'].present?
  return [] unless respond_to? :signature_ids
  ESP::Signature.where(id_in: signature_ids)
end