smplkit 3.0.112 → 3.0.114

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e838dad6d55b34ff943e6098ef70867585eaacfdf3598bbebdfaa04c41243be
4
- data.tar.gz: bb246e8ac29688fc37d4ebc687d31a1231a2be1eb0625c18e453a31e4ea4a0e2
3
+ metadata.gz: ac8fe2c97dbe9e809353ffa9240572f0b8121322dce79d599308dba14bf89654
4
+ data.tar.gz: '04689fee543ee875c6d8b0ba68ed3cbd67242a490bee6ed3dafd5b33e030348e'
5
5
  SHA512:
6
- metadata.gz: b0b3291a8c8f129f16b36f0e271c6c9519c0ac6f4a40bf3b391501c512c22e069e6500c60e95b3c03ea9c0211af2f6b5a0c227f84a3b161c64e5803b4e378024
7
- data.tar.gz: d9c58b7d15d2b49810ffd56a2d900ff9c17dd9818ad6176baae8178ad1957107b610efc375951b0f43b18ea652681eb14d32147da000a3af62932d084db9af11
6
+ metadata.gz: 1f26e6bec44ef6259a7d384ce5cd80c99eba77116a73bd22c3be814fcf683712a6a8b2fd1774e3a0e76cfe58bf28fc0184edcd91266ce3b453db60dd1a6e7fea
7
+ data.tar.gz: bee0e18d7f5d8f4b9bbe64085da2782888ecd82fff072c92d4f81c4379c27f21dfc82643d26261d7a7c0af809b58d112239ae12e840c11b989331dd22317fd29
@@ -20,7 +20,7 @@ module SmplkitGeneratedClient::Jobs
20
20
  @api_client = api_client
21
21
  end
22
22
  # Create Job
23
- # Create a job for this account. The caller supplies the job's id as `data.id`. Ids are unique within an account and immutable. A recurring job supplies `environments` to choose where it runs and begins scheduling immediately in each enabled environment. A one-off job is created in the environment named by the `X-Smplkit-Environment` header (implied when the credential is scoped to a single environment).
23
+ # Create a job for this account. The caller supplies the job's id as `data.id`. Ids are unique within an account and immutable. The job's kind follows from its `schedule`: omit the schedule for a permanent **manual** job (triggered on demand), give a cron expression for a **recurring** job, or a datetime / `now` for a **one-off** job. A recurring or manual job supplies `environments` to choose where it runs; a recurring job begins scheduling immediately in each enabled environment. A one-off job is created in the environment named by the `X-Smplkit-Environment` header (implied when the credential is scoped to a single environment); a `now` one-off enqueues its single run immediately.
24
24
  # @param job_create_request [JobCreateRequest]
25
25
  # @param [Hash] opts the optional parameters
26
26
  # @option opts [String] :x_smplkit_environment The environment to operate in. Names the single environment a one-off job is born in (or a manual run executes in). Optional when the credential is scoped to a single environment (which is then implied); required when the credential can reach several environments and the choice is otherwise ambiguous. Ignored for a recurring job, whose environments come from its `environments` map.
@@ -31,7 +31,7 @@ module SmplkitGeneratedClient::Jobs
31
31
  end
32
32
 
33
33
  # Create Job
34
- # Create a job for this account. The caller supplies the job's id as `data.id`. Ids are unique within an account and immutable. A recurring job supplies `environments` to choose where it runs and begins scheduling immediately in each enabled environment. A one-off job is created in the environment named by the `X-Smplkit-Environment` header (implied when the credential is scoped to a single environment).
34
+ # Create a job for this account. The caller supplies the job's id as `data.id`. Ids are unique within an account and immutable. The job's kind follows from its `schedule`: omit the schedule for a permanent **manual** job (triggered on demand), give a cron expression for a **recurring** job, or a datetime / `now` for a **one-off** job. A recurring or manual job supplies `environments` to choose where it runs; a recurring job begins scheduling immediately in each enabled environment. A one-off job is created in the environment named by the `X-Smplkit-Environment` header (implied when the credential is scoped to a single environment); a `now` one-off enqueues its single run immediately.
35
35
  # @param job_create_request [JobCreateRequest]
36
36
  # @param [Hash] opts the optional parameters
37
37
  # @option opts [String] :x_smplkit_environment The environment to operate in. Names the single environment a one-off job is born in (or a manual run executes in). Optional when the credential is scoped to a single environment (which is then implied); required when the credential can reach several environments and the choice is otherwise ambiguous. Ignored for a recurring job, whose environments come from its `environments` map.
@@ -215,12 +215,12 @@ module SmplkitGeneratedClient::Jobs
215
215
  end
216
216
 
217
217
  # List Jobs
218
- # List this account's jobs. Default sort is `name` ascending. Sort by `name`, `created_at`, `updated_at`, `next_run_at`, or `enabled`, ascending or descending (prefix `-` for descending). Filter with `filter[enabled]` (enabled in at least one environment), `filter[recurring]`, and `filter[name]` (case-insensitive substring match on the name); filters compose with AND. A scoped caller sees each job's `environments` map narrowed to the environments it may access.
218
+ # List this account's jobs. Default sort is `name` ascending. Sort by `name`, `created_at`, or `updated_at`, ascending or descending (prefix `-` for descending). By default the list omits transient one-off jobs (request `filter[kind]=one_off` to see them). Filter with `filter[kind]` (`recurring` / `manual` / `one_off`), `filter[scheduled]` (jobs with an upcoming fire in some environment — the feed for an upcoming-runs view, which includes one-offs), and `filter[name]` (case-insensitive substring); filters compose with AND. Each job reports its per-environment enablement and `next_run_at` inside its `environments` map; a scoped caller sees that map narrowed to the environments it may access.
219
219
  # @param [Hash] opts the optional parameters
220
- # @option opts [Boolean] :filter_enabled
221
- # @option opts [Boolean] :filter_recurring
220
+ # @option opts [String] :filter_kind Restrict to a single job kind: `recurring`, `manual`, or `one_off`. By default one-off jobs are omitted (they are transient and short-lived); request `filter[kind]=one_off` to list them.
221
+ # @option opts [Boolean] :filter_scheduled When `true`, list only jobs that have an upcoming fire in at least one environment (a recurring job's next occurrence, or a pending future one-off) — the feed for an upcoming-runs view; this includes one-off jobs. When `false`, list only jobs with no upcoming fire.
222
222
  # @option opts [String] :filter_name Case-insensitive substring match on the job `name` (matches when the name contains the given text).
223
- # @option opts [String] :sort Field to sort by. Prefix with `-` for descending order. Default: `name`. Allowed values: `created_at`, `-created_at`, `enabled`, `-enabled`, `name`, `-name`, `next_run_at`, `-next_run_at`, `updated_at`, `-updated_at`. (default to 'name')
223
+ # @option opts [String] :sort Field to sort by. Prefix with `-` for descending order. Default: `name`. Allowed values: `created_at`, `-created_at`, `name`, `-name`, `updated_at`, `-updated_at`. (default to 'name')
224
224
  # @option opts [Integer] :page_number 1-based page number to return. Optional; defaults to `1` when omitted. Must be `>= 1` — requests with a smaller value are rejected with a 400 error. (default to 1)
225
225
  # @option opts [Integer] :page_size Number of items per page. Optional; defaults to `1000` when omitted. Must be between `1` and `1000` inclusive — requests outside that range are rejected with a 400 error. (default to 1000)
226
226
  # @option opts [Boolean] :meta_total When `true`, the response's `meta.pagination` block includes `total` (the total number of matching items across all pages) and `total_pages`. Computing these requires an extra `COUNT` query, so omit (or pass `false`) when the totals are not needed. Defaults to `false`. (default to false)
@@ -231,12 +231,12 @@ module SmplkitGeneratedClient::Jobs
231
231
  end
232
232
 
233
233
  # List Jobs
234
- # List this account's jobs. Default sort is `name` ascending. Sort by `name`, `created_at`, `updated_at`, `next_run_at`, or `enabled`, ascending or descending (prefix `-` for descending). Filter with `filter[enabled]` (enabled in at least one environment), `filter[recurring]`, and `filter[name]` (case-insensitive substring match on the name); filters compose with AND. A scoped caller sees each job's `environments` map narrowed to the environments it may access.
234
+ # List this account's jobs. Default sort is `name` ascending. Sort by `name`, `created_at`, or `updated_at`, ascending or descending (prefix `-` for descending). By default the list omits transient one-off jobs (request `filter[kind]=one_off` to see them). Filter with `filter[kind]` (`recurring` / `manual` / `one_off`), `filter[scheduled]` (jobs with an upcoming fire in some environment — the feed for an upcoming-runs view, which includes one-offs), and `filter[name]` (case-insensitive substring); filters compose with AND. Each job reports its per-environment enablement and `next_run_at` inside its `environments` map; a scoped caller sees that map narrowed to the environments it may access.
235
235
  # @param [Hash] opts the optional parameters
236
- # @option opts [Boolean] :filter_enabled
237
- # @option opts [Boolean] :filter_recurring
236
+ # @option opts [String] :filter_kind Restrict to a single job kind: `recurring`, `manual`, or `one_off`. By default one-off jobs are omitted (they are transient and short-lived); request `filter[kind]=one_off` to list them.
237
+ # @option opts [Boolean] :filter_scheduled When `true`, list only jobs that have an upcoming fire in at least one environment (a recurring job's next occurrence, or a pending future one-off) — the feed for an upcoming-runs view; this includes one-off jobs. When `false`, list only jobs with no upcoming fire.
238
238
  # @option opts [String] :filter_name Case-insensitive substring match on the job `name` (matches when the name contains the given text).
239
- # @option opts [String] :sort Field to sort by. Prefix with `-` for descending order. Default: `name`. Allowed values: `created_at`, `-created_at`, `enabled`, `-enabled`, `name`, `-name`, `next_run_at`, `-next_run_at`, `updated_at`, `-updated_at`. (default to 'name')
239
+ # @option opts [String] :sort Field to sort by. Prefix with `-` for descending order. Default: `name`. Allowed values: `created_at`, `-created_at`, `name`, `-name`, `updated_at`, `-updated_at`. (default to 'name')
240
240
  # @option opts [Integer] :page_number 1-based page number to return. Optional; defaults to `1` when omitted. Must be `>= 1` — requests with a smaller value are rejected with a 400 error. (default to 1)
241
241
  # @option opts [Integer] :page_size Number of items per page. Optional; defaults to `1000` when omitted. Must be between `1` and `1000` inclusive — requests outside that range are rejected with a 400 error. (default to 1000)
242
242
  # @option opts [Boolean] :meta_total When `true`, the response's `meta.pagination` block includes `total` (the total number of matching items across all pages) and `total_pages`. Computing these requires an extra `COUNT` query, so omit (or pass `false`) when the totals are not needed. Defaults to `false`. (default to false)
@@ -245,7 +245,7 @@ module SmplkitGeneratedClient::Jobs
245
245
  if @api_client.config.debugging
246
246
  @api_client.config.logger.debug 'Calling API: JobsApi.list_jobs ...'
247
247
  end
248
- allowable_values = ["created_at", "-created_at", "enabled", "-enabled", "name", "-name", "next_run_at", "-next_run_at", "updated_at", "-updated_at"]
248
+ allowable_values = ["created_at", "-created_at", "name", "-name", "updated_at", "-updated_at"]
249
249
  if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])
250
250
  fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}"
251
251
  end
@@ -254,8 +254,8 @@ module SmplkitGeneratedClient::Jobs
254
254
 
255
255
  # query parameters
256
256
  query_params = opts[:query_params] || {}
257
- query_params[:'filter[enabled]'] = opts[:'filter_enabled'] if !opts[:'filter_enabled'].nil?
258
- query_params[:'filter[recurring]'] = opts[:'filter_recurring'] if !opts[:'filter_recurring'].nil?
257
+ query_params[:'filter[kind]'] = opts[:'filter_kind'] if !opts[:'filter_kind'].nil?
258
+ query_params[:'filter[scheduled]'] = opts[:'filter_scheduled'] if !opts[:'filter_scheduled'].nil?
259
259
  query_params[:'filter[name]'] = opts[:'filter_name'] if !opts[:'filter_name'].nil?
260
260
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
261
261
  query_params[:'page[number]'] = opts[:'page_number'] if !opts[:'page_number'].nil?
@@ -297,7 +297,7 @@ module SmplkitGeneratedClient::Jobs
297
297
  end
298
298
 
299
299
  # Run Job Now
300
- # Trigger one immediate run of the job (a `MANUAL` run). The job's schedule and enabled state are untouched. The run executes in the environment named by the `X-Smplkit-Environment` header; when the job is enabled in exactly one environment that environment is used, and a single-environment credential implies it. The run executes the job's effective configuration for that environment. It is enqueued and executed by the worker; if the account is over its run allotment the run will fail with reason `QUOTA_EXCEEDED` rather than being rejected here.
300
+ # Trigger one immediate run of the job in a specified environment (a `MANUAL` run). This is the primary execution path for a manual job and is also usable ad hoc for a recurring job (\"run now\"). The job's schedule and enabled state are untouched. The run executes in the environment named by the `X-Smplkit-Environment` header; when the job is enabled in exactly one environment that environment is used, and a single-environment credential implies it. The environment must be one the job is **enabled** in (409 otherwise). The run executes the job's effective configuration for that environment. It is enqueued and executed by the worker; if the account is over its run allotment the run will fail with reason `QUOTA_EXCEEDED` rather than being rejected here.
301
301
  # @param job_id [String]
302
302
  # @param [Hash] opts the optional parameters
303
303
  # @option opts [String] :x_smplkit_environment The environment to operate in. Names the single environment a one-off job is born in (or a manual run executes in). Optional when the credential is scoped to a single environment (which is then implied); required when the credential can reach several environments and the choice is otherwise ambiguous. Ignored for a recurring job, whose environments come from its `environments` map.
@@ -308,7 +308,7 @@ module SmplkitGeneratedClient::Jobs
308
308
  end
309
309
 
310
310
  # Run Job Now
311
- # Trigger one immediate run of the job (a `MANUAL` run). The job's schedule and enabled state are untouched. The run executes in the environment named by the `X-Smplkit-Environment` header; when the job is enabled in exactly one environment that environment is used, and a single-environment credential implies it. The run executes the job's effective configuration for that environment. It is enqueued and executed by the worker; if the account is over its run allotment the run will fail with reason `QUOTA_EXCEEDED` rather than being rejected here.
311
+ # Trigger one immediate run of the job in a specified environment (a `MANUAL` run). This is the primary execution path for a manual job and is also usable ad hoc for a recurring job (\"run now\"). The job's schedule and enabled state are untouched. The run executes in the environment named by the `X-Smplkit-Environment` header; when the job is enabled in exactly one environment that environment is used, and a single-environment credential implies it. The environment must be one the job is **enabled** in (409 otherwise). The run executes the job's effective configuration for that environment. It is enqueued and executed by the worker; if the account is over its run allotment the run will fail with reason `QUOTA_EXCEEDED` rather than being rejected here.
312
312
  # @param job_id [String]
313
313
  # @param [Hash] opts the optional parameters
314
314
  # @option opts [String] :x_smplkit_environment The environment to operate in. Names the single environment a one-off job is born in (or a manual run executes in). Optional when the credential is scoped to a single environment (which is then implied); required when the credential can reach several environments and the choice is otherwise ambiguous. Ignored for a recurring job, whose environments come from its `environments` map.
@@ -363,7 +363,7 @@ module SmplkitGeneratedClient::Jobs
363
363
  end
364
364
 
365
365
  # Update Job
366
- # Replace an existing job. Every writable field is overwritten. Set enablement per environment via the `environments` map (a recurring job), or by recreating a one-off job in the desired environment. Editing the schedule recomputes the next fire time; changing only which environments are enabled preserves the existing cadence.
366
+ # Replace an existing job. Every writable field is overwritten. The job's kind is re-derived from the new `schedule` (omit it for a manual job). Set enablement per environment via the `environments` map (a recurring or manual job), or by recreating a one-off job in the desired environment. Each environment may carry its own cron `schedule` override (recurring jobs only). Editing a recurring environment's effective schedule recomputes its next fire time; an edit that leaves it unchanged preserves the existing cadence.
367
367
  # @param job_id [String]
368
368
  # @param job_request [JobRequest]
369
369
  # @param [Hash] opts the optional parameters
@@ -375,7 +375,7 @@ module SmplkitGeneratedClient::Jobs
375
375
  end
376
376
 
377
377
  # Update Job
378
- # Replace an existing job. Every writable field is overwritten. Set enablement per environment via the `environments` map (a recurring job), or by recreating a one-off job in the desired environment. Editing the schedule recomputes the next fire time; changing only which environments are enabled preserves the existing cadence.
378
+ # Replace an existing job. Every writable field is overwritten. The job's kind is re-derived from the new `schedule` (omit it for a manual job). Set enablement per environment via the `environments` map (a recurring or manual job), or by recreating a one-off job in the desired environment. Each environment may carry its own cron `schedule` override (recurring jobs only). Editing a recurring environment's effective schedule recomputes its next fire time; an edit that leaves it unchanged preserves the existing cadence.
379
379
  # @param job_id [String]
380
380
  # @param job_request [JobRequest]
381
381
  # @param [Hash] opts the optional parameters
@@ -20,7 +20,7 @@ module SmplkitGeneratedClient::Jobs
20
20
  @api_client = api_client
21
21
  end
22
22
  # Get Usage
23
- # Report this account's current-period usage against its plan allotments. `runs_used` is the number of runs metered so far this calendar month; `active_jobs` is the number of currently-enabled jobs.
23
+ # Report this account's current-period usage against its plan allotments. `runs_used` is the number of runs metered so far this calendar month; `active_jobs` is the number of permanent jobs (recurring + manual), which is what the plan's job limit bounds (one-off jobs do not count).
24
24
  # @param [Hash] opts the optional parameters
25
25
  # @option opts [String] :filter_period (default to 'current')
26
26
  # @return [UsageResponse]
@@ -30,7 +30,7 @@ module SmplkitGeneratedClient::Jobs
30
30
  end
31
31
 
32
32
  # Get Usage
33
- # Report this account's current-period usage against its plan allotments. `runs_used` is the number of runs metered so far this calendar month; `active_jobs` is the number of currently-enabled jobs.
33
+ # Report this account's current-period usage against its plan allotments. `runs_used` is the number of runs metered so far this calendar month; `active_jobs` is the number of permanent jobs (recurring + manual), which is what the plan's job limit bounds (one-off jobs do not count).
34
34
  # @param [Hash] opts the optional parameters
35
35
  # @option opts [String] :filter_period (default to 'current')
36
36
  # @return [Array<(UsageResponse, Integer, Hash)>] UsageResponse data, response status code and response headers
@@ -14,7 +14,7 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module SmplkitGeneratedClient::Jobs
17
- # A scheduled unit of work: an HTTP request run on a schedule. The job is the definition; each time it fires the service records a run capturing the request, response, timing, and outcome. A job is enabled per environment: set `environments[<env>].enabled` to schedule runs there. A recurring (cron) job may be enabled in several environments at once and fires once per enabled environment; a one-off (`now` or future datetime) job runs a single time in the environment it was created in.
17
+ # A unit of work: an HTTP request, run on a schedule or triggered on demand. The job is the definition; each time it fires the service records a run capturing the request, response, timing, and outcome. A job runs per environment: set `environments[<env>].enabled` to enable it there, and optionally give that environment its own `schedule` or `configuration`. A job's `kind` follows from its `schedule`: a **recurring** (cron) job may be enabled in several environments at once and fires once per enabled environment, each on its own next-fire schedule; a **manual** job (no schedule) is permanent and never auto-fires — it runs only when triggered; a **one-off** (`now` or a future datetime) job runs a single time in the environment it was created in and is then spent.
18
18
  class Job < ApiModelBase
19
19
  # Human-readable name for the job.
20
20
  attr_accessor :name
@@ -22,29 +22,23 @@ module SmplkitGeneratedClient::Jobs
22
22
  # Free-text description for the job.
23
23
  attr_accessor :description
24
24
 
25
- # Whether the job is enabled in at least one environment. Read-only roll-up of `environments[*].enabled`; set enablement per environment via `environments`.
26
- attr_accessor :enabled
27
-
28
25
  # Job type. Only `http` is supported today.
29
26
  attr_accessor :type
30
27
 
31
- # When the job runs. One of: an ISO-8601 datetime (a one-off run at that instant), a 5-field cron expression evaluated in **UTC** (recurring), or the literal `now` (run once, as soon as possible). A datetime or `now` job disables itself after it fires.
28
+ # The base schedule every environment inherits unless it overrides it, and the field that determines the job's `kind`. Omit it (or send `null`) to create a permanent **manual** job that never auto-fires and runs only when triggered. Provide a 5-field cron expression evaluated in **UTC** for a **recurring** job, an ISO-8601 datetime for a **one-off** run at that instant, or the literal `now` for a one-off run as soon as possible. A datetime or `now` job disables itself after it fires.
32
29
  attr_accessor :schedule
33
30
 
34
31
  # The HTTP request to perform, including method, url, headers, body, and timeout.
35
32
  attr_accessor :configuration
36
33
 
37
- # Per-environment overrides keyed by environment key (e.g. `production`, `staging`). Each entry sets `enabled` (whether the job schedules runs in that environment) and an optional `configuration` override (omit to inherit the base `configuration`). A job with no entry for an environment is disabled there. For a recurring job, supply this map to choose where it runs. For a one-off job, the environment it is created in is recorded here automatically — name it with the `X-Smplkit-Environment` header. Every referenced environment must exist for the account.
34
+ # Per-environment overrides keyed by environment key (e.g. `production`, `staging`). Each entry sets `enabled` (whether the job is enabled — scheduled, for a recurring job, or triggerable, for a manual job — in that environment), an optional `schedule` override (a cron expression for recurring jobs; omit to inherit the base `schedule`), and an optional `configuration` override (omit to inherit the base `configuration`); it also reports the read-only `next_run_at` for that environment. A job with no entry for an environment is disabled there. For a recurring or manual job, supply this map to choose where it runs. For a one-off job, the environment it is created in is recorded here automatically — name it with the `X-Smplkit-Environment` header. Every referenced environment must exist for the account.
38
35
  attr_accessor :environments
39
36
 
40
37
  # How overlapping runs are handled. `ALLOW` (the only value today) permits them.
41
38
  attr_accessor :concurrency_policy
42
39
 
43
- # The next scheduled fire time. `null` once a one-off job has fired.
44
- attr_accessor :next_run_at
45
-
46
- # Whether the job runs on a repeating schedule. `true` for a cron schedule; `false` for a one-off datetime or `now` schedule, which runs a single time. Derived from `schedule`.
47
- attr_accessor :recurring
40
+ # How the job runs, derived from its base `schedule`: `recurring` for a cron schedule (fires on a repeating cadence), `manual` for no schedule (never auto-fires; runs only when triggered), or `one_off` for a `now` or datetime schedule (runs a single time, then is spent).
41
+ attr_accessor :kind
48
42
 
49
43
  # When the job was created.
50
44
  attr_accessor :created_at
@@ -85,14 +79,12 @@ module SmplkitGeneratedClient::Jobs
85
79
  {
86
80
  :'name' => :'name',
87
81
  :'description' => :'description',
88
- :'enabled' => :'enabled',
89
82
  :'type' => :'type',
90
83
  :'schedule' => :'schedule',
91
84
  :'configuration' => :'configuration',
92
85
  :'environments' => :'environments',
93
86
  :'concurrency_policy' => :'concurrency_policy',
94
- :'next_run_at' => :'next_run_at',
95
- :'recurring' => :'recurring',
87
+ :'kind' => :'kind',
96
88
  :'created_at' => :'created_at',
97
89
  :'updated_at' => :'updated_at',
98
90
  :'deleted_at' => :'deleted_at',
@@ -115,14 +107,12 @@ module SmplkitGeneratedClient::Jobs
115
107
  {
116
108
  :'name' => :'String',
117
109
  :'description' => :'String',
118
- :'enabled' => :'Boolean',
119
110
  :'type' => :'String',
120
111
  :'schedule' => :'String',
121
112
  :'configuration' => :'JobHttpConfiguration',
122
113
  :'environments' => :'Hash<String, JobEnvironment>',
123
114
  :'concurrency_policy' => :'String',
124
- :'next_run_at' => :'Time',
125
- :'recurring' => :'Boolean',
115
+ :'kind' => :'String',
126
116
  :'created_at' => :'Time',
127
117
  :'updated_at' => :'Time',
128
118
  :'deleted_at' => :'Time',
@@ -134,9 +124,8 @@ module SmplkitGeneratedClient::Jobs
134
124
  def self.openapi_nullable
135
125
  Set.new([
136
126
  :'description',
137
- :'enabled',
138
- :'next_run_at',
139
- :'recurring',
127
+ :'schedule',
128
+ :'kind',
140
129
  :'created_at',
141
130
  :'updated_at',
142
131
  :'deleted_at',
@@ -170,10 +159,6 @@ module SmplkitGeneratedClient::Jobs
170
159
  self.description = attributes[:'description']
171
160
  end
172
161
 
173
- if attributes.key?(:'enabled')
174
- self.enabled = attributes[:'enabled']
175
- end
176
-
177
162
  if attributes.key?(:'type')
178
163
  self.type = attributes[:'type']
179
164
  else
@@ -182,8 +167,6 @@ module SmplkitGeneratedClient::Jobs
182
167
 
183
168
  if attributes.key?(:'schedule')
184
169
  self.schedule = attributes[:'schedule']
185
- else
186
- self.schedule = nil
187
170
  end
188
171
 
189
172
  if attributes.key?(:'configuration')
@@ -204,12 +187,8 @@ module SmplkitGeneratedClient::Jobs
204
187
  self.concurrency_policy = 'ALLOW'
205
188
  end
206
189
 
207
- if attributes.key?(:'next_run_at')
208
- self.next_run_at = attributes[:'next_run_at']
209
- end
210
-
211
- if attributes.key?(:'recurring')
212
- self.recurring = attributes[:'recurring']
190
+ if attributes.key?(:'kind')
191
+ self.kind = attributes[:'kind']
213
192
  end
214
193
 
215
194
  if attributes.key?(:'created_at')
@@ -250,10 +229,6 @@ module SmplkitGeneratedClient::Jobs
250
229
  invalid_properties.push('invalid value for "description", the character length must be smaller than or equal to 2000.')
251
230
  end
252
231
 
253
- if @schedule.nil?
254
- invalid_properties.push('invalid value for "schedule", schedule cannot be nil.')
255
- end
256
-
257
232
  if @configuration.nil?
258
233
  invalid_properties.push('invalid value for "configuration", configuration cannot be nil.')
259
234
  end
@@ -271,10 +246,11 @@ module SmplkitGeneratedClient::Jobs
271
246
  return false if !@description.nil? && @description.to_s.length > 2000
272
247
  type_validator = EnumAttributeValidator.new('String', ["http"])
273
248
  return false unless type_validator.valid?(@type)
274
- return false if @schedule.nil?
275
249
  return false if @configuration.nil?
276
250
  concurrency_policy_validator = EnumAttributeValidator.new('String', ["ALLOW"])
277
251
  return false unless concurrency_policy_validator.valid?(@concurrency_policy)
252
+ kind_validator = EnumAttributeValidator.new('String', ["recurring", "manual", "one_off"])
253
+ return false unless kind_validator.valid?(@kind)
278
254
  true
279
255
  end
280
256
 
@@ -316,16 +292,6 @@ module SmplkitGeneratedClient::Jobs
316
292
  @type = type
317
293
  end
318
294
 
319
- # Custom attribute writer method with validation
320
- # @param [Object] schedule Value to be assigned
321
- def schedule=(schedule)
322
- if schedule.nil?
323
- fail ArgumentError, 'schedule cannot be nil'
324
- end
325
-
326
- @schedule = schedule
327
- end
328
-
329
295
  # Custom attribute writer method with validation
330
296
  # @param [Object] configuration Value to be assigned
331
297
  def configuration=(configuration)
@@ -346,6 +312,16 @@ module SmplkitGeneratedClient::Jobs
346
312
  @concurrency_policy = concurrency_policy
347
313
  end
348
314
 
315
+ # Custom attribute writer method checking allowed values (enum).
316
+ # @param [Object] kind Object to be assigned
317
+ def kind=(kind)
318
+ validator = EnumAttributeValidator.new('String', ["recurring", "manual", "one_off"])
319
+ unless validator.valid?(kind)
320
+ fail ArgumentError, "invalid value for \"kind\", must be one of #{validator.allowable_values}."
321
+ end
322
+ @kind = kind
323
+ end
324
+
349
325
  # Checks equality by comparing each attribute.
350
326
  # @param [Object] Object to be compared
351
327
  def ==(o)
@@ -353,14 +329,12 @@ module SmplkitGeneratedClient::Jobs
353
329
  self.class == o.class &&
354
330
  name == o.name &&
355
331
  description == o.description &&
356
- enabled == o.enabled &&
357
332
  type == o.type &&
358
333
  schedule == o.schedule &&
359
334
  configuration == o.configuration &&
360
335
  environments == o.environments &&
361
336
  concurrency_policy == o.concurrency_policy &&
362
- next_run_at == o.next_run_at &&
363
- recurring == o.recurring &&
337
+ kind == o.kind &&
364
338
  created_at == o.created_at &&
365
339
  updated_at == o.updated_at &&
366
340
  deleted_at == o.deleted_at &&
@@ -376,7 +350,7 @@ module SmplkitGeneratedClient::Jobs
376
350
  # Calculates hash code according to all attributes.
377
351
  # @return [Integer] Hash code
378
352
  def hash
379
- [name, description, enabled, type, schedule, configuration, environments, concurrency_policy, next_run_at, recurring, created_at, updated_at, deleted_at, version].hash
353
+ [name, description, type, schedule, configuration, environments, concurrency_policy, kind, created_at, updated_at, deleted_at, version].hash
380
354
  end
381
355
 
382
356
  # Builds the object from hash
@@ -14,19 +14,27 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module SmplkitGeneratedClient::Jobs
17
- # Per-environment override for a job's enablement and configuration.
17
+ # Per-environment override for a job's enablement, schedule, and configuration.
18
18
  class JobEnvironment < ApiModelBase
19
19
  # Whether the job schedules runs in this environment. A job runs in an environment only via this field; it is disabled in every environment by default.
20
20
  attr_accessor :enabled
21
21
 
22
+ # Per-environment schedule override. Omit to inherit the job's base `schedule`. When present, it must be a 5-field cron expression evaluated in **UTC** (e.g. `0 3 * * *`), and is only allowed on a recurring (cron) job — it varies the cadence within that environment. It cannot appear on a manual or one-off job, and cannot change a job's kind.
23
+ attr_accessor :schedule
24
+
22
25
  # Per-environment HTTP request override. Omit to inherit the job's base `configuration`. When present, it fully replaces the base configuration for runs in this environment.
23
26
  attr_accessor :configuration
24
27
 
28
+ # The next scheduled fire time in this environment. `null` when the environment is not enabled, or once a one-off run has fired.
29
+ attr_accessor :next_run_at
30
+
25
31
  # Attribute mapping from ruby-style variable name to JSON key.
26
32
  def self.attribute_map
27
33
  {
28
34
  :'enabled' => :'enabled',
29
- :'configuration' => :'configuration'
35
+ :'schedule' => :'schedule',
36
+ :'configuration' => :'configuration',
37
+ :'next_run_at' => :'next_run_at'
30
38
  }
31
39
  end
32
40
 
@@ -44,14 +52,18 @@ module SmplkitGeneratedClient::Jobs
44
52
  def self.openapi_types
45
53
  {
46
54
  :'enabled' => :'Boolean',
47
- :'configuration' => :'JobHttpConfiguration'
55
+ :'schedule' => :'String',
56
+ :'configuration' => :'JobHttpConfiguration',
57
+ :'next_run_at' => :'Time'
48
58
  }
49
59
  end
50
60
 
51
61
  # List of attributes with nullable: true
52
62
  def self.openapi_nullable
53
63
  Set.new([
54
- :'configuration'
64
+ :'schedule',
65
+ :'configuration',
66
+ :'next_run_at'
55
67
  ])
56
68
  end
57
69
 
@@ -77,9 +89,17 @@ module SmplkitGeneratedClient::Jobs
77
89
  self.enabled = false
78
90
  end
79
91
 
92
+ if attributes.key?(:'schedule')
93
+ self.schedule = attributes[:'schedule']
94
+ end
95
+
80
96
  if attributes.key?(:'configuration')
81
97
  self.configuration = attributes[:'configuration']
82
98
  end
99
+
100
+ if attributes.key?(:'next_run_at')
101
+ self.next_run_at = attributes[:'next_run_at']
102
+ end
83
103
  end
84
104
 
85
105
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -103,7 +123,9 @@ module SmplkitGeneratedClient::Jobs
103
123
  return true if self.equal?(o)
104
124
  self.class == o.class &&
105
125
  enabled == o.enabled &&
106
- configuration == o.configuration
126
+ schedule == o.schedule &&
127
+ configuration == o.configuration &&
128
+ next_run_at == o.next_run_at
107
129
  end
108
130
 
109
131
  # @see the `==` method
@@ -115,7 +137,7 @@ module SmplkitGeneratedClient::Jobs
115
137
  # Calculates hash code according to all attributes.
116
138
  # @return [Integer] Hash code
117
139
  def hash
118
- [enabled, configuration].hash
140
+ [enabled, schedule, configuration, next_run_at].hash
119
141
  end
120
142
 
121
143
  # Builds the object from hash
@@ -25,10 +25,10 @@ module SmplkitGeneratedClient::Jobs
25
25
  # Runs included in the plan this period (`-1` means unlimited).
26
26
  attr_accessor :runs_included
27
27
 
28
- # Number of currently-enabled jobs.
28
+ # Number of permanent jobs (recurring and manual) counted against the plan's job limit.
29
29
  attr_accessor :active_jobs
30
30
 
31
- # Maximum enabled jobs the plan allows (`-1` means unlimited).
31
+ # Maximum permanent jobs the plan allows (`-1` means unlimited).
32
32
  attr_accessor :active_jobs_limit
33
33
 
34
34
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -34,7 +34,7 @@ describe 'JobsApi' do
34
34
 
35
35
  # unit tests for create_job
36
36
  # Create Job
37
- # Create a job for this account. The caller supplies the job&#39;s id as &#x60;data.id&#x60;. Ids are unique within an account and immutable. A recurring job supplies &#x60;environments&#x60; to choose where it runs and begins scheduling immediately in each enabled environment. A one-off job is created in the environment named by the &#x60;X-Smplkit-Environment&#x60; header (implied when the credential is scoped to a single environment).
37
+ # Create a job for this account. The caller supplies the job&#39;s id as &#x60;data.id&#x60;. Ids are unique within an account and immutable. The job&#39;s kind follows from its &#x60;schedule&#x60;: omit the schedule for a permanent **manual** job (triggered on demand), give a cron expression for a **recurring** job, or a datetime / &#x60;now&#x60; for a **one-off** job. A recurring or manual job supplies &#x60;environments&#x60; to choose where it runs; a recurring job begins scheduling immediately in each enabled environment. A one-off job is created in the environment named by the &#x60;X-Smplkit-Environment&#x60; header (implied when the credential is scoped to a single environment); a &#x60;now&#x60; one-off enqueues its single run immediately.
38
38
  # @param job_create_request
39
39
  # @param [Hash] opts the optional parameters
40
40
  # @option opts [String] :x_smplkit_environment The environment to operate in. Names the single environment a one-off job is born in (or a manual run executes in). Optional when the credential is scoped to a single environment (which is then implied); required when the credential can reach several environments and the choice is otherwise ambiguous. Ignored for a recurring job, whose environments come from its &#x60;environments&#x60; map.
@@ -71,12 +71,12 @@ describe 'JobsApi' do
71
71
 
72
72
  # unit tests for list_jobs
73
73
  # List Jobs
74
- # List this account&#39;s jobs. Default sort is &#x60;name&#x60; ascending. Sort by &#x60;name&#x60;, &#x60;created_at&#x60;, &#x60;updated_at&#x60;, &#x60;next_run_at&#x60;, or &#x60;enabled&#x60;, ascending or descending (prefix &#x60;-&#x60; for descending). Filter with &#x60;filter[enabled]&#x60; (enabled in at least one environment), &#x60;filter[recurring]&#x60;, and &#x60;filter[name]&#x60; (case-insensitive substring match on the name); filters compose with AND. A scoped caller sees each job&#39;s &#x60;environments&#x60; map narrowed to the environments it may access.
74
+ # List this account&#39;s jobs. Default sort is &#x60;name&#x60; ascending. Sort by &#x60;name&#x60;, &#x60;created_at&#x60;, or &#x60;updated_at&#x60;, ascending or descending (prefix &#x60;-&#x60; for descending). By default the list omits transient one-off jobs (request &#x60;filter[kind]&#x3D;one_off&#x60; to see them). Filter with &#x60;filter[kind]&#x60; (&#x60;recurring&#x60; / &#x60;manual&#x60; / &#x60;one_off&#x60;), &#x60;filter[scheduled]&#x60; (jobs with an upcoming fire in some environment — the feed for an upcoming-runs view, which includes one-offs), and &#x60;filter[name]&#x60; (case-insensitive substring); filters compose with AND. Each job reports its per-environment enablement and &#x60;next_run_at&#x60; inside its &#x60;environments&#x60; map; a scoped caller sees that map narrowed to the environments it may access.
75
75
  # @param [Hash] opts the optional parameters
76
- # @option opts [Boolean] :filter_enabled
77
- # @option opts [Boolean] :filter_recurring
76
+ # @option opts [String] :filter_kind Restrict to a single job kind: &#x60;recurring&#x60;, &#x60;manual&#x60;, or &#x60;one_off&#x60;. By default one-off jobs are omitted (they are transient and short-lived); request &#x60;filter[kind]&#x3D;one_off&#x60; to list them.
77
+ # @option opts [Boolean] :filter_scheduled When &#x60;true&#x60;, list only jobs that have an upcoming fire in at least one environment (a recurring job&#39;s next occurrence, or a pending future one-off) — the feed for an upcoming-runs view; this includes one-off jobs. When &#x60;false&#x60;, list only jobs with no upcoming fire.
78
78
  # @option opts [String] :filter_name Case-insensitive substring match on the job &#x60;name&#x60; (matches when the name contains the given text).
79
- # @option opts [String] :sort Field to sort by. Prefix with &#x60;-&#x60; for descending order. Default: &#x60;name&#x60;. Allowed values: &#x60;created_at&#x60;, &#x60;-created_at&#x60;, &#x60;enabled&#x60;, &#x60;-enabled&#x60;, &#x60;name&#x60;, &#x60;-name&#x60;, &#x60;next_run_at&#x60;, &#x60;-next_run_at&#x60;, &#x60;updated_at&#x60;, &#x60;-updated_at&#x60;.
79
+ # @option opts [String] :sort Field to sort by. Prefix with &#x60;-&#x60; for descending order. Default: &#x60;name&#x60;. Allowed values: &#x60;created_at&#x60;, &#x60;-created_at&#x60;, &#x60;name&#x60;, &#x60;-name&#x60;, &#x60;updated_at&#x60;, &#x60;-updated_at&#x60;.
80
80
  # @option opts [Integer] :page_number 1-based page number to return. Optional; defaults to &#x60;1&#x60; when omitted. Must be &#x60;&gt;&#x3D; 1&#x60; — requests with a smaller value are rejected with a 400 error.
81
81
  # @option opts [Integer] :page_size Number of items per page. Optional; defaults to &#x60;1000&#x60; when omitted. Must be between &#x60;1&#x60; and &#x60;1000&#x60; inclusive — requests outside that range are rejected with a 400 error.
82
82
  # @option opts [Boolean] :meta_total When &#x60;true&#x60;, the response&#39;s &#x60;meta.pagination&#x60; block includes &#x60;total&#x60; (the total number of matching items across all pages) and &#x60;total_pages&#x60;. Computing these requires an extra &#x60;COUNT&#x60; query, so omit (or pass &#x60;false&#x60;) when the totals are not needed. Defaults to &#x60;false&#x60;.
@@ -89,7 +89,7 @@ describe 'JobsApi' do
89
89
 
90
90
  # unit tests for run_job_now
91
91
  # Run Job Now
92
- # Trigger one immediate run of the job (a &#x60;MANUAL&#x60; run). The job&#39;s schedule and enabled state are untouched. The run executes in the environment named by the &#x60;X-Smplkit-Environment&#x60; header; when the job is enabled in exactly one environment that environment is used, and a single-environment credential implies it. The run executes the job&#39;s effective configuration for that environment. It is enqueued and executed by the worker; if the account is over its run allotment the run will fail with reason &#x60;QUOTA_EXCEEDED&#x60; rather than being rejected here.
92
+ # Trigger one immediate run of the job in a specified environment (a &#x60;MANUAL&#x60; run). This is the primary execution path for a manual job and is also usable ad hoc for a recurring job (\&quot;run now\&quot;). The job&#39;s schedule and enabled state are untouched. The run executes in the environment named by the &#x60;X-Smplkit-Environment&#x60; header; when the job is enabled in exactly one environment that environment is used, and a single-environment credential implies it. The environment must be one the job is **enabled** in (409 otherwise). The run executes the job&#39;s effective configuration for that environment. It is enqueued and executed by the worker; if the account is over its run allotment the run will fail with reason &#x60;QUOTA_EXCEEDED&#x60; rather than being rejected here.
93
93
  # @param job_id
94
94
  # @param [Hash] opts the optional parameters
95
95
  # @option opts [String] :x_smplkit_environment The environment to operate in. Names the single environment a one-off job is born in (or a manual run executes in). Optional when the credential is scoped to a single environment (which is then implied); required when the credential can reach several environments and the choice is otherwise ambiguous. Ignored for a recurring job, whose environments come from its &#x60;environments&#x60; map.
@@ -102,7 +102,7 @@ describe 'JobsApi' do
102
102
 
103
103
  # unit tests for update_job
104
104
  # Update Job
105
- # Replace an existing job. Every writable field is overwritten. Set enablement per environment via the &#x60;environments&#x60; map (a recurring job), or by recreating a one-off job in the desired environment. Editing the schedule recomputes the next fire time; changing only which environments are enabled preserves the existing cadence.
105
+ # Replace an existing job. Every writable field is overwritten. The job&#39;s kind is re-derived from the new &#x60;schedule&#x60; (omit it for a manual job). Set enablement per environment via the &#x60;environments&#x60; map (a recurring or manual job), or by recreating a one-off job in the desired environment. Each environment may carry its own cron &#x60;schedule&#x60; override (recurring jobs only). Editing a recurring environment&#39;s effective schedule recomputes its next fire time; an edit that leaves it unchanged preserves the existing cadence.
106
106
  # @param job_id
107
107
  # @param job_request
108
108
  # @param [Hash] opts the optional parameters
@@ -34,7 +34,7 @@ describe 'UsageApi' do
34
34
 
35
35
  # unit tests for get_usage
36
36
  # Get Usage
37
- # Report this account&#39;s current-period usage against its plan allotments. &#x60;runs_used&#x60; is the number of runs metered so far this calendar month; &#x60;active_jobs&#x60; is the number of currently-enabled jobs.
37
+ # Report this account&#39;s current-period usage against its plan allotments. &#x60;runs_used&#x60; is the number of runs metered so far this calendar month; &#x60;active_jobs&#x60; is the number of permanent jobs (recurring + manual), which is what the plan&#39;s job limit bounds (one-off jobs do not count).
38
38
  # @param [Hash] opts the optional parameters
39
39
  # @option opts [String] :filter_period
40
40
  # @return [UsageResponse]
@@ -33,10 +33,22 @@ describe SmplkitGeneratedClient::Jobs::JobEnvironment do
33
33
  end
34
34
  end
35
35
 
36
+ describe 'test attribute "schedule"' do
37
+ it 'should work' do
38
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
39
+ end
40
+ end
41
+
36
42
  describe 'test attribute "configuration"' do
37
43
  it 'should work' do
38
44
  # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
39
45
  end
40
46
  end
41
47
 
48
+ describe 'test attribute "next_run_at"' do
49
+ it 'should work' do
50
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
51
+ end
52
+ end
53
+
42
54
  end
@@ -39,12 +39,6 @@ describe SmplkitGeneratedClient::Jobs::Job do
39
39
  end
40
40
  end
41
41
 
42
- describe 'test attribute "enabled"' do
43
- it 'should work' do
44
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
45
- end
46
- end
47
-
48
42
  describe 'test attribute "type"' do
49
43
  it 'should work' do
50
44
  # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
@@ -83,15 +77,13 @@ describe SmplkitGeneratedClient::Jobs::Job do
83
77
  end
84
78
  end
85
79
 
86
- describe 'test attribute "next_run_at"' do
87
- it 'should work' do
88
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
89
- end
90
- end
91
-
92
- describe 'test attribute "recurring"' do
80
+ describe 'test attribute "kind"' do
93
81
  it 'should work' do
94
82
  # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
83
+ # validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["recurring", "manual", "one_off"])
84
+ # validator.allowable_values.each do |value|
85
+ # expect { instance.kind = value }.not_to raise_error
86
+ # end
95
87
  end
96
88
  end
97
89
 
@@ -1,22 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "time"
4
+
3
5
  # The Smpl Jobs client — one unified +JobsClient+.
4
6
  #
5
- # Smpl Jobs schedules HTTP calls (cron-style +schedule+ + +http+ configuration)
6
- # and records their run history. Unlike Config/Flags/Logging it installs no
7
- # in-process machinery, so it has no runtime/management split: a single
8
- # +JobsClient+ exposes the full surface and is reachable as +client.jobs+ on
9
- # +Smplkit::Client+ or constructed directly.
7
+ # Smpl Jobs runs HTTP calls on a schedule or on demand — and records their
8
+ # run history. Unlike Config/Flags/Logging it installs no in-process machinery,
9
+ # so it has no runtime/management split: a single +JobsClient+ exposes the full
10
+ # surface and is reachable as +client.jobs+ on +Smplkit::Client+ or constructed
11
+ # directly.
10
12
  #
11
- # client.jobs.{new,get,list,delete,run,usage}
13
+ # client.jobs.{new_recurring_job,new_manual_job,schedule,get,list,delete,run,usage}
12
14
  # client.jobs.runs.{list,get,cancel,rerun}
13
15
  # Job#{save,delete,trigger,list_runs}
14
16
  # Run#{rerun,cancel}
15
17
  #
16
18
  # A job is enabled per environment: a recurring (cron) job may be enabled in
17
- # several environments at once, a one-off (+now+ / future datetime) job is born
18
- # in exactly one. A client-level +environment+ default supplies the one-off
19
- # birth environment on create, the run-now environment, and the +runs.list+
19
+ # several environments at once, a manual job (no schedule) runs only when
20
+ # triggered, and a one-off (+now+ / future datetime) job is born in exactly
21
+ # one. A client-level +environment+ default supplies the one-off birth
22
+ # environment on create, the run-now environment, and the +runs.list+
20
23
  # +filter[environment]+ scope.
21
24
  #
22
25
  # The shared model classes (+Job+, +JobEnvironment+, +Run+, +Usage+,
@@ -98,7 +101,7 @@ module Smplkit
98
101
  # one client. Defining a job, triggering a run, and reading run history are
99
102
  # all plain request/response calls here:
100
103
  #
101
- # client.jobs.{new,get,list,delete,run,usage}
104
+ # client.jobs.{new_recurring_job,new_manual_job,schedule,get,list,delete,run,usage}
102
105
  # client.jobs.runs.{list,get,cancel,rerun}
103
106
  # Job#{save,delete,trigger,list_runs}
104
107
  # Run#{rerun,cancel}
@@ -125,9 +128,10 @@ module Smplkit
125
128
  Transport.build_api_client(SmplkitGeneratedClient::Jobs, "jobs", tcfg, accept: "application/vnd.api+json")
126
129
  end
127
130
 
128
- # The active-record entry point is {#new}: instantiate a draft, mutate
129
- # fields, then call {Smplkit::Jobs::Job#save}. Run history and the cancel /
130
- # rerun run actions live on {#runs}.
131
+ # The active-record entry points are {#new_recurring_job}, {#new_manual_job},
132
+ # and {#schedule}: instantiate a draft, mutate fields, then call
133
+ # {Smplkit::Jobs::Job#save}. Run history and the cancel / rerun run actions
134
+ # live on {#runs}.
131
135
  #
132
136
  # Reachable as +client.jobs+ (+Smplkit::Client+) or constructed directly —
133
137
  # +JobsClient.new+ resolves credentials from +~/.smplkit+ / env vars.
@@ -179,61 +183,113 @@ module Smplkit
179
183
  end
180
184
  end
181
185
 
182
- # Construct an unsaved {Smplkit::Jobs::Job} bound to this client. Call
183
- # +#save+ on the returned instance to create it.
186
+ # Construct an unsaved recurring {Smplkit::Jobs::Job} bound to this client.
187
+ # Call +#save+ on the returned instance to create it.
184
188
  #
185
189
  # @param id [String] Caller-supplied unique identifier for the job. Unique
186
190
  # within the account and immutable; the service returns 409 if another
187
191
  # live job already uses this id.
188
192
  # @param name [String] Human-readable name for the job.
189
- # @param schedule [String] An ISO-8601 datetime, a 5-field UTC cron
190
- # expression, or the literal +"now"+. The schedule is environment-agnostic.
191
- # @param configuration [Smplkit::Jobs::HttpConfig] The base HTTP request
192
- # the job performs.
193
+ # @param schedule [String] The base cadence a 5-field cron expression
194
+ # evaluated in UTC (e.g. +"0 2 * * *"+) that every environment inherits
195
+ # unless it sets its own override.
196
+ # @param configuration [Smplkit::Jobs::HttpConfig] The HTTP request the job
197
+ # sends each time it fires.
193
198
  # @param description [String, nil] Optional free-text description.
194
199
  # @param environments [Hash{String => Smplkit::Jobs::JobEnvironment, Hash}, nil]
195
- # Per-environment overrides for a recurring job, keyed by environment key
196
- # — each a {Smplkit::Jobs::JobEnvironment}, or a plain hash
197
- # (+{ enabled: true }+, optionally with a +:configuration+
198
- # {Smplkit::Jobs::HttpConfig} override). A recurring job fires only in
199
- # environments enabled here. Ignored for a one-off job, which is born in
200
- # +environment+ below.
200
+ # Per-environment overrides keyed by environment key — each a
201
+ # {Smplkit::Jobs::JobEnvironment}, or a plain hash (+{ enabled: true }+,
202
+ # optionally with a +:schedule+ cron override and/or a +:configuration+
203
+ # {Smplkit::Jobs::HttpConfig} override). The job is scheduled only in
204
+ # environments enabled here.
201
205
  # @param concurrency_policy [String] How overlapping runs are handled.
202
206
  # Defaults to +"ALLOW"+.
203
- # @param environment [String, nil] For a one-off job (+"now"+ / datetime
204
- # schedule), the environment it is born in. Defaults to the client's
205
- # configured environment. Ignored for a recurring job.
206
207
  # @return [Smplkit::Jobs::Job]
207
- def new(id, name:, schedule:, configuration:, description: nil,
208
- environments: nil, concurrency_policy: "ALLOW", environment: nil)
209
- Job.new(
210
- self,
211
- id: id,
212
- name: name,
213
- schedule: schedule,
214
- configuration: configuration,
215
- description: description,
216
- environments: Jobs.normalize_environments(environments),
217
- concurrency_policy: concurrency_policy,
218
- birth_environment: environment.nil? ? @environment : environment
208
+ def new_recurring_job(id, name:, schedule:, configuration:, description: nil,
209
+ environments: nil, concurrency_policy: "ALLOW")
210
+ _new_job(
211
+ id, name: name, schedule: schedule, configuration: configuration,
212
+ description: description, environments: environments,
213
+ concurrency_policy: concurrency_policy, environment: nil
214
+ )
215
+ end
216
+
217
+ # Construct an unsaved manual {Smplkit::Jobs::Job} bound to this client.
218
+ # Call +#save+ on the returned instance to create it.
219
+ #
220
+ # A manual job has no schedule — it never auto-fires and runs only when
221
+ # triggered via {#run} / {Smplkit::Jobs::Job#trigger}.
222
+ #
223
+ # @param id [String] Caller-supplied unique identifier for the job. Unique
224
+ # within the account and immutable; the service returns 409 if another
225
+ # live job already uses this id.
226
+ # @param name [String] Human-readable name for the job.
227
+ # @param configuration [Smplkit::Jobs::HttpConfig] The HTTP request the job
228
+ # sends each time it runs.
229
+ # @param description [String, nil] Optional free-text description.
230
+ # @param environments [Hash{String => Smplkit::Jobs::JobEnvironment, Hash}, nil]
231
+ # Per-environment overrides keyed by environment key — each a
232
+ # {Smplkit::Jobs::JobEnvironment}, or a plain hash (+{ enabled: true }+,
233
+ # optionally with a +:configuration+ {Smplkit::Jobs::HttpConfig}
234
+ # override). The job is triggerable only in environments enabled here.
235
+ # @param concurrency_policy [String] How overlapping runs are handled.
236
+ # Defaults to +"ALLOW"+.
237
+ # @return [Smplkit::Jobs::Job]
238
+ def new_manual_job(id, name:, configuration:, description: nil,
239
+ environments: nil, concurrency_policy: "ALLOW")
240
+ _new_job(
241
+ id, name: name, schedule: nil, configuration: configuration,
242
+ description: description, environments: environments,
243
+ concurrency_policy: concurrency_policy, environment: nil
244
+ )
245
+ end
246
+
247
+ # Construct an unsaved one-off {Smplkit::Jobs::Job} bound to this client.
248
+ # Call +#save+ on the returned instance to create it.
249
+ #
250
+ # A one-off job runs a single time at +schedule+ and is then spent.
251
+ #
252
+ # @param id [String] Caller-supplied unique identifier for the job. Unique
253
+ # within the account and immutable; the service returns 409 if another
254
+ # live job already uses this id.
255
+ # @param name [String] Human-readable name for the job.
256
+ # @param schedule [Time] The instant the single run fires.
257
+ # @param configuration [Smplkit::Jobs::HttpConfig] The HTTP request the job
258
+ # sends when it runs.
259
+ # @param description [String, nil] Optional free-text description.
260
+ # @param concurrency_policy [String] How overlapping runs are handled.
261
+ # Defaults to +"ALLOW"+.
262
+ # @param environment [String, nil] The environment the job is born in.
263
+ # Defaults to the client's configured environment.
264
+ # @return [Smplkit::Jobs::Job]
265
+ def schedule(id, name:, schedule:, configuration:, description: nil,
266
+ concurrency_policy: "ALLOW", environment: nil)
267
+ _new_job(
268
+ id, name: name, schedule: schedule.iso8601, configuration: configuration,
269
+ description: description, environments: nil,
270
+ concurrency_policy: concurrency_policy, environment: environment
219
271
  )
220
272
  end
221
273
 
222
274
  # List jobs for the authenticated account.
223
275
  #
224
- # @param enabled [Boolean, nil] Filter to jobs matching this enabled state
225
- # (the server-derived roll-up across environments).
226
- # @param recurring [Boolean, nil] Filter to recurring (+true+) or one-off
227
- # (+false+) jobs. +nil+ lists both.
276
+ # @param kind [String, nil] Filter to a single {Smplkit::Jobs::JobKind}
277
+ # (+JobKind::RECURRING+ / +JobKind::MANUAL+ / +JobKind::ONE_OFF+). +nil+
278
+ # lists recurring and manual jobs; one-off jobs are omitted unless you
279
+ # pass +JobKind::ONE_OFF+.
280
+ # @param scheduled [Boolean, nil] Filter to jobs that have an upcoming fire
281
+ # in some environment (+true+) or none (+false+) — the feed for an
282
+ # upcoming-runs view, which includes one-offs. +nil+ does not filter on
283
+ # scheduling.
228
284
  # @param name [String, nil] Filter to jobs whose name contains this text
229
285
  # (case-insensitive). +nil+ lists all.
230
286
  # @param page_number [Integer, nil] 1-based page number to return.
231
287
  # @param page_size [Integer, nil] Items per page.
232
288
  # @return [Array<Smplkit::Jobs::Job>]
233
- def list(enabled: nil, recurring: nil, name: nil, page_number: nil, page_size: nil)
289
+ def list(kind: nil, scheduled: nil, name: nil, page_number: nil, page_size: nil)
234
290
  opts = {}
235
- opts[:filter_enabled] = enabled unless enabled.nil?
236
- opts[:filter_recurring] = recurring unless recurring.nil?
291
+ opts[:filter_kind] = kind unless kind.nil?
292
+ opts[:filter_scheduled] = scheduled unless scheduled.nil?
237
293
  opts[:filter_name] = name unless name.nil?
238
294
  opts[:page_number] = page_number unless page_number.nil?
239
295
  opts[:page_size] = page_size unless page_size.nil?
@@ -271,7 +327,8 @@ module Smplkit
271
327
  # @param environment [String, nil] Environment the manual run executes in.
272
328
  # Defaults to the client's configured environment; when the job is
273
329
  # enabled in exactly one environment that environment is used, and a
274
- # single-environment credential implies it.
330
+ # single-environment credential implies it. The job must be enabled in
331
+ # the chosen environment.
275
332
  # @return [Smplkit::Jobs::Run] The run that was started, with +trigger+
276
333
  # set to +MANUAL+.
277
334
  def run(id, environment: nil)
@@ -316,14 +373,34 @@ module Smplkit
316
373
 
317
374
  private
318
375
 
376
+ # Build an unsaved {Smplkit::Jobs::Job} bound to this client. The three
377
+ # public constructors ({#new_recurring_job}, {#new_manual_job}, {#schedule})
378
+ # funnel through here.
379
+ def _new_job(id, name:, schedule:, configuration:, description:,
380
+ environments:, concurrency_policy:, environment:)
381
+ Job.new(
382
+ self,
383
+ id: id,
384
+ name: name,
385
+ schedule: schedule,
386
+ configuration: configuration,
387
+ description: description,
388
+ environments: Jobs.normalize_environments(environments),
389
+ concurrency_policy: concurrency_policy,
390
+ birth_environment: environment.nil? ? @environment : environment
391
+ )
392
+ end
393
+
319
394
  # Convert the wrapper +environments+ map to the generated model hash.
320
395
  #
321
- # Each entry's +enabled+ is always written; a per-environment
322
- # +configuration+ override is sent as a full {HttpConfig} payload only when
323
- # present (omit to inherit the base configuration).
396
+ # Each entry's +enabled+ is always written; a per-environment +schedule+
397
+ # (cron) override and +configuration+ override are each sent only when
398
+ # present (omit to inherit the job's base +schedule+ / +configuration+).
399
+ # The read-only per-environment +next_run_at+ is never written.
324
400
  def environments_to_wire(environments)
325
401
  (environments || {}).each_with_object({}) do |(env_key, env), out|
326
402
  attrs = { enabled: env.enabled }
403
+ attrs[:schedule] = env.schedule unless env.schedule.nil?
327
404
  attrs[:configuration] = HttpConfig.to_wire(env.configuration) unless env.configuration.nil?
328
405
  out[env_key.to_s] = SmplkitGeneratedClient::Jobs::JobEnvironment.new(attrs)
329
406
  end
@@ -6,15 +6,18 @@ module Smplkit
6
6
  # Unlike Config/Flags/Logging, Jobs has no live "phone-home" agent — no
7
7
  # environment registration, no WebSocket — so its entire surface lives on a
8
8
  # single client. A {Job} is an active record: build it with
9
- # +client.jobs.new(...)+, set fields, and call {Job#save} (create when new,
9
+ # +client.jobs.new_recurring_job(...)+ / +new_manual_job(...)+ /
10
+ # +schedule(...)+, set fields, and call {Job#save} (create when new,
10
11
  # full-replace update when it already exists) or {Job#delete}. Runs are
11
12
  # read-only views with +rerun+ / +cancel+ actions; run history lives on
12
13
  # +client.jobs.runs+.
13
14
  #
14
15
  # A job is enabled per environment: a recurring (cron) job may run in several
15
- # environments at once, a one-off (+now+ / future datetime) job runs a single
16
- # time in the environment it was created in. Base +enabled+ is a read-only,
17
- # server-derived roll-up (+true+ when enabled in at least one environment).
16
+ # environments at once, a manual job (no schedule) runs only when triggered,
17
+ # and a one-off (+now+ / future datetime) job runs a single time in the
18
+ # environment it was created in. Base {Job#enabled} is a derived roll-up
19
+ # (+true+ when enabled in at least one environment), computed from the
20
+ # per-environment {Job#environments} map.
18
21
  module Jobs
19
22
  # Wrap a generated-jobs-API call and translate +ApiError+ into the
20
23
  # +Smplkit::Error+ hierarchy. Connection-level failures (no response
@@ -73,10 +76,10 @@ module Smplkit
73
76
  # Coerce a caller's +environments+ map to {JobEnvironment} instances.
74
77
  #
75
78
  # Accepts either {JobEnvironment} values or plain hashes
76
- # (+{ enabled: true, configuration: HttpConfig.new(...) }+) so callers can
77
- # use the lightweight hash form without importing the model. A dict-form
78
- # +configuration+ override is coerced to an {HttpConfig} so it serializes on
79
- # save.
79
+ # (+{ enabled: true, schedule: "0 3 * * *", configuration: HttpConfig.new(...) }+)
80
+ # so callers can use the lightweight hash form without importing the model. A
81
+ # dict-form +configuration+ override is coerced to an {HttpConfig} so it
82
+ # serializes on save; an optional +schedule+ cron override passes through.
80
83
  #
81
84
  # @api private
82
85
  def self.normalize_environments(environments)
@@ -90,12 +93,40 @@ module Smplkit
90
93
  cfg = HttpConfig.new(**cfg) if cfg.is_a?(Hash)
91
94
  JobEnvironment.new(
92
95
  enabled: value[:enabled] || value["enabled"] || false,
96
+ schedule: value[:schedule] || value["schedule"],
93
97
  configuration: cfg
94
98
  )
95
99
  end
96
100
  end
97
101
  end
98
102
 
103
+ # How a job runs, derived from its schedule (read-only).
104
+ #
105
+ # - +MANUAL+: No schedule — never auto-fires; runs only when triggered.
106
+ # - +ONE_OFF+: A +now+ or datetime schedule — runs a single time, then is
107
+ # spent.
108
+ # - +RECURRING+: A cron schedule — fires on a repeating cadence.
109
+ module JobKind
110
+ MANUAL = "manual"
111
+ ONE_OFF = "one_off"
112
+ RECURRING = "recurring"
113
+
114
+ VALUES = [MANUAL, ONE_OFF, RECURRING].freeze
115
+ end
116
+
117
+ # What started a run (read-only).
118
+ #
119
+ # - +MANUAL+: A +run+ / +trigger+ call started it on demand.
120
+ # - +RERUN+: It repeats an earlier run.
121
+ # - +SCHEDULE+: The job's schedule fired.
122
+ module RunTrigger
123
+ MANUAL = "MANUAL"
124
+ RERUN = "RERUN"
125
+ SCHEDULE = "SCHEDULE"
126
+
127
+ VALUES = [MANUAL, RERUN, SCHEDULE].freeze
128
+ end
129
+
99
130
  # HTTP verb a job uses when it fires.
100
131
  #
101
132
  # Mirrors the jobs spec's method enum so a job's
@@ -244,23 +275,34 @@ module Smplkit
244
275
  end
245
276
  # rubocop:enable Lint/StructNewOverride
246
277
 
247
- # Per-environment enablement and optional configuration override for a job.
278
+ # Per-environment enablement, schedule, and configuration override for a job.
248
279
  #
249
- # A recurring job fires in a given environment only when that environment
250
- # has an entry in {Job#environments} with +enabled: true+; an environment
251
- # with no entry (or +enabled: false+) does not fire there.
280
+ # A job runs in a given environment only when that environment has an entry
281
+ # in {Job#environments} with +enabled: true+ (scheduled there for a
282
+ # recurring job, triggerable there for a manual one); an environment with no
283
+ # entry (or +enabled: false+) is disabled there.
252
284
  #
253
285
  # @!attribute [rw] enabled
254
- # @return [Boolean] Whether the job fires in this environment. Defaults to
255
- # +false+.
286
+ # @return [Boolean] Whether the job is enabled in this environment.
287
+ # Defaults to +false+.
288
+ # @!attribute [rw] schedule
289
+ # @return [String, nil] Optional per-environment cron schedule override
290
+ # that varies the cadence in this environment. +nil+ (the default)
291
+ # inherits the job's base {Job#schedule}. When present, it must be a
292
+ # 5-field UTC cron expression and is only meaningful on a recurring job —
293
+ # it cannot turn a one-off job recurring or vice-versa.
256
294
  # @!attribute [rw] configuration
257
295
  # @return [HttpConfig, nil] Optional per-environment request configuration
258
296
  # that fully replaces the job's base {Job#configuration} for this
259
297
  # environment. +nil+ (the default) inherits the base configuration. As
260
298
  # with the base configuration, header values are returned in plaintext on
261
299
  # reads, so a get-mutate-put round-trip preserves them.
262
- JobEnvironment = Struct.new(:enabled, :configuration, keyword_init: true) do
263
- def initialize(enabled: false, configuration: nil)
300
+ # @!attribute [rw] next_run_at
301
+ # @return [String, nil] Read-only. The next scheduled fire time in this
302
+ # environment. +nil+ when the environment is not enabled, or once a
303
+ # one-off run has fired. Never written back on save.
304
+ JobEnvironment = Struct.new(:enabled, :schedule, :configuration, :next_run_at, keyword_init: true) do
305
+ def initialize(enabled: false, schedule: nil, configuration: nil, next_run_at: nil)
264
306
  super
265
307
  end
266
308
 
@@ -275,23 +317,29 @@ module Smplkit
275
317
  cfg = src.configuration
276
318
  new(
277
319
  enabled: src.enabled.nil? ? false : src.enabled,
278
- configuration: cfg.nil? ? nil : HttpConfig.from_wire(cfg)
320
+ schedule: src.schedule,
321
+ configuration: cfg.nil? ? nil : HttpConfig.from_wire(cfg),
322
+ next_run_at: src.next_run_at
279
323
  )
280
324
  end
281
325
  end
282
326
 
283
- # A scheduled unit of work: an HTTP request run on a schedule.
327
+ # A unit of work: an HTTP request, run on a schedule or triggered on demand.
284
328
  #
285
- # Active-record style: instantiate via +client.jobs.new(...)+, mutate fields
286
- # directly, and call {#save} to persist or {#delete} to remove. Header
287
- # values in +configuration.headers+ are returned in plaintext on reads, so
288
- # fetching a job, mutating it, and calling {#save} preserves its header
289
- # values without re-entering secrets.
329
+ # Active-record style: instantiate via +client.jobs.new_recurring_job(...)+,
330
+ # +new_manual_job(...)+, or +schedule(...)+, mutate fields directly, and call
331
+ # {#save} to persist or {#delete} to remove. Header values in
332
+ # +configuration.headers+ are returned in plaintext on reads, so fetching a
333
+ # job, mutating it, and calling {#save} preserves its header values without
334
+ # re-entering secrets.
290
335
  #
291
- # Enablement is per environment, set via {#set_enabled} (and read via
292
- # {#is_enabled}); base {#enabled} is a read-only roll-up. The schedule is
293
- # environment-agnostic one cron / datetime / +now+ shared across every
294
- # environment the job runs in.
336
+ # A job's {#kind} follows from its {#schedule}: a recurring (cron) job, a
337
+ # manual job (no schedule, runs only when triggered), or a one-off (+now+ /
338
+ # datetime) job that runs a single time. Enablement is per environment, set
339
+ # via {#set_enabled} (and read via {#is_enabled}); base {#enabled} is a
340
+ # derived roll-up over {#environments}. The base schedule is
341
+ # environment-agnostic, while each environment may carry its own cron
342
+ # {#set_schedule} override.
295
343
  class Job
296
344
  # @return [String] Caller-supplied unique identifier for the job (the
297
345
  # resource +id+). Unique within the account and immutable; the service
@@ -304,11 +352,13 @@ module Smplkit
304
352
  # @return [String, nil] Free-text description. +nil+ when unset.
305
353
  attr_accessor :description
306
354
 
307
- # @return [Boolean] Read-only, server-derived roll-up: +true+ when the job
308
- # is enabled in at least one environment. Set enablement per environment
309
- # via {#set_enabled} / {#environments}; mutating this field directly has
310
- # no effect on the server (it is never written).
311
- attr_accessor :enabled
355
+ # @return [Boolean] Derived roll-up: +true+ when the job is enabled in at
356
+ # least one environment. Computed from {#environments} rather than read
357
+ # from the wire the API no longer carries a top-level +enabled+. Set
358
+ # enablement per environment via {#set_enabled} / {#environments}.
359
+ def enabled
360
+ (@environments || {}).each_value.any?(&:enabled)
361
+ end
312
362
 
313
363
  # @return [Hash{String => JobEnvironment}] Per-environment overrides keyed
314
364
  # by environment key (e.g. +"production"+). The writable surface for
@@ -318,19 +368,22 @@ module Smplkit
318
368
  # Every referenced environment must exist and be managed for the account.
319
369
  attr_accessor :environments
320
370
 
321
- # @return [Boolean, nil] Read-only. +true+ for a recurring (cron) schedule,
322
- # +false+ for a one-off datetime / +now+ schedule. Derived from
323
- # {#schedule} by the server.
324
- attr_accessor :recurring
371
+ # @return [String, nil] Read-only. How the job runs, derived from its
372
+ # {#schedule} by the server: one of {JobKind::RECURRING},
373
+ # {JobKind::MANUAL}, or {JobKind::ONE_OFF}. +nil+ on an unsaved instance.
374
+ attr_accessor :kind
325
375
 
326
376
  # @return [String] Job type. Only +"http"+ is supported today.
327
377
  attr_accessor :type
328
378
 
329
- # @return [String] When the job runs: an ISO-8601 datetime (a one-off
330
- # run), a 5-field cron expression evaluated in UTC (recurring), or the
331
- # literal +"now"+ (run once, as soon as possible). A datetime or +"now"+
332
- # job disables itself after it fires. The schedule is environment-agnostic
333
- # set it with {#set_schedule}.
379
+ # @return [String, nil] The base schedule every environment inherits, and
380
+ # the field that determines the job's {#kind}: +nil+ (omitted) for a
381
+ # permanent manual job that never auto-fires; a 5-field cron expression
382
+ # evaluated in UTC for a recurring job; an ISO-8601 datetime for a
383
+ # one-off run at that instant; or the literal +"now"+ for a one-off run
384
+ # as soon as possible. A datetime or +"now"+ job disables itself after it
385
+ # fires. The schedule is environment-agnostic — set it with
386
+ # {#set_schedule}.
334
387
  attr_accessor :schedule
335
388
 
336
389
  # @return [HttpConfig] The base HTTP request to perform when the job fires.
@@ -341,10 +394,6 @@ module Smplkit
341
394
  # value) permits them.
342
395
  attr_accessor :concurrency_policy
343
396
 
344
- # @return [String, nil] The next scheduled fire time. +nil+ once a one-off
345
- # job has fired.
346
- attr_accessor :next_run_at
347
-
348
397
  # @return [String, nil] ISO-8601 timestamp of first persist. +nil+ for an
349
398
  # unsaved instance.
350
399
  attr_accessor :created_at
@@ -362,27 +411,26 @@ module Smplkit
362
411
 
363
412
  # @api private — For a one-off job, the environment it is born in, sent as
364
413
  # the +X-Smplkit-Environment+ header by {JobsClient#_create_job}. Ignored
365
- # for a recurring job, whose environments come from {#environments}.
414
+ # for recurring and manual jobs, whose environments come from
415
+ # {#environments}.
366
416
  attr_accessor :birth_environment
367
417
 
368
- def initialize(client = nil, id:, name:, schedule:, configuration:,
369
- description: nil, environments: nil, enabled: false,
370
- recurring: nil, type: "http", concurrency_policy: "ALLOW",
371
- birth_environment: nil, next_run_at: nil, created_at: nil,
418
+ def initialize(client = nil, id:, name:, configuration:, schedule: nil,
419
+ description: nil, environments: nil,
420
+ kind: nil, type: "http", concurrency_policy: "ALLOW",
421
+ birth_environment: nil, created_at: nil,
372
422
  updated_at: nil, deleted_at: nil, version: nil)
373
423
  @client = client
374
424
  @id = id
375
425
  @name = name
376
426
  @description = description
377
427
  @environments = environments || {}
378
- @enabled = enabled
379
- @recurring = recurring
428
+ @kind = kind
380
429
  @type = type
381
430
  @schedule = schedule
382
431
  @configuration = configuration
383
432
  @concurrency_policy = concurrency_policy
384
433
  @birth_environment = birth_environment
385
- @next_run_at = next_run_at
386
434
  @created_at = created_at
387
435
  @updated_at = updated_at
388
436
  @deleted_at = deleted_at
@@ -394,8 +442,8 @@ module Smplkit
394
442
  # Upsert behavior is driven by {#created_at}: a job with no +created_at+
395
443
  # is created (POST); otherwise it's full-replace updated (PUT). After the
396
444
  # call, every field is refreshed from the server response (including
397
- # newly-assigned +created_at+, +version+, +next_run_at+, and the derived
398
- # +enabled+ roll-up).
445
+ # newly-assigned +created_at+, +version+, and per-environment +next_run_at+
446
+ # inside {#environments}).
399
447
  #
400
448
  # @return [self]
401
449
  def save
@@ -440,7 +488,7 @@ module Smplkit
440
488
  # roll-up across every environment.
441
489
  # @return [Boolean]
442
490
  def is_enabled(environment: nil)
443
- return @enabled if environment.nil?
491
+ return enabled if environment.nil?
444
492
 
445
493
  override = @environments[environment]
446
494
  return false if override.nil?
@@ -448,6 +496,27 @@ module Smplkit
448
496
  override.enabled
449
497
  end
450
498
 
499
+ # Whether this is a recurring (cron-scheduled) job.
500
+ #
501
+ # @return [Boolean]
502
+ def is_recurring
503
+ @kind == JobKind::RECURRING
504
+ end
505
+
506
+ # Whether this is a manual job — no schedule; runs only when triggered.
507
+ #
508
+ # @return [Boolean]
509
+ def is_manual
510
+ @kind == JobKind::MANUAL
511
+ end
512
+
513
+ # Whether this is a one-off job — a single +now+ / datetime run.
514
+ #
515
+ # @return [Boolean]
516
+ def is_one_off
517
+ @kind == JobKind::ONE_OFF
518
+ end
519
+
451
520
  # Set the job's configuration — base (+environment+ omitted) or
452
521
  # per-environment.
453
522
  #
@@ -485,17 +554,30 @@ module Smplkit
485
554
  @configuration
486
555
  end
487
556
 
488
- # Set the job's schedule.
557
+ # Set the job's schedule — base (+environment+ omitted) or per-environment.
489
558
  #
490
- # The schedule is environment-agnostic a job has a single cron /
491
- # datetime / +"now"+ schedule shared across every environment it runs in
492
- # (each enabled environment fires on the same cadence). There is no
493
- # per-environment schedule, so this setter takes no +environment+.
559
+ # With +environment+ omitted (the default), sets the base {#schedule}
560
+ # an ISO-8601 datetime, a 5-field UTC cron expression, or the literal
561
+ # +"now"+ which every environment inherits unless it overrides it.
562
+ #
563
+ # With +environment+ given, sets that environment's per-environment cron
564
+ # +schedule+ override on {#environments}, creating the override entry if it
565
+ # doesn't exist yet (preserving any already-set +enabled+ / +configuration+
566
+ # on it). A per-environment override is a cron expression only and varies
567
+ # the cadence within that environment; it cannot turn a one-off job
568
+ # recurring or vice-versa. Call {#save} to persist.
494
569
  #
495
570
  # @param schedule [String] An ISO-8601 datetime, a 5-field UTC cron
496
- # expression, or the literal +"now"+.
497
- def set_schedule(schedule)
498
- @schedule = schedule
571
+ # expression, or the literal +"now"+ (base); a 5-field UTC cron
572
+ # expression (per-environment).
573
+ # @param environment [String, nil] An environment key for a per-environment
574
+ # override, or +nil+ to set the base schedule.
575
+ def set_schedule(schedule, environment: nil)
576
+ if environment.nil?
577
+ @schedule = schedule
578
+ else
579
+ _environment_override(environment).schedule = schedule
580
+ end
499
581
  end
500
582
 
501
583
  # Trigger one immediate, manual run of this job (a +MANUAL+ run).
@@ -547,14 +629,12 @@ module Smplkit
547
629
  @id = other.id
548
630
  @name = other.name
549
631
  @description = other.description
550
- @enabled = other.enabled
551
632
  @environments = other.environments
552
- @recurring = other.recurring
633
+ @kind = other.kind
553
634
  @type = other.type
554
635
  @schedule = other.schedule
555
636
  @configuration = other.configuration
556
637
  @concurrency_policy = other.concurrency_policy
557
- @next_run_at = other.next_run_at
558
638
  @created_at = other.created_at
559
639
  @updated_at = other.updated_at
560
640
  @deleted_at = other.deleted_at
@@ -577,16 +657,14 @@ module Smplkit
577
657
  id: resource.id,
578
658
  name: a.name,
579
659
  description: a.description,
580
- # The base +enabled+ is a server-derived roll-up; round-trip whatever
581
- # the server returned without assuming a default of true.
582
- enabled: a.enabled.nil? ? false : a.enabled,
660
+ # The base +enabled+ roll-up is derived from +environments+, not read
661
+ # from the wire the API no longer carries a top-level +enabled+.
583
662
  environments: environments,
584
- recurring: a.recurring,
663
+ kind: a.kind,
585
664
  type: a.type || "http",
586
665
  schedule: a.schedule,
587
666
  configuration: HttpConfig.from_wire(a.configuration),
588
667
  concurrency_policy: a.concurrency_policy || "ALLOW",
589
- next_run_at: a.next_run_at,
590
668
  created_at: a.created_at,
591
669
  updated_at: a.updated_at,
592
670
  deleted_at: a.deleted_at,
@@ -613,7 +691,8 @@ module Smplkit
613
691
  # inherits the firing job-environment; a manual run uses the environment
614
692
  # named on the run-now request; a rerun copies its source run's environment.
615
693
  # @!attribute [rw] trigger
616
- # @return [String] Why the run exists: +SCHEDULE+, +MANUAL+ (run now), or +RERUN+.
694
+ # @return [String] Why the run exists a raw string equal to one of the
695
+ # {RunTrigger} constants: +SCHEDULE+, +MANUAL+ (run now), or +RERUN+.
617
696
  # @!attribute [rw] rerun_of
618
697
  # @return [String, nil] The source run's id; set only when +trigger+ is +RERUN+.
619
698
  # @!attribute [rw] scheduled_for
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smplkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.112
4
+ version: 3.0.114
5
5
  platform: ruby
6
6
  authors:
7
7
  - Smpl Solutions LLC