Class: Threatstack::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/threatstack/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entity, raw) ⇒ Response

Returns a new instance of Response.



11
12
13
14
# File 'lib/threatstack/response.rb', line 11

def initialize(entity, raw)
  @raw = raw
  @entity = entity
end

Instance Attribute Details

#entityObject (readonly)

Returns the value of attribute entity.



10
11
12
# File 'lib/threatstack/response.rb', line 10

def entity
  @entity
end

#rawObject (readonly)

Returns the value of attribute raw.



10
11
12
# File 'lib/threatstack/response.rb', line 10

def raw
  @raw
end

Instance Method Details

#agentsObject

Raises:



16
17
18
19
# File 'lib/threatstack/response.rb', line 16

def agents
  raise InvalidEntity unless entity == :agent
  raw.map{ |a| Agent.new(a) }
end

#alertsObject

Raises:



21
22
23
24
# File 'lib/threatstack/response.rb', line 21

def alerts
  raise InvalidEntity unless entity == :alert
  raw.map{ |a| Alert.new(a) }
end

#logsObject

Raises:



26
27
28
29
# File 'lib/threatstack/response.rb', line 26

def logs
  raise InvalidEntity unless entity == :log
  raw.map{ |a| Log.new(a) }
end

#organizationsObject

Raises:



31
32
33
34
# File 'lib/threatstack/response.rb', line 31

def organizations
  raise InvalidEntity unless entity == :organization
  raw.map{ |a| Organization.new(a) }
end

#policiesObject

Raises:



36
37
38
39
# File 'lib/threatstack/response.rb', line 36

def policies
  raise InvalidEntity unless entity == :policy
  raw.map{ |a| Policy.new(a) }
end