1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
6pub enum ExecutionMethod {
7 #[serde(rename = "ssh")]
8 SSH,
9 #[serde(rename = "websocket")]
10 WebSocket,
11}
12
13#[derive(Debug, Clone, Serialize, Deserialize)]
15pub struct SshConfig {
16 pub host: String,
17 pub port: u16,
18 pub username: String,
19 pub password: Option<String>,
20 pub private_key_path: Option<String>,
21 pub session_timeout_seconds: Option<u64>,
22 pub timeout_seconds: Option<u64>,
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27pub struct WebSocketConfig {
28 pub url: String,
29 pub timeout_seconds: Option<u64>,
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34pub struct ClientConfig {
35 pub name: String,
36 pub execution_method: ExecutionMethod,
37 pub ssh_config: Option<SshConfig>,
38 pub websocket_config: Option<WebSocketConfig>,
39}
40
41#[derive(Debug, Clone, Serialize, Deserialize)]
43pub struct ExtractRule {
44 pub name: String,
45 pub patterns: Vec<String>, pub source: String, #[serde(default = "default_cascade")]
48 pub cascade: bool, }
50
51fn default_cascade() -> bool {
53 true
54}
55
56#[derive(Debug, Clone, Serialize, Deserialize, Default)]
58pub struct Step {
59 pub name: String,
60 pub script: String,
61 #[serde(default)]
62 pub servers: Vec<String>,
63 pub timeout_seconds: Option<u64>,
64 pub extract: Option<Vec<ExtractRule>>,
65 #[serde(default)]
66 pub variables: Option<HashMap<String, String>>,
67}
68
69#[derive(Debug, Clone, Serialize, Deserialize)]
71pub struct Pipeline {
72 pub name: String,
73 pub steps: Vec<Step>,
74}
75
76#[derive(Debug, Clone, Serialize, Deserialize)]
78pub struct RemoteExecutionConfig {
79 pub variables: Option<HashMap<String, String>>,
80 pub clients: HashMap<String, ClientConfig>,
81 pub pipelines: Vec<Pipeline>,
82 pub default_timeout: Option<u64>,
83}
84
85#[derive(Debug, Clone)]
87pub enum OutputType {
88 Stdout,
89 Stderr,
90 Log,
91 StepStarted, StepCompleted, }
94
95#[derive(Debug, Clone)]
97pub struct OutputEvent {
98 pub pipeline_name: String,
99 pub server_name: String,
100 pub step: Step, pub output_type: OutputType,
102 pub content: String,
103 pub timestamp: std::time::Instant,
104 pub variables: HashMap<String, String>, }
106
107pub type OutputCallback = std::sync::Arc<dyn Fn(OutputEvent) + Send + Sync>;
109
110#[derive(Debug, Clone, Serialize, Deserialize)]
112pub struct ExecutionResult {
113 pub success: bool,
114 pub stdout: String,
115 pub stderr: String,
116 pub script: String,
117 pub exit_code: i32,
118 pub execution_time_ms: u64,
119 pub error_message: Option<String>,
120}
121
122#[derive(Debug, Clone, Serialize, Deserialize)]
124pub struct StepExecutionResult {
125 pub step_name: String,
126 pub server_name: String,
127 pub execution_result: ExecutionResult,
128 pub overall_success: bool,
129 pub execution_time_ms: u64,
130}
131
132#[derive(Debug, Clone, Serialize, Deserialize)]
134pub struct PipelineExecutionResult {
135 pub pipeline_name: String,
136 pub step_results: Vec<StepExecutionResult>,
137 pub overall_success: bool,
138 pub total_execution_time_ms: u64,
139}