Skip to main content

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

1#[derive(Debug, Clone)]
2pub struct FileWriteClient<T> {
3    client: T,
4    path: String,
5}
6impl<T> FileWriteClient<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, "/file-write"),
14        }
15    }
16}
17impl<T> FileWriteClient<T>
18where
19    T: crate::client::Client,
20{
21    #[doc = "Writes the given file via guest agent."]
22    #[doc = ""]
23    #[doc = "Permission check: perm(\"/vms/{vmid}\", [\"VM.GuestAgent.FileWrite\", \"VM.GuestAgent.Unrestricted\"], any)"]
24    pub async fn post(&self, params: PostParams) -> Result<(), T::Error> {
25        let path = self.path.to_string();
26        self.client.post(&path, &params).await
27    }
28}
29impl PostParams {
30    pub fn new(content: ContentStr, file: String) -> Self {
31        Self {
32            content,
33            file,
34            encode: ::std::default::Default::default(),
35            additional_properties: ::std::default::Default::default(),
36        }
37    }
38}
39#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
40pub struct PostParams {
41    #[doc = "The content to write into the file."]
42    #[doc = ""]
43    pub content: ContentStr,
44    #[serde(
45        serialize_with = "crate::types::serialize_bool_optional",
46        deserialize_with = "crate::types::deserialize_bool_optional"
47    )]
48    #[serde(skip_serializing_if = "Option::is_none", default)]
49    #[doc = "If set, the content will be encoded as base64 (required by QEMU).Otherwise the content needs to be encoded beforehand - defaults to true."]
50    #[doc = ""]
51    pub encode: Option<bool>,
52    #[doc = "The path to the file."]
53    #[doc = ""]
54    pub file: String,
55    #[serde(
56        flatten,
57        default,
58        skip_serializing_if = "::std::collections::HashMap::is_empty"
59    )]
60    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
61}
62#[derive(Debug, Clone, PartialEq, PartialOrd)]
63pub struct ContentStr {
64    value: String,
65}
66impl crate::types::bounded_string::BoundedString for ContentStr {
67    const MIN_LENGTH: Option<usize> = None::<usize>;
68    const MAX_LENGTH: Option<usize> = Some(61440usize);
69    const DEFAULT: Option<&'static str> = None::<&'static str>;
70    const PATTERN: Option<&'static str> = None::<&'static str>;
71    const TYPE_DESCRIPTION: &'static str = "a string with length at most 61440";
72    fn get_value(&self) -> &str {
73        &self.value
74    }
75    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
76        Self::validate(&value)?;
77        Ok(Self { value })
78    }
79}
80impl std::convert::TryFrom<String> for ContentStr {
81    type Error = crate::types::bounded_string::BoundedStringError;
82    fn try_from(value: String) -> Result<Self, Self::Error> {
83        crate::types::bounded_string::BoundedString::new(value)
84    }
85}
86impl ::serde::Serialize for ContentStr {
87    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
88    where
89        S: ::serde::Serializer,
90    {
91        crate::types::bounded_string::serialize_bounded_string(self, serializer)
92    }
93}
94impl<'de> ::serde::Deserialize<'de> for ContentStr {
95    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
96    where
97        D: ::serde::Deserializer<'de>,
98    {
99        crate::types::bounded_string::deserialize_bounded_string(deserializer)
100    }
101}