Skip to main content

proxmox_api/generated/cluster/mapping/
dir.rs

1pub mod id;
2#[derive(Debug, Clone)]
3pub struct DirClient<T> {
4    client: T,
5    path: String,
6}
7impl<T> DirClient<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, "/dir"),
15        }
16    }
17}
18impl<T> DirClient<T>
19where
20    T: crate::client::Client,
21{
22    #[doc = "List directory mapping"]
23    #[doc = ""]
24    #[doc = "Only lists entries where you have 'Mapping.Modify', 'Mapping.Use' or 'Mapping.Audit' permissions on '/mapping/dir/\\<id\\>'."]
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<T> DirClient<T>
32where
33    T: crate::client::Client,
34{
35    #[doc = "Create a new directory mapping."]
36    #[doc = ""]
37    #[doc = "Permission check: perm(\"/mapping/dir\", [\"Mapping.Modify\"])"]
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 ChecksGetOutputItemsChecksItems {
44    pub fn new(message: String, severity: Severity) -> Self {
45        Self {
46            message,
47            severity,
48            additional_properties: ::std::default::Default::default(),
49        }
50    }
51}
52#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
53pub struct ChecksGetOutputItemsChecksItems {
54    #[doc = "The message of the error"]
55    #[doc = ""]
56    pub message: String,
57    #[doc = "The severity of the error"]
58    #[doc = ""]
59    pub severity: Severity,
60    #[serde(
61        flatten,
62        default,
63        skip_serializing_if = "::std::collections::HashMap::is_empty"
64    )]
65    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
66}
67impl GetOutputItems {
68    pub fn new(description: String, id: String, map: Vec<String>) -> Self {
69        Self {
70            description,
71            id,
72            map,
73            checks: ::std::default::Default::default(),
74            additional_properties: ::std::default::Default::default(),
75        }
76    }
77}
78#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
79pub struct GetOutputItems {
80    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
81    #[doc = "A list of checks, only present if 'check-node' is set."]
82    #[doc = ""]
83    pub checks: Vec<ChecksGetOutputItemsChecksItems>,
84    #[doc = "A description of the logical mapping."]
85    #[doc = ""]
86    pub description: String,
87    #[doc = "The logical ID of the mapping."]
88    #[doc = ""]
89    pub id: String,
90    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
91    #[doc = "The entries of the mapping."]
92    #[doc = ""]
93    pub map: Vec<String>,
94    #[serde(
95        flatten,
96        default,
97        skip_serializing_if = "::std::collections::HashMap::is_empty"
98    )]
99    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
100}
101#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
102pub struct GetParams {
103    #[serde(rename = "check-node")]
104    #[serde(skip_serializing_if = "Option::is_none", default)]
105    #[doc = "If given, checks the configurations on the given node for correctness, and adds relevant diagnostics for the directory to the response."]
106    #[doc = ""]
107    pub check_node: Option<String>,
108    #[serde(
109        flatten,
110        default,
111        skip_serializing_if = "::std::collections::HashMap::is_empty"
112    )]
113    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
114}
115impl PostParams {
116    pub fn new(id: String, map: Vec<String>) -> Self {
117        Self {
118            id,
119            map,
120            description: ::std::default::Default::default(),
121            additional_properties: ::std::default::Default::default(),
122        }
123    }
124}
125#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
126pub struct PostParams {
127    #[serde(skip_serializing_if = "Option::is_none", default)]
128    #[doc = "Description of the directory mapping"]
129    #[doc = ""]
130    pub description: Option<DescriptionStr>,
131    #[doc = "The ID of the directory mapping"]
132    #[doc = ""]
133    pub id: String,
134    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
135    #[doc = "A list of maps for the cluster nodes."]
136    #[doc = ""]
137    pub map: Vec<String>,
138    #[serde(
139        flatten,
140        default,
141        skip_serializing_if = "::std::collections::HashMap::is_empty"
142    )]
143    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
144}
145#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
146#[doc = "The severity of the error"]
147#[doc = ""]
148pub enum Severity {
149    #[serde(rename = "error")]
150    Error,
151    #[serde(rename = "warning")]
152    Warning,
153}
154impl TryFrom<&str> for Severity {
155    type Error = String;
156    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
157        match value {
158            "error" => Ok(Self::Error),
159            "warning" => Ok(Self::Warning),
160            v => Err(format!("Unknown variant {v}")),
161        }
162    }
163}
164#[derive(Debug, Clone, PartialEq, PartialOrd)]
165pub struct DescriptionStr {
166    value: String,
167}
168impl crate::types::bounded_string::BoundedString for DescriptionStr {
169    const MIN_LENGTH: Option<usize> = None::<usize>;
170    const MAX_LENGTH: Option<usize> = Some(4096usize);
171    const DEFAULT: Option<&'static str> = None::<&'static str>;
172    const PATTERN: Option<&'static str> = None::<&'static str>;
173    const TYPE_DESCRIPTION: &'static str = "a string with length at most 4096";
174    fn get_value(&self) -> &str {
175        &self.value
176    }
177    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
178        Self::validate(&value)?;
179        Ok(Self { value })
180    }
181}
182impl std::convert::TryFrom<String> for DescriptionStr {
183    type Error = crate::types::bounded_string::BoundedStringError;
184    fn try_from(value: String) -> Result<Self, Self::Error> {
185        crate::types::bounded_string::BoundedString::new(value)
186    }
187}
188impl ::serde::Serialize for DescriptionStr {
189    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
190    where
191        S: ::serde::Serializer,
192    {
193        crate::types::bounded_string::serialize_bounded_string(self, serializer)
194    }
195}
196impl<'de> ::serde::Deserialize<'de> for DescriptionStr {
197    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
198    where
199        D: ::serde::Deserializer<'de>,
200    {
201        crate::types::bounded_string::deserialize_bounded_string(deserializer)
202    }
203}
204impl<T> DirClient<T>
205where
206    T: crate::client::Client,
207{
208    pub fn id(&self, id: &str) -> id::IdClient<T> {
209        id::IdClient::<T>::new(self.client.clone(), &self.path, id)
210    }
211}