Class: Smplkit::Audit::Forwarder
- Inherits:
-
Object
- Object
- Smplkit::Audit::Forwarder
- Defined in:
- lib/smplkit/audit/models.rb
Overview
A SIEM streaming forwarder configured on the customer’s account.
Active-record style: instantiate via mgmt.audit.forwarders.new_forwarder(…), mutate fields directly, and call #save to persist or #delete to remove. Header values in configuration.headers are returned redacted on reads — the GET path on the audit API replaces every header value with “<redacted>”. Re-supply real values before calling #save; the SDK does not cache them client-side.
Instance Attribute Summary collapse
-
#configuration ⇒ HttpConfiguration
Destination request configuration.
-
#created_at ⇒ String?
ISO-8601 timestamp of first persist.
-
#deleted_at ⇒ String?
Soft-delete timestamp.
-
#description ⇒ String?
Optional free-text description.
-
#enabled ⇒ Boolean
When
false, the audit service skips delivery for this forwarder but still recordsfiltered_outdeliveries. -
#filter ⇒ Hash?
Optional JSON Logic expression evaluated per event.
- #forwarder_type ⇒ String
-
#id ⇒ String?
Server-assigned UUID,
niluntil #save has run. -
#name ⇒ String
Display name.
-
#transform ⇒ String?
Optional template applied to each event before delivery.
-
#transform_type ⇒ String?
Engine that evaluates #transform.
-
#updated_at ⇒ String?
ISO-8601 timestamp of the most recent mutation.
-
#version ⇒ Integer?
Monotonic version counter, bumped on every server-side write.
Class Method Summary collapse
Instance Method Summary collapse
- #_apply(other) ⇒ Object private
-
#delete ⇒ nil
(also: #delete!)
Soft-delete this forwarder on the server.
-
#initialize(client = nil, name:, forwarder_type:, configuration:, id: nil, enabled: true, description: nil, filter: nil, transform: nil, transform_type: nil, created_at: nil, updated_at: nil, deleted_at: nil, version: nil) ⇒ Forwarder
constructor
A new instance of Forwarder.
-
#save ⇒ self
(also: #save!)
Create or update this forwarder on the server.
Constructor Details
#initialize(client = nil, name:, forwarder_type:, configuration:, id: nil, enabled: true, description: nil, filter: nil, transform: nil, transform_type: nil, created_at: nil, updated_at: nil, deleted_at: nil, version: nil) ⇒ Forwarder
Returns a new instance of Forwarder.
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
# File 'lib/smplkit/audit/models.rb', line 334 def initialize(client = nil, name:, forwarder_type:, configuration:, id: nil, enabled: true, description: nil, filter: nil, transform: nil, transform_type: nil, created_at: nil, updated_at: nil, deleted_at: nil, version: nil) @client = client @id = id @name = name @forwarder_type = ForwarderType.coerce(forwarder_type) @configuration = configuration @enabled = enabled @description = description @filter = filter @transform = transform @transform_type = transform_type @created_at = created_at @updated_at = updated_at @deleted_at = deleted_at @version = version end |
Instance Attribute Details
#configuration ⇒ HttpConfiguration
Returns Destination request configuration.
303 304 305 |
# File 'lib/smplkit/audit/models.rb', line 303 def configuration @configuration end |
#created_at ⇒ String?
Returns ISO-8601 timestamp of first persist. nil for an unsaved instance.
323 324 325 |
# File 'lib/smplkit/audit/models.rb', line 323 def created_at @created_at end |
#deleted_at ⇒ String?
Returns Soft-delete timestamp. nil for live forwarders.
329 330 331 |
# File 'lib/smplkit/audit/models.rb', line 329 def deleted_at @deleted_at end |
#description ⇒ String?
Returns Optional free-text description.
306 307 308 |
# File 'lib/smplkit/audit/models.rb', line 306 def description @description end |
#enabled ⇒ Boolean
Returns When false, the audit service skips delivery for this forwarder but still records filtered_out deliveries.
300 301 302 |
# File 'lib/smplkit/audit/models.rb', line 300 def enabled @enabled end |
#filter ⇒ Hash?
Returns Optional JSON Logic expression evaluated per event. When set, events that don’t match are recorded as filtered_out deliveries instead of being delivered to the destination.
311 312 313 |
# File 'lib/smplkit/audit/models.rb', line 311 def filter @filter end |
#forwarder_type ⇒ String
Returns One of Smplkit::Audit::ForwarderType::VALUES.
296 297 298 |
# File 'lib/smplkit/audit/models.rb', line 296 def forwarder_type @forwarder_type end |
#id ⇒ String?
Returns Server-assigned UUID, nil until #save has run.
290 291 292 |
# File 'lib/smplkit/audit/models.rb', line 290 def id @id end |
#name ⇒ String
Returns Display name. Free-form.
293 294 295 |
# File 'lib/smplkit/audit/models.rb', line 293 def name @name end |
#transform ⇒ String?
Returns Optional template applied to each event before delivery. Shape depends on #transform_type; for “JSONATA”, a JSONata expression. nil delivers the event JSON as-is.
316 317 318 |
# File 'lib/smplkit/audit/models.rb', line 316 def transform @transform end |
#transform_type ⇒ String?
Returns Engine that evaluates #transform. Currently only “JSONATA” is supported.
320 321 322 |
# File 'lib/smplkit/audit/models.rb', line 320 def transform_type @transform_type end |
#updated_at ⇒ String?
Returns ISO-8601 timestamp of the most recent mutation.
326 327 328 |
# File 'lib/smplkit/audit/models.rb', line 326 def updated_at @updated_at end |
#version ⇒ Integer?
Returns Monotonic version counter, bumped on every server-side write.
332 333 334 |
# File 'lib/smplkit/audit/models.rb', line 332 def version @version end |
Class Method Details
.from_resource(resource, client: nil) ⇒ Object
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
# File 'lib/smplkit/audit/models.rb', line 399 def self.from_resource(resource, client: nil) a = resource.attributes new( client, id: resource.id, name: a.name, description: a.description, forwarder_type: a.forwarder_type, enabled: a.enabled.nil? || a.enabled, filter: a.filter.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.filter), transform_type: a.transform_type, transform: a.transform, configuration: HttpConfiguration.from_wire(a.configuration), created_at: a.created_at, updated_at: a.updated_at, deleted_at: a.deleted_at, version: a.version ) end |
Instance Method Details
#_apply(other) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
# File 'lib/smplkit/audit/models.rb', line 383 def _apply(other) @id = other.id @name = other.name @forwarder_type = other.forwarder_type @configuration = other.configuration @enabled = other.enabled @description = other.description @filter = other.filter @transform = other.transform @transform_type = other.transform_type @created_at = other.created_at @updated_at = other.updated_at @deleted_at = other.deleted_at @version = other.version end |
#delete ⇒ nil Also known as: delete!
Soft-delete this forwarder on the server.
375 376 377 378 379 |
# File 'lib/smplkit/audit/models.rb', line 375 def delete raise "Forwarder was constructed without a client or id; cannot delete" if @client.nil? || @id.nil? @client.delete(@id) end |
#save ⇒ self Also known as: save!
Create or update this forwarder on the server.
Upsert behavior is driven by #created_at: a forwarder with no created_at is created (POST); otherwise it’s full-replace updated (PUT). After the call, every field is refreshed from the server response (including newly-assigned id, created_at, updated_at, version).
363 364 365 366 367 368 369 |
# File 'lib/smplkit/audit/models.rb', line 363 def save raise "Forwarder was constructed without a client; cannot save" if @client.nil? updated = @created_at.nil? ? @client._create_forwarder(self) : @client._update_forwarder(self) _apply(updated) self end |