Module: Smplkit::Jobs
- Defined in:
- lib/smplkit/jobs/models.rb,
lib/smplkit/jobs/client.rb
Overview
Smpl Jobs surface — exposed through client.jobs.*.
Unlike Config/Flags/Logging, Jobs has no live “phone-home” agent — no environment registration, no WebSocket — so its entire surface lives on a single client. A Job is an active record: build it with client.jobs.new(…), set fields, and call Job#save (create when new, full-replace update when it already exists) or Job#delete. Runs are read-only views; run actions live on client.jobs.runs.
Defined Under Namespace
Modules: HttpMethod Classes: HttpConfig, HttpHeader, Job, JobsClient, Run, RunsClient, Usage
Class Method Summary collapse
-
.call_api ⇒ Object
Wrap a generated-jobs-API call and translate
ApiErrorinto theSmplkit::Errorhierarchy. -
.jobs_transport(api_key:, profile:, base_domain:, scheme:, debug:, extra_headers:) ⇒ Object
The Smpl Jobs client — accessed via
client.jobs.
Class Method Details
.call_api ⇒ Object
Wrap a generated-jobs-API call and translate ApiError into the Smplkit::Error hierarchy. Connection-level failures (no response code) become ConnectionError; status-coded failures route through Errors.raise_for_status, which emits PaymentRequiredError / NotFoundError / ConflictError / ValidationError / Error depending on the JSON:API body.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/smplkit/jobs/models.rb', line 19 def self.call_api yield rescue SmplkitGeneratedClient::Jobs::ApiError => e raise Smplkit::ConnectionError, e..to_s if e.code.nil? || e.code.zero? Smplkit::Errors.raise_for_status(e.code, e.response_body.to_s) # raise_for_status only returns on 2xx; if we get here the generated # layer raised on a 2xx (shouldn't happen) — re-raise the original so # the caller can inspect. raise end |
.jobs_transport(api_key:, profile:, base_domain:, scheme:, debug:, extra_headers:) ⇒ Object
The Smpl Jobs client — accessed via client.jobs.
Unlike Config/Flags/Logging, Jobs has no live “phone-home” agent — no environment registration, no WebSocket — so its entire surface lives on one client. Defining a job, triggering a run, and reading run history are all plain request/response calls here:
client.jobs.{new,get,list,delete,run,usage}
client.jobs.runs.{list,get,cancel,rerun}
Job#{save,delete}
Build a standalone Smpl Jobs transport from resolved config.
Reuses the config resolver (jobs is account-global and never environment-scoped) so a standalone jobs client resolves credentials/base-domain from ~/.smplkit / env vars / constructor args exactly like the top-level clients do. Smpl Jobs is JSON:API, so the transport carries the application/vnd.apijson+ Accept header.
95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/smplkit/jobs/client.rb', line 95 def self.jobs_transport(api_key:, profile:, base_domain:, scheme:, debug:, extra_headers:) cfg = ConfigResolution.resolve_client_config( profile: profile, api_key: api_key, base_domain: base_domain, scheme: scheme, debug: debug ) merged = {} merged.merge!(cfg.extra_headers || {}) merged.merge!(extra_headers || {}) tcfg = ConfigResolution::ResolvedClientConfig.new( api_key: cfg.api_key, base_domain: cfg.base_domain, scheme: cfg.scheme, debug: cfg.debug, extra_headers: merged ) Transport.build_api_client(SmplkitGeneratedClient::Jobs, "jobs", tcfg, accept: "application/vnd.api+json") end |