use nzr_api::model; use tabled::Tabled; #[derive(Tabled)] pub struct Instance { #[tabled(rename = "Hostname")] hostname: String, #[tabled(rename = "IP Address")] ip_addr: String, #[tabled(rename = "State")] state: model::DomainState, } impl From<&model::Instance> for Instance { fn from(value: &model::Instance) -> Self { Self { hostname: value.name.to_owned(), ip_addr: value.lease.addr.to_string(), state: value.state, } } } #[derive(Tabled)] pub struct Subnet { #[tabled(rename = "Name")] name: String, #[tabled(rename = "Interface")] interface: String, #[tabled(rename = "Network")] network: String, } impl From<&model::Subnet> for Subnet { fn from(value: &model::Subnet) -> Self { Self { name: value.name.clone(), interface: value.data.ifname.to_string(), network: value.data.network.to_string(), } } } #[derive(Tabled)] pub struct SshKey { #[tabled(rename = "ID")] id: i32, #[tabled(rename = "Comment")] comment: String, #[tabled(rename = "Key data")] key_data: String, } impl From<&model::SshPubkey> for SshKey { fn from(value: &model::SshPubkey) -> Self { Self { id: value.id.unwrap_or(-1), comment: value.comment.clone().unwrap_or_default(), key_data: format!("{} {}", value.algorithm, value.key_data), } } }