use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;
use super::{Handler, Step, Storage};
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct Workflow {
#[serde(default)]
pub is_template: bool,
pub dsl_version: String,
pub name: String,
pub description: Option<String>,
pub cron: Option<String>,
pub libraries: Vec<Library>,
#[serde(default)]
pub step_libraries: Vec<StepLibrary>,
#[serde(default)]
pub includes: Vec<Include>,
pub strategy: Option<Strategy>,
pub quotas: Option<Quotas>,
pub storage: Vec<Storage>,
pub inputs: Vec<Input>,
pub outputs: Vec<Output>,
pub handlers: Vec<Handler>,
pub steps: Vec<Step>,
pub on_failure: Option<Vec<Step>>,
pub finally: Option<Vec<Step>>,
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct Library {
pub name: String,
pub source: String,
pub version: String,
pub checksum: String,
}
use super::RetryPolicy;
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct StepLibrary {
pub name: String,
pub r#type: String,
#[serde(default)]
pub params: HashMap<String, String>,
#[serde(default)]
pub spec: Value,
pub timeout: Option<String>,
pub allow_failure: Option<bool>,
pub retry: Option<RetryPolicy>,
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct Include {
pub name: String,
pub workflow: String,
#[serde(default)]
pub inputs: HashMap<String, String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct Strategy {
pub affinity: Option<String>,
pub fail_fast: Option<bool>,
pub max_parallel: Option<u32>,
pub process_allow_list: Option<Vec<String>>,
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct Quotas {
pub max_concurrency: Option<u32>,
pub max_cpu: Option<String>,
pub max_memory: Option<String>,
pub max_storage: Option<String>,
pub timeout: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct Input {
pub name: String,
pub r#type: String,
pub description: Option<String>,
pub default: Option<Value>,
pub validation: Option<String>,
pub options: Option<Vec<String>>,
pub query: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct Output {
pub name: String,
pub value: String, }