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 pub handler_version: Option<String>,
53}
54
55impl From<Run> for RunResponse {
56 fn from(run: Run) -> Self {
57 RunResponse {
58 id: run.id,
59 workflow_name: run.workflow_name,
60 status: run.status.state,
61 trigger: run.trigger,
62 error: run.error,
63 retry_count: run.retry_count,
64 max_retries: run.max_retries,
65 cost_usd: run.cost_usd,
66 duration_ms: run.duration_ms,
67 created_at: run.created_at,
68 updated_at: run.updated_at,
69 started_at: run.started_at,
70 completed_at: run.completed_at,
71 handler_version: run.handler_version,
72 }
73 }
74}
75
76#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
78#[derive(Debug, Serialize)]
79pub struct RunDetailResponse {
80 pub run: RunResponse,
82 pub steps: Vec<StepResponse>,
84}
85
86#[cfg_attr(feature = "openapi", derive(utoipa::IntoParams, utoipa::ToSchema))]
88#[derive(Debug, Deserialize)]
89pub struct ListRunsQuery {
90 pub workflow: Option<String>,
92 pub status: Option<RunStatus>,
94 pub has_steps: Option<bool>,
97 pub page: Option<u32>,
99 pub per_page: Option<u32>,
101}