use crate::ActionParam;
use crate::ParamType;
use super::{ActionAddress, RemoteActionTarget};
pub const PROVIDER: &str = "tilo.machines";
pub const RESOURCE: &str = "machines";
pub const PLAN: &str = "machine.plan";
pub const LIST: &str = "machine.list";
pub const SHOW: &str = "machine.show";
pub const SERVERS: &str = "machine.servers";
pub const ADMIT: &str = "machine.admit";
pub const RECOVERY_KEYS: &str = "machine.recovery-keys";
pub const KEEP_RECOVERY_KEY: &str = "machine.keep-recovery-key";
pub const STEPS: [&str; 6] = [PLAN, LIST, SHOW, SERVERS, ADMIT, RECOVERY_KEYS];
#[must_use]
pub fn params(step: &str) -> Vec<ActionParam> {
match step {
PLAN => vec![
ActionParam::required(
"plan",
ParamType::Text,
"The plan document, as the command or the window wrote it (JSON).",
),
ActionParam::required(
"label",
ParamType::Text,
"The name you see the machine by, 1 to 80 bytes.",
),
ActionParam::required(
"token_file",
ParamType::Text,
"Where the token file the medium carries is, which the answer names.",
),
ActionParam::optional(
"installer_url",
ParamType::Text,
"Where the installer is served, for the command the answer prints.",
),
],
SHOW => vec![ActionParam::required(
"plan",
ParamType::Text,
"The plan's id, as listing the machines prints it.",
)],
ADMIT => vec![
ActionParam::required(
"device",
ParamType::Text,
"The machine's device key, 64 lowercase hex characters.",
),
ActionParam::required(
"nonce",
ParamType::Text,
"The token's nonce, 32 lowercase hex characters.",
),
ActionParam::optional(
"drives",
ParamType::Text,
"The drives the machine reported, as JSON; none when it has not reported.",
),
ActionParam::optional(
"ask",
ParamType::Text,
"The choices the machine asks about, choice to reason, as JSON.",
),
],
_ => Vec::new(),
}
}
#[must_use]
pub fn target(step: &str) -> RemoteActionTarget {
RemoteActionTarget {
provider: PROVIDER.to_owned(),
address: ActionAddress::new(RESOURCE, step),
}
}