Class: Scanii::TraceResult
- Inherits:
-
Object
- Object
- Scanii::TraceResult
- Defined in:
- lib/scanii/trace_result.rb
Overview
Result of Client#retrieve_trace — ordered processing events for a scan.
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#host_id ⇒ Object
readonly
Returns the value of attribute host_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#raw_response ⇒ Object
readonly
Returns the value of attribute raw_response.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id:, events:, request_id:, host_id:, raw_response:) ⇒ TraceResult
constructor
A new instance of TraceResult.
Constructor Details
#initialize(id:, events:, request_id:, host_id:, raw_response:) ⇒ TraceResult
Returns a new instance of TraceResult.
10 11 12 13 14 15 16 |
# File 'lib/scanii/trace_result.rb', line 10 def initialize(id:, events:, request_id:, host_id:, raw_response:) @id = id @events = events @request_id = request_id @host_id = host_id @raw_response = raw_response end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
8 9 10 |
# File 'lib/scanii/trace_result.rb', line 8 def events @events end |
#host_id ⇒ Object (readonly)
Returns the value of attribute host_id.
8 9 10 |
# File 'lib/scanii/trace_result.rb', line 8 def host_id @host_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/scanii/trace_result.rb', line 8 def id @id end |
#raw_response ⇒ Object (readonly)
Returns the value of attribute raw_response.
8 9 10 |
# File 'lib/scanii/trace_result.rb', line 8 def raw_response @raw_response end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
8 9 10 |
# File 'lib/scanii/trace_result.rb', line 8 def request_id @request_id end |
Class Method Details
.from_response(body, headers) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/scanii/trace_result.rb', line 18 def self.from_response(body, headers) json = body.nil? || body.empty? ? {} : JSON.parse(body) new( id: (json["id"] || "").to_s, events: Array(json["events"]).map { |e| TraceEvent.from_hash(e) }, request_id: headers["x-scanii-request-id"], host_id: headers["x-scanii-host-id"], raw_response: body ) end |