/*
* Santati
*
* Santati's HTTP API. Operations under `/api/v0/` take a team API key in `Authorization: Api-Key <key>`; a missing, invalid or under-scoped key is answered with `403`, never `401`. Errors on `/api/v0/` use one of three bodies: `ErrorDetail` (`{\"detail\": ...}`), `FieldErrors` (messages keyed by request field) or `ErrorEnvelope` (`{\"error\": {\"code\", \"message\", \"field\"}}`, returned by event ingestion and log stream quota checks). Lists on `/api/v0/` are cursor-paginated: follow `next` until it is `null`.
*
* The version of the OpenAPI document: 0.2.1
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct AuditEvent {
/// The producer's event id, or a generated ULID when none was sent.
#[serde(rename = "id")]
pub id: String,
/// The audit log trail the event was indexed on.
#[serde(rename = "trail")]
pub trail: String,
/// The event type, e.g. invoice.voided.
#[serde(rename = "event")]
pub event: String,
/// RFC 3339, when the producer says the event happened.
#[serde(rename = "created_at")]
pub created_at: String,
/// RFC 3339, when Santati indexed the event.
#[serde(rename = "received_at")]
pub received_at: String,
/// The end-customer organization the producer attributed the event to; empty when none.
#[serde(rename = "organization_id", skip_serializing_if = "Option::is_none")]
pub organization_id: Option<String>,
/// Who acted: the actor columns first, the producer's payload behind them.
#[serde(rename = "actor")]
pub actor: models::EventActor,
/// The objects this event acted on, in the producer's order.
#[serde(rename = "targets")]
pub targets: Vec<models::EventTarget>,
/// The event's own key/value map; keys and values are strings on the wire.
#[serde(rename = "metadata")]
pub metadata: std::collections::HashMap<String, String>,
/// The producer's own payload for the event, stored verbatim.
#[serde(rename = "data")]
pub data: std::collections::HashMap<String, serde_json::Value>,
/// The producer's extra context, stored verbatim; the read path falls back to it for `actor` and `targets` when the top-level members are absent.
#[serde(rename = "context")]
pub context: std::collections::HashMap<String, serde_json::Value>,
/// sha256 of this event's chain record; empty until the seal task has run.
#[serde(rename = "hash")]
pub hash: String,
/// The event schema version the event was validated against.
#[serde(rename = "schema_version", deserialize_with = "Option::deserialize")]
pub schema_version: Option<i32>,
}
impl AuditEvent {
pub fn new(id: String, trail: String, event: String, created_at: String, received_at: String, actor: models::EventActor, targets: Vec<models::EventTarget>, metadata: std::collections::HashMap<String, String>, data: std::collections::HashMap<String, serde_json::Value>, context: std::collections::HashMap<String, serde_json::Value>, hash: String, schema_version: Option<i32>) -> AuditEvent {
AuditEvent {
id,
trail,
event,
created_at,
received_at,
organization_id: None,
actor,
targets,
metadata,
data,
context,
hash,
schema_version,
}
}
}