Skip to main content

proxmox_api/generated/nodes/node/apt/
repositories.rs

1#[derive(Debug, Clone)]
2pub struct RepositoriesClient<T> {
3    client: T,
4    path: String,
5}
6impl<T> RepositoriesClient<T>
7where
8    T: crate::client::Client,
9{
10    pub fn new(client: T, parent_path: &str) -> Self {
11        Self {
12            client,
13            path: format!("{}{}", parent_path, "/repositories"),
14        }
15    }
16}
17impl<T> RepositoriesClient<T>
18where
19    T: crate::client::Client,
20{
21    #[doc = "Get APT repository information."]
22    #[doc = ""]
23    #[doc = "Permission check: perm(\"/nodes/{node}\", [\"Sys.Audit\"])"]
24    pub async fn get(&self) -> Result<GetOutput, T::Error> {
25        let path = self.path.to_string();
26        self.client.get(&path, &()).await
27    }
28}
29impl<T> RepositoriesClient<T>
30where
31    T: crate::client::Client,
32{
33    #[doc = "Change the properties of a repository. Currently only allows enabling/disabling."]
34    #[doc = ""]
35    #[doc = "Permission check: perm(\"/nodes/{node}\", [\"Sys.Modify\"])"]
36    pub async fn post(&self, params: PostParams) -> Result<(), T::Error> {
37        let path = self.path.to_string();
38        self.client.post(&path, &params).await
39    }
40}
41impl<T> RepositoriesClient<T>
42where
43    T: crate::client::Client,
44{
45    #[doc = "Add a standard repository to the configuration"]
46    #[doc = ""]
47    #[doc = "Permission check: perm(\"/nodes/{node}\", [\"Sys.Modify\"])"]
48    pub async fn put(&self, params: PutParams) -> Result<(), T::Error> {
49        let path = self.path.to_string();
50        self.client.put(&path, &params).await
51    }
52}
53impl ErrorsGetOutputErrorsItems {
54    pub fn new(error: String, path: String) -> Self {
55        Self {
56            error,
57            path,
58            additional_properties: ::std::default::Default::default(),
59        }
60    }
61}
62#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
63pub struct ErrorsGetOutputErrorsItems {
64    #[doc = "The error message"]
65    #[doc = ""]
66    pub error: String,
67    #[doc = "Path to the problematic file."]
68    #[doc = ""]
69    pub path: String,
70    #[serde(
71        flatten,
72        default,
73        skip_serializing_if = "::std::collections::HashMap::is_empty"
74    )]
75    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
76}
77impl FilesGetOutputFilesItems {
78    pub fn new(
79        digest: Vec<i64>,
80        file_type: FileType,
81        path: String,
82        repositories: Vec<RepositoriesGetOutputFilesItemsRepositoriesItems>,
83    ) -> Self {
84        Self {
85            digest,
86            file_type,
87            path,
88            repositories,
89            additional_properties: ::std::default::Default::default(),
90        }
91    }
92}
93#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
94pub struct FilesGetOutputFilesItems {
95    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
96    #[doc = "Digest of the file as bytes."]
97    #[doc = ""]
98    pub digest: Vec<i64>,
99    #[serde(rename = "file-type")]
100    #[doc = "Format of the file."]
101    #[doc = ""]
102    pub file_type: FileType,
103    #[doc = "Path to the problematic file."]
104    #[doc = ""]
105    pub path: String,
106    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
107    #[doc = "The parsed repositories."]
108    #[doc = ""]
109    pub repositories: Vec<RepositoriesGetOutputFilesItemsRepositoriesItems>,
110    #[serde(
111        flatten,
112        default,
113        skip_serializing_if = "::std::collections::HashMap::is_empty"
114    )]
115    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
116}
117impl GetOutput {
118    pub fn new(
119        digest: String,
120        errors: Vec<ErrorsGetOutputErrorsItems>,
121        files: Vec<FilesGetOutputFilesItems>,
122        infos: Vec<InfosGetOutputInfosItems>,
123        standard_repos: Vec<StandardReposGetOutputStandardReposItems>,
124    ) -> Self {
125        Self {
126            digest,
127            errors,
128            files,
129            infos,
130            standard_repos,
131            additional_properties: ::std::default::Default::default(),
132        }
133    }
134}
135#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
136pub struct GetOutput {
137    #[doc = "Common digest of all files."]
138    #[doc = ""]
139    pub digest: String,
140    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
141    #[doc = "List of problematic repository files."]
142    #[doc = ""]
143    pub errors: Vec<ErrorsGetOutputErrorsItems>,
144    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
145    #[doc = "List of parsed repository files."]
146    #[doc = ""]
147    pub files: Vec<FilesGetOutputFilesItems>,
148    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
149    #[doc = "Additional information/warnings for APT repositories."]
150    #[doc = ""]
151    pub infos: Vec<InfosGetOutputInfosItems>,
152    #[serde(rename = "standard-repos")]
153    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
154    #[doc = "List of standard repositories and their configuration status"]
155    #[doc = ""]
156    pub standard_repos: Vec<StandardReposGetOutputStandardReposItems>,
157    #[serde(
158        flatten,
159        default,
160        skip_serializing_if = "::std::collections::HashMap::is_empty"
161    )]
162    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
163}
164impl InfosGetOutputInfosItems {
165    pub fn new(index: String, kind: String, message: String, path: String) -> Self {
166        Self {
167            index,
168            kind,
169            message,
170            path,
171            property: ::std::default::Default::default(),
172            additional_properties: ::std::default::Default::default(),
173        }
174    }
175}
176#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
177pub struct InfosGetOutputInfosItems {
178    #[doc = "Index of the associated repository within the file."]
179    #[doc = ""]
180    pub index: String,
181    #[doc = "Kind of the information (e.g. warning)."]
182    #[doc = ""]
183    pub kind: String,
184    #[doc = "Information message."]
185    #[doc = ""]
186    pub message: String,
187    #[doc = "Path to the associated file."]
188    #[doc = ""]
189    pub path: String,
190    #[serde(skip_serializing_if = "Option::is_none", default)]
191    #[doc = "Property from which the info originates."]
192    #[doc = ""]
193    pub property: Option<String>,
194    #[serde(
195        flatten,
196        default,
197        skip_serializing_if = "::std::collections::HashMap::is_empty"
198    )]
199    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
200}
201impl OptionsGetOutputFilesItemsRepositoriesItemsOptionsItems {
202    pub fn new(key: String, values: Vec<String>) -> Self {
203        Self {
204            key,
205            values,
206            additional_properties: ::std::default::Default::default(),
207        }
208    }
209}
210#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
211pub struct OptionsGetOutputFilesItemsRepositoriesItemsOptionsItems {
212    #[serde(rename = "Key")]
213    pub key: String,
214    #[serde(rename = "Values")]
215    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
216    pub values: Vec<String>,
217    #[serde(
218        flatten,
219        default,
220        skip_serializing_if = "::std::collections::HashMap::is_empty"
221    )]
222    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
223}
224impl PostParams {
225    pub fn new(index: i64, path: String) -> Self {
226        Self {
227            index,
228            path,
229            digest: ::std::default::Default::default(),
230            enabled: ::std::default::Default::default(),
231            additional_properties: ::std::default::Default::default(),
232        }
233    }
234}
235#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
236pub struct PostParams {
237    #[serde(skip_serializing_if = "Option::is_none", default)]
238    #[doc = "Digest to detect modifications."]
239    #[doc = ""]
240    pub digest: Option<DigestStr>,
241    #[serde(
242        serialize_with = "crate::types::serialize_bool_optional",
243        deserialize_with = "crate::types::deserialize_bool_optional"
244    )]
245    #[serde(skip_serializing_if = "Option::is_none", default)]
246    #[doc = "Whether the repository should be enabled or not."]
247    #[doc = ""]
248    pub enabled: Option<bool>,
249    #[serde(
250        serialize_with = "crate::types::serialize_int",
251        deserialize_with = "crate::types::deserialize_int"
252    )]
253    #[doc = "Index within the file (starting from 0)."]
254    #[doc = ""]
255    pub index: i64,
256    #[doc = "Path to the containing file."]
257    #[doc = ""]
258    pub path: String,
259    #[serde(
260        flatten,
261        default,
262        skip_serializing_if = "::std::collections::HashMap::is_empty"
263    )]
264    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
265}
266impl PutParams {
267    pub fn new(handle: String) -> Self {
268        Self {
269            handle,
270            digest: ::std::default::Default::default(),
271            additional_properties: ::std::default::Default::default(),
272        }
273    }
274}
275#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
276pub struct PutParams {
277    #[serde(skip_serializing_if = "Option::is_none", default)]
278    #[doc = "Digest to detect modifications."]
279    #[doc = ""]
280    pub digest: Option<DigestStr>,
281    #[doc = "Handle that identifies a repository."]
282    #[doc = ""]
283    pub handle: String,
284    #[serde(
285        flatten,
286        default,
287        skip_serializing_if = "::std::collections::HashMap::is_empty"
288    )]
289    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
290}
291impl RepositoriesGetOutputFilesItemsRepositoriesItems {
292    pub fn new(
293        enabled: bool,
294        filetype: FileType,
295        suites: Vec<String>,
296        types: Vec<Types>,
297        uris: Vec<String>,
298    ) -> Self {
299        Self {
300            enabled,
301            filetype,
302            suites,
303            types,
304            uris,
305            comment: ::std::default::Default::default(),
306            components: ::std::default::Default::default(),
307            options: ::std::default::Default::default(),
308            additional_properties: ::std::default::Default::default(),
309        }
310    }
311}
312#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
313pub struct RepositoriesGetOutputFilesItemsRepositoriesItems {
314    #[serde(rename = "Comment")]
315    #[serde(skip_serializing_if = "Option::is_none", default)]
316    #[doc = "Associated comment"]
317    #[doc = ""]
318    pub comment: Option<String>,
319    #[serde(rename = "Components")]
320    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
321    #[doc = "List of repository components"]
322    #[doc = ""]
323    pub components: Vec<String>,
324    #[serde(rename = "Enabled")]
325    #[serde(
326        serialize_with = "crate::types::serialize_bool",
327        deserialize_with = "crate::types::deserialize_bool"
328    )]
329    #[doc = "Whether the repository is enabled or not"]
330    #[doc = ""]
331    pub enabled: bool,
332    #[serde(rename = "FileType")]
333    #[doc = "Format of the defining file."]
334    #[doc = ""]
335    pub filetype: FileType,
336    #[serde(rename = "Options")]
337    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
338    #[doc = "Additional options"]
339    #[doc = ""]
340    pub options: Vec<OptionsGetOutputFilesItemsRepositoriesItemsOptionsItems>,
341    #[serde(rename = "Suites")]
342    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
343    #[doc = "List of package distribuitions"]
344    #[doc = ""]
345    pub suites: Vec<String>,
346    #[serde(rename = "Types")]
347    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
348    #[doc = "List of package types."]
349    #[doc = ""]
350    pub types: Vec<Types>,
351    #[serde(rename = "URIs")]
352    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
353    #[doc = "List of repository URIs."]
354    #[doc = ""]
355    pub uris: Vec<String>,
356    #[serde(
357        flatten,
358        default,
359        skip_serializing_if = "::std::collections::HashMap::is_empty"
360    )]
361    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
362}
363impl StandardReposGetOutputStandardReposItems {
364    pub fn new(handle: String, name: String) -> Self {
365        Self {
366            handle,
367            name,
368            status: ::std::default::Default::default(),
369            additional_properties: ::std::default::Default::default(),
370        }
371    }
372}
373#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
374pub struct StandardReposGetOutputStandardReposItems {
375    #[doc = "Handle to identify the repository."]
376    #[doc = ""]
377    pub handle: String,
378    #[doc = "Full name of the repository."]
379    #[doc = ""]
380    pub name: String,
381    #[serde(
382        serialize_with = "crate::types::serialize_bool_optional",
383        deserialize_with = "crate::types::deserialize_bool_optional"
384    )]
385    #[serde(skip_serializing_if = "Option::is_none", default)]
386    #[doc = "Indicating enabled/disabled status, if the repository is configured."]
387    #[doc = ""]
388    pub status: Option<bool>,
389    #[serde(
390        flatten,
391        default,
392        skip_serializing_if = "::std::collections::HashMap::is_empty"
393    )]
394    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
395}
396#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
397#[doc = "Format of the file."]
398#[doc = ""]
399pub enum FileType {
400    #[serde(rename = "list")]
401    List,
402    #[serde(rename = "sources")]
403    Sources,
404}
405impl TryFrom<&str> for FileType {
406    type Error = String;
407    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
408        match value {
409            "list" => Ok(Self::List),
410            "sources" => Ok(Self::Sources),
411            v => Err(format!("Unknown variant {v}")),
412        }
413    }
414}
415#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
416pub enum Types {
417    #[serde(rename = "deb")]
418    Deb,
419    #[serde(rename = "deb-src")]
420    DebSrc,
421}
422impl TryFrom<&str> for Types {
423    type Error = String;
424    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
425        match value {
426            "deb" => Ok(Self::Deb),
427            "deb-src" => Ok(Self::DebSrc),
428            v => Err(format!("Unknown variant {v}")),
429        }
430    }
431}
432#[derive(Debug, Clone, PartialEq, PartialOrd)]
433pub struct DigestStr {
434    value: String,
435}
436impl crate::types::bounded_string::BoundedString for DigestStr {
437    const MIN_LENGTH: Option<usize> = None::<usize>;
438    const MAX_LENGTH: Option<usize> = Some(80usize);
439    const DEFAULT: Option<&'static str> = None::<&'static str>;
440    const PATTERN: Option<&'static str> = None::<&'static str>;
441    const TYPE_DESCRIPTION: &'static str = "a string with length at most 80";
442    fn get_value(&self) -> &str {
443        &self.value
444    }
445    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
446        Self::validate(&value)?;
447        Ok(Self { value })
448    }
449}
450impl std::convert::TryFrom<String> for DigestStr {
451    type Error = crate::types::bounded_string::BoundedStringError;
452    fn try_from(value: String) -> Result<Self, Self::Error> {
453        crate::types::bounded_string::BoundedString::new(value)
454    }
455}
456impl ::serde::Serialize for DigestStr {
457    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
458    where
459        S: ::serde::Serializer,
460    {
461        crate::types::bounded_string::serialize_bounded_string(self, serializer)
462    }
463}
464impl<'de> ::serde::Deserialize<'de> for DigestStr {
465    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
466    where
467        D: ::serde::Deserializer<'de>,
468    {
469        crate::types::bounded_string::deserialize_bounded_string(deserializer)
470    }
471}