Skip to main content

ironflow_api/entities/
create_run.rs

1//! Request type for triggering a workflow.
2
3use std::collections::HashMap;
4
5use chrono::{DateTime, Utc};
6use serde::Deserialize;
7use serde_json::Value;
8
9/// Request to trigger a workflow.
10///
11/// # Examples
12///
13/// ```
14/// use ironflow_api::entities::CreateRunRequest;
15/// use serde_json::json;
16///
17/// let req = CreateRunRequest {
18///     workflow: "deploy".to_string(),
19///     payload: Some(json!({"env": "prod"})),
20///     labels: None,
21///     scheduled_at: None,
22/// };
23/// assert_eq!(req.workflow, "deploy");
24/// ```
25#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
26#[derive(Debug, Deserialize)]
27pub struct CreateRunRequest {
28    /// The workflow name to trigger.
29    pub workflow: String,
30    /// Optional input payload for the workflow.
31    #[cfg_attr(feature = "openapi", schema(value_type = Option<std::collections::HashMap<String, serde_json::Value>>))]
32    pub payload: Option<Value>,
33    /// Optional key-value labels for categorization and filtering.
34    #[serde(default)]
35    pub labels: Option<HashMap<String, String>>,
36    /// Optional deferred execution time. `None` means run immediately.
37    #[serde(default)]
38    pub scheduled_at: Option<DateTime<Utc>>,
39}