proxmox_api/generated/nodes/node/qemu/vmid/
snapshot.rs1pub mod snapname;
2#[derive(Debug, Clone)]
3pub struct SnapshotClient<T> {
4 client: T,
5 path: String,
6}
7impl<T> SnapshotClient<T>
8where
9 T: crate::client::Client,
10{
11 pub fn new(client: T, parent_path: &str) -> Self {
12 Self {
13 client,
14 path: format!("{}{}", parent_path, "/snapshot"),
15 }
16 }
17}
18impl<T> SnapshotClient<T>
19where
20 T: crate::client::Client,
21{
22 #[doc = "List all snapshots."]
23 #[doc = ""]
24 #[doc = "Permission check: perm(\"/vms/{vmid}\", [\"VM.Audit\"])"]
25 pub async fn get(&self) -> Result<Vec<GetOutputItems>, T::Error> {
26 let path = self.path.to_string();
27 let optional_vec: Option<Vec<GetOutputItems>> = self.client.get(&path, &()).await?;
28 Ok(optional_vec.unwrap_or_default())
29 }
30}
31impl<T> SnapshotClient<T>
32where
33 T: crate::client::Client,
34{
35 #[doc = "Snapshot a VM."]
36 #[doc = ""]
37 #[doc = "Permission check: perm(\"/vms/{vmid}\", [\"VM.Snapshot\"])"]
38 pub async fn post(&self, params: PostParams) -> Result<String, T::Error> {
39 let path = self.path.to_string();
40 self.client.post(&path, ¶ms).await
41 }
42}
43impl GetOutputItems {
44 pub fn new(description: String, name: String) -> Self {
45 Self {
46 description,
47 name,
48 parent: ::std::default::Default::default(),
49 snaptime: ::std::default::Default::default(),
50 vmstate: ::std::default::Default::default(),
51 additional_properties: ::std::default::Default::default(),
52 }
53 }
54}
55#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
56pub struct GetOutputItems {
57 #[doc = "Snapshot description."]
58 #[doc = ""]
59 pub description: String,
60 #[doc = "Snapshot identifier. Value 'current' identifies the current VM."]
61 #[doc = ""]
62 pub name: String,
63 #[serde(skip_serializing_if = "Option::is_none", default)]
64 #[doc = "Parent snapshot identifier."]
65 #[doc = ""]
66 pub parent: Option<String>,
67 #[serde(
68 serialize_with = "crate::types::serialize_int_optional",
69 deserialize_with = "crate::types::deserialize_int_optional"
70 )]
71 #[serde(skip_serializing_if = "Option::is_none", default)]
72 #[doc = "Snapshot creation time"]
73 #[doc = ""]
74 pub snaptime: Option<i64>,
75 #[serde(
76 serialize_with = "crate::types::serialize_bool_optional",
77 deserialize_with = "crate::types::deserialize_bool_optional"
78 )]
79 #[serde(skip_serializing_if = "Option::is_none", default)]
80 #[doc = "Snapshot includes RAM."]
81 #[doc = ""]
82 pub vmstate: Option<bool>,
83 #[serde(
84 flatten,
85 default,
86 skip_serializing_if = "::std::collections::HashMap::is_empty"
87 )]
88 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
89}
90impl PostParams {
91 pub fn new(snapname: SnapnameStr) -> Self {
92 Self {
93 snapname,
94 description: ::std::default::Default::default(),
95 vmstate: ::std::default::Default::default(),
96 additional_properties: ::std::default::Default::default(),
97 }
98 }
99}
100#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
101pub struct PostParams {
102 #[serde(skip_serializing_if = "Option::is_none", default)]
103 #[doc = "A textual description or comment."]
104 #[doc = ""]
105 pub description: Option<String>,
106 #[doc = "The name of the snapshot."]
107 #[doc = ""]
108 pub snapname: SnapnameStr,
109 #[serde(
110 serialize_with = "crate::types::serialize_bool_optional",
111 deserialize_with = "crate::types::deserialize_bool_optional"
112 )]
113 #[serde(skip_serializing_if = "Option::is_none", default)]
114 #[doc = "Save the vmstate"]
115 #[doc = ""]
116 pub vmstate: Option<bool>,
117 #[serde(
118 flatten,
119 default,
120 skip_serializing_if = "::std::collections::HashMap::is_empty"
121 )]
122 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
123}
124#[derive(Debug, Clone, PartialEq, PartialOrd)]
125pub struct SnapnameStr {
126 value: String,
127}
128impl crate::types::bounded_string::BoundedString for SnapnameStr {
129 const MIN_LENGTH: Option<usize> = None::<usize>;
130 const MAX_LENGTH: Option<usize> = Some(40usize);
131 const DEFAULT: Option<&'static str> = None::<&'static str>;
132 const PATTERN: Option<&'static str> = None::<&'static str>;
133 const TYPE_DESCRIPTION: &'static str = "a string with length at most 40";
134 fn get_value(&self) -> &str {
135 &self.value
136 }
137 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
138 Self::validate(&value)?;
139 Ok(Self { value })
140 }
141}
142impl std::convert::TryFrom<String> for SnapnameStr {
143 type Error = crate::types::bounded_string::BoundedStringError;
144 fn try_from(value: String) -> Result<Self, Self::Error> {
145 crate::types::bounded_string::BoundedString::new(value)
146 }
147}
148impl ::serde::Serialize for SnapnameStr {
149 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
150 where
151 S: ::serde::Serializer,
152 {
153 crate::types::bounded_string::serialize_bounded_string(self, serializer)
154 }
155}
156impl<'de> ::serde::Deserialize<'de> for SnapnameStr {
157 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
158 where
159 D: ::serde::Deserializer<'de>,
160 {
161 crate::types::bounded_string::deserialize_bounded_string(deserializer)
162 }
163}
164impl<T> SnapshotClient<T>
165where
166 T: crate::client::Client,
167{
168 pub fn snapname(&self, snapname: &str) -> snapname::SnapnameClient<T> {
169 snapname::SnapnameClient::<T>::new(self.client.clone(), &self.path, snapname)
170 }
171}