1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use utoipa::ToSchema;
4
5#[derive(Debug, Serialize, ToSchema)]
6pub struct HealthResponse {
7 pub status: &'static str,
8 pub version: &'static str,
9}
10
11#[derive(Debug, Serialize, ToSchema)]
12pub struct SourceInfo {
13 pub name: String,
14 pub connector: String,
15 pub interval_secs: u64,
16 pub queries: Vec<QueryInfo>,
17 pub status: SourceStatus,
18}
19
20#[derive(Debug, Serialize, ToSchema)]
21pub struct QueryInfo {
22 pub id: String,
23 pub key_column: String,
24}
25
26#[derive(Debug, Clone, Serialize, ToSchema)]
27pub struct SourceStatus {
28 pub last_cycle: Option<CycleInfo>,
29 pub total_cycles: u64,
30}
31
32#[derive(Debug, Clone, Serialize, ToSchema)]
33pub struct CycleInfo {
34 pub cycle_id: u64,
35 pub source: String,
36 pub query: String,
37 pub status: String,
38 pub started_at: DateTime<Utc>,
39 pub finished_at: Option<DateTime<Utc>>,
40 pub rows_created: u64,
41 pub rows_updated: u64,
42 pub rows_deleted: u64,
43 pub duration_ms: Option<u64>,
44 pub error: Option<String>,
45}
46
47#[derive(Debug, Serialize, ToSchema)]
48pub struct SinkInfo {
49 pub name: String,
50 pub sink_type: String,
51 #[serde(skip_serializing_if = "Option::is_none")]
52 pub config: Option<serde_json::Value>,
53}
54
55#[derive(Debug, Serialize, ToSchema)]
56pub struct TriggerResponse {
57 pub source: String,
58 pub message: String,
59}
60
61#[derive(Debug, Serialize, ToSchema)]
62pub struct ErrorResponse {
63 pub error: String,
64}
65
66#[derive(Debug, Serialize, ToSchema)]
67pub struct SourceListResponse {
68 pub sources: Vec<SourceInfo>,
69}
70
71#[derive(Debug, Serialize, ToSchema)]
72pub struct SinkListResponse {
73 pub sinks: Vec<SinkInfo>,
74}
75
76#[derive(Debug, Deserialize, ToSchema)]
79pub struct CreateSourceRequest {
80 pub name: String,
81 pub connector: String,
82 #[serde(default)]
83 pub config: serde_json::Value,
84}
85
86#[derive(Debug, Deserialize, ToSchema)]
87pub struct UpdateSourceRequest {
88 pub connector: Option<String>,
89 pub config: Option<serde_json::Value>,
90 pub enabled: Option<bool>,
91}
92
93#[derive(Debug, Deserialize, ToSchema)]
94pub struct CreateSinkRequest {
95 pub name: String,
96 pub sink_type: String,
97 #[serde(default)]
98 pub config: serde_json::Value,
99}
100
101#[derive(Debug, Deserialize, ToSchema)]
102pub struct UpdateSinkRequest {
103 pub sink_type: Option<String>,
104 pub config: Option<serde_json::Value>,
105 pub enabled: Option<bool>,
106}
107
108#[derive(Debug, Deserialize, ToSchema)]
109pub struct CreateQueryRequest {
110 pub name: String,
111 pub query: String,
112 pub key_column: String,
113 #[serde(default)]
114 pub sinks: Option<Vec<String>>,
115}
116
117#[derive(Debug, Deserialize, ToSchema)]
118pub struct UpdateQueryRequest {
119 pub query: Option<String>,
120 pub key_column: Option<String>,
121 pub sinks: Option<Vec<String>>,
122 pub enabled: Option<bool>,
123}
124
125#[derive(Debug, Serialize, ToSchema)]
126pub struct QueryListResponse {
127 pub queries: Vec<QueryDetail>,
128}
129
130#[derive(Debug, Serialize, ToSchema)]
131pub struct QueryDetail {
132 pub name: String,
133 pub query: String,
134 pub key_column: String,
135 pub sinks: Option<Vec<String>>,
136 pub enabled: bool,
137}
138
139#[derive(Debug, Serialize, ToSchema)]
140pub struct MutationResponse {
141 pub ok: bool,
142 pub message: String,
143}
144
145#[derive(Debug, Serialize, ToSchema)]
146pub struct HistoryResponse {
147 pub cycles: Vec<CycleInfo>,
148}
149
150#[derive(Debug, Serialize, ToSchema)]
151pub struct StatusResponse {
152 pub running: bool,
153 pub paused: bool,
154}
155
156#[derive(Debug, Serialize, ToSchema)]
159pub struct PipeListResponse {
160 pub pipes: Vec<PipeInfo>,
161}
162
163#[derive(Debug, Serialize, ToSchema)]
164pub struct PipeInfo {
165 pub name: String,
166 pub origin_connector: String,
167 pub origin_dsn: String,
168 pub targets: Vec<String>,
169 pub interval_secs: u64,
170 pub enabled: bool,
171}
172
173#[derive(Debug, Deserialize, ToSchema)]
174pub struct CreatePipeRequest {
175 pub name: String,
176 pub origin_connector: String,
177 pub origin_dsn: String,
178 #[serde(default)]
179 pub origin_config: serde_json::Value,
180 #[serde(default)]
181 pub targets: Vec<String>,
182 #[serde(default)]
183 pub schedule: serde_json::Value,
184 #[serde(default)]
185 pub delta: serde_json::Value,
186 #[serde(default)]
187 pub retry: serde_json::Value,
188}
189
190#[derive(Debug, Deserialize, ToSchema)]
191pub struct UpdatePipeRequest {
192 pub origin_connector: Option<String>,
193 pub origin_dsn: Option<String>,
194 pub origin_config: Option<serde_json::Value>,
195 pub targets: Option<Vec<String>>,
196 pub schedule: Option<serde_json::Value>,
197 pub delta: Option<serde_json::Value>,
198 pub retry: Option<serde_json::Value>,
199 pub enabled: Option<bool>,
200}
201
202#[derive(Debug, Serialize, ToSchema)]
205pub struct CredentialListResponse {
206 pub credentials: Vec<CredentialInfo>,
207}
208
209#[derive(Debug, Serialize, ToSchema)]
210pub struct CredentialInfo {
211 pub name: String,
212 pub credential_type: String,
213 pub created_at: String,
214}
215
216#[derive(Debug, Deserialize, ToSchema)]
217pub struct CreateCredentialRequest {
218 pub name: String,
219 pub credential_type: String,
220 pub secret: String,
221}
222
223#[derive(Debug, Deserialize, ToSchema)]
224pub struct UpdateCredentialRequest {
225 pub secret: Option<String>,
226 pub credential_type: Option<String>,
227}