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#[derive(Debug, Serialize, Deserialize)]
22pub struct RunResponse {
23 pub id: Uuid,
25 pub workflow_name: String,
27 pub status: RunStatus,
29 pub trigger: TriggerKind,
31 pub error: Option<String>,
33 pub retry_count: u32,
35 pub max_retries: u32,
37 pub cost_usd: Decimal,
39 pub duration_ms: u64,
41 pub created_at: DateTime<Utc>,
43 pub updated_at: DateTime<Utc>,
45 pub started_at: Option<DateTime<Utc>>,
47 pub completed_at: Option<DateTime<Utc>>,
49}
50
51impl From<Run> for RunResponse {
52 fn from(run: Run) -> Self {
53 RunResponse {
54 id: run.id,
55 workflow_name: run.workflow_name,
56 status: run.status.state,
57 trigger: run.trigger,
58 error: run.error,
59 retry_count: run.retry_count,
60 max_retries: run.max_retries,
61 cost_usd: run.cost_usd,
62 duration_ms: run.duration_ms,
63 created_at: run.created_at,
64 updated_at: run.updated_at,
65 started_at: run.started_at,
66 completed_at: run.completed_at,
67 }
68 }
69}
70
71#[derive(Debug, Serialize)]
73pub struct RunDetailResponse {
74 pub run: RunResponse,
76 pub steps: Vec<StepResponse>,
78}
79
80#[derive(Debug, Deserialize)]
82pub struct ListRunsQuery {
83 pub workflow: Option<String>,
85 pub status: Option<RunStatus>,
87 pub page: Option<u32>,
89 pub per_page: Option<u32>,
91}