Skip to main content

proxmox_api/generated/nodes/node/
termproxy.rs

1#[derive(Debug, Clone)]
2pub struct TermproxyClient<T> {
3    client: T,
4    path: String,
5}
6impl<T> TermproxyClient<T>
7where
8    T: crate::client::Client,
9{
10    pub fn new(client: T, parent_path: &str) -> Self {
11        Self {
12            client,
13            path: format!("{}{}", parent_path, "/termproxy"),
14        }
15    }
16}
17impl<T> TermproxyClient<T>
18where
19    T: crate::client::Client,
20{
21    #[doc = "Creates a VNC Shell proxy."]
22    #[doc = ""]
23    #[doc = "Permission check: perm(\"/nodes/{node}\", [\"Sys.Console\"])"]
24    pub async fn post(&self, params: PostParams) -> Result<PostOutput, T::Error> {
25        let path = self.path.to_string();
26        self.client.post(&path, &params).await
27    }
28}
29impl PostOutput {
30    pub fn new(port: i64, ticket: String, upid: String, user: String) -> Self {
31        Self {
32            port,
33            ticket,
34            upid,
35            user,
36        }
37    }
38}
39#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
40pub struct PostOutput {
41    #[serde(
42        serialize_with = "crate::types::serialize_int",
43        deserialize_with = "crate::types::deserialize_int"
44    )]
45    #[doc = "port used to bind termproxy to."]
46    #[doc = ""]
47    pub port: i64,
48    #[doc = "VNC ticket used to verify websocket connection."]
49    #[doc = ""]
50    pub ticket: String,
51    #[doc = "UPID for termproxy worker task."]
52    #[doc = ""]
53    pub upid: String,
54    #[doc = "user/token that generated the VNC ticket in `ticket`."]
55    #[doc = ""]
56    pub user: String,
57}
58#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
59pub struct PostParams {
60    #[serde(skip_serializing_if = "Option::is_none", default)]
61    #[doc = "Run specific command or default to login (requires 'root@pam')"]
62    #[doc = ""]
63    pub cmd: Option<Cmd>,
64    #[serde(rename = "cmd-opts")]
65    #[serde(skip_serializing_if = "Option::is_none", default)]
66    #[doc = "Add parameters to a command. Encoded as null terminated strings."]
67    #[doc = ""]
68    pub cmd_opts: Option<String>,
69    #[serde(
70        flatten,
71        default,
72        skip_serializing_if = "::std::collections::HashMap::is_empty"
73    )]
74    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
75}
76#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq, Default)]
77#[doc = "Run specific command or default to login (requires 'root@pam')"]
78#[doc = ""]
79pub enum Cmd {
80    #[serde(rename = "ceph_install")]
81    CephInstall,
82    #[serde(rename = "login")]
83    #[default]
84    Login,
85    #[serde(rename = "upgrade")]
86    Upgrade,
87}
88impl TryFrom<&str> for Cmd {
89    type Error = String;
90    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
91        match value {
92            "ceph_install" => Ok(Self::CephInstall),
93            "login" => Ok(Self::Login),
94            "upgrade" => Ok(Self::Upgrade),
95            v => Err(format!("Unknown variant {v}")),
96        }
97    }
98}