convergio_provisioning/
types.rs1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct ProvisionRun {
8 pub id: i64,
9 pub peer_name: String,
10 pub ssh_target: String,
11 pub status: ProvisionStatus,
12 pub items_total: u32,
13 pub items_done: u32,
14 pub started_at: String,
15 pub completed_at: Option<String>,
16 pub error_message: Option<String>,
17}
18
19#[derive(Debug, Clone, Serialize, Deserialize)]
21pub struct ProvisionItem {
22 pub id: i64,
23 pub run_id: i64,
24 pub item_type: ProvisionItemType,
25 pub source_path: String,
26 pub dest_path: String,
27 pub status: ProvisionStatus,
28 pub bytes_transferred: u64,
29 pub duration_ms: u64,
30 pub error_message: Option<String>,
31}
32
33#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
35pub enum ProvisionStatus {
36 Pending,
37 Running,
38 Success,
39 Failed,
40 Skipped,
41}
42
43impl std::fmt::Display for ProvisionStatus {
44 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
45 match self {
46 Self::Pending => write!(f, "pending"),
47 Self::Running => write!(f, "running"),
48 Self::Success => write!(f, "success"),
49 Self::Failed => write!(f, "failed"),
50 Self::Skipped => write!(f, "skipped"),
51 }
52 }
53}
54
55#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
57pub enum ProvisionItemType {
58 Config,
59 AgentDefs,
60 Binary,
61 Memory,
62 Keys,
63}
64
65impl std::fmt::Display for ProvisionItemType {
66 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
67 match self {
68 Self::Config => write!(f, "config"),
69 Self::AgentDefs => write!(f, "agent_defs"),
70 Self::Binary => write!(f, "binary"),
71 Self::Memory => write!(f, "memory"),
72 Self::Keys => write!(f, "keys"),
73 }
74 }
75}
76
77#[derive(Debug, Clone, Deserialize)]
79pub struct ProvisionRequest {
80 pub peer_name: String,
81 pub ssh_target: String,
82 #[serde(default = "default_remote_base")]
83 pub remote_base: String,
84 #[serde(default)]
85 pub include_binary: bool,
86 #[serde(default = "default_true")]
87 pub include_config: bool,
88 #[serde(default = "default_true")]
89 pub include_agent_defs: bool,
90 #[serde(default)]
91 pub include_memory: bool,
92}
93
94fn default_remote_base() -> String {
95 "~/.convergio".to_string()
96}
97fn default_true() -> bool {
98 true
99}