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 /// The standard curve the source applied to produce the annotated value. The API freezes an
23 /// annotation's curve and text once stored with one, reporting later edits as `frozen`.
24 #[serde(default, skip_serializing_if = "Option::is_none")]
25 pub standard_curve_id: Option<Uuid>,
26}
27
28/// The API-side outcome for one registered annotation.
29#[derive(Debug, Clone, Deserialize)]
30pub struct AnnotationMapping {
31 pub source_key: String,
32 /// None when the annotation could not be stored (`unpaired`).
33 pub id: Option<Uuid>,
34 /// created | updated | unchanged | frozen | unpaired
35 pub status: String,
36}
37
38/// One source-authored site note to register. `source_key` identifies the note
39/// within the source system; registration is idempotent per
40/// (source_system, source_key).
41///
42/// `site_name` is the source's own station name, which the API resolves against
43/// sites that already exist. A note mints nothing: one naming a station
44/// river-data has never seen is reported `unresolved` and is re-asserted on a
45/// later cycle, once pairing has created the site.
46#[derive(Debug, Clone, Serialize)]
47pub struct NoteUpsert {
48 pub source_key: String,
49 pub site_name: String,
50 pub text: String,
51 pub verified: bool,
52}
53
54/// The API-side outcome for one registered note.
55#[derive(Debug, Clone, Deserialize)]
56pub struct NoteMapping {
57 pub source_key: String,
58 /// None when the note could not be stored (`unresolved`).
59 pub id: Option<Uuid>,
60 /// created | updated | unchanged | unresolved
61 pub status: String,
62}