Skip to main content

winterbaume_timestreamwrite/
types.rs

1use std::collections::HashMap;
2
3use chrono::{DateTime, Utc};
4use serde_json::Value;
5
6/// A Timestream database.
7#[derive(Debug, Clone)]
8pub struct Database {
9    pub database_name: String,
10    pub arn: String,
11    pub kms_key_id: Option<String>,
12    pub table_count: i64,
13    pub creation_time: DateTime<Utc>,
14    pub last_updated_time: DateTime<Utc>,
15    pub tags: HashMap<String, String>,
16}
17
18/// A Timestream table.
19#[derive(Debug, Clone)]
20pub struct Table {
21    pub table_name: String,
22    pub database_name: String,
23    pub arn: String,
24    pub table_status: String,
25    pub retention_properties: RetentionProperties,
26    pub magnetic_store_write_properties: MagneticStoreWriteProperties,
27    pub creation_time: DateTime<Utc>,
28    pub last_updated_time: DateTime<Utc>,
29    pub tags: HashMap<String, String>,
30    pub records: Vec<Record>,
31}
32
33/// Retention properties for a Timestream table.
34#[derive(Debug, Clone)]
35pub struct RetentionProperties {
36    pub memory_store_retention_period_in_hours: i64,
37    pub magnetic_store_retention_period_in_days: i64,
38}
39
40impl Default for RetentionProperties {
41    fn default() -> Self {
42        Self {
43            memory_store_retention_period_in_hours: 6,
44            magnetic_store_retention_period_in_days: 73000,
45        }
46    }
47}
48
49/// Magnetic store write properties for a Timestream table.
50#[derive(Debug, Clone, Default)]
51pub struct MagneticStoreWriteProperties {
52    pub enable_magnetic_store_writes: bool,
53}
54
55/// A record written to a Timestream table.
56#[derive(Debug, Clone)]
57pub struct Record {
58    pub dimensions: Vec<Dimension>,
59    pub measure_name: Option<String>,
60    pub measure_value: Option<String>,
61    pub measure_value_type: Option<String>,
62    pub time: Option<String>,
63    pub time_unit: Option<String>,
64}
65
66/// A dimension in a record.
67#[derive(Debug, Clone)]
68pub struct Dimension {
69    pub name: String,
70    pub value: String,
71    pub dimension_value_type: Option<String>,
72}
73
74/// A batch load task that loads data from S3 into a Timestream table.
75#[derive(Debug, Clone)]
76pub struct BatchLoadTask {
77    pub task_id: String,
78    pub task_status: String,
79    pub database_name: String,
80    pub table_name: String,
81    /// Raw JSON value of DataSourceConfiguration as provided by the caller.
82    pub data_source_configuration: Value,
83    /// Raw JSON value of ReportConfiguration as provided by the caller.
84    pub report_configuration: Value,
85    /// Raw JSON value of DataModelConfiguration as provided by the caller (optional).
86    pub data_model_configuration: Option<Value>,
87    pub creation_time: DateTime<Utc>,
88    pub last_updated_time: DateTime<Utc>,
89    pub error_message: Option<String>,
90}