Class: Smplkit::Audit::AuditEvent

Inherits:
Struct
  • Object
show all
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

Class Method Summary collapse

Instance Attribute Details

#actionString

Returns Action slug — e.g. “user.created”, “invoice.paid”.

Returns:

  • (String)

    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_idString?

Returns UUID of the actor when the actor is a tracked entity (user, api_key); nil for system or anonymous events.

Returns:

  • (String, nil)

    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_labelString?

Returns Display label for the actor — typically a name or email.

Returns:

  • (String, nil)

    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_typeString?

Returns Type of actor (+“user”+, “api_key”, “system”, …) — nil when unknown.

Returns:

  • (String, nil)

    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_atString

Returns ISO-8601 timestamp of when the audit service first ingested this event.

Returns:

  • (String)

    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

#dataHash{String => Object}

Returns Free-form per-event payload defined by the customer.

Returns:

  • (Hash{String => Object})

    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_forwardBoolean

Returns When true, skip SIEM forwarder delivery regardless of any matching filter.

Returns:

  • (Boolean)

    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

#idString

Returns Server-assigned UUID for this event.

Returns:

  • (String)

    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_keyString?

Returns Customer-supplied dedupe key, nil if not provided.

Returns:

  • (String, nil)

    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_atString

Returns ISO-8601 timestamp of when the action happened, as reported by the source.

Returns:

  • (String)

    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_idString

Returns Customer-facing id of the resource the action operated on.

Returns:

  • (String)

    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_typeString

Returns Type of resource the action operated on — e.g. “invoice”.

Returns:

  • (String)

    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