santati 0.2.0

Official Rust SDK for the Santati audit-log API
Documentation
/*
 * 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};

/// EventEnvelopeRequest : Documentation-only shape of one producer envelope.  Never used to validate: `apps.audit_trails.envelope.parse_envelope` is the single validator, because it also has to serve the relay path's lenient mode. This class exists so the OpenAPI schema and the generated client show producers what to send, in the envelope's field order.  The published limits are enforced by ingest, not here: the three metadata maps (the event's, the actor's and each target's) hold at most 50 keys, keys are at most 40 characters of `A-Z a-z 0-9 _ . -`, values are at most 500 characters, and an event names at most 10 targets.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct EventEnvelopeRequest {
    /// The event type, e.g. invoice.voided.
    #[serde(rename = "event")]
    pub event: String,
    /// The audit log trail to index this event on; the key must be scoped to it.
    #[serde(rename = "trail")]
    pub trail: String,
    /// RFC 3339 with an offset: when the event happened. Defaults to receipt time; a timestamp without an offset is refused.
    #[serde(rename = "created_at", skip_serializing_if = "Option::is_none")]
    pub created_at: Option<String>,
    /// The end-customer organization this event belongs to.
    #[serde(rename = "organization_id", skip_serializing_if = "Option::is_none")]
    pub organization_id: Option<String>,
    /// Replay guard, per trail: a repeat of the same key within 24 hours returns the event already stored instead of indexing a new one.
    #[serde(rename = "idempotency_key", skip_serializing_if = "Option::is_none")]
    pub idempotency_key: Option<String>,
    /// Who acted; omit it for an event with no actor.
    #[serde(rename = "actor", skip_serializing_if = "Option::is_none")]
    pub actor: Option<models::EventActorRequest>,
    /// The objects the event acted on; at most 10.
    #[serde(rename = "targets", skip_serializing_if = "Option::is_none")]
    pub targets: Option<Vec<models::EventTargetRequest>>,
    /// Event metadata: at most 50 keys, each at most 40 characters of A-Z a-z 0-9 _ . -, each value at most 500 characters.
    #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")]
    pub metadata: Option<std::collections::HashMap<String, String>>,
    /// The producer's own payload for the event, stored verbatim and never interpreted.
    #[serde(rename = "data", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub data: Option<Option<serde_json::Value>>,
    /// Extra producer context, stored verbatim; `context.actor` and `context.targets` are read as a fallback when the top-level members are absent.
    #[serde(rename = "context", skip_serializing_if = "Option::is_none")]
    pub context: Option<std::collections::HashMap<String, serde_json::Value>>,
}

impl EventEnvelopeRequest {
    /// Documentation-only shape of one producer envelope.  Never used to validate: `apps.audit_trails.envelope.parse_envelope` is the single validator, because it also has to serve the relay path's lenient mode. This class exists so the OpenAPI schema and the generated client show producers what to send, in the envelope's field order.  The published limits are enforced by ingest, not here: the three metadata maps (the event's, the actor's and each target's) hold at most 50 keys, keys are at most 40 characters of `A-Z a-z 0-9 _ . -`, values are at most 500 characters, and an event names at most 10 targets.
    pub fn new(event: String, trail: String) -> EventEnvelopeRequest {
        EventEnvelopeRequest {
            event,
            trail,
            created_at: None,
            organization_id: None,
            idempotency_key: None,
            actor: None,
            targets: None,
            metadata: None,
            data: None,
            context: None,
        }
    }
}