#[derive(Debug, Clone)]
pub struct SpiceshellClient<T> {
client: T,
path: String,
}
impl<T> SpiceshellClient<T>
where
T: crate::client::Client,
{
pub fn new(client: T, parent_path: &str) -> Self {
Self {
client,
path: format!("{}{}", parent_path, "/spiceshell"),
}
}
}
impl<T> SpiceshellClient<T>
where
T: crate::client::Client,
{
#[doc = "Creates a SPICE shell."]
#[doc = ""]
#[doc = "Permission check: perm(\"/nodes/{node}\", [\"Sys.Console\"])"]
pub async fn post(&self, params: PostParams) -> Result<PostOutput, T::Error> {
let path = self.path.to_string();
self.client.post(&path, ¶ms).await
}
}
impl PostOutput {
pub fn new(host: String, password: String, proxy: String, tls_port: i64, ty: String) -> Self {
Self {
host,
password,
proxy,
tls_port,
ty,
additional_properties: ::std::default::Default::default(),
}
}
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
pub struct PostOutput {
pub host: String,
pub password: String,
pub proxy: String,
#[serde(rename = "tls-port")]
#[serde(
serialize_with = "crate::types::serialize_int",
deserialize_with = "crate::types::deserialize_int"
)]
pub tls_port: i64,
#[serde(rename = "type")]
pub ty: String,
#[serde(
flatten,
default,
skip_serializing_if = "::std::collections::HashMap::is_empty"
)]
pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
pub struct PostParams {
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Run specific command or default to login (requires 'root@pam')"]
#[doc = ""]
pub cmd: Option<Cmd>,
#[serde(rename = "cmd-opts")]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Add parameters to a command. Encoded as null terminated strings."]
#[doc = ""]
pub cmd_opts: Option<String>,
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "SPICE proxy server. This can be used by the client to specify the proxy server. All nodes in a cluster runs 'spiceproxy', so it is up to the client to choose one. By default, we return the node where the VM is currently running. As reasonable setting is to use same node you use to connect to the API (This is window.location.hostname for the JS GUI)."]
#[doc = ""]
pub proxy: Option<String>,
#[serde(
flatten,
default,
skip_serializing_if = "::std::collections::HashMap::is_empty"
)]
pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq, Default)]
#[doc = "Run specific command or default to login (requires 'root@pam')"]
#[doc = ""]
pub enum Cmd {
#[serde(rename = "ceph_install")]
CephInstall,
#[serde(rename = "login")]
#[default]
Login,
#[serde(rename = "upgrade")]
Upgrade,
}
impl TryFrom<&str> for Cmd {
type Error = String;
fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
match value {
"ceph_install" => Ok(Self::CephInstall),
"login" => Ok(Self::Login),
"upgrade" => Ok(Self::Upgrade),
v => Err(format!("Unknown variant {v}")),
}
}
}