#[cfg(feature = "http-api")]
use serde::{Deserialize, Serialize};
#[cfg(feature = "http-api")]
use utoipa::ToSchema;
#[cfg(feature = "http-api")]
use crate::types::{AgentId, AgentState};
#[cfg(feature = "http-api")]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct WorkflowExecutionRequest {
pub workflow_id: String,
pub parameters: serde_json::Value,
pub agent_id: Option<AgentId>,
}
#[cfg(feature = "http-api")]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct AgentStatusResponse {
pub agent_id: AgentId,
pub state: AgentState,
pub last_activity: chrono::DateTime<chrono::Utc>,
pub resource_usage: ResourceUsage,
}
#[cfg(feature = "http-api")]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct ResourceUsage {
pub memory_bytes: u64,
pub cpu_percent: f64,
pub active_tasks: u32,
}
#[cfg(feature = "http-api")]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct HealthResponse {
pub status: String,
pub uptime_seconds: u64,
pub timestamp: chrono::DateTime<chrono::Utc>,
pub version: String,
}
#[cfg(feature = "http-api")]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct SchedulerHealthResponse {
pub is_running: bool,
pub store_accessible: bool,
pub jobs_total: usize,
pub jobs_active: usize,
pub jobs_paused: usize,
pub jobs_dead_letter: usize,
pub global_active_runs: usize,
pub max_concurrent: usize,
pub runs_total: u64,
pub runs_succeeded: u64,
pub runs_failed: u64,
pub average_execution_time_ms: f64,
pub longest_run_ms: u64,
}
#[cfg(feature = "http-api")]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct CreateAgentRequest {
pub name: String,
pub dsl: String,
}
#[cfg(feature = "http-api")]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct CreateAgentResponse {
pub id: String,
pub status: String,
}
#[cfg(feature = "http-api")]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct UpdateAgentRequest {
pub name: Option<String>,
pub dsl: Option<String>,
}
#[cfg(feature = "http-api")]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct UpdateAgentResponse {
pub id: String,
pub status: String,
}
#[cfg(feature = "http-api")]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct DeleteAgentResponse {
pub id: String,
pub status: String,
}
#[cfg(feature = "http-api")]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct ExecuteAgentRequest {
}
#[cfg(feature = "http-api")]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct ExecuteAgentResponse {
pub execution_id: String,
pub status: String,
}
#[cfg(feature = "http-api")]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct AgentExecutionRecord {
pub execution_id: String,
pub status: String,
pub timestamp: String,
}
#[cfg(feature = "http-api")]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct GetAgentHistoryResponse {
pub history: Vec<AgentExecutionRecord>,
}
#[cfg(feature = "http-api")]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct ErrorResponse {
pub error: String,
pub code: String,
pub details: Option<serde_json::Value>,
}
#[cfg(feature = "http-api")]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct CreateScheduleRequest {
pub name: String,
pub cron_expression: String,
#[serde(default = "default_timezone")]
pub timezone: String,
pub agent_name: String,
#[serde(default)]
pub policy_ids: Vec<String>,
#[serde(default)]
pub one_shot: bool,
}
#[cfg(feature = "http-api")]
fn default_timezone() -> String {
"UTC".to_string()
}
#[cfg(feature = "http-api")]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct CreateScheduleResponse {
pub job_id: String,
pub next_run: Option<String>,
pub status: String,
}
#[cfg(feature = "http-api")]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct UpdateScheduleRequest {
pub cron_expression: Option<String>,
pub timezone: Option<String>,
pub policy_ids: Option<Vec<String>>,
pub one_shot: Option<bool>,
}
#[cfg(feature = "http-api")]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct ScheduleSummary {
pub job_id: String,
pub name: String,
pub cron_expression: String,
pub timezone: String,
pub status: String,
pub enabled: bool,
pub next_run: Option<String>,
pub run_count: u64,
}
#[cfg(feature = "http-api")]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct ScheduleDetail {
pub job_id: String,
pub name: String,
pub cron_expression: String,
pub timezone: String,
pub status: String,
pub enabled: bool,
pub one_shot: bool,
pub next_run: Option<String>,
pub last_run: Option<String>,
pub run_count: u64,
pub failure_count: u64,
pub created_at: String,
pub updated_at: String,
}
#[cfg(feature = "http-api")]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct NextRunsResponse {
pub job_id: String,
pub next_runs: Vec<String>,
}
#[cfg(feature = "http-api")]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct ScheduleRunEntry {
pub run_id: String,
pub started_at: String,
pub completed_at: Option<String>,
pub status: String,
pub error: Option<String>,
pub execution_time_ms: Option<u64>,
}
#[cfg(feature = "http-api")]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct ScheduleHistoryResponse {
pub job_id: String,
pub history: Vec<ScheduleRunEntry>,
}
#[cfg(feature = "http-api")]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct ScheduleActionResponse {
pub job_id: String,
pub action: String,
pub status: String,
}
#[cfg(feature = "http-api")]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct DeleteScheduleResponse {
pub job_id: String,
pub deleted: bool,
}