use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
#[derive(Debug, Clone, Copy, Serialize, Deserialize, ToSchema)]
#[serde(rename_all = "lowercase")]
pub enum BosOperation {
Boot,
Reboot,
Shutdown,
}
impl BosOperation {
pub fn as_str(&self) -> &'static str {
match self {
Self::Boot => "boot",
Self::Reboot => "reboot",
Self::Shutdown => "shutdown",
}
}
}
#[derive(Debug, Serialize, Deserialize, ToSchema)]
pub struct PostTemplateSessionRequest {
pub operation: BosOperation,
pub limit: String,
pub session_name: Option<String>,
#[serde(default)]
pub include_disabled: bool,
#[serde(default)]
pub dry_run: bool,
}
pub struct GetTemplateParams {
pub name: Option<String>,
pub group_name: Option<String>,
pub settings_group_name: Option<String>,
pub limit: Option<u8>,
}
impl GetTemplateParams {
pub fn effective_group(&self) -> Option<&str> {
self
.group_name
.as_deref()
.or(self.settings_group_name.as_deref())
}
}
pub struct ApplyTemplateParams {
pub bos_session_name: Option<String>,
pub bos_sessiontemplate_name: String,
pub bos_session_operation: String,
pub limit: String,
pub include_disabled: bool,
}