smplkit 3.0.23 → 3.0.24
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/audit/models.rb +24 -0
- data/lib/smplkit/management/audit.rb +11 -12
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e01aa3cb437ae82f20a01f1e0c8db011df81743411217757e0f7bebebd0210c1
|
|
4
|
+
data.tar.gz: 885c582b378994dae192d1453020e211e97a3552c5938a695c1fae9e3e316d56
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4eb6729884abcc3a25a82355c426a316b10beef8ecd0fe7f2cbecf96d1a94644730086348bf35c826600cd8a36c3c604aeb495ceada93c0e3471e62a7c8d9cd5
|
|
7
|
+
data.tar.gz: 8235e725b934305e260595371f2bc330bd409a33a0bb965f2002349f564467891f1afe3777609b5caa1a7b2d423c459d3bcec0abdacb250d1446e205da0675de
|
data/lib/smplkit/audit/models.rb
CHANGED
|
@@ -386,10 +386,14 @@ module Smplkit
|
|
|
386
386
|
# response (including newly-assigned +id+, +created_at+, +updated_at+,
|
|
387
387
|
# +version+).
|
|
388
388
|
#
|
|
389
|
+
# @raise [ArgumentError] when {#transform} and {#transform_type} are not
|
|
390
|
+
# both nil or both set, or when {#transform_type} is +JSONATA+ and
|
|
391
|
+
# {#transform} is not a +String+.
|
|
389
392
|
# @return [self]
|
|
390
393
|
def save
|
|
391
394
|
raise "Forwarder was constructed without a client; cannot save" if @client.nil?
|
|
392
395
|
|
|
396
|
+
self.class.send(:validate_transform_pair!, @transform, @transform_type)
|
|
393
397
|
updated = @created_at.nil? ? @client._create_forwarder(self) : @client._update_forwarder(self)
|
|
394
398
|
_apply(updated)
|
|
395
399
|
self
|
|
@@ -423,6 +427,26 @@ module Smplkit
|
|
|
423
427
|
@version = other.version
|
|
424
428
|
end
|
|
425
429
|
|
|
430
|
+
# Validate the +(transform, transform_type)+ pair.
|
|
431
|
+
#
|
|
432
|
+
# Both must be nil or both must be set. When +transform_type+ is
|
|
433
|
+
# +TransformType::JSONATA+, +transform+ must be a +String+ (the
|
|
434
|
+
# JSONata expression). Other engines accept any value.
|
|
435
|
+
#
|
|
436
|
+
# @api private
|
|
437
|
+
def self.validate_transform_pair!(transform, transform_type)
|
|
438
|
+
if transform.nil? != transform_type.nil?
|
|
439
|
+
raise ArgumentError,
|
|
440
|
+
"transform and transform_type must be specified together (both nil or both set)"
|
|
441
|
+
end
|
|
442
|
+
return if transform.nil?
|
|
443
|
+
return unless transform_type == TransformType::JSONATA && !transform.is_a?(String)
|
|
444
|
+
|
|
445
|
+
raise ArgumentError,
|
|
446
|
+
"transform must be a String when transform_type is JSONATA " \
|
|
447
|
+
"(got #{transform.class})"
|
|
448
|
+
end
|
|
449
|
+
|
|
426
450
|
def self.from_resource(resource, client: nil)
|
|
427
451
|
a = resource.attributes
|
|
428
452
|
new(
|
|
@@ -44,23 +44,22 @@ module Smplkit
|
|
|
44
44
|
# @param filter [Hash, nil] Optional JSON Logic filter; events that don't
|
|
45
45
|
# match are recorded as +filtered_out+ deliveries.
|
|
46
46
|
# @param transform [Object, nil] Optional template applied to each event
|
|
47
|
-
# before delivery. Free-form — the audit service passes the
|
|
48
|
-
# verbatim to the engine named by +transform_type+. Must be paired
|
|
49
|
-
# a non-nil +transform_type
|
|
47
|
+
# before delivery. Free-form by default — the audit service passes the
|
|
48
|
+
# value verbatim to the engine named by +transform_type+. Must be paired
|
|
49
|
+
# with a non-nil +transform_type+; when +transform_type+ is
|
|
50
|
+
# +TransformType::JSONATA+, +transform+ must be a +String+ (the JSONata
|
|
51
|
+
# expression).
|
|
50
52
|
# @param transform_type [String, nil] Engine that evaluates +transform+ —
|
|
51
|
-
# one of {Smplkit::Audit::TransformType::VALUES}.
|
|
52
|
-
# +transform
|
|
53
|
-
# @raise [ArgumentError] when +transform+
|
|
53
|
+
# one of {Smplkit::Audit::TransformType::VALUES}. Must be paired with a
|
|
54
|
+
# non-nil +transform+.
|
|
55
|
+
# @raise [ArgumentError] when +transform+ and +transform_type+ are not both
|
|
56
|
+
# nil or both set, or when +transform_type+ is +JSONATA+ and +transform+
|
|
57
|
+
# is not a +String+.
|
|
54
58
|
# @return [Smplkit::Audit::Forwarder]
|
|
55
59
|
def new_forwarder(name:, forwarder_type:, configuration:,
|
|
56
60
|
enabled: true, description: nil,
|
|
57
61
|
filter: nil, transform: nil, transform_type: nil)
|
|
58
|
-
|
|
59
|
-
raise ArgumentError,
|
|
60
|
-
"transform_type is required when transform is provided " \
|
|
61
|
-
"(one of #{Smplkit::Audit::TransformType::VALUES.inspect})"
|
|
62
|
-
end
|
|
63
|
-
|
|
62
|
+
Smplkit::Audit::Forwarder.send(:validate_transform_pair!, transform, transform_type)
|
|
64
63
|
Smplkit::Audit::Forwarder.new(
|
|
65
64
|
self,
|
|
66
65
|
name: name,
|