|
| 1 | +use indexmap::IndexMap; |
| 2 | +use schemars::JsonSchema; |
| 3 | +use serde::{Deserialize, Serialize}; |
| 4 | + |
| 5 | +/// Configure SSH server credentials and settings. |
| 6 | +#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug, PartialEq, Eq)] |
| 7 | +pub struct CapabilitySshServerV1 { |
| 8 | + /// Enable an SSH server. |
| 9 | + #[serde(default, skip_serializing_if = "Option::is_none")] |
| 10 | + pub enabled: Option<bool>, |
| 11 | + |
| 12 | + #[serde(skip_serializing_if = "Option::is_none")] |
| 13 | + pub users: Option<Vec<SshUserV1>>, |
| 14 | + |
| 15 | + /// Additional unknown fields. |
| 16 | + /// This provides a small bit of forwards compatibility. |
| 17 | + #[serde(flatten)] |
| 18 | + pub other: IndexMap<String, serde_json::Value>, |
| 19 | +} |
| 20 | + |
| 21 | +#[derive(Serialize, Deserialize, JsonSchema, PartialEq, Eq, Clone, Debug)] |
| 22 | +pub struct SshUserV1 { |
| 23 | + /// The username used for SSH login. |
| 24 | + pub username: String, |
| 25 | + |
| 26 | + /// Passwords for this user. |
| 27 | + #[serde(skip_serializing_if = "Option::is_none")] |
| 28 | + pub passwords: Option<Vec<PasswordV1>>, |
| 29 | + |
| 30 | + /// SSH public keys for this user. |
| 31 | + #[serde(skip_serializing_if = "Option::is_none")] |
| 32 | + pub authorized_keys: Option<Vec<String>>, |
| 33 | + |
| 34 | + /// Additional unknown fields. |
| 35 | + /// This provides a small bit of forwards compatibility. |
| 36 | + #[serde(flatten)] |
| 37 | + pub other: IndexMap<String, serde_json::Value>, |
| 38 | +} |
| 39 | + |
| 40 | +#[derive(Serialize, Deserialize, JsonSchema, PartialEq, Eq, Clone, Debug)] |
| 41 | +#[serde(rename_all = "snake_case", tag = "type")] |
| 42 | +pub enum PasswordV1 { |
| 43 | + /// Plain text password. |
| 44 | + Plain { password: String }, |
| 45 | + /// Bcrypt password hash. |
| 46 | + Bcrypt { hash: String }, |
| 47 | +} |
0 commit comments