Skip to main content

proxmox_api/generated/nodes/node/
vncshell.rs

1#[derive(Debug, Clone)]
2pub struct VncshellClient<T> {
3    client: T,
4    path: String,
5}
6impl<T> VncshellClient<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, "/vncshell"),
14        }
15    }
16}
17impl<T> VncshellClient<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(cert: String, port: i64, ticket: String, upid: String, user: String) -> Self {
31        Self {
32            cert,
33            port,
34            ticket,
35            upid,
36            user,
37        }
38    }
39}
40#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
41pub struct PostOutput {
42    pub cert: String,
43    #[serde(
44        serialize_with = "crate::types::serialize_int",
45        deserialize_with = "crate::types::deserialize_int"
46    )]
47    pub port: i64,
48    pub ticket: String,
49    pub upid: String,
50    pub user: String,
51}
52#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
53pub struct PostParams {
54    #[serde(skip_serializing_if = "Option::is_none", default)]
55    #[doc = "Run specific command or default to login (requires 'root@pam')"]
56    #[doc = ""]
57    pub cmd: Option<Cmd>,
58    #[serde(rename = "cmd-opts")]
59    #[serde(skip_serializing_if = "Option::is_none", default)]
60    #[doc = "Add parameters to a command. Encoded as null terminated strings."]
61    #[doc = ""]
62    pub cmd_opts: Option<String>,
63    #[serde(skip_serializing_if = "Option::is_none", default)]
64    #[doc = "sets the height of the console in pixels."]
65    #[doc = ""]
66    pub height: Option<HeightInt>,
67    #[serde(
68        serialize_with = "crate::types::serialize_bool_optional",
69        deserialize_with = "crate::types::deserialize_bool_optional"
70    )]
71    #[serde(skip_serializing_if = "Option::is_none", default)]
72    #[doc = "use websocket instead of standard vnc."]
73    #[doc = ""]
74    pub websocket: Option<bool>,
75    #[serde(skip_serializing_if = "Option::is_none", default)]
76    #[doc = "sets the width of the console in pixels."]
77    #[doc = ""]
78    pub width: Option<WidthInt>,
79    #[serde(
80        flatten,
81        default,
82        skip_serializing_if = "::std::collections::HashMap::is_empty"
83    )]
84    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
85}
86#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq, Default)]
87#[doc = "Run specific command or default to login (requires 'root@pam')"]
88#[doc = ""]
89pub enum Cmd {
90    #[serde(rename = "ceph_install")]
91    CephInstall,
92    #[serde(rename = "login")]
93    #[default]
94    Login,
95    #[serde(rename = "upgrade")]
96    Upgrade,
97}
98impl TryFrom<&str> for Cmd {
99    type Error = String;
100    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
101        match value {
102            "ceph_install" => Ok(Self::CephInstall),
103            "login" => Ok(Self::Login),
104            "upgrade" => Ok(Self::Upgrade),
105            v => Err(format!("Unknown variant {v}")),
106        }
107    }
108}
109#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
110pub struct HeightInt(i128);
111impl crate::types::bounded_integer::BoundedInteger for HeightInt {
112    const MIN: Option<i128> = Some(16i128);
113    const MAX: Option<i128> = Some(2160i128);
114    const DEFAULT: Option<i128> = None::<i128>;
115    const TYPE_DESCRIPTION: &'static str = "an integer between 16 and 2160";
116    fn get(&self) -> i128 {
117        self.0
118    }
119    fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
120        Self::validate(value)?;
121        Ok(Self(value))
122    }
123}
124impl std::convert::TryFrom<i128> for HeightInt {
125    type Error = crate::types::bounded_integer::BoundedIntegerError;
126    fn try_from(value: i128) -> Result<Self, Self::Error> {
127        crate::types::bounded_integer::BoundedInteger::new(value)
128    }
129}
130impl ::serde::Serialize for HeightInt {
131    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
132    where
133        S: ::serde::Serializer,
134    {
135        crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
136    }
137}
138impl<'de> ::serde::Deserialize<'de> for HeightInt {
139    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
140    where
141        D: ::serde::Deserializer<'de>,
142    {
143        crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
144    }
145}
146#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
147pub struct WidthInt(i128);
148impl crate::types::bounded_integer::BoundedInteger for WidthInt {
149    const MIN: Option<i128> = Some(16i128);
150    const MAX: Option<i128> = Some(4096i128);
151    const DEFAULT: Option<i128> = None::<i128>;
152    const TYPE_DESCRIPTION: &'static str = "an integer between 16 and 4096";
153    fn get(&self) -> i128 {
154        self.0
155    }
156    fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
157        Self::validate(value)?;
158        Ok(Self(value))
159    }
160}
161impl std::convert::TryFrom<i128> for WidthInt {
162    type Error = crate::types::bounded_integer::BoundedIntegerError;
163    fn try_from(value: i128) -> Result<Self, Self::Error> {
164        crate::types::bounded_integer::BoundedInteger::new(value)
165    }
166}
167impl ::serde::Serialize for WidthInt {
168    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
169    where
170        S: ::serde::Serializer,
171    {
172        crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
173    }
174}
175impl<'de> ::serde::Deserialize<'de> for WidthInt {
176    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
177    where
178        D: ::serde::Deserializer<'de>,
179    {
180        crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
181    }
182}