smplkit 3.0.95 → 3.0.97
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 +4 -4
- data/lib/smplkit/account/client.rb +128 -0
- data/lib/smplkit/account/models.rb +71 -0
- data/lib/smplkit/api_support.rb +91 -0
- data/lib/smplkit/audit/buffer.rb +3 -1
- data/lib/smplkit/audit/categories.rb +21 -10
- data/lib/smplkit/audit/client.rb +18 -9
- data/lib/smplkit/audit/event_types.rb +26 -10
- data/lib/smplkit/audit/events.rb +93 -17
- data/lib/smplkit/{management/audit.rb → audit/forwarders.rb} +93 -85
- data/lib/smplkit/audit/models.rb +86 -32
- data/lib/smplkit/audit/resource_types.rb +21 -9
- data/lib/smplkit/buffers.rb +250 -0
- data/lib/smplkit/client.rb +161 -70
- data/lib/smplkit/config/client.rb +874 -186
- data/lib/smplkit/config/helpers.rb +44 -6
- data/lib/smplkit/config/models.rb +114 -7
- data/lib/smplkit/config_resolution.rb +17 -9
- data/lib/smplkit/errors.rb +14 -3
- data/lib/smplkit/flags/client.rb +602 -116
- data/lib/smplkit/flags/models.rb +110 -8
- data/lib/smplkit/flags/types.rb +8 -9
- data/lib/smplkit/jobs/client.rb +306 -0
- data/lib/smplkit/jobs/models.rb +47 -18
- data/lib/smplkit/logging/client.rb +755 -191
- data/lib/smplkit/logging/helpers.rb +5 -1
- data/lib/smplkit/logging/levels.rb +3 -1
- data/lib/smplkit/logging/models.rb +163 -6
- data/lib/smplkit/logging/normalize.rb +3 -1
- data/lib/smplkit/logging/resolution.rb +4 -4
- data/lib/smplkit/logging/sources.rb +1 -1
- data/lib/smplkit/platform/client.rb +597 -0
- data/lib/smplkit/platform/models.rb +282 -0
- data/lib/smplkit/{management → platform}/types.rb +21 -4
- data/lib/smplkit/transport.rb +103 -0
- data/lib/smplkit/ws.rb +1 -1
- data/lib/smplkit.rb +18 -6
- metadata +11 -7
- data/lib/smplkit/management/buffer.rb +0 -198
- data/lib/smplkit/management/client.rb +0 -1074
- data/lib/smplkit/management/jobs.rb +0 -226
- data/lib/smplkit/management/models.rb +0 -178
data/lib/smplkit/jobs/models.rb
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Smplkit
|
|
4
|
-
# Smpl Jobs surface — exposed through +
|
|
4
|
+
# Smpl Jobs surface — exposed through +client.jobs.*+.
|
|
5
5
|
#
|
|
6
6
|
# Unlike Config/Flags/Logging, Jobs has no live "phone-home" agent — no
|
|
7
|
-
# environment registration, no WebSocket — so its entire surface lives on
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
# +mgmt.jobs.runs+.
|
|
7
|
+
# environment registration, no WebSocket — so its entire surface lives on a
|
|
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,
|
|
10
|
+
# full-replace update when it already exists) or {Job#delete}. Runs are
|
|
11
|
+
# read-only views; run actions live on +client.jobs.runs+.
|
|
13
12
|
module Jobs
|
|
14
13
|
# Wrap a generated-jobs-API call and translate +ApiError+ into the
|
|
15
14
|
# +Smplkit::Error+ hierarchy. Connection-level failures (no response
|
|
@@ -29,7 +28,7 @@ module Smplkit
|
|
|
29
28
|
raise
|
|
30
29
|
end
|
|
31
30
|
|
|
32
|
-
# HTTP verb a job uses when it fires
|
|
31
|
+
# HTTP verb a job uses when it fires.
|
|
33
32
|
#
|
|
34
33
|
# Mirrors the jobs spec's method enum so a job's
|
|
35
34
|
# +configuration.method+ field is constrained to a known value instead
|
|
@@ -64,8 +63,8 @@ module Smplkit
|
|
|
64
63
|
# @!attribute [rw] name
|
|
65
64
|
# @return [String] Header name (e.g. +"Authorization"+, +"Content-Type"+).
|
|
66
65
|
# @!attribute [rw] value
|
|
67
|
-
# @return [String] Header value
|
|
68
|
-
#
|
|
66
|
+
# @return [String] Header value. Returned in plaintext on reads, so a
|
|
67
|
+
# get-mutate-put round-trip preserves it without re-entering secrets.
|
|
69
68
|
HttpHeader = Struct.new(:name, :value, keyword_init: true)
|
|
70
69
|
|
|
71
70
|
# The HTTP request a job performs when it fires (the +http+ configuration).
|
|
@@ -79,7 +78,8 @@ module Smplkit
|
|
|
79
78
|
# @return [String] Destination URL the job requests on each run.
|
|
80
79
|
# @!attribute [rw] headers
|
|
81
80
|
# @return [Array<HttpHeader>] Headers attached to every request. Values
|
|
82
|
-
# are
|
|
81
|
+
# often carry credentials and are returned in plaintext on reads, so a
|
|
82
|
+
# get-mutate-put round-trip preserves them without re-entering secrets.
|
|
83
83
|
# @!attribute [rw] body
|
|
84
84
|
# @return [String, nil] Request body sent on each run. +nil+ (the default)
|
|
85
85
|
# sends an empty body, suitable for a connectivity ping. Sent verbatim —
|
|
@@ -118,6 +118,11 @@ module Smplkit
|
|
|
118
118
|
)
|
|
119
119
|
end
|
|
120
120
|
|
|
121
|
+
# @api private — Convert an {HttpConfig} (or a Hash with the same keys)
|
|
122
|
+
# into the generated wire model the jobs service expects.
|
|
123
|
+
#
|
|
124
|
+
# @param src [HttpConfig, Hash] The HTTP configuration to serialize.
|
|
125
|
+
# @return [SmplkitGeneratedClient::Jobs::JobHttpConfiguration] The wire model.
|
|
121
126
|
def self.to_wire(src)
|
|
122
127
|
h = src.is_a?(Hash) ? new(**src) : src
|
|
123
128
|
SmplkitGeneratedClient::Jobs::JobHttpConfiguration.new(
|
|
@@ -139,6 +144,13 @@ module Smplkit
|
|
|
139
144
|
)
|
|
140
145
|
end
|
|
141
146
|
|
|
147
|
+
# @api private — Build an {HttpConfig} from the generated wire model
|
|
148
|
+
# returned by the jobs service. Header values arrive in plaintext, so a
|
|
149
|
+
# round-trip back through {to_wire} preserves them.
|
|
150
|
+
#
|
|
151
|
+
# @param src [SmplkitGeneratedClient::Jobs::JobHttpConfiguration, nil] The
|
|
152
|
+
# wire model, or +nil+ for an empty configuration.
|
|
153
|
+
# @return [HttpConfig] The wrapper-side configuration.
|
|
142
154
|
def self.from_wire(src)
|
|
143
155
|
return new if src.nil?
|
|
144
156
|
|
|
@@ -166,11 +178,11 @@ module Smplkit
|
|
|
166
178
|
|
|
167
179
|
# A scheduled unit of work: an HTTP request run on a schedule.
|
|
168
180
|
#
|
|
169
|
-
# Active-record style: instantiate via +
|
|
181
|
+
# Active-record style: instantiate via +client.jobs.new(...)+, mutate fields
|
|
170
182
|
# directly, and call {#save} to persist or {#delete} to remove. Header
|
|
171
|
-
# values in +configuration.headers+ are returned
|
|
172
|
-
#
|
|
173
|
-
#
|
|
183
|
+
# values in +configuration.headers+ are returned in plaintext on reads, so
|
|
184
|
+
# fetching a job, mutating it, and calling {#save} preserves its header
|
|
185
|
+
# values without re-entering secrets.
|
|
174
186
|
class Job
|
|
175
187
|
# @return [String] Caller-supplied unique identifier for the job (the
|
|
176
188
|
# resource +id+). Unique within the account and immutable; the service
|
|
@@ -214,7 +226,8 @@ module Smplkit
|
|
|
214
226
|
# @return [String, nil] ISO-8601 timestamp of the most recent mutation.
|
|
215
227
|
attr_accessor :updated_at
|
|
216
228
|
|
|
217
|
-
# @return [String, nil]
|
|
229
|
+
# @return [String, nil] Timestamp when the job was deleted; +nil+ for live
|
|
230
|
+
# jobs.
|
|
218
231
|
attr_accessor :deleted_at
|
|
219
232
|
|
|
220
233
|
# @return [Integer, nil] Monotonic version counter, bumped on every
|
|
@@ -258,7 +271,7 @@ module Smplkit
|
|
|
258
271
|
end
|
|
259
272
|
alias save! save
|
|
260
273
|
|
|
261
|
-
#
|
|
274
|
+
# Delete this job on the server.
|
|
262
275
|
#
|
|
263
276
|
# @return [nil]
|
|
264
277
|
def delete
|
|
@@ -285,6 +298,12 @@ module Smplkit
|
|
|
285
298
|
@version = other.version
|
|
286
299
|
end
|
|
287
300
|
|
|
301
|
+
# @api private — Build a {Job} from a JSON:API resource returned by the
|
|
302
|
+
# jobs service, binding it to +client+ so {#save} and {#delete} work.
|
|
303
|
+
#
|
|
304
|
+
# @param resource [Object] The JSON:API resource (id + attributes).
|
|
305
|
+
# @param client [JobsClient, nil] Client to bind the job to.
|
|
306
|
+
# @return [Job] The hydrated job.
|
|
288
307
|
def self.from_resource(resource, client: nil)
|
|
289
308
|
a = resource.attributes
|
|
290
309
|
new(
|
|
@@ -310,7 +329,7 @@ module Smplkit
|
|
|
310
329
|
#
|
|
311
330
|
# Runs are created and mutated by the jobs service, not by clients; clients
|
|
312
331
|
# influence runs only through the +run+ / +cancel+ / +rerun+ actions on
|
|
313
|
-
# +
|
|
332
|
+
# +client.jobs+.
|
|
314
333
|
#
|
|
315
334
|
# @!attribute [rw] id
|
|
316
335
|
# @return [String] Server-assigned UUID for this run.
|
|
@@ -353,6 +372,11 @@ module Smplkit
|
|
|
353
372
|
:total_duration_ms, :failure_reason, :error, :request, :result, :created_at,
|
|
354
373
|
keyword_init: true
|
|
355
374
|
) do
|
|
375
|
+
# @api private — Build a {Run} from a JSON:API resource returned by the
|
|
376
|
+
# jobs service.
|
|
377
|
+
#
|
|
378
|
+
# @param resource [Object] The JSON:API resource (id + attributes).
|
|
379
|
+
# @return [Run] The hydrated run.
|
|
356
380
|
def self.from_resource(resource)
|
|
357
381
|
a = resource.attributes
|
|
358
382
|
new(
|
|
@@ -393,6 +417,11 @@ module Smplkit
|
|
|
393
417
|
:period, :runs_used, :runs_included, :active_jobs, :active_jobs_limit,
|
|
394
418
|
keyword_init: true
|
|
395
419
|
) do
|
|
420
|
+
# @api private — Build a {Usage} snapshot from a JSON:API resource
|
|
421
|
+
# returned by the jobs service.
|
|
422
|
+
#
|
|
423
|
+
# @param resource [Object] The JSON:API resource (attributes).
|
|
424
|
+
# @return [Usage] The usage snapshot.
|
|
396
425
|
def self.from_resource(resource)
|
|
397
426
|
a = resource.attributes
|
|
398
427
|
new(
|