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.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#actor_idString?

Returns Customer-supplied free-form actor identifier — nil when not provided.

Returns:

  • (String, nil)

    Customer-supplied free-form actor identifier — nil when not provided.



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/smplkit/audit/models.rb', line 208

AuditEvent = Struct.new(
  :id, :event_type, :resource_type, :resource_id,
  :occurred_at, :created_at,
  :actor_type, :actor_id, :actor_label, :category,
  :data, :idempotency_key, :do_not_forward, :environment,
  keyword_init: true
) do
  def self.from_resource(resource)
    attrs = resource.attributes
    new(
      id: resource.id,
      event_type: attrs.event_type,
      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,
      category: attrs.category,
      data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}),
      idempotency_key: attrs.idempotency_key,
      do_not_forward: attrs.do_not_forward || false,
      environment: attrs.environment
    )
  end
end

#actor_labelString?

Returns Customer-supplied display label for the actor — typically a name or email.

Returns:

  • (String, nil)

    Customer-supplied display label for the actor — typically a name or email.



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/smplkit/audit/models.rb', line 208

AuditEvent = Struct.new(
  :id, :event_type, :resource_type, :resource_id,
  :occurred_at, :created_at,
  :actor_type, :actor_id, :actor_label, :category,
  :data, :idempotency_key, :do_not_forward, :environment,
  keyword_init: true
) do
  def self.from_resource(resource)
    attrs = resource.attributes
    new(
      id: resource.id,
      event_type: attrs.event_type,
      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,
      category: attrs.category,
      data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}),
      idempotency_key: attrs.idempotency_key,
      do_not_forward: attrs.do_not_forward || false,
      environment: attrs.environment
    )
  end
end

#actor_typeString?

Returns Customer-supplied free-form actor type string — nil when not provided.

Returns:

  • (String, nil)

    Customer-supplied free-form actor type string — nil when not provided.



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/smplkit/audit/models.rb', line 208

AuditEvent = Struct.new(
  :id, :event_type, :resource_type, :resource_id,
  :occurred_at, :created_at,
  :actor_type, :actor_id, :actor_label, :category,
  :data, :idempotency_key, :do_not_forward, :environment,
  keyword_init: true
) do
  def self.from_resource(resource)
    attrs = resource.attributes
    new(
      id: resource.id,
      event_type: attrs.event_type,
      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,
      category: attrs.category,
      data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}),
      idempotency_key: attrs.idempotency_key,
      do_not_forward: attrs.do_not_forward || false,
      environment: attrs.environment
    )
  end
end

#categoryString?

Returns Free-form bucket label for the event — e.g. “auth”, “billing”, “config-change”. Stored exactly as supplied; drives the audit log’s category filter and the categories discovery listing (Smplkit::Audit::AuditClient#categories). nil when not supplied.

Returns:

  • (String, nil)

    Free-form bucket label for the event — e.g. “auth”, “billing”, “config-change”. Stored exactly as supplied; drives the audit log’s category filter and the categories discovery listing (Smplkit::Audit::AuditClient#categories). nil when not supplied.



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/smplkit/audit/models.rb', line 208

AuditEvent = Struct.new(
  :id, :event_type, :resource_type, :resource_id,
  :occurred_at, :created_at,
  :actor_type, :actor_id, :actor_label, :category,
  :data, :idempotency_key, :do_not_forward, :environment,
  keyword_init: true
) do
  def self.from_resource(resource)
    attrs = resource.attributes
    new(
      id: resource.id,
      event_type: attrs.event_type,
      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,
      category: attrs.category,
      data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}),
      idempotency_key: attrs.idempotency_key,
      do_not_forward: attrs.do_not_forward || false,
      environment: attrs.environment
    )
  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.



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/smplkit/audit/models.rb', line 208

AuditEvent = Struct.new(
  :id, :event_type, :resource_type, :resource_id,
  :occurred_at, :created_at,
  :actor_type, :actor_id, :actor_label, :category,
  :data, :idempotency_key, :do_not_forward, :environment,
  keyword_init: true
) do
  def self.from_resource(resource)
    attrs = resource.attributes
    new(
      id: resource.id,
      event_type: attrs.event_type,
      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,
      category: attrs.category,
      data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}),
      idempotency_key: attrs.idempotency_key,
      do_not_forward: attrs.do_not_forward || false,
      environment: attrs.environment
    )
  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.



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/smplkit/audit/models.rb', line 208

AuditEvent = Struct.new(
  :id, :event_type, :resource_type, :resource_id,
  :occurred_at, :created_at,
  :actor_type, :actor_id, :actor_label, :category,
  :data, :idempotency_key, :do_not_forward, :environment,
  keyword_init: true
) do
  def self.from_resource(resource)
    attrs = resource.attributes
    new(
      id: resource.id,
      event_type: attrs.event_type,
      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,
      category: attrs.category,
      data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}),
      idempotency_key: attrs.idempotency_key,
      do_not_forward: attrs.do_not_forward || false,
      environment: attrs.environment
    )
  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.



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/smplkit/audit/models.rb', line 208

AuditEvent = Struct.new(
  :id, :event_type, :resource_type, :resource_id,
  :occurred_at, :created_at,
  :actor_type, :actor_id, :actor_label, :category,
  :data, :idempotency_key, :do_not_forward, :environment,
  keyword_init: true
) do
  def self.from_resource(resource)
    attrs = resource.attributes
    new(
      id: resource.id,
      event_type: attrs.event_type,
      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,
      category: attrs.category,
      data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}),
      idempotency_key: attrs.idempotency_key,
      do_not_forward: attrs.do_not_forward || false,
      environment: attrs.environment
    )
  end
end

#environmentString?

Returns The environment the event was recorded in. Read-only and always present on reads — the audit service resolves it when the event is recorded (from a single-environment credential, or from the runtime SDK’s configured environment, which the SDK sends on every recording call). Never set on the recording request body.

Returns:

  • (String, nil)

    The environment the event was recorded in. Read-only and always present on reads — the audit service resolves it when the event is recorded (from a single-environment credential, or from the runtime SDK’s configured environment, which the SDK sends on every recording call). Never set on the recording request body.



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/smplkit/audit/models.rb', line 208

AuditEvent = Struct.new(
  :id, :event_type, :resource_type, :resource_id,
  :occurred_at, :created_at,
  :actor_type, :actor_id, :actor_label, :category,
  :data, :idempotency_key, :do_not_forward, :environment,
  keyword_init: true
) do
  def self.from_resource(resource)
    attrs = resource.attributes
    new(
      id: resource.id,
      event_type: attrs.event_type,
      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,
      category: attrs.category,
      data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}),
      idempotency_key: attrs.idempotency_key,
      do_not_forward: attrs.do_not_forward || false,
      environment: attrs.environment
    )
  end
end

#event_typeString

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

Returns:

  • (String)

    Event type slug — e.g. “user.created”, “invoice.paid”.



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/smplkit/audit/models.rb', line 208

AuditEvent = Struct.new(
  :id, :event_type, :resource_type, :resource_id,
  :occurred_at, :created_at,
  :actor_type, :actor_id, :actor_label, :category,
  :data, :idempotency_key, :do_not_forward, :environment,
  keyword_init: true
) do
  def self.from_resource(resource)
    attrs = resource.attributes
    new(
      id: resource.id,
      event_type: attrs.event_type,
      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,
      category: attrs.category,
      data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}),
      idempotency_key: attrs.idempotency_key,
      do_not_forward: attrs.do_not_forward || false,
      environment: attrs.environment
    )
  end
end

#idString

Returns Server-assigned UUID for this event.

Returns:

  • (String)

    Server-assigned UUID for this event.



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/smplkit/audit/models.rb', line 208

AuditEvent = Struct.new(
  :id, :event_type, :resource_type, :resource_id,
  :occurred_at, :created_at,
  :actor_type, :actor_id, :actor_label, :category,
  :data, :idempotency_key, :do_not_forward, :environment,
  keyword_init: true
) do
  def self.from_resource(resource)
    attrs = resource.attributes
    new(
      id: resource.id,
      event_type: attrs.event_type,
      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,
      category: attrs.category,
      data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}),
      idempotency_key: attrs.idempotency_key,
      do_not_forward: attrs.do_not_forward || false,
      environment: attrs.environment
    )
  end
end

#idempotency_keyString?

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

Returns:

  • (String, nil)

    Customer-supplied dedupe key, nil if not provided.



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/smplkit/audit/models.rb', line 208

AuditEvent = Struct.new(
  :id, :event_type, :resource_type, :resource_id,
  :occurred_at, :created_at,
  :actor_type, :actor_id, :actor_label, :category,
  :data, :idempotency_key, :do_not_forward, :environment,
  keyword_init: true
) do
  def self.from_resource(resource)
    attrs = resource.attributes
    new(
      id: resource.id,
      event_type: attrs.event_type,
      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,
      category: attrs.category,
      data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}),
      idempotency_key: attrs.idempotency_key,
      do_not_forward: attrs.do_not_forward || false,
      environment: attrs.environment
    )
  end
end

#occurred_atString

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

Returns:

  • (String)

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



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/smplkit/audit/models.rb', line 208

AuditEvent = Struct.new(
  :id, :event_type, :resource_type, :resource_id,
  :occurred_at, :created_at,
  :actor_type, :actor_id, :actor_label, :category,
  :data, :idempotency_key, :do_not_forward, :environment,
  keyword_init: true
) do
  def self.from_resource(resource)
    attrs = resource.attributes
    new(
      id: resource.id,
      event_type: attrs.event_type,
      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,
      category: attrs.category,
      data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}),
      idempotency_key: attrs.idempotency_key,
      do_not_forward: attrs.do_not_forward || false,
      environment: attrs.environment
    )
  end
end

#resource_idString

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

Returns:

  • (String)

    Customer-facing id of the resource the event operated on.



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/smplkit/audit/models.rb', line 208

AuditEvent = Struct.new(
  :id, :event_type, :resource_type, :resource_id,
  :occurred_at, :created_at,
  :actor_type, :actor_id, :actor_label, :category,
  :data, :idempotency_key, :do_not_forward, :environment,
  keyword_init: true
) do
  def self.from_resource(resource)
    attrs = resource.attributes
    new(
      id: resource.id,
      event_type: attrs.event_type,
      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,
      category: attrs.category,
      data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}),
      idempotency_key: attrs.idempotency_key,
      do_not_forward: attrs.do_not_forward || false,
      environment: attrs.environment
    )
  end
end

#resource_typeString

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

Returns:

  • (String)

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



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/smplkit/audit/models.rb', line 208

AuditEvent = Struct.new(
  :id, :event_type, :resource_type, :resource_id,
  :occurred_at, :created_at,
  :actor_type, :actor_id, :actor_label, :category,
  :data, :idempotency_key, :do_not_forward, :environment,
  keyword_init: true
) do
  def self.from_resource(resource)
    attrs = resource.attributes
    new(
      id: resource.id,
      event_type: attrs.event_type,
      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,
      category: attrs.category,
      data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}),
      idempotency_key: attrs.idempotency_key,
      do_not_forward: attrs.do_not_forward || false,
      environment: attrs.environment
    )
  end
end

Class Method Details

.from_resource(resource) ⇒ Object



215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/smplkit/audit/models.rb', line 215

def self.from_resource(resource)
  attrs = resource.attributes
  new(
    id: resource.id,
    event_type: attrs.event_type,
    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,
    category: attrs.category,
    data: Smplkit::Helpers.deep_stringify_keys(attrs.data || {}),
    idempotency_key: attrs.idempotency_key,
    do_not_forward: attrs.do_not_forward || false,
    environment: attrs.environment
  )
end