river_data_core/models/annotations.rs
1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use uuid::Uuid;
4
5/// One source-authored annotation to register. `source_key` identifies the
6/// annotation within the source system; registration is idempotent per
7/// (source_system, source_key), so a full-content pass re-asserting the same
8/// key updates in place rather than duplicating.
9///
10/// The API resolves the site and parameter from the stream's pairing; an
11/// annotation on an unpaired stream is reported back as `unpaired` and is
12/// re-asserted on a later cycle once the stream is paired.
13#[derive(Debug, Clone, Serialize)]
14pub struct AnnotationUpsert {
15 pub source_key: String,
16 pub stream_id: Uuid,
17 /// The instant the annotation covers; the API stores it as a point
18 /// annotation (start_time == end_time).
19 pub time: DateTime<Utc>,
20 pub category: String,
21 pub text: String,
22}
23
24/// The API-side outcome for one registered annotation.
25#[derive(Debug, Clone, Deserialize)]
26pub struct AnnotationMapping {
27 pub source_key: String,
28 /// None when the annotation could not be stored (`unpaired`).
29 pub id: Option<Uuid>,
30 /// created | updated | unchanged | unpaired
31 pub status: String,
32}