Skip to main content

proxmox_api/generated/cluster/
replication.rs

1pub mod id;
2#[derive(Debug, Clone)]
3pub struct ReplicationClient<T> {
4    client: T,
5    path: String,
6}
7impl<T> ReplicationClient<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, "/replication"),
15        }
16    }
17}
18impl<T> ReplicationClient<T>
19where
20    T: crate::client::Client,
21{
22    #[doc = "List replication jobs."]
23    #[doc = ""]
24    #[doc = "Will only return replication jobs for which the calling user has VM.Audit permission on /vms/\\<vmid\\>."]
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> ReplicationClient<T>
32where
33    T: crate::client::Client,
34{
35    #[doc = "Create a new replication job"]
36    #[doc = ""]
37    #[doc = "Requires the VM.Replicate permission on /vms/\\<vmid\\>."]
38    pub async fn post(&self, params: PostParams) -> Result<(), T::Error> {
39        let path = self.path.to_string();
40        self.client.post(&path, &params).await
41    }
42}
43impl GetOutputItems {
44    pub fn new(guest: i64, id: IdStr, jobnum: i64, target: String, ty: Type) -> Self {
45        Self {
46            guest,
47            id,
48            jobnum,
49            target,
50            ty,
51            comment: ::std::default::Default::default(),
52            disable: ::std::default::Default::default(),
53            rate: ::std::default::Default::default(),
54            remove_job: ::std::default::Default::default(),
55            schedule: ::std::default::Default::default(),
56            source: ::std::default::Default::default(),
57            additional_properties: ::std::default::Default::default(),
58        }
59    }
60}
61#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
62pub struct GetOutputItems {
63    #[serde(skip_serializing_if = "Option::is_none", default)]
64    #[doc = "Description."]
65    #[doc = ""]
66    pub comment: Option<CommentStr>,
67    #[serde(
68        serialize_with = "crate::types::serialize_bool_optional",
69        deserialize_with = "crate::types::deserialize_bool_optional"
70    )]
71    #[serde(skip_serializing_if = "Option::is_none", default)]
72    #[doc = "Flag to disable/deactivate the entry."]
73    #[doc = ""]
74    pub disable: Option<bool>,
75    #[serde(
76        serialize_with = "crate::types::serialize_int",
77        deserialize_with = "crate::types::deserialize_int"
78    )]
79    #[doc = "Guest ID."]
80    #[doc = ""]
81    pub guest: i64,
82    #[doc = "Replication Job ID. The ID is composed of a Guest ID and a job number, separated by a hyphen, i.e. '\\\\<GUEST\\\\>-\\\\<JOBNUM\\\\>'."]
83    #[doc = ""]
84    pub id: IdStr,
85    #[serde(
86        serialize_with = "crate::types::serialize_int",
87        deserialize_with = "crate::types::deserialize_int"
88    )]
89    #[doc = "Unique, sequential ID assigned to each job."]
90    #[doc = ""]
91    pub jobnum: i64,
92    #[serde(skip_serializing_if = "Option::is_none", default)]
93    #[doc = "Rate limit in mbps (megabytes per second) as floating point number."]
94    #[doc = ""]
95    pub rate: Option<RateNum>,
96    #[serde(skip_serializing_if = "Option::is_none", default)]
97    #[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."]
98    #[doc = ""]
99    pub remove_job: Option<RemoveJob>,
100    #[serde(skip_serializing_if = "Option::is_none", default)]
101    #[doc = "Storage replication schedule. The format is a subset of `systemd` calendar events."]
102    #[doc = ""]
103    pub schedule: Option<ScheduleStr>,
104    #[serde(skip_serializing_if = "Option::is_none", default)]
105    #[doc = "For internal use, to detect if the guest was stolen."]
106    #[doc = ""]
107    pub source: Option<String>,
108    #[doc = "Target node."]
109    #[doc = ""]
110    pub target: String,
111    #[serde(rename = "type")]
112    #[doc = "Section type."]
113    #[doc = ""]
114    pub ty: Type,
115    #[serde(
116        flatten,
117        default,
118        skip_serializing_if = "::std::collections::HashMap::is_empty"
119    )]
120    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
121}
122impl PostParams {
123    pub fn new(id: IdStr, target: String, ty: Type) -> Self {
124        Self {
125            id,
126            target,
127            ty,
128            comment: ::std::default::Default::default(),
129            disable: ::std::default::Default::default(),
130            rate: ::std::default::Default::default(),
131            remove_job: ::std::default::Default::default(),
132            schedule: ::std::default::Default::default(),
133            source: ::std::default::Default::default(),
134            additional_properties: ::std::default::Default::default(),
135        }
136    }
137}
138#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
139pub struct PostParams {
140    #[serde(skip_serializing_if = "Option::is_none", default)]
141    #[doc = "Description."]
142    #[doc = ""]
143    pub comment: Option<CommentStr>,
144    #[serde(
145        serialize_with = "crate::types::serialize_bool_optional",
146        deserialize_with = "crate::types::deserialize_bool_optional"
147    )]
148    #[serde(skip_serializing_if = "Option::is_none", default)]
149    #[doc = "Flag to disable/deactivate the entry."]
150    #[doc = ""]
151    pub disable: Option<bool>,
152    #[doc = "Replication Job ID. The ID is composed of a Guest ID and a job number, separated by a hyphen, i.e. '\\\\<GUEST\\\\>-\\\\<JOBNUM\\\\>'."]
153    #[doc = ""]
154    pub id: IdStr,
155    #[serde(skip_serializing_if = "Option::is_none", default)]
156    #[doc = "Rate limit in mbps (megabytes per second) as floating point number."]
157    #[doc = ""]
158    pub rate: Option<RateNum>,
159    #[serde(skip_serializing_if = "Option::is_none", default)]
160    #[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."]
161    #[doc = ""]
162    pub remove_job: Option<RemoveJob>,
163    #[serde(skip_serializing_if = "Option::is_none", default)]
164    #[doc = "Storage replication schedule. The format is a subset of `systemd` calendar events."]
165    #[doc = ""]
166    pub schedule: Option<ScheduleStr>,
167    #[serde(skip_serializing_if = "Option::is_none", default)]
168    #[doc = "For internal use, to detect if the guest was stolen."]
169    #[doc = ""]
170    pub source: Option<String>,
171    #[doc = "Target node."]
172    #[doc = ""]
173    pub target: String,
174    #[serde(rename = "type")]
175    #[doc = "Section type."]
176    #[doc = ""]
177    pub ty: Type,
178    #[serde(
179        flatten,
180        default,
181        skip_serializing_if = "::std::collections::HashMap::is_empty"
182    )]
183    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
184}
185#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
186#[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."]
187#[doc = ""]
188pub enum RemoveJob {
189    #[serde(rename = "full")]
190    Full,
191    #[serde(rename = "local")]
192    Local,
193}
194impl TryFrom<&str> for RemoveJob {
195    type Error = String;
196    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
197        match value {
198            "full" => Ok(Self::Full),
199            "local" => Ok(Self::Local),
200            v => Err(format!("Unknown variant {v}")),
201        }
202    }
203}
204#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
205#[doc = "Section type."]
206#[doc = ""]
207pub enum Type {
208    #[serde(rename = "local")]
209    Local,
210}
211impl TryFrom<&str> for Type {
212    type Error = String;
213    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
214        match value {
215            "local" => Ok(Self::Local),
216            v => Err(format!("Unknown variant {v}")),
217        }
218    }
219}
220#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
221pub struct RateNum(f64);
222impl crate::types::bounded_number::BoundedNumber for RateNum {
223    const MIN: Option<f64> = Some(1f64);
224    const MAX: Option<f64> = None::<f64>;
225    const DEFAULT: Option<f64> = None::<f64>;
226    const TYPE_DESCRIPTION: &'static str = "an number greater than or equal to 1";
227    fn get(&self) -> f64 {
228        self.0
229    }
230    fn new(value: f64) -> Result<Self, crate::types::bounded_number::BoundedNumberError> {
231        Self::validate(value)?;
232        Ok(Self(value))
233    }
234}
235impl std::convert::TryFrom<f64> for RateNum {
236    type Error = crate::types::bounded_number::BoundedNumberError;
237    fn try_from(value: f64) -> Result<Self, Self::Error> {
238        crate::types::bounded_number::BoundedNumber::new(value)
239    }
240}
241impl std::convert::TryFrom<f32> for RateNum {
242    type Error = crate::types::bounded_number::BoundedNumberError;
243    fn try_from(value: f32) -> Result<Self, Self::Error> {
244        crate::types::bounded_number::BoundedNumber::new(value as f64)
245    }
246}
247impl std::convert::TryFrom<i32> for RateNum {
248    type Error = crate::types::bounded_number::BoundedNumberError;
249    fn try_from(value: i32) -> Result<Self, Self::Error> {
250        crate::types::bounded_number::BoundedNumber::new(value as f64)
251    }
252}
253impl std::convert::TryFrom<i64> for RateNum {
254    type Error = crate::types::bounded_number::BoundedNumberError;
255    fn try_from(value: i64) -> Result<Self, Self::Error> {
256        crate::types::bounded_number::BoundedNumber::new(value as f64)
257    }
258}
259impl ::serde::Serialize for RateNum {
260    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
261    where
262        S: ::serde::Serializer,
263    {
264        crate::types::bounded_number::serialize_bounded_number(self, serializer)
265    }
266}
267impl<'de> ::serde::Deserialize<'de> for RateNum {
268    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
269    where
270        D: ::serde::Deserializer<'de>,
271    {
272        crate::types::bounded_number::deserialize_bounded_number(deserializer)
273    }
274}
275#[derive(Debug, Clone, PartialEq, PartialOrd)]
276pub struct CommentStr {
277    value: String,
278}
279impl crate::types::bounded_string::BoundedString for CommentStr {
280    const MIN_LENGTH: Option<usize> = None::<usize>;
281    const MAX_LENGTH: Option<usize> = Some(4096usize);
282    const DEFAULT: Option<&'static str> = None::<&'static str>;
283    const PATTERN: Option<&'static str> = None::<&'static str>;
284    const TYPE_DESCRIPTION: &'static str = "a string with length at most 4096";
285    fn get_value(&self) -> &str {
286        &self.value
287    }
288    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
289        Self::validate(&value)?;
290        Ok(Self { value })
291    }
292}
293impl std::convert::TryFrom<String> for CommentStr {
294    type Error = crate::types::bounded_string::BoundedStringError;
295    fn try_from(value: String) -> Result<Self, Self::Error> {
296        crate::types::bounded_string::BoundedString::new(value)
297    }
298}
299impl ::serde::Serialize for CommentStr {
300    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
301    where
302        S: ::serde::Serializer,
303    {
304        crate::types::bounded_string::serialize_bounded_string(self, serializer)
305    }
306}
307impl<'de> ::serde::Deserialize<'de> for CommentStr {
308    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
309    where
310        D: ::serde::Deserializer<'de>,
311    {
312        crate::types::bounded_string::deserialize_bounded_string(deserializer)
313    }
314}
315#[derive(Debug, Clone, PartialEq, PartialOrd)]
316pub struct IdStr {
317    value: String,
318}
319impl crate::types::bounded_string::BoundedString for IdStr {
320    const MIN_LENGTH: Option<usize> = None::<usize>;
321    const MAX_LENGTH: Option<usize> = None::<usize>;
322    const DEFAULT: Option<&'static str> = None::<&'static str>;
323    const PATTERN: Option<&'static str> = Some("[1-9][0-9]{2,8}-\\d{1,9}");
324    const TYPE_DESCRIPTION: &'static str =
325        "a string with pattern r\"[1-9][0-9]{2,8}-\\d{1,9}\" and no length constraints";
326    fn get_value(&self) -> &str {
327        &self.value
328    }
329    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
330        Self::validate(&value)?;
331        Ok(Self { value })
332    }
333}
334impl std::convert::TryFrom<String> for IdStr {
335    type Error = crate::types::bounded_string::BoundedStringError;
336    fn try_from(value: String) -> Result<Self, Self::Error> {
337        crate::types::bounded_string::BoundedString::new(value)
338    }
339}
340impl ::serde::Serialize for IdStr {
341    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
342    where
343        S: ::serde::Serializer,
344    {
345        crate::types::bounded_string::serialize_bounded_string(self, serializer)
346    }
347}
348impl<'de> ::serde::Deserialize<'de> for IdStr {
349    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
350    where
351        D: ::serde::Deserializer<'de>,
352    {
353        crate::types::bounded_string::deserialize_bounded_string(deserializer)
354    }
355}
356#[derive(Debug, Clone, PartialEq, PartialOrd)]
357pub struct ScheduleStr {
358    value: String,
359}
360impl crate::types::bounded_string::BoundedString for ScheduleStr {
361    const MIN_LENGTH: Option<usize> = None::<usize>;
362    const MAX_LENGTH: Option<usize> = Some(128usize);
363    const DEFAULT: Option<&'static str> = Some("*/15");
364    const PATTERN: Option<&'static str> = None::<&'static str>;
365    const TYPE_DESCRIPTION: &'static str = "a string with length at most 128";
366    fn get_value(&self) -> &str {
367        &self.value
368    }
369    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
370        Self::validate(&value)?;
371        Ok(Self { value })
372    }
373}
374impl std::convert::TryFrom<String> for ScheduleStr {
375    type Error = crate::types::bounded_string::BoundedStringError;
376    fn try_from(value: String) -> Result<Self, Self::Error> {
377        crate::types::bounded_string::BoundedString::new(value)
378    }
379}
380impl ::serde::Serialize for ScheduleStr {
381    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
382    where
383        S: ::serde::Serializer,
384    {
385        crate::types::bounded_string::serialize_bounded_string(self, serializer)
386    }
387}
388impl<'de> ::serde::Deserialize<'de> for ScheduleStr {
389    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
390    where
391        D: ::serde::Deserializer<'de>,
392    {
393        crate::types::bounded_string::deserialize_bounded_string(deserializer)
394    }
395}
396impl<T> ReplicationClient<T>
397where
398    T: crate::client::Client,
399{
400    pub fn id(&self, id: &str) -> id::IdClient<T> {
401        id::IdClient::<T>::new(self.client.clone(), &self.path, id)
402    }
403}