Skip to main content

proxmox_api/generated/nodes/node/
tasks.rs

1pub mod upid;
2#[derive(Debug, Clone)]
3pub struct TasksClient<T> {
4    client: T,
5    path: String,
6}
7impl<T> TasksClient<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, "/tasks"),
15        }
16    }
17}
18impl<T> TasksClient<T>
19where
20    T: crate::client::Client,
21{
22    #[doc = "Read task list for one node (finished tasks)."]
23    #[doc = ""]
24    #[doc = "List task associated with the current user, or all task the user has 'Sys.Audit' permissions on /nodes/\\<node\\> (the \\<node\\> the task runs on)."]
25    pub async fn get(&self, params: GetParams) -> Result<Vec<GetOutputItems>, T::Error> {
26        let path = self.path.to_string();
27        let optional_vec: Option<Vec<GetOutputItems>> = self.client.get(&path, &params).await?;
28        Ok(optional_vec.unwrap_or_default())
29    }
30}
31impl GetOutputItems {
32    pub fn new(
33        id: String,
34        node: String,
35        pid: i64,
36        pstart: i64,
37        starttime: i64,
38        ty: String,
39        upid: String,
40        user: String,
41    ) -> Self {
42        Self {
43            id,
44            node,
45            pid,
46            pstart,
47            starttime,
48            ty,
49            upid,
50            user,
51            endtime: ::std::default::Default::default(),
52            status: ::std::default::Default::default(),
53            additional_properties: ::std::default::Default::default(),
54        }
55    }
56}
57#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
58pub struct GetOutputItems {
59    #[serde(
60        serialize_with = "crate::types::serialize_int_optional",
61        deserialize_with = "crate::types::deserialize_int_optional"
62    )]
63    #[serde(skip_serializing_if = "Option::is_none", default)]
64    pub endtime: Option<i64>,
65    pub id: String,
66    pub node: String,
67    #[serde(
68        serialize_with = "crate::types::serialize_int",
69        deserialize_with = "crate::types::deserialize_int"
70    )]
71    pub pid: i64,
72    #[serde(
73        serialize_with = "crate::types::serialize_int",
74        deserialize_with = "crate::types::deserialize_int"
75    )]
76    pub pstart: i64,
77    #[serde(
78        serialize_with = "crate::types::serialize_int",
79        deserialize_with = "crate::types::deserialize_int"
80    )]
81    pub starttime: i64,
82    #[serde(skip_serializing_if = "Option::is_none", default)]
83    pub status: Option<String>,
84    #[serde(rename = "type")]
85    pub ty: String,
86    pub upid: String,
87    pub user: String,
88    #[serde(
89        flatten,
90        default,
91        skip_serializing_if = "::std::collections::HashMap::is_empty"
92    )]
93    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
94}
95#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
96pub struct GetParams {
97    #[serde(
98        serialize_with = "crate::types::serialize_bool_optional",
99        deserialize_with = "crate::types::deserialize_bool_optional"
100    )]
101    #[serde(skip_serializing_if = "Option::is_none", default)]
102    #[doc = "Only list tasks with a status of ERROR."]
103    #[doc = ""]
104    pub errors: Option<bool>,
105    #[serde(skip_serializing_if = "Option::is_none", default)]
106    #[doc = "Only list this number of tasks."]
107    #[doc = ""]
108    pub limit: Option<LimitInt>,
109    #[serde(
110        serialize_with = "crate::types::serialize_int_optional",
111        deserialize_with = "crate::types::deserialize_int_optional"
112    )]
113    #[serde(skip_serializing_if = "Option::is_none", default)]
114    #[doc = "Only list tasks since this UNIX epoch."]
115    #[doc = ""]
116    pub since: Option<i64>,
117    #[serde(skip_serializing_if = "Option::is_none", default)]
118    #[doc = "List archived, active or all tasks."]
119    #[doc = ""]
120    pub source: Option<Source>,
121    #[serde(
122        serialize_with = "crate::types::serialize_unsigned_int_optional",
123        deserialize_with = "crate::types::deserialize_unsigned_int_optional"
124    )]
125    #[serde(skip_serializing_if = "Option::is_none", default)]
126    #[doc = "List tasks beginning from this offset."]
127    #[doc = ""]
128    pub start: Option<u64>,
129    #[serde(skip_serializing_if = "Option::is_none", default)]
130    #[doc = "List of Task States that should be returned."]
131    #[doc = ""]
132    pub statusfilter: Option<String>,
133    #[serde(skip_serializing_if = "Option::is_none", default)]
134    #[doc = "Only list tasks of this type (e.g., vzstart, vzdump)."]
135    #[doc = ""]
136    pub typefilter: Option<String>,
137    #[serde(
138        serialize_with = "crate::types::serialize_int_optional",
139        deserialize_with = "crate::types::deserialize_int_optional"
140    )]
141    #[serde(skip_serializing_if = "Option::is_none", default)]
142    #[doc = "Only list tasks until this UNIX epoch."]
143    #[doc = ""]
144    pub until: Option<i64>,
145    #[serde(skip_serializing_if = "Option::is_none", default)]
146    #[doc = "Only list tasks from this user."]
147    #[doc = ""]
148    pub userfilter: Option<String>,
149    #[serde(skip_serializing_if = "Option::is_none", default)]
150    #[doc = "Only list tasks for this VM."]
151    #[doc = ""]
152    pub vmid: Option<VmidInt>,
153    #[serde(
154        flatten,
155        default,
156        skip_serializing_if = "::std::collections::HashMap::is_empty"
157    )]
158    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
159}
160#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq, Default)]
161#[doc = "List archived, active or all tasks."]
162#[doc = ""]
163pub enum Source {
164    #[serde(rename = "active")]
165    Active,
166    #[serde(rename = "all")]
167    All,
168    #[serde(rename = "archive")]
169    #[default]
170    Archive,
171}
172impl TryFrom<&str> for Source {
173    type Error = String;
174    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
175        match value {
176            "active" => Ok(Self::Active),
177            "all" => Ok(Self::All),
178            "archive" => Ok(Self::Archive),
179            v => Err(format!("Unknown variant {v}")),
180        }
181    }
182}
183#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
184pub struct LimitInt(i128);
185impl crate::types::bounded_integer::BoundedInteger for LimitInt {
186    const MIN: Option<i128> = Some(0i128);
187    const MAX: Option<i128> = None::<i128>;
188    const DEFAULT: Option<i128> = Some(50i128);
189    const TYPE_DESCRIPTION: &'static str = "an integer greater than or equal to 0";
190    fn get(&self) -> i128 {
191        self.0
192    }
193    fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
194        Self::validate(value)?;
195        Ok(Self(value))
196    }
197}
198impl std::convert::TryFrom<i128> for LimitInt {
199    type Error = crate::types::bounded_integer::BoundedIntegerError;
200    fn try_from(value: i128) -> Result<Self, Self::Error> {
201        crate::types::bounded_integer::BoundedInteger::new(value)
202    }
203}
204impl ::serde::Serialize for LimitInt {
205    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
206    where
207        S: ::serde::Serializer,
208    {
209        crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
210    }
211}
212impl<'de> ::serde::Deserialize<'de> for LimitInt {
213    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
214    where
215        D: ::serde::Deserializer<'de>,
216    {
217        crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
218    }
219}
220#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
221pub struct VmidInt(i128);
222impl crate::types::bounded_integer::BoundedInteger for VmidInt {
223    const MIN: Option<i128> = Some(100i128);
224    const MAX: Option<i128> = Some(999999999i128);
225    const DEFAULT: Option<i128> = None::<i128>;
226    const TYPE_DESCRIPTION: &'static str = "an integer between 100 and 999999999";
227    fn get(&self) -> i128 {
228        self.0
229    }
230    fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
231        Self::validate(value)?;
232        Ok(Self(value))
233    }
234}
235impl std::convert::TryFrom<i128> for VmidInt {
236    type Error = crate::types::bounded_integer::BoundedIntegerError;
237    fn try_from(value: i128) -> Result<Self, Self::Error> {
238        crate::types::bounded_integer::BoundedInteger::new(value)
239    }
240}
241impl ::serde::Serialize for VmidInt {
242    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
243    where
244        S: ::serde::Serializer,
245    {
246        crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
247    }
248}
249impl<'de> ::serde::Deserialize<'de> for VmidInt {
250    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
251    where
252        D: ::serde::Deserializer<'de>,
253    {
254        crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
255    }
256}
257impl<T> TasksClient<T>
258where
259    T: crate::client::Client,
260{
261    pub fn upid(&self, upid: &str) -> upid::UpidClient<T> {
262        upid::UpidClient::<T>::new(self.client.clone(), &self.path, upid)
263    }
264}