sheepd/src/herd_core/model.rs
2025-04-30 10:02:04 +02:00

29 lines
667 B
Rust

use crate::api;
use crate::generate_token;
use owl::prelude::*;
/// Joined Machine
#[model]
pub struct Machine {
/// Machine ID
pub id: Id,
/// Hostname
pub hostname: String,
/// Token
pub token: String,
pub next_token: Option<String>,
/// Identity (Public Keys)
pub identity: (String, String),
}
impl Machine {
pub fn from_join_param(join: api::JoinParams) -> Self {
Self {
id: Id::String(join.machine_id.trim().to_string()),
hostname: join.hostname.trim().to_string(),
identity: join.identity,
token: generate_token(),
next_token: None,
}
}
}