Skip to main content

proxmox_api/generated/nodes/node/qemu/vmid/agent/
exec.rs

1#[derive(Debug, Clone)]
2pub struct ExecClient<T> {
3    client: T,
4    path: String,
5}
6impl<T> ExecClient<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, "/exec"),
14        }
15    }
16}
17impl<T> ExecClient<T>
18where
19    T: crate::client::Client,
20{
21    #[doc = "Executes the given command in the vm via the guest-agent and returns an object with the pid."]
22    #[doc = ""]
23    #[doc = "Permission check: perm(\"/vms/{vmid}\", [\"VM.GuestAgent.Unrestricted\"])"]
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(pid: i64) -> Self {
31        Self {
32            pid,
33            additional_properties: ::std::default::Default::default(),
34        }
35    }
36}
37#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
38pub struct PostOutput {
39    #[serde(
40        serialize_with = "crate::types::serialize_int",
41        deserialize_with = "crate::types::deserialize_int"
42    )]
43    #[doc = "The PID of the process started by the guest-agent."]
44    #[doc = ""]
45    pub pid: i64,
46    #[serde(
47        flatten,
48        default,
49        skip_serializing_if = "::std::collections::HashMap::is_empty"
50    )]
51    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
52}
53impl PostParams {
54    pub fn new(command: Vec<String>) -> Self {
55        Self {
56            command,
57            input_data: ::std::default::Default::default(),
58            additional_properties: ::std::default::Default::default(),
59        }
60    }
61}
62#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
63pub struct PostParams {
64    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
65    #[doc = "The command as a list of program + arguments."]
66    #[doc = ""]
67    pub command: Vec<String>,
68    #[serde(rename = "input-data")]
69    #[serde(skip_serializing_if = "Option::is_none", default)]
70    #[doc = "Data to pass as 'input-data' to the guest. Usually treated as STDIN to 'command'."]
71    #[doc = ""]
72    pub input_data: Option<InputDataStr>,
73    #[serde(
74        flatten,
75        default,
76        skip_serializing_if = "::std::collections::HashMap::is_empty"
77    )]
78    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
79}
80#[derive(Debug, Clone, PartialEq, PartialOrd)]
81pub struct InputDataStr {
82    value: String,
83}
84impl crate::types::bounded_string::BoundedString for InputDataStr {
85    const MIN_LENGTH: Option<usize> = None::<usize>;
86    const MAX_LENGTH: Option<usize> = Some(65536usize);
87    const DEFAULT: Option<&'static str> = None::<&'static str>;
88    const PATTERN: Option<&'static str> = None::<&'static str>;
89    const TYPE_DESCRIPTION: &'static str = "a string with length at most 65536";
90    fn get_value(&self) -> &str {
91        &self.value
92    }
93    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
94        Self::validate(&value)?;
95        Ok(Self { value })
96    }
97}
98impl std::convert::TryFrom<String> for InputDataStr {
99    type Error = crate::types::bounded_string::BoundedStringError;
100    fn try_from(value: String) -> Result<Self, Self::Error> {
101        crate::types::bounded_string::BoundedString::new(value)
102    }
103}
104impl ::serde::Serialize for InputDataStr {
105    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
106    where
107        S: ::serde::Serializer,
108    {
109        crate::types::bounded_string::serialize_bounded_string(self, serializer)
110    }
111}
112impl<'de> ::serde::Deserialize<'de> for InputDataStr {
113    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
114    where
115        D: ::serde::Deserializer<'de>,
116    {
117        crate::types::bounded_string::deserialize_bounded_string(deserializer)
118    }
119}