Class: Invoance::Resources::Traces
- Inherits:
-
Object
- Object
- Invoance::Resources::Traces
- Defined in:
- lib/invoance/resources/traces.rb
Overview
Traces resource — client.traces.*
Instance Method Summary collapse
-
#create(label:, metadata: nil) ⇒ Hash
POST /traces — Create a new trace.
-
#delete(trace_id) ⇒ Hash
DELETE /traces/:trace_id — Delete an empty open trace.
-
#get(trace_id, event_page: nil, event_limit: nil) ⇒ Hash
GET /traces/:trace_id — Trace detail with paginated events.
-
#initialize(http) ⇒ Traces
constructor
A new instance of Traces.
-
#list(page: nil, limit: nil, status: nil) ⇒ Hash
GET /traces — Paginated trace listing.
-
#proof(trace_id) ⇒ Hash
GET /traces/:trace_id/proof — Export proof bundle as JSON.
-
#proof_pdf(trace_id) ⇒ String
GET /traces/:trace_id/proof/pdf — Download proof bundle as PDF.
-
#seal(trace_id) ⇒ Hash
POST /traces/:trace_id/seal — Seal a trace (async, 202).
Constructor Details
#initialize(http) ⇒ Traces
Returns a new instance of Traces.
8 9 10 |
# File 'lib/invoance/resources/traces.rb', line 8 def initialize(http) @http = http end |
Instance Method Details
#create(label:, metadata: nil) ⇒ Hash
POST /traces — Create a new trace.
14 15 16 17 18 |
# File 'lib/invoance/resources/traces.rb', line 14 def create(label:, metadata: nil) body = { "label" => label } body["metadata"] = if @http.post("/traces", body) end |
#delete(trace_id) ⇒ Hash
DELETE /traces/:trace_id — Delete an empty open trace.
37 38 39 |
# File 'lib/invoance/resources/traces.rb', line 37 def delete(trace_id) @http.delete("/traces/#{trace_id}") end |
#get(trace_id, event_page: nil, event_limit: nil) ⇒ Hash
GET /traces/:trace_id — Trace detail with paginated events.
28 29 30 31 32 33 |
# File 'lib/invoance/resources/traces.rb', line 28 def get(trace_id, event_page: nil, event_limit: nil) @http.get("/traces/#{trace_id}", { "event_page" => event_page, "event_limit" => event_limit }) end |
#list(page: nil, limit: nil, status: nil) ⇒ Hash
GET /traces — Paginated trace listing. status in open|sealed.
22 23 24 |
# File 'lib/invoance/resources/traces.rb', line 22 def list(page: nil, limit: nil, status: nil) @http.get("/traces", { "page" => page, "limit" => limit, "status" => status }) end |
#proof(trace_id) ⇒ Hash
GET /traces/:trace_id/proof — Export proof bundle as JSON.
49 50 51 |
# File 'lib/invoance/resources/traces.rb', line 49 def proof(trace_id) @http.get("/traces/#{trace_id}/proof") end |
#proof_pdf(trace_id) ⇒ String
GET /traces/:trace_id/proof/pdf — Download proof bundle as PDF.
55 56 57 |
# File 'lib/invoance/resources/traces.rb', line 55 def proof_pdf(trace_id) @http.get_bytes("/traces/#{trace_id}/proof/pdf") end |
#seal(trace_id) ⇒ Hash
POST /traces/:trace_id/seal — Seal a trace (async, 202).
43 44 45 |
# File 'lib/invoance/resources/traces.rb', line 43 def seal(trace_id) @http.post("/traces/#{trace_id}/seal", {}) end |