ironflow_api/entities/
run.rs1use chrono::{DateTime, Utc};
4use ironflow_store::models::{Run, RunStatus, TriggerKind};
5use rust_decimal::Decimal;
6use serde::{Deserialize, Serialize};
7use uuid::Uuid;
8
9use super::StepResponse;
10
11#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
22#[derive(Debug, Serialize, Deserialize)]
23pub struct RunResponse {
24 pub id: Uuid,
26 pub workflow_name: String,
28 pub status: RunStatus,
30 pub trigger: TriggerKind,
32 pub error: Option<String>,
34 pub retry_count: u32,
36 pub max_retries: u32,
38 #[cfg_attr(feature = "openapi", schema(value_type = f64))]
40 pub cost_usd: Decimal,
41 pub duration_ms: u64,
43 pub created_at: DateTime<Utc>,
45 pub updated_at: DateTime<Utc>,
47 pub started_at: Option<DateTime<Utc>>,
49 pub completed_at: Option<DateTime<Utc>>,
51}
52
53impl From<Run> for RunResponse {
54 fn from(run: Run) -> Self {
55 RunResponse {
56 id: run.id,
57 workflow_name: run.workflow_name,
58 status: run.status.state,
59 trigger: run.trigger,
60 error: run.error,
61 retry_count: run.retry_count,
62 max_retries: run.max_retries,
63 cost_usd: run.cost_usd,
64 duration_ms: run.duration_ms,
65 created_at: run.created_at,
66 updated_at: run.updated_at,
67 started_at: run.started_at,
68 completed_at: run.completed_at,
69 }
70 }
71}
72
73#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
75#[derive(Debug, Serialize)]
76pub struct RunDetailResponse {
77 pub run: RunResponse,
79 pub steps: Vec<StepResponse>,
81}
82
83#[cfg_attr(feature = "openapi", derive(utoipa::IntoParams, utoipa::ToSchema))]
85#[derive(Debug, Deserialize)]
86pub struct ListRunsQuery {
87 pub workflow: Option<String>,
89 pub status: Option<RunStatus>,
91 pub has_steps: Option<bool>,
94 pub page: Option<u32>,
96 pub per_page: Option<u32>,
98}