proxmox_api/generated/nodes/node/lxc/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 container."]
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 additional_properties: ::std::default::Default::default(),
51 }
52 }
53}
54#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
55pub struct GetOutputItems {
56 #[doc = "Snapshot description."]
57 #[doc = ""]
58 pub description: String,
59 #[doc = "Snapshot identifier. Value 'current' identifies the current VM."]
60 #[doc = ""]
61 pub name: String,
62 #[serde(skip_serializing_if = "Option::is_none", default)]
63 #[doc = "Parent snapshot identifier."]
64 #[doc = ""]
65 pub parent: Option<String>,
66 #[serde(
67 serialize_with = "crate::types::serialize_int_optional",
68 deserialize_with = "crate::types::deserialize_int_optional"
69 )]
70 #[serde(skip_serializing_if = "Option::is_none", default)]
71 #[doc = "Snapshot creation time"]
72 #[doc = ""]
73 pub snaptime: Option<i64>,
74 #[serde(
75 flatten,
76 default,
77 skip_serializing_if = "::std::collections::HashMap::is_empty"
78 )]
79 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
80}
81impl PostParams {
82 pub fn new(snapname: SnapnameStr) -> Self {
83 Self {
84 snapname,
85 description: ::std::default::Default::default(),
86 additional_properties: ::std::default::Default::default(),
87 }
88 }
89}
90#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
91pub struct PostParams {
92 #[serde(skip_serializing_if = "Option::is_none", default)]
93 #[doc = "A textual description or comment."]
94 #[doc = ""]
95 pub description: Option<String>,
96 #[doc = "The name of the snapshot."]
97 #[doc = ""]
98 pub snapname: SnapnameStr,
99 #[serde(
100 flatten,
101 default,
102 skip_serializing_if = "::std::collections::HashMap::is_empty"
103 )]
104 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
105}
106#[derive(Debug, Clone, PartialEq, PartialOrd)]
107pub struct SnapnameStr {
108 value: String,
109}
110impl crate::types::bounded_string::BoundedString for SnapnameStr {
111 const MIN_LENGTH: Option<usize> = None::<usize>;
112 const MAX_LENGTH: Option<usize> = Some(40usize);
113 const DEFAULT: Option<&'static str> = None::<&'static str>;
114 const PATTERN: Option<&'static str> = None::<&'static str>;
115 const TYPE_DESCRIPTION: &'static str = "a string with length at most 40";
116 fn get_value(&self) -> &str {
117 &self.value
118 }
119 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
120 Self::validate(&value)?;
121 Ok(Self { value })
122 }
123}
124impl std::convert::TryFrom<String> for SnapnameStr {
125 type Error = crate::types::bounded_string::BoundedStringError;
126 fn try_from(value: String) -> Result<Self, Self::Error> {
127 crate::types::bounded_string::BoundedString::new(value)
128 }
129}
130impl ::serde::Serialize for SnapnameStr {
131 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
132 where
133 S: ::serde::Serializer,
134 {
135 crate::types::bounded_string::serialize_bounded_string(self, serializer)
136 }
137}
138impl<'de> ::serde::Deserialize<'de> for SnapnameStr {
139 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
140 where
141 D: ::serde::Deserializer<'de>,
142 {
143 crate::types::bounded_string::deserialize_bounded_string(deserializer)
144 }
145}
146impl<T> SnapshotClient<T>
147where
148 T: crate::client::Client,
149{
150 pub fn snapname(&self, snapname: &str) -> snapname::SnapnameClient<T> {
151 snapname::SnapnameClient::<T>::new(self.client.clone(), &self.path, snapname)
152 }
153}