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 status: String,
36 pub started_at: DateTime<Utc>,
37 pub finished_at: Option<DateTime<Utc>>,
38 pub rows_created: u64,
39 pub rows_updated: u64,
40 pub rows_deleted: u64,
41}
42
43#[derive(Debug, Serialize, ToSchema)]
44pub struct SinkInfo {
45 pub name: String,
46 pub sink_type: String,
47}
48
49#[derive(Debug, Serialize, ToSchema)]
50pub struct TriggerResponse {
51 pub source: String,
52 pub message: String,
53}
54
55#[derive(Debug, Serialize, ToSchema)]
56pub struct ErrorResponse {
57 pub error: String,
58}
59
60#[derive(Debug, Serialize, ToSchema)]
61pub struct SourceListResponse {
62 pub sources: Vec<SourceInfo>,
63}
64
65#[derive(Debug, Serialize, ToSchema)]
66pub struct SinkListResponse {
67 pub sinks: Vec<SinkInfo>,
68}
69
70#[derive(Debug, Deserialize, ToSchema)]
73pub struct CreateSourceRequest {
74 pub name: String,
75 pub connector: String,
76 #[serde(default)]
77 pub config: serde_json::Value,
78}
79
80#[derive(Debug, Deserialize, ToSchema)]
81pub struct UpdateSourceRequest {
82 pub connector: Option<String>,
83 pub config: Option<serde_json::Value>,
84 pub enabled: Option<bool>,
85}
86
87#[derive(Debug, Deserialize, ToSchema)]
88pub struct CreateSinkRequest {
89 pub name: String,
90 pub sink_type: String,
91 #[serde(default)]
92 pub config: serde_json::Value,
93}
94
95#[derive(Debug, Deserialize, ToSchema)]
96pub struct UpdateSinkRequest {
97 pub sink_type: Option<String>,
98 pub config: Option<serde_json::Value>,
99 pub enabled: Option<bool>,
100}
101
102#[derive(Debug, Deserialize, ToSchema)]
103pub struct CreateQueryRequest {
104 pub name: String,
105 pub query: String,
106 pub key_column: String,
107 #[serde(default)]
108 pub sinks: Option<Vec<String>>,
109}
110
111#[derive(Debug, Deserialize, ToSchema)]
112pub struct UpdateQueryRequest {
113 pub query: Option<String>,
114 pub key_column: Option<String>,
115 pub sinks: Option<Vec<String>>,
116 pub enabled: Option<bool>,
117}
118
119#[derive(Debug, Serialize, ToSchema)]
120pub struct QueryListResponse {
121 pub queries: Vec<QueryDetail>,
122}
123
124#[derive(Debug, Serialize, ToSchema)]
125pub struct QueryDetail {
126 pub name: String,
127 pub query: String,
128 pub key_column: String,
129 pub sinks: Option<Vec<String>>,
130 pub enabled: bool,
131}
132
133#[derive(Debug, Serialize, ToSchema)]
134pub struct MutationResponse {
135 pub ok: bool,
136 pub message: String,
137}
138
139#[derive(Debug, Serialize, ToSchema)]
140pub struct HistoryResponse {
141 pub cycles: Vec<CycleInfo>,
142}
143
144#[derive(Debug, Serialize, ToSchema)]
145pub struct StatusResponse {
146 pub running: bool,
147 pub paused: bool,
148}
149
150#[derive(Debug, Serialize, ToSchema)]
153pub struct PipeListResponse {
154 pub pipes: Vec<PipeInfo>,
155}
156
157#[derive(Debug, Serialize, ToSchema)]
158pub struct PipeInfo {
159 pub name: String,
160 pub origin_connector: String,
161 pub origin_dsn: String,
162 pub targets: Vec<String>,
163 pub interval_secs: u64,
164 pub enabled: bool,
165}
166
167#[derive(Debug, Deserialize, ToSchema)]
168pub struct CreatePipeRequest {
169 pub name: String,
170 pub origin_connector: String,
171 pub origin_dsn: String,
172 #[serde(default)]
173 pub origin_config: serde_json::Value,
174 #[serde(default)]
175 pub targets: Vec<String>,
176 #[serde(default)]
177 pub schedule: serde_json::Value,
178 #[serde(default)]
179 pub delta: serde_json::Value,
180 #[serde(default)]
181 pub retry: serde_json::Value,
182}
183
184#[derive(Debug, Deserialize, ToSchema)]
185pub struct UpdatePipeRequest {
186 pub origin_connector: Option<String>,
187 pub origin_dsn: Option<String>,
188 pub origin_config: Option<serde_json::Value>,
189 pub targets: Option<Vec<String>>,
190 pub schedule: Option<serde_json::Value>,
191 pub delta: Option<serde_json::Value>,
192 pub retry: Option<serde_json::Value>,
193 pub enabled: Option<bool>,
194}
195
196#[derive(Debug, Serialize, ToSchema)]
199pub struct CredentialListResponse {
200 pub credentials: Vec<CredentialInfo>,
201}
202
203#[derive(Debug, Serialize, ToSchema)]
204pub struct CredentialInfo {
205 pub name: String,
206 pub credential_type: String,
207 pub created_at: String,
208}
209
210#[derive(Debug, Deserialize, ToSchema)]
211pub struct CreateCredentialRequest {
212 pub name: String,
213 pub credential_type: String,
214 pub secret: String,
215}
216
217#[derive(Debug, Deserialize, ToSchema)]
218pub struct UpdateCredentialRequest {
219 pub secret: Option<String>,
220 pub credential_type: Option<String>,
221}