Class: Smplkit::Audit::AuditEvent
- Inherits:
-
Struct
- Object
- Struct
- Smplkit::Audit::AuditEvent
- Defined in:
- lib/smplkit/audit/models.rb
Overview
A single audit event as returned by the audit service (ADR-047 §2.3.1).
Instance Attribute Summary collapse
-
#action ⇒ String
Action slug — e.g.
-
#actor_id ⇒ String?
UUID of the actor when the actor is a tracked entity (user, api_key);
nilfor system or anonymous events. -
#actor_label ⇒ String?
Display label for the actor — typically a name or email.
-
#actor_type ⇒ String?
Type of actor (+“user”+, “api_key”, “system”, …) —
nilwhen unknown. -
#created_at ⇒ String
ISO-8601 timestamp of when the audit service first ingested this event.
-
#data ⇒ Hash{String => Object}
Free-form per-event payload defined by the customer.
-
#do_not_forward ⇒ Boolean
When
true, skip SIEM forwarder delivery regardless of any matching filter. -
#id ⇒ String
Server-assigned UUID for this event.
-
#idempotency_key ⇒ String?
Customer-supplied dedupe key,
nilif not provided. -
#occurred_at ⇒ String
ISO-8601 timestamp of when the action happened, as reported by the source.
-
#resource_id ⇒ String
Customer-facing id of the resource the action operated on.
-
#resource_type ⇒ String
Type of resource the action operated on — e.g.
Class Method Summary collapse
Instance Attribute Details
#action ⇒ String
Returns Action slug — e.g. “user.created”, “invoice.paid”.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/smplkit/audit/models.rb', line 143 AuditEvent = Struct.new( :id, :action, :resource_type, :resource_id, :occurred_at, :created_at, :actor_type, :actor_id, :actor_label, :data, :idempotency_key, :do_not_forward, keyword_init: true ) do def self.from_resource(resource) attrs = resource.attributes new( id: resource.id, action: attrs.action, resource_type: attrs.resource_type, resource_id: attrs.resource_id, occurred_at: attrs.occurred_at, created_at: attrs.created_at, actor_type: attrs.actor_type, actor_id: attrs.actor_id, actor_label: attrs.actor_label, data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}), idempotency_key: attrs.idempotency_key, do_not_forward: attrs.do_not_forward || false ) end end |
#actor_id ⇒ String?
Returns UUID of the actor when the actor is a tracked entity (user, api_key); nil for system or anonymous events.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/smplkit/audit/models.rb', line 143 AuditEvent = Struct.new( :id, :action, :resource_type, :resource_id, :occurred_at, :created_at, :actor_type, :actor_id, :actor_label, :data, :idempotency_key, :do_not_forward, keyword_init: true ) do def self.from_resource(resource) attrs = resource.attributes new( id: resource.id, action: attrs.action, resource_type: attrs.resource_type, resource_id: attrs.resource_id, occurred_at: attrs.occurred_at, created_at: attrs.created_at, actor_type: attrs.actor_type, actor_id: attrs.actor_id, actor_label: attrs.actor_label, data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}), idempotency_key: attrs.idempotency_key, do_not_forward: attrs.do_not_forward || false ) end end |
#actor_label ⇒ String?
Returns Display label for the actor — typically a name or email.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/smplkit/audit/models.rb', line 143 AuditEvent = Struct.new( :id, :action, :resource_type, :resource_id, :occurred_at, :created_at, :actor_type, :actor_id, :actor_label, :data, :idempotency_key, :do_not_forward, keyword_init: true ) do def self.from_resource(resource) attrs = resource.attributes new( id: resource.id, action: attrs.action, resource_type: attrs.resource_type, resource_id: attrs.resource_id, occurred_at: attrs.occurred_at, created_at: attrs.created_at, actor_type: attrs.actor_type, actor_id: attrs.actor_id, actor_label: attrs.actor_label, data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}), idempotency_key: attrs.idempotency_key, do_not_forward: attrs.do_not_forward || false ) end end |
#actor_type ⇒ String?
Returns Type of actor (+“user”+, “api_key”, “system”, …) — nil when unknown.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/smplkit/audit/models.rb', line 143 AuditEvent = Struct.new( :id, :action, :resource_type, :resource_id, :occurred_at, :created_at, :actor_type, :actor_id, :actor_label, :data, :idempotency_key, :do_not_forward, keyword_init: true ) do def self.from_resource(resource) attrs = resource.attributes new( id: resource.id, action: attrs.action, resource_type: attrs.resource_type, resource_id: attrs.resource_id, occurred_at: attrs.occurred_at, created_at: attrs.created_at, actor_type: attrs.actor_type, actor_id: attrs.actor_id, actor_label: attrs.actor_label, data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}), idempotency_key: attrs.idempotency_key, do_not_forward: attrs.do_not_forward || false ) end end |
#created_at ⇒ String
Returns ISO-8601 timestamp of when the audit service first ingested this event.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/smplkit/audit/models.rb', line 143 AuditEvent = Struct.new( :id, :action, :resource_type, :resource_id, :occurred_at, :created_at, :actor_type, :actor_id, :actor_label, :data, :idempotency_key, :do_not_forward, keyword_init: true ) do def self.from_resource(resource) attrs = resource.attributes new( id: resource.id, action: attrs.action, resource_type: attrs.resource_type, resource_id: attrs.resource_id, occurred_at: attrs.occurred_at, created_at: attrs.created_at, actor_type: attrs.actor_type, actor_id: attrs.actor_id, actor_label: attrs.actor_label, data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}), idempotency_key: attrs.idempotency_key, do_not_forward: attrs.do_not_forward || false ) end end |
#data ⇒ Hash{String => Object}
Returns Free-form per-event payload defined by the customer.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/smplkit/audit/models.rb', line 143 AuditEvent = Struct.new( :id, :action, :resource_type, :resource_id, :occurred_at, :created_at, :actor_type, :actor_id, :actor_label, :data, :idempotency_key, :do_not_forward, keyword_init: true ) do def self.from_resource(resource) attrs = resource.attributes new( id: resource.id, action: attrs.action, resource_type: attrs.resource_type, resource_id: attrs.resource_id, occurred_at: attrs.occurred_at, created_at: attrs.created_at, actor_type: attrs.actor_type, actor_id: attrs.actor_id, actor_label: attrs.actor_label, data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}), idempotency_key: attrs.idempotency_key, do_not_forward: attrs.do_not_forward || false ) end end |
#do_not_forward ⇒ Boolean
Returns When true, skip SIEM forwarder delivery regardless of any matching filter.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/smplkit/audit/models.rb', line 143 AuditEvent = Struct.new( :id, :action, :resource_type, :resource_id, :occurred_at, :created_at, :actor_type, :actor_id, :actor_label, :data, :idempotency_key, :do_not_forward, keyword_init: true ) do def self.from_resource(resource) attrs = resource.attributes new( id: resource.id, action: attrs.action, resource_type: attrs.resource_type, resource_id: attrs.resource_id, occurred_at: attrs.occurred_at, created_at: attrs.created_at, actor_type: attrs.actor_type, actor_id: attrs.actor_id, actor_label: attrs.actor_label, data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}), idempotency_key: attrs.idempotency_key, do_not_forward: attrs.do_not_forward || false ) end end |
#id ⇒ String
Returns Server-assigned UUID for this event.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/smplkit/audit/models.rb', line 143 AuditEvent = Struct.new( :id, :action, :resource_type, :resource_id, :occurred_at, :created_at, :actor_type, :actor_id, :actor_label, :data, :idempotency_key, :do_not_forward, keyword_init: true ) do def self.from_resource(resource) attrs = resource.attributes new( id: resource.id, action: attrs.action, resource_type: attrs.resource_type, resource_id: attrs.resource_id, occurred_at: attrs.occurred_at, created_at: attrs.created_at, actor_type: attrs.actor_type, actor_id: attrs.actor_id, actor_label: attrs.actor_label, data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}), idempotency_key: attrs.idempotency_key, do_not_forward: attrs.do_not_forward || false ) end end |
#idempotency_key ⇒ String?
Returns Customer-supplied dedupe key, nil if not provided.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/smplkit/audit/models.rb', line 143 AuditEvent = Struct.new( :id, :action, :resource_type, :resource_id, :occurred_at, :created_at, :actor_type, :actor_id, :actor_label, :data, :idempotency_key, :do_not_forward, keyword_init: true ) do def self.from_resource(resource) attrs = resource.attributes new( id: resource.id, action: attrs.action, resource_type: attrs.resource_type, resource_id: attrs.resource_id, occurred_at: attrs.occurred_at, created_at: attrs.created_at, actor_type: attrs.actor_type, actor_id: attrs.actor_id, actor_label: attrs.actor_label, data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}), idempotency_key: attrs.idempotency_key, do_not_forward: attrs.do_not_forward || false ) end end |
#occurred_at ⇒ String
Returns ISO-8601 timestamp of when the action happened, as reported by the source.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/smplkit/audit/models.rb', line 143 AuditEvent = Struct.new( :id, :action, :resource_type, :resource_id, :occurred_at, :created_at, :actor_type, :actor_id, :actor_label, :data, :idempotency_key, :do_not_forward, keyword_init: true ) do def self.from_resource(resource) attrs = resource.attributes new( id: resource.id, action: attrs.action, resource_type: attrs.resource_type, resource_id: attrs.resource_id, occurred_at: attrs.occurred_at, created_at: attrs.created_at, actor_type: attrs.actor_type, actor_id: attrs.actor_id, actor_label: attrs.actor_label, data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}), idempotency_key: attrs.idempotency_key, do_not_forward: attrs.do_not_forward || false ) end end |
#resource_id ⇒ String
Returns Customer-facing id of the resource the action operated on.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/smplkit/audit/models.rb', line 143 AuditEvent = Struct.new( :id, :action, :resource_type, :resource_id, :occurred_at, :created_at, :actor_type, :actor_id, :actor_label, :data, :idempotency_key, :do_not_forward, keyword_init: true ) do def self.from_resource(resource) attrs = resource.attributes new( id: resource.id, action: attrs.action, resource_type: attrs.resource_type, resource_id: attrs.resource_id, occurred_at: attrs.occurred_at, created_at: attrs.created_at, actor_type: attrs.actor_type, actor_id: attrs.actor_id, actor_label: attrs.actor_label, data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}), idempotency_key: attrs.idempotency_key, do_not_forward: attrs.do_not_forward || false ) end end |
#resource_type ⇒ String
Returns Type of resource the action operated on — e.g. “invoice”.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/smplkit/audit/models.rb', line 143 AuditEvent = Struct.new( :id, :action, :resource_type, :resource_id, :occurred_at, :created_at, :actor_type, :actor_id, :actor_label, :data, :idempotency_key, :do_not_forward, keyword_init: true ) do def self.from_resource(resource) attrs = resource.attributes new( id: resource.id, action: attrs.action, resource_type: attrs.resource_type, resource_id: attrs.resource_id, occurred_at: attrs.occurred_at, created_at: attrs.created_at, actor_type: attrs.actor_type, actor_id: attrs.actor_id, actor_label: attrs.actor_label, data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}), idempotency_key: attrs.idempotency_key, do_not_forward: attrs.do_not_forward || false ) end end |
Class Method Details
.from_resource(resource) ⇒ Object
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/smplkit/audit/models.rb', line 150 def self.from_resource(resource) attrs = resource.attributes new( id: resource.id, action: attrs.action, resource_type: attrs.resource_type, resource_id: attrs.resource_id, occurred_at: attrs.occurred_at, created_at: attrs.created_at, actor_type: attrs.actor_type, actor_id: attrs.actor_id, actor_label: attrs.actor_label, data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}), idempotency_key: attrs.idempotency_key, do_not_forward: attrs.do_not_forward || false ) end |