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 run that has not finished yet.
-
#get(run_id) ⇒ Smplkit::Jobs::Run
Fetch a single run by its id.
-
#initialize(api, environment: nil) ⇒ RunsClient
constructor
A new instance of RunsClient.
-
#list(job: nil, environments: nil, page_size: nil, after: nil) ⇒ Array<Smplkit::Jobs::Run>
List past runs, most recent first.
-
#rerun(run_id) ⇒ Smplkit::Jobs::Run
Start a new run that repeats a previous one.
Constructor Details
#initialize(api, environment: nil) ⇒ RunsClient
Returns a new instance of RunsClient.
32 33 34 35 |
# File 'lib/smplkit/jobs/client.rb', line 32 def initialize(api, environment: nil) @api = api @environment = environment end |
Instance Method Details
#cancel(run_id) ⇒ Smplkit::Jobs::Run
Cancel a run that has not finished yet.
78 79 80 81 |
# File 'lib/smplkit/jobs/client.rb', line 78 def cancel(run_id) resp = Jobs.call_api { @api.cancel_run(run_id) } Run.from_resource(resp.data, runs: self) end |
#get(run_id) ⇒ Smplkit::Jobs::Run
Fetch a single run by its id.
69 70 71 72 |
# File 'lib/smplkit/jobs/client.rb', line 69 def get(run_id) resp = Jobs.call_api { @api.get_run(run_id) } Run.from_resource(resp.data, runs: self) end |
#list(job: nil, environments: nil, page_size: nil, after: nil) ⇒ Array<Smplkit::Jobs::Run>
List past runs, most recent first. Cursor paginated: pass page_size and the after cursor from the prior page. Pass job to scope to a single job’s history.
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/smplkit/jobs/client.rb', line 52 def list(job: nil, environments: nil, page_size: nil, after: nil) opts = {} opts[:filter_job] = job unless job.nil? filter_environment = Jobs.resolve_environment_filter(environments, @environment) opts[:filter_environment] = filter_environment unless filter_environment.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, runs: self) } end |
#rerun(run_id) ⇒ Smplkit::Jobs::Run
Start a new run that repeats a previous one.
88 89 90 91 |
# File 'lib/smplkit/jobs/client.rb', line 88 def rerun(run_id) resp = Jobs.call_api { @api.rerun_run(run_id) } Run.from_resource(resp.data, runs: self) end |