Class: Smplkit::Management::RunsNamespace

Inherits:
Object
  • Object
show all
Defined in:
lib/smplkit/management/jobs.rb

Overview

mgmt.jobs.runs.* — read-only run history plus the cancel / rerun run actions.

Instance Method Summary collapse

Constructor Details

#initialize(api) ⇒ RunsNamespace

Returns a new instance of RunsNamespace.



176
177
178
# File 'lib/smplkit/management/jobs.rb', line 176

def initialize(api)
  @api = api
end

Instance Method Details

#cancel(run_id) ⇒ Smplkit::Jobs::Run

Cancel a pending run.

Parameters:

  • run_id (String)

Returns:



211
212
213
214
# File 'lib/smplkit/management/jobs.rb', line 211

def cancel(run_id)
  resp = Smplkit::Jobs.call_api { @api.cancel_run(run_id) }
  Smplkit::Jobs::Run.from_resource(resp.data)
end

#get(run_id) ⇒ Smplkit::Jobs::Run

Fetch a single run by id.

Parameters:

  • run_id (String)

Returns:



202
203
204
205
# File 'lib/smplkit/management/jobs.rb', line 202

def get(run_id)
  resp = Smplkit::Jobs.call_api { @api.get_run(run_id) }
  Smplkit::Jobs::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.

Parameters:

  • job (String, nil) (defaults to: nil)

    Filter to a single job’s run history, by job id.

  • page_size (Integer, nil) (defaults to: nil)

    Items per page (cursor pagination).

  • after (String, nil) (defaults to: nil)

    Opaque cursor token from a prior page.

Returns:



188
189
190
191
192
193
194
195
196
# File 'lib/smplkit/management/jobs.rb', line 188

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 = Smplkit::Jobs.call_api { @api.list_runs(opts) }
  (resp.data || []).map { |r| Smplkit::Jobs::Run.from_resource(r) }
end

#rerun(run_id) ⇒ Smplkit::Jobs::Run

Re-run a prior run, spawning a new RERUN run.

Parameters:

  • run_id (String)

Returns:



220
221
222
223
# File 'lib/smplkit/management/jobs.rb', line 220

def rerun(run_id)
  resp = Smplkit::Jobs.call_api { @api.rerun_run(run_id) }
  Smplkit::Jobs::Run.from_resource(resp.data)
end