1#[derive(Debug, Clone)]
2pub struct IdClient<T> {
3 client: T,
4 path: String,
5}
6impl<T> IdClient<T>
7where
8 T: crate::client::Client,
9{
10 pub fn new(client: T, parent_path: &str, id: &str) -> Self {
11 Self {
12 client,
13 path: format!("{}/{}", parent_path, id),
14 }
15 }
16}
17impl<T> IdClient<T>
18where
19 T: crate::client::Client,
20{
21 #[doc = "Mark replication job for removal."]
22 #[doc = ""]
23 #[doc = "Requires the VM.Replicate permission on /vms/\\<vmid\\>."]
24 pub async fn delete(&self, params: DeleteParams) -> Result<(), T::Error> {
25 let path = self.path.to_string();
26 self.client.delete(&path, ¶ms).await
27 }
28}
29impl<T> IdClient<T>
30where
31 T: crate::client::Client,
32{
33 #[doc = "Read replication job configuration."]
34 #[doc = ""]
35 #[doc = "Requires the VM.Audit permission on /vms/\\<vmid\\>."]
36 pub async fn get(&self) -> Result<GetOutput, T::Error> {
37 let path = self.path.to_string();
38 self.client.get(&path, &()).await
39 }
40}
41impl<T> IdClient<T>
42where
43 T: crate::client::Client,
44{
45 #[doc = "Update replication job configuration."]
46 #[doc = ""]
47 #[doc = "Requires the VM.Replicate permission on /vms/\\<vmid\\>."]
48 pub async fn put(&self, params: PutParams) -> Result<(), T::Error> {
49 let path = self.path.to_string();
50 self.client.put(&path, ¶ms).await
51 }
52}
53#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
54pub struct DeleteParams {
55 #[serde(
56 serialize_with = "crate::types::serialize_bool_optional",
57 deserialize_with = "crate::types::deserialize_bool_optional"
58 )]
59 #[serde(skip_serializing_if = "Option::is_none", default)]
60 #[doc = "Will remove the jobconfig entry, but will not cleanup."]
61 #[doc = ""]
62 pub force: Option<bool>,
63 #[serde(
64 serialize_with = "crate::types::serialize_bool_optional",
65 deserialize_with = "crate::types::deserialize_bool_optional"
66 )]
67 #[serde(skip_serializing_if = "Option::is_none", default)]
68 #[doc = "Keep replicated data at target (do not remove)."]
69 #[doc = ""]
70 pub keep: Option<bool>,
71 #[serde(
72 flatten,
73 default,
74 skip_serializing_if = "::std::collections::HashMap::is_empty"
75 )]
76 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
77}
78impl GetOutput {
79 pub fn new(guest: i64, id: IdStr, jobnum: i64, target: String, ty: Type) -> Self {
80 Self {
81 guest,
82 id,
83 jobnum,
84 target,
85 ty,
86 comment: ::std::default::Default::default(),
87 digest: ::std::default::Default::default(),
88 disable: ::std::default::Default::default(),
89 rate: ::std::default::Default::default(),
90 remove_job: ::std::default::Default::default(),
91 schedule: ::std::default::Default::default(),
92 source: ::std::default::Default::default(),
93 additional_properties: ::std::default::Default::default(),
94 }
95 }
96}
97#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
98pub struct GetOutput {
99 #[serde(skip_serializing_if = "Option::is_none", default)]
100 #[doc = "Description."]
101 #[doc = ""]
102 pub comment: Option<CommentStr>,
103 #[serde(skip_serializing_if = "Option::is_none", default)]
104 #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
105 #[doc = ""]
106 pub digest: Option<DigestStr>,
107 #[serde(
108 serialize_with = "crate::types::serialize_bool_optional",
109 deserialize_with = "crate::types::deserialize_bool_optional"
110 )]
111 #[serde(skip_serializing_if = "Option::is_none", default)]
112 #[doc = "Flag to disable/deactivate the entry."]
113 #[doc = ""]
114 pub disable: Option<bool>,
115 #[serde(
116 serialize_with = "crate::types::serialize_int",
117 deserialize_with = "crate::types::deserialize_int"
118 )]
119 #[doc = "Guest ID."]
120 #[doc = ""]
121 pub guest: i64,
122 #[doc = "Replication Job ID. The ID is composed of a Guest ID and a job number, separated by a hyphen, i.e. '\\\\<GUEST\\\\>-\\\\<JOBNUM\\\\>'."]
123 #[doc = ""]
124 pub id: IdStr,
125 #[serde(
126 serialize_with = "crate::types::serialize_int",
127 deserialize_with = "crate::types::deserialize_int"
128 )]
129 #[doc = "Unique, sequential ID assigned to each job."]
130 #[doc = ""]
131 pub jobnum: i64,
132 #[serde(skip_serializing_if = "Option::is_none", default)]
133 #[doc = "Rate limit in mbps (megabytes per second) as floating point number."]
134 #[doc = ""]
135 pub rate: Option<RateNum>,
136 #[serde(skip_serializing_if = "Option::is_none", default)]
137 #[doc = "Mark the replication job for removal. The job will remove all local replication snapshots. When set to 'full', it also tries to remove replicated volumes on the target. The job then removes itself from the configuration file."]
138 #[doc = ""]
139 pub remove_job: Option<RemoveJob>,
140 #[serde(skip_serializing_if = "Option::is_none", default)]
141 #[doc = "Storage replication schedule. The format is a subset of `systemd` calendar events."]
142 #[doc = ""]
143 pub schedule: Option<ScheduleStr>,
144 #[serde(skip_serializing_if = "Option::is_none", default)]
145 #[doc = "For internal use, to detect if the guest was stolen."]
146 #[doc = ""]
147 pub source: Option<String>,
148 #[doc = "Target node."]
149 #[doc = ""]
150 pub target: String,
151 #[serde(rename = "type")]
152 #[doc = "Section type."]
153 #[doc = ""]
154 pub ty: Type,
155 #[serde(
156 flatten,
157 default,
158 skip_serializing_if = "::std::collections::HashMap::is_empty"
159 )]
160 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
161}
162#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
163pub struct PutParams {
164 #[serde(skip_serializing_if = "Option::is_none", default)]
165 #[doc = "Description."]
166 #[doc = ""]
167 pub comment: Option<CommentStr>,
168 #[serde(skip_serializing_if = "Option::is_none", default)]
169 #[doc = "A list of settings you want to delete."]
170 #[doc = ""]
171 pub delete: Option<DeleteStr>,
172 #[serde(skip_serializing_if = "Option::is_none", default)]
173 #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
174 #[doc = ""]
175 pub digest: Option<DigestStr>,
176 #[serde(
177 serialize_with = "crate::types::serialize_bool_optional",
178 deserialize_with = "crate::types::deserialize_bool_optional"
179 )]
180 #[serde(skip_serializing_if = "Option::is_none", default)]
181 #[doc = "Flag to disable/deactivate the entry."]
182 #[doc = ""]
183 pub disable: Option<bool>,
184 #[serde(skip_serializing_if = "Option::is_none", default)]
185 #[doc = "Rate limit in mbps (megabytes per second) as floating point number."]
186 #[doc = ""]
187 pub rate: Option<RateNum>,
188 #[serde(skip_serializing_if = "Option::is_none", default)]
189 #[doc = "Mark the replication job for removal. The job will remove all local replication snapshots. When set to 'full', it also tries to remove replicated volumes on the target. The job then removes itself from the configuration file."]
190 #[doc = ""]
191 pub remove_job: Option<RemoveJob>,
192 #[serde(skip_serializing_if = "Option::is_none", default)]
193 #[doc = "Storage replication schedule. The format is a subset of `systemd` calendar events."]
194 #[doc = ""]
195 pub schedule: Option<ScheduleStr>,
196 #[serde(skip_serializing_if = "Option::is_none", default)]
197 #[doc = "For internal use, to detect if the guest was stolen."]
198 #[doc = ""]
199 pub source: Option<String>,
200 #[serde(
201 flatten,
202 default,
203 skip_serializing_if = "::std::collections::HashMap::is_empty"
204 )]
205 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
206}
207#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
208#[doc = "Mark the replication job for removal. The job will remove all local replication snapshots. When set to 'full', it also tries to remove replicated volumes on the target. The job then removes itself from the configuration file."]
209#[doc = ""]
210pub enum RemoveJob {
211 #[serde(rename = "full")]
212 Full,
213 #[serde(rename = "local")]
214 Local,
215}
216impl TryFrom<&str> for RemoveJob {
217 type Error = String;
218 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
219 match value {
220 "full" => Ok(Self::Full),
221 "local" => Ok(Self::Local),
222 v => Err(format!("Unknown variant {v}")),
223 }
224 }
225}
226#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
227#[doc = "Section type."]
228#[doc = ""]
229pub enum Type {
230 #[serde(rename = "local")]
231 Local,
232}
233impl TryFrom<&str> for Type {
234 type Error = String;
235 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
236 match value {
237 "local" => Ok(Self::Local),
238 v => Err(format!("Unknown variant {v}")),
239 }
240 }
241}
242#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
243pub struct RateNum(f64);
244impl crate::types::bounded_number::BoundedNumber for RateNum {
245 const MIN: Option<f64> = Some(1f64);
246 const MAX: Option<f64> = None::<f64>;
247 const DEFAULT: Option<f64> = None::<f64>;
248 const TYPE_DESCRIPTION: &'static str = "an number greater than or equal to 1";
249 fn get(&self) -> f64 {
250 self.0
251 }
252 fn new(value: f64) -> Result<Self, crate::types::bounded_number::BoundedNumberError> {
253 Self::validate(value)?;
254 Ok(Self(value))
255 }
256}
257impl std::convert::TryFrom<f64> for RateNum {
258 type Error = crate::types::bounded_number::BoundedNumberError;
259 fn try_from(value: f64) -> Result<Self, Self::Error> {
260 crate::types::bounded_number::BoundedNumber::new(value)
261 }
262}
263impl std::convert::TryFrom<f32> for RateNum {
264 type Error = crate::types::bounded_number::BoundedNumberError;
265 fn try_from(value: f32) -> Result<Self, Self::Error> {
266 crate::types::bounded_number::BoundedNumber::new(value as f64)
267 }
268}
269impl std::convert::TryFrom<i32> for RateNum {
270 type Error = crate::types::bounded_number::BoundedNumberError;
271 fn try_from(value: i32) -> Result<Self, Self::Error> {
272 crate::types::bounded_number::BoundedNumber::new(value as f64)
273 }
274}
275impl std::convert::TryFrom<i64> for RateNum {
276 type Error = crate::types::bounded_number::BoundedNumberError;
277 fn try_from(value: i64) -> Result<Self, Self::Error> {
278 crate::types::bounded_number::BoundedNumber::new(value as f64)
279 }
280}
281impl ::serde::Serialize for RateNum {
282 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
283 where
284 S: ::serde::Serializer,
285 {
286 crate::types::bounded_number::serialize_bounded_number(self, serializer)
287 }
288}
289impl<'de> ::serde::Deserialize<'de> for RateNum {
290 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
291 where
292 D: ::serde::Deserializer<'de>,
293 {
294 crate::types::bounded_number::deserialize_bounded_number(deserializer)
295 }
296}
297#[derive(Debug, Clone, PartialEq, PartialOrd)]
298pub struct CommentStr {
299 value: String,
300}
301impl crate::types::bounded_string::BoundedString for CommentStr {
302 const MIN_LENGTH: Option<usize> = None::<usize>;
303 const MAX_LENGTH: Option<usize> = Some(4096usize);
304 const DEFAULT: Option<&'static str> = None::<&'static str>;
305 const PATTERN: Option<&'static str> = None::<&'static str>;
306 const TYPE_DESCRIPTION: &'static str = "a string with length at most 4096";
307 fn get_value(&self) -> &str {
308 &self.value
309 }
310 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
311 Self::validate(&value)?;
312 Ok(Self { value })
313 }
314}
315impl std::convert::TryFrom<String> for CommentStr {
316 type Error = crate::types::bounded_string::BoundedStringError;
317 fn try_from(value: String) -> Result<Self, Self::Error> {
318 crate::types::bounded_string::BoundedString::new(value)
319 }
320}
321impl ::serde::Serialize for CommentStr {
322 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
323 where
324 S: ::serde::Serializer,
325 {
326 crate::types::bounded_string::serialize_bounded_string(self, serializer)
327 }
328}
329impl<'de> ::serde::Deserialize<'de> for CommentStr {
330 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
331 where
332 D: ::serde::Deserializer<'de>,
333 {
334 crate::types::bounded_string::deserialize_bounded_string(deserializer)
335 }
336}
337#[derive(Debug, Clone, PartialEq, PartialOrd)]
338pub struct DeleteStr {
339 value: String,
340}
341impl crate::types::bounded_string::BoundedString for DeleteStr {
342 const MIN_LENGTH: Option<usize> = None::<usize>;
343 const MAX_LENGTH: Option<usize> = Some(4096usize);
344 const DEFAULT: Option<&'static str> = None::<&'static str>;
345 const PATTERN: Option<&'static str> = None::<&'static str>;
346 const TYPE_DESCRIPTION: &'static str = "a string with length at most 4096";
347 fn get_value(&self) -> &str {
348 &self.value
349 }
350 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
351 Self::validate(&value)?;
352 Ok(Self { value })
353 }
354}
355impl std::convert::TryFrom<String> for DeleteStr {
356 type Error = crate::types::bounded_string::BoundedStringError;
357 fn try_from(value: String) -> Result<Self, Self::Error> {
358 crate::types::bounded_string::BoundedString::new(value)
359 }
360}
361impl ::serde::Serialize for DeleteStr {
362 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
363 where
364 S: ::serde::Serializer,
365 {
366 crate::types::bounded_string::serialize_bounded_string(self, serializer)
367 }
368}
369impl<'de> ::serde::Deserialize<'de> for DeleteStr {
370 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
371 where
372 D: ::serde::Deserializer<'de>,
373 {
374 crate::types::bounded_string::deserialize_bounded_string(deserializer)
375 }
376}
377#[derive(Debug, Clone, PartialEq, PartialOrd)]
378pub struct DigestStr {
379 value: String,
380}
381impl crate::types::bounded_string::BoundedString for DigestStr {
382 const MIN_LENGTH: Option<usize> = None::<usize>;
383 const MAX_LENGTH: Option<usize> = Some(64usize);
384 const DEFAULT: Option<&'static str> = None::<&'static str>;
385 const PATTERN: Option<&'static str> = None::<&'static str>;
386 const TYPE_DESCRIPTION: &'static str = "a string with length at most 64";
387 fn get_value(&self) -> &str {
388 &self.value
389 }
390 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
391 Self::validate(&value)?;
392 Ok(Self { value })
393 }
394}
395impl std::convert::TryFrom<String> for DigestStr {
396 type Error = crate::types::bounded_string::BoundedStringError;
397 fn try_from(value: String) -> Result<Self, Self::Error> {
398 crate::types::bounded_string::BoundedString::new(value)
399 }
400}
401impl ::serde::Serialize for DigestStr {
402 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
403 where
404 S: ::serde::Serializer,
405 {
406 crate::types::bounded_string::serialize_bounded_string(self, serializer)
407 }
408}
409impl<'de> ::serde::Deserialize<'de> for DigestStr {
410 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
411 where
412 D: ::serde::Deserializer<'de>,
413 {
414 crate::types::bounded_string::deserialize_bounded_string(deserializer)
415 }
416}
417#[derive(Debug, Clone, PartialEq, PartialOrd)]
418pub struct IdStr {
419 value: String,
420}
421impl crate::types::bounded_string::BoundedString for IdStr {
422 const MIN_LENGTH: Option<usize> = None::<usize>;
423 const MAX_LENGTH: Option<usize> = None::<usize>;
424 const DEFAULT: Option<&'static str> = None::<&'static str>;
425 const PATTERN: Option<&'static str> = Some("[1-9][0-9]{2,8}-\\d{1,9}");
426 const TYPE_DESCRIPTION: &'static str =
427 "a string with pattern r\"[1-9][0-9]{2,8}-\\d{1,9}\" and no length constraints";
428 fn get_value(&self) -> &str {
429 &self.value
430 }
431 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
432 Self::validate(&value)?;
433 Ok(Self { value })
434 }
435}
436impl std::convert::TryFrom<String> for IdStr {
437 type Error = crate::types::bounded_string::BoundedStringError;
438 fn try_from(value: String) -> Result<Self, Self::Error> {
439 crate::types::bounded_string::BoundedString::new(value)
440 }
441}
442impl ::serde::Serialize for IdStr {
443 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
444 where
445 S: ::serde::Serializer,
446 {
447 crate::types::bounded_string::serialize_bounded_string(self, serializer)
448 }
449}
450impl<'de> ::serde::Deserialize<'de> for IdStr {
451 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
452 where
453 D: ::serde::Deserializer<'de>,
454 {
455 crate::types::bounded_string::deserialize_bounded_string(deserializer)
456 }
457}
458#[derive(Debug, Clone, PartialEq, PartialOrd)]
459pub struct ScheduleStr {
460 value: String,
461}
462impl crate::types::bounded_string::BoundedString for ScheduleStr {
463 const MIN_LENGTH: Option<usize> = None::<usize>;
464 const MAX_LENGTH: Option<usize> = Some(128usize);
465 const DEFAULT: Option<&'static str> = Some("*/15");
466 const PATTERN: Option<&'static str> = None::<&'static str>;
467 const TYPE_DESCRIPTION: &'static str = "a string with length at most 128";
468 fn get_value(&self) -> &str {
469 &self.value
470 }
471 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
472 Self::validate(&value)?;
473 Ok(Self { value })
474 }
475}
476impl std::convert::TryFrom<String> for ScheduleStr {
477 type Error = crate::types::bounded_string::BoundedStringError;
478 fn try_from(value: String) -> Result<Self, Self::Error> {
479 crate::types::bounded_string::BoundedString::new(value)
480 }
481}
482impl ::serde::Serialize for ScheduleStr {
483 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
484 where
485 S: ::serde::Serializer,
486 {
487 crate::types::bounded_string::serialize_bounded_string(self, serializer)
488 }
489}
490impl<'de> ::serde::Deserialize<'de> for ScheduleStr {
491 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
492 where
493 D: ::serde::Deserializer<'de>,
494 {
495 crate::types::bounded_string::deserialize_bounded_string(deserializer)
496 }
497}