smplkit 3.0.60 → 3.0.61

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: '06975d5368d200b5bb4b41bd75a0bcfe2e73719134384a996e1d1329139f5e43'
4
- data.tar.gz: a3009fbe825b7504452ed98c620e9dc86011cd127a7be32168130456898960ef
3
+ metadata.gz: 43242353842d4384ef5fee09749bb8030fe60d62ed0124a368694470adf7341c
4
+ data.tar.gz: 9149f6dd070aad95584fba15b9d7ced15b1e1103ef2a845d304854c03a51da6a
5
5
  SHA512:
6
- metadata.gz: a606827a20f3a7e00a34d0ae73cf38803355809a0b2cc0896fa7bbfa7e7489da35ae67973de05433aecd094d5dee307e4ae0e306d4019b3117013d9fa46a8641
7
- data.tar.gz: e935a07f39bf40bd0c68ebe7cc668d0476b3a0c8212a6a47185ebf2585626be84ae66211a6bc742f5437a5e1742f4abb3c82e5adc8d608f5f61ce715b1be8170
6
+ metadata.gz: b8fa96a1fbaaf9e0c7d9c8b5d8064c31c9a1115714c3f3e5a5d4771664c3e3cf655b939b26b6fc90fc2166fd73d9b9c425a50bd47adadd98eac1cb21f9927bbb
7
+ data.tar.gz: 188a87a5c388d4ebc7277dcdef51633c01fc244e58c5bb53b560ee4d2a602afffc5128c079aa523b7a1135ca9fa831898be4861b8ab1736da84f29f9d3c0ec01
@@ -262,12 +262,32 @@ module Smplkit
262
262
  # @return [String] Status the destination must return for delivery to count
263
263
  # as success — an exact code (+"200"+, +"204"+) or a class (+"2xx"+, +"4xx"+).
264
264
  # Defaults to +"2xx"+.
265
+ # @!attribute [rw] tls_verify
266
+ # @return [Boolean] Whether to verify the destination's TLS certificate
267
+ # chain. Defaults to +true+; flip to +false+ only for short-lived
268
+ # testing against a destination that serves an untrusted certificate.
269
+ # Prefer pinning the issuing CA via +ca_cert+ for long-lived self-signed
270
+ # setups.
271
+ # @!attribute [rw] ca_cert
272
+ # @return [String, nil] Optional PEM-encoded certificate (or bundle)
273
+ # trusted in addition to the system CA store. Ignored when
274
+ # +tls_verify+ is +false+. +nil+ (the default) means "use system CAs
275
+ # only".
265
276
  #
266
277
  # rubocop:disable Lint/StructNewOverride -- ``:method`` matches the
267
278
  # API attribute and shadowing Struct#method is the expected ergonomics.
268
- HttpConfiguration = Struct.new(:method, :url, :headers, :success_status, keyword_init: true) do
269
- def initialize(method: HttpMethod::POST, url: "", headers: nil, success_status: "2xx")
270
- super(method: HttpMethod.coerce(method), url: url, headers: headers || [], success_status: success_status)
279
+ HttpConfiguration = Struct.new(
280
+ :method, :url, :headers, :success_status, :tls_verify, :ca_cert,
281
+ keyword_init: true
282
+ ) do
283
+ def initialize(
284
+ method: HttpMethod::POST, url: "", headers: nil,
285
+ success_status: "2xx", tls_verify: true, ca_cert: nil
286
+ )
287
+ super(
288
+ method: HttpMethod.coerce(method), url: url, headers: headers || [],
289
+ success_status: success_status, tls_verify: tls_verify, ca_cert: ca_cert
290
+ )
271
291
  end
272
292
 
273
293
  def self.to_wire(src)
@@ -284,18 +304,29 @@ module Smplkit
284
304
  end
285
305
  SmplkitGeneratedClient::Audit::HttpHeader.new(name: name, value: value)
286
306
  end,
287
- success_status: h.success_status
307
+ success_status: h.success_status,
308
+ tls_verify: h.tls_verify,
309
+ ca_cert: h.ca_cert
288
310
  )
289
311
  end
290
312
 
291
313
  def self.from_wire(src)
292
314
  return new if src.nil?
293
315
 
316
+ # Absent ``tls_verify`` on the wire means a forwarder persisted
317
+ # before the field landed — default to verifying so its prior
318
+ # secure behaviour is preserved.
294
319
  new(
295
320
  method: src.method || HttpMethod::POST,
296
321
  url: src.url || "",
297
322
  headers: (src.headers || []).map { |h| HttpHeader.new(name: h.name, value: h.value) },
298
- success_status: src.success_status || "2xx"
323
+ success_status: src.success_status || "2xx",
324
+ # rubocop:disable Style/RedundantCondition -- nil and false are
325
+ # distinct: nil means "field absent on the wire" (default to true);
326
+ # explicit false means "verification disabled".
327
+ tls_verify: src.tls_verify.nil? ? true : src.tls_verify,
328
+ # rubocop:enable Style/RedundantCondition
329
+ ca_cert: src.ca_cert
299
330
  )
300
331
  end
301
332
  end
@@ -311,7 +342,10 @@ module Smplkit
311
342
  # Re-supply real values before calling {#save}; the SDK does not cache
312
343
  # them client-side.
313
344
  class Forwarder
314
- # @return [String, nil] Server-assigned UUID, +nil+ until {#save} has run.
345
+ # @return [String, nil] Caller-supplied unique identifier (key) for this
346
+ # forwarder. Unique within an account; immutable for the lifetime of
347
+ # the forwarder. +nil+ only while the object represents an unsaved
348
+ # instance constructed without an id (which {#save} would then reject).
315
349
  attr_accessor :id
316
350
 
317
351
  # @return [String] Display name. Free-form.
@@ -56,13 +56,14 @@ module Smplkit
56
56
  # nil or both set, or when +transform_type+ is +JSONATA+ and +transform+
57
57
  # is not a +String+.
58
58
  # @return [Smplkit::Audit::Forwarder]
59
- def new_forwarder(name:, forwarder_type:, configuration:,
59
+ def new_forwarder(id, forwarder_type:, configuration:, name: nil,
60
60
  enabled: true, description: nil,
61
61
  filter: nil, transform: nil, transform_type: nil)
62
62
  Smplkit::Audit::Forwarder.send(:validate_transform_pair!, transform, transform_type)
63
63
  Smplkit::Audit::Forwarder.new(
64
64
  self,
65
- name: name,
65
+ id: id,
66
+ name: name || id,
66
67
  forwarder_type: forwarder_type,
67
68
  configuration: configuration,
68
69
  enabled: enabled,
@@ -118,7 +119,11 @@ module Smplkit
118
119
  # @api private — POST a new forwarder. Called by
119
120
  # {Smplkit::Audit::Forwarder#save} on unsaved instances.
120
121
  def _create_forwarder(forwarder)
121
- resp = Smplkit::Audit.call_api { @api.create_forwarder(build_body(forwarder)) }
122
+ if forwarder.id.nil? || forwarder.id.empty?
123
+ raise ArgumentError, "Forwarder.id is required on create (caller-supplied key)"
124
+ end
125
+
126
+ resp = Smplkit::Audit.call_api { @api.create_forwarder(build_create_body(forwarder)) }
122
127
  Smplkit::Audit::Forwarder.from_resource(resp.data, client: self)
123
128
  end
124
129
 
@@ -138,8 +143,8 @@ module Smplkit
138
143
 
139
144
  private
140
145
 
141
- def build_body(forwarder)
142
- attrs = SmplkitGeneratedClient::Audit::Forwarder.new(
146
+ def build_attrs(forwarder)
147
+ SmplkitGeneratedClient::Audit::Forwarder.new(
143
148
  name: forwarder.name,
144
149
  description: forwarder.description,
145
150
  forwarder_type: Smplkit::Audit::ForwarderType.coerce(forwarder.forwarder_type),
@@ -149,10 +154,26 @@ module Smplkit
149
154
  transform: forwarder.transform,
150
155
  configuration: Smplkit::Audit::HttpConfiguration.to_wire(forwarder.configuration)
151
156
  )
157
+ end
158
+
159
+ def build_create_body(forwarder)
160
+ # Create uses the distinct ForwarderCreateRequest envelope; the
161
+ # audit service requires data.id (the customer-supplied key) on
162
+ # create and 409s on conflict.
163
+ resource = SmplkitGeneratedClient::Audit::ForwarderCreateResource.new(
164
+ id: forwarder.id.to_s,
165
+ type: "forwarder",
166
+ attributes: build_attrs(forwarder)
167
+ )
168
+ SmplkitGeneratedClient::Audit::ForwarderCreateRequest.new(data: resource)
169
+ end
170
+
171
+ def build_body(forwarder)
172
+ # Update path uses the generic ForwarderRequest envelope.
152
173
  resource = SmplkitGeneratedClient::Audit::ForwarderResource.new(
153
- id: forwarder.id ? forwarder.id.to_s : "",
174
+ id: forwarder.id.to_s,
154
175
  type: "forwarder",
155
- attributes: attrs
176
+ attributes: build_attrs(forwarder)
156
177
  )
157
178
  SmplkitGeneratedClient::Audit::ForwarderRequest.new(data: resource)
158
179
  end
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.60
4
+ version: 3.0.61
5
5
  platform: ruby
6
6
  authors:
7
7
  - Smpl Solutions LLC