1use serde_json::Value;
2use std::collections::HashMap;
3use stormchaser_model::workflow::RunStatus;
4pub mod auth;
6pub mod cron;
8pub mod event_rule;
10pub mod schema;
12pub mod step;
14pub mod storage;
16pub mod webhook;
18pub mod workflow;
20
21use chrono::{DateTime, Utc};
22use serde::{Deserialize, Serialize};
23use utoipa::{IntoParams, ToSchema};
24
25use stormchaser_model::step::{StepInstance, StepOutput, StepStatusHistory};
26use stormchaser_model::storage::{ArtifactRegistry, BackendType};
27use stormchaser_model::test_report;
28
29#[derive(Debug, Deserialize, ToSchema)]
30pub struct AuthExchangeRequest {
32 pub sso_token: String,
34 pub callback_url: String,
36}
37
38#[derive(Debug, Serialize, Deserialize, ToSchema)]
39pub struct AuthExchangeResponse {
41 pub access_token: String,
43 pub refresh_token: Option<String>,
45 pub token_type: String,
47 pub expires_in: usize,
49}
50
51#[derive(Debug, Deserialize, ToSchema)]
52pub struct AuthRefreshRequest {
54 pub refresh_token: String,
56}
57
58#[derive(Debug, Deserialize, ToSchema)]
59pub struct EnqueueRequest {
61 pub workflow_name: String,
63 pub repo_url: String,
65 pub workflow_path: String,
67 pub git_ref: String,
69 #[schema(value_type = Object)]
71 pub inputs: Value,
72 pub overrides: Option<RunOverrides>,
74}
75
76#[derive(Debug, Deserialize, ToSchema)]
77pub struct RunOverrides {
79 pub timeout: Option<String>,
81}
82
83#[derive(Debug, Serialize, Deserialize, ToSchema)]
84pub struct EnqueueResponse {
86 pub run_id: stormchaser_model::RunId,
88 pub status: String,
90}
91
92#[derive(Debug, Deserialize, ToSchema, IntoParams)]
93#[into_params(parameter_in = Query)]
94pub struct ListRunsQuery {
96 pub workflow_name: Option<String>,
98 #[schema(value_type = Option<String>)]
99 #[param(value_type = Option<String>)]
100 pub status: Option<RunStatus>,
102 pub initiating_user: Option<String>,
104 pub repo_url: Option<String>,
106 pub workflow_path: Option<String>,
108 pub created_after: Option<DateTime<Utc>>,
110 pub created_before: Option<DateTime<Utc>>,
112 pub limit: Option<usize>,
114 pub offset: Option<usize>,
116}
117
118#[derive(Debug, Serialize, Deserialize, ToSchema, sqlx::FromRow)]
119pub struct WorkflowRunDetail {
121 pub id: stormchaser_model::RunId,
123 pub workflow_name: String,
125 pub initiating_user: String,
127 pub repo_url: String,
129 pub workflow_path: String,
131 pub git_ref: String,
133 pub status: RunStatus,
135 pub version: i32,
137 pub created_at: DateTime<Utc>,
139 pub updated_at: DateTime<Utc>,
141 pub started_resolving_at: Option<DateTime<Utc>>,
143 pub started_at: Option<DateTime<Utc>>,
145 pub finished_at: Option<DateTime<Utc>>,
147 pub error: Option<String>,
149 #[schema(value_type = Object)]
151 pub inputs: Value,
152 pub secrets: Value,
154 pub source_code: String,
156 pub dsl_version: String,
158}
159
160#[derive(Debug, Serialize, Deserialize, ToSchema)]
161pub struct WorkflowRunFullDetail {
163 pub detail: WorkflowRunDetail,
165 pub steps: Vec<StepDetail>,
167 #[schema(value_type = Vec<Object>)]
168 pub artifacts: Vec<ArtifactRegistry>,
170 pub test_summaries: Vec<TestSummaryResponse>,
172 #[schema(value_type = Vec<Object>)]
173 pub test_cases: Vec<test_report::TestCase>,
175}
176
177#[derive(Debug, Serialize, Deserialize, ToSchema)]
178pub struct StepDetail {
180 pub instance: StepInstance,
182 pub outputs: Vec<StepOutput>,
184 pub history: Vec<StepStatusHistory>,
186 pub logs: Vec<String>,
188}
189
190#[derive(Debug, Deserialize, ToSchema)]
191pub struct DirectRunRequest {
193 pub dsl: String,
195 #[schema(value_type = Object)]
197 pub inputs: Value,
198}
199
200#[derive(Debug, Deserialize, ToSchema)]
201pub struct CreateWebhookRequest {
203 pub name: String,
205 pub description: Option<String>,
207 pub source_type: String, pub secret_token: Option<String>,
211}
212
213#[derive(Debug, Deserialize, ToSchema)]
214pub struct UpdateWebhookRequest {
216 pub name: Option<String>,
218 pub description: Option<String>,
220 pub source_type: Option<String>, pub secret_token: Option<String>,
224 pub is_active: Option<bool>,
226}
227
228#[derive(Debug, Deserialize, ToSchema)]
229pub struct CreateEventRuleRequest {
231 pub name: String,
233 pub description: Option<String>,
235 pub webhook_id: stormchaser_model::WebhookId,
237 pub event_type_pattern: String,
239 pub condition_expr: Option<String>,
241 pub workflow_name: String,
243 pub repo_url: String,
245 pub workflow_path: String,
247 pub git_ref: String,
249 pub input_mappings: HashMap<String, String>,
251}
252
253#[derive(Debug, Deserialize, ToSchema)]
254pub struct CreateCronWorkflowRequest {
256 pub name: String,
258 pub description: Option<String>,
260 pub cronspec: String,
262 pub workflow_name: String,
264 pub repo_url: String,
266 pub workflow_path: String,
268 pub git_ref: String,
270 #[schema(value_type = Object)]
272 pub inputs: Value,
273}
274
275#[derive(Debug, Serialize, ToSchema)]
276pub struct CronWorkflowResponse {
278 pub id: stormchaser_model::CronWorkflowId,
280 pub secret_token: String,
282 pub external_job_id: Option<String>,
284}
285
286#[derive(Debug, Deserialize, ToSchema)]
287pub struct CreateStorageBackendRequest {
289 pub name: String,
291 pub description: Option<String>,
293 pub backend_type: BackendType,
295 #[schema(value_type = Object)]
297 pub config: Value,
298 pub aws_assume_role_arn: Option<String>,
300 pub is_default_sfs: bool,
302}
303
304#[derive(Debug, Deserialize, ToSchema)]
305pub struct UpdateStorageBackendRequest {
307 pub name: Option<String>,
309 pub description: Option<String>,
311 pub backend_type: Option<BackendType>,
313 #[schema(value_type = Object)]
315 pub config: Option<Value>,
316 pub aws_assume_role_arn: Option<String>,
318 pub is_default_sfs: Option<bool>,
320}
321
322#[derive(Debug, Serialize, Deserialize, sqlx::FromRow, ToSchema)]
323pub struct TestReportSummary {
325 pub id: stormchaser_model::TestReportId,
327 pub report_name: String,
329 pub file_name: String,
331 pub format: String,
333 pub checksum: String,
335 pub backend_id: Option<stormchaser_model::BackendId>,
337 pub remote_path: Option<String>,
339 pub created_at: DateTime<Utc>,
341}
342
343#[derive(Debug, Serialize, Deserialize, sqlx::FromRow, ToSchema)]
344pub struct TestSummaryResponse {
346 pub id: stormchaser_model::TestReportId,
348 pub run_id: stormchaser_model::RunId,
350 pub step_instance_id: stormchaser_model::StepInstanceId,
352 pub report_name: String,
354 pub total_tests: i32,
356 pub passed: i32,
358 pub failed: i32,
360 pub skipped: i32,
362 pub errors: i32,
364 pub duration_ms: i64,
366 pub created_at: DateTime<Utc>,
368}