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.
This is a v2.2 preview surface; the API shape may shift before it is marked stable.
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.
13 14 15 16 17 18 19 |
# File 'lib/scanii/trace_result.rb', line 13 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.
11 12 13 |
# File 'lib/scanii/trace_result.rb', line 11 def events @events end |
#host_id ⇒ Object (readonly)
Returns the value of attribute host_id.
11 12 13 |
# File 'lib/scanii/trace_result.rb', line 11 def host_id @host_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
11 12 13 |
# File 'lib/scanii/trace_result.rb', line 11 def id @id end |
#raw_response ⇒ Object (readonly)
Returns the value of attribute raw_response.
11 12 13 |
# File 'lib/scanii/trace_result.rb', line 11 def raw_response @raw_response end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
11 12 13 |
# File 'lib/scanii/trace_result.rb', line 11 def request_id @request_id end |
Class Method Details
.from_response(body, headers) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/scanii/trace_result.rb', line 21 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 |