cognite/dto/data_ingestion/
raw.rs1use serde::{Deserialize, Serialize};
2use serde_with::skip_serializing_none;
3
4use crate::{to_query, IntoParams, SetCursor};
5
6#[derive(Serialize, Deserialize, Debug, Clone)]
7#[serde(rename_all = "camelCase")]
8pub struct Database {
10 pub name: String,
12}
13
14#[derive(Serialize, Deserialize, Debug)]
15#[serde(rename_all = "camelCase")]
16pub struct DeleteDatabasesRequest {
18 pub items: Vec<Database>,
20 pub recursive: bool,
22}
23
24#[derive(Serialize, Deserialize, Debug, Clone)]
25#[serde(rename_all = "camelCase")]
26pub struct Table {
28 pub name: String,
30}
31
32#[derive(Serialize, Deserialize, Debug, Clone)]
33#[serde(rename_all = "camelCase")]
34pub struct RawRow {
36 pub key: String,
38 pub columns: ::serde_json::Value,
40 pub last_updated_time: i64,
42}
43
44#[derive(Serialize, Deserialize, Debug, Default, Clone)]
45pub struct RawRowCreate {
47 pub key: String,
49 pub columns: ::serde_json::Value,
51}
52
53#[derive(Serialize, Deserialize, Debug, Clone)]
54pub struct DeleteRow {
56 pub key: String,
58}
59
60#[derive(Debug, Default, Clone)]
61pub struct RetrieveCursorsQuery {
63 pub min_last_updated_time: Option<i64>,
65 pub max_last_updated_time: Option<i64>,
67 pub number_of_cursors: Option<i32>,
69}
70
71impl IntoParams for RetrieveCursorsQuery {
72 fn into_params(self) -> Vec<(String, String)> {
73 let mut params = Vec::<(String, String)>::new();
74 to_query(
75 "minLastUpdatedTime",
76 &self.min_last_updated_time,
77 &mut params,
78 );
79 to_query(
80 "maxLastUpdatedTime",
81 &self.max_last_updated_time,
82 &mut params,
83 );
84 to_query("numberOfCursors", &self.number_of_cursors, &mut params);
85 params
86 }
87}
88
89#[skip_serializing_none]
90#[derive(Debug, Default, Serialize, Clone)]
91pub struct RetrieveRowsQuery {
93 pub limit: Option<i32>,
95 pub columns: Option<Vec<String>>,
97 pub cursor: Option<String>,
99 pub min_last_updated_time: Option<i64>,
101 pub max_last_updated_time: Option<i64>,
103}
104
105impl IntoParams for RetrieveRowsQuery {
106 fn into_params(self) -> Vec<(String, String)> {
107 let mut params = Vec::<(String, String)>::new();
108 to_query("limit", &self.limit, &mut params);
109 if let Some(columns) = self.columns {
110 to_query("columns", &Some(columns.join(",")), &mut params);
111 }
112 to_query("cursor", &self.cursor, &mut params);
113 to_query(
114 "minLastUpdatedTime",
115 &self.min_last_updated_time,
116 &mut params,
117 );
118 to_query(
119 "maxLastUpdatedTime",
120 &self.max_last_updated_time,
121 &mut params,
122 );
123 params
124 }
125}
126
127impl SetCursor for RetrieveRowsQuery {
128 fn set_cursor(&mut self, cursor: Option<String>) {
129 self.cursor = cursor;
130 }
131}
132
133#[derive(Debug, Default, Clone, Copy)]
134pub struct EnsureParentQuery {
137 pub ensure_parent: Option<bool>,
139}
140
141impl EnsureParentQuery {
142 pub fn new(ensure_parent: bool) -> Self {
148 Self {
149 ensure_parent: Some(ensure_parent),
150 }
151 }
152}
153
154impl IntoParams for EnsureParentQuery {
155 fn into_params(self) -> Vec<(String, String)> {
156 let mut params = Vec::<(String, String)>::new();
157 to_query("ensureParent", &self.ensure_parent, &mut params);
158 params
159 }
160}
161
162#[derive(Debug, Default, Clone)]
163pub struct RetrieveAllPartitionedQuery {
165 pub min_last_updated_time: Option<i64>,
167 pub max_last_updated_time: Option<i64>,
169 pub number_of_cursors: Option<i32>,
171 pub columns: Option<Vec<String>>,
173 pub limit: Option<i32>,
175}