Class: Smplkit::Jobs::RunsClient
- Inherits:
-
Object
- Object
- Smplkit::Jobs::RunsClient
- Defined in:
- lib/smplkit/jobs/client.rb
Overview
client.jobs.runs.* — read-only run history plus the cancel / rerun run actions.
Instance Method Summary collapse
-
#cancel(run_id) ⇒ Smplkit::Jobs::Run
Cancel a pending run.
-
#get(run_id) ⇒ Smplkit::Jobs::Run
Fetch a single run by id.
-
#initialize(api) ⇒ RunsClient
constructor
A new instance of RunsClient.
-
#list(job: nil, page_size: nil, after: nil) ⇒ Array<Smplkit::Jobs::Run>
List runs for the authenticated account, newest first.
-
#rerun(run_id) ⇒ Smplkit::Jobs::Run
Re-run a prior run, spawning a new
RERUNrun.
Constructor Details
#initialize(api) ⇒ RunsClient
Returns a new instance of RunsClient.
22 23 24 |
# File 'lib/smplkit/jobs/client.rb', line 22 def initialize(api) @api = api end |
Instance Method Details
#cancel(run_id) ⇒ Smplkit::Jobs::Run
Cancel a pending run.
57 58 59 60 |
# File 'lib/smplkit/jobs/client.rb', line 57 def cancel(run_id) resp = Jobs.call_api { @api.cancel_run(run_id) } Run.from_resource(resp.data) end |
#get(run_id) ⇒ Smplkit::Jobs::Run
Fetch a single run by id.
48 49 50 51 |
# File 'lib/smplkit/jobs/client.rb', line 48 def get(run_id) resp = Jobs.call_api { @api.get_run(run_id) } Run.from_resource(resp.data) end |
#list(job: nil, page_size: nil, after: nil) ⇒ Array<Smplkit::Jobs::Run>
List runs for the authenticated account, newest first. Cursor paginated (ADR-014): pass page_size and the after cursor from the prior page. Pass job to scope to a single job’s history.
34 35 36 37 38 39 40 41 42 |
# File 'lib/smplkit/jobs/client.rb', line 34 def list(job: nil, page_size: nil, after: nil) opts = {} opts[:filter_job] = job unless job.nil? opts[:page_size] = page_size unless page_size.nil? opts[:page_after] = after unless after.nil? resp = Jobs.call_api { @api.list_runs(opts) } (resp.data || []).map { |r| Run.from_resource(r) } end |
#rerun(run_id) ⇒ Smplkit::Jobs::Run
Re-run a prior run, spawning a new RERUN run.
66 67 68 69 |
# File 'lib/smplkit/jobs/client.rb', line 66 def rerun(run_id) resp = Jobs.call_api { @api.rerun_run(run_id) } Run.from_resource(resp.data) end |