1pub mod status;
2#[derive(Debug, Clone)]
3pub struct NameClient<T> {
4 client: T,
5 path: String,
6}
7impl<T> NameClient<T>
8where
9 T: crate::client::Client,
10{
11 pub fn new(client: T, parent_path: &str, name: &str) -> Self {
12 Self {
13 client,
14 path: format!("{}/{}", parent_path, name),
15 }
16 }
17}
18impl<T> NameClient<T>
19where
20 T: crate::client::Client,
21{
22 #[doc = "Destroy pool"]
23 #[doc = ""]
24 #[doc = "Permission check: perm(\"/\", [\"Sys.Modify\"])"]
25 pub async fn delete(&self, params: DeleteParams) -> Result<String, T::Error> {
26 let path = self.path.to_string();
27 self.client.delete(&path, ¶ms).await
28 }
29}
30impl<T> NameClient<T>
31where
32 T: crate::client::Client,
33{
34 #[doc = "Pool index."]
35 #[doc = ""]
36 #[doc = "Permission check: perm(\"/\", [\"Sys.Audit\", \"Datastore.Audit\"], any)"]
37 pub async fn get(&self) -> Result<Vec<GetOutputItems>, T::Error> {
38 let path = self.path.to_string();
39 let optional_vec: Option<Vec<GetOutputItems>> = self.client.get(&path, &()).await?;
40 Ok(optional_vec.unwrap_or_default())
41 }
42}
43impl<T> NameClient<T>
44where
45 T: crate::client::Client,
46{
47 #[doc = "Change POOL settings"]
48 #[doc = ""]
49 #[doc = "Permission check: perm(\"/\", [\"Sys.Modify\"])"]
50 pub async fn put(&self, params: PutParams) -> Result<String, T::Error> {
51 let path = self.path.to_string();
52 self.client.put(&path, ¶ms).await
53 }
54}
55#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
56pub struct DeleteParams {
57 #[serde(
58 serialize_with = "crate::types::serialize_bool_optional",
59 deserialize_with = "crate::types::deserialize_bool_optional"
60 )]
61 #[serde(skip_serializing_if = "Option::is_none", default)]
62 #[doc = "If true, destroys pool even if in use"]
63 #[doc = ""]
64 pub force: Option<bool>,
65 #[serde(
66 serialize_with = "crate::types::serialize_bool_optional",
67 deserialize_with = "crate::types::deserialize_bool_optional"
68 )]
69 #[serde(skip_serializing_if = "Option::is_none", default)]
70 #[doc = "Remove the erasure code profile. Defaults to true, if applicable."]
71 #[doc = ""]
72 pub remove_ecprofile: Option<bool>,
73 #[serde(
74 serialize_with = "crate::types::serialize_bool_optional",
75 deserialize_with = "crate::types::deserialize_bool_optional"
76 )]
77 #[serde(skip_serializing_if = "Option::is_none", default)]
78 #[doc = "Remove all pveceph-managed storages configured for this pool"]
79 #[doc = ""]
80 pub remove_storages: Option<bool>,
81 #[serde(
82 flatten,
83 default,
84 skip_serializing_if = "::std::collections::HashMap::is_empty"
85 )]
86 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
87}
88#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
89pub struct GetOutputItems {
90 #[serde(
91 flatten,
92 default,
93 skip_serializing_if = "::std::collections::HashMap::is_empty"
94 )]
95 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
96}
97#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
98pub struct PutParams {
99 #[serde(skip_serializing_if = "Option::is_none", default)]
100 #[doc = "The application of the pool."]
101 #[doc = ""]
102 pub application: Option<Application>,
103 #[serde(skip_serializing_if = "Option::is_none", default)]
104 #[doc = "The rule to use for mapping object placement in the cluster."]
105 #[doc = ""]
106 pub crush_rule: Option<String>,
107 #[serde(skip_serializing_if = "Option::is_none", default)]
108 #[doc = "Minimum number of replicas per object"]
109 #[doc = ""]
110 pub min_size: Option<MinSizeInt>,
111 #[serde(skip_serializing_if = "Option::is_none", default)]
112 #[doc = "The automatic PG scaling mode of the pool."]
113 #[doc = ""]
114 pub pg_autoscale_mode: Option<PgAutoscaleMode>,
115 #[serde(skip_serializing_if = "Option::is_none", default)]
116 #[doc = "Number of placement groups."]
117 #[doc = ""]
118 pub pg_num: Option<PgNumInt>,
119 #[serde(skip_serializing_if = "Option::is_none", default)]
120 #[doc = "Minimal number of placement groups."]
121 #[doc = ""]
122 pub pg_num_min: Option<PgNumMinInt>,
123 #[serde(skip_serializing_if = "Option::is_none", default)]
124 #[doc = "Number of replicas per object"]
125 #[doc = ""]
126 pub size: Option<SizeInt>,
127 #[serde(skip_serializing_if = "Option::is_none", default)]
128 #[doc = "The estimated target size of the pool for the PG autoscaler."]
129 #[doc = ""]
130 pub target_size: Option<TargetSizeStr>,
131 #[serde(
132 serialize_with = "crate::types::serialize_number_optional",
133 deserialize_with = "crate::types::deserialize_number_optional"
134 )]
135 #[serde(skip_serializing_if = "Option::is_none", default)]
136 #[doc = "The estimated target ratio of the pool for the PG autoscaler."]
137 #[doc = ""]
138 pub target_size_ratio: Option<f64>,
139 #[serde(
140 flatten,
141 default,
142 skip_serializing_if = "::std::collections::HashMap::is_empty"
143 )]
144 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
145}
146#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
147#[doc = "The application of the pool."]
148#[doc = ""]
149pub enum Application {
150 #[serde(rename = "cephfs")]
151 Cephfs,
152 #[serde(rename = "rbd")]
153 Rbd,
154 #[serde(rename = "rgw")]
155 Rgw,
156}
157impl TryFrom<&str> for Application {
158 type Error = String;
159 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
160 match value {
161 "cephfs" => Ok(Self::Cephfs),
162 "rbd" => Ok(Self::Rbd),
163 "rgw" => Ok(Self::Rgw),
164 v => Err(format!("Unknown variant {v}")),
165 }
166 }
167}
168#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
169#[doc = "The automatic PG scaling mode of the pool."]
170#[doc = ""]
171pub enum PgAutoscaleMode {
172 #[serde(rename = "off")]
173 Off,
174 #[serde(rename = "on")]
175 On,
176 #[serde(rename = "warn")]
177 Warn,
178}
179impl TryFrom<&str> for PgAutoscaleMode {
180 type Error = String;
181 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
182 match value {
183 "off" => Ok(Self::Off),
184 "on" => Ok(Self::On),
185 "warn" => Ok(Self::Warn),
186 v => Err(format!("Unknown variant {v}")),
187 }
188 }
189}
190#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
191pub struct MinSizeInt(i128);
192impl crate::types::bounded_integer::BoundedInteger for MinSizeInt {
193 const MIN: Option<i128> = Some(1i128);
194 const MAX: Option<i128> = Some(7i128);
195 const DEFAULT: Option<i128> = None::<i128>;
196 const TYPE_DESCRIPTION: &'static str = "an integer between 1 and 7";
197 fn get(&self) -> i128 {
198 self.0
199 }
200 fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
201 Self::validate(value)?;
202 Ok(Self(value))
203 }
204}
205impl std::convert::TryFrom<i128> for MinSizeInt {
206 type Error = crate::types::bounded_integer::BoundedIntegerError;
207 fn try_from(value: i128) -> Result<Self, Self::Error> {
208 crate::types::bounded_integer::BoundedInteger::new(value)
209 }
210}
211impl ::serde::Serialize for MinSizeInt {
212 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
213 where
214 S: ::serde::Serializer,
215 {
216 crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
217 }
218}
219impl<'de> ::serde::Deserialize<'de> for MinSizeInt {
220 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
221 where
222 D: ::serde::Deserializer<'de>,
223 {
224 crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
225 }
226}
227#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
228pub struct PgNumInt(i128);
229impl crate::types::bounded_integer::BoundedInteger for PgNumInt {
230 const MIN: Option<i128> = Some(1i128);
231 const MAX: Option<i128> = Some(32768i128);
232 const DEFAULT: Option<i128> = None::<i128>;
233 const TYPE_DESCRIPTION: &'static str = "an integer between 1 and 32768";
234 fn get(&self) -> i128 {
235 self.0
236 }
237 fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
238 Self::validate(value)?;
239 Ok(Self(value))
240 }
241}
242impl std::convert::TryFrom<i128> for PgNumInt {
243 type Error = crate::types::bounded_integer::BoundedIntegerError;
244 fn try_from(value: i128) -> Result<Self, Self::Error> {
245 crate::types::bounded_integer::BoundedInteger::new(value)
246 }
247}
248impl ::serde::Serialize for PgNumInt {
249 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
250 where
251 S: ::serde::Serializer,
252 {
253 crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
254 }
255}
256impl<'de> ::serde::Deserialize<'de> for PgNumInt {
257 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
258 where
259 D: ::serde::Deserializer<'de>,
260 {
261 crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
262 }
263}
264#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
265pub struct PgNumMinInt(i128);
266impl crate::types::bounded_integer::BoundedInteger for PgNumMinInt {
267 const MIN: Option<i128> = None::<i128>;
268 const MAX: Option<i128> = Some(32768i128);
269 const DEFAULT: Option<i128> = None::<i128>;
270 const TYPE_DESCRIPTION: &'static str = "an integer less than or equal to 32768";
271 fn get(&self) -> i128 {
272 self.0
273 }
274 fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
275 Self::validate(value)?;
276 Ok(Self(value))
277 }
278}
279impl std::convert::TryFrom<i128> for PgNumMinInt {
280 type Error = crate::types::bounded_integer::BoundedIntegerError;
281 fn try_from(value: i128) -> Result<Self, Self::Error> {
282 crate::types::bounded_integer::BoundedInteger::new(value)
283 }
284}
285impl ::serde::Serialize for PgNumMinInt {
286 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
287 where
288 S: ::serde::Serializer,
289 {
290 crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
291 }
292}
293impl<'de> ::serde::Deserialize<'de> for PgNumMinInt {
294 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
295 where
296 D: ::serde::Deserializer<'de>,
297 {
298 crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
299 }
300}
301#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
302pub struct SizeInt(i128);
303impl crate::types::bounded_integer::BoundedInteger for SizeInt {
304 const MIN: Option<i128> = Some(1i128);
305 const MAX: Option<i128> = Some(7i128);
306 const DEFAULT: Option<i128> = None::<i128>;
307 const TYPE_DESCRIPTION: &'static str = "an integer between 1 and 7";
308 fn get(&self) -> i128 {
309 self.0
310 }
311 fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
312 Self::validate(value)?;
313 Ok(Self(value))
314 }
315}
316impl std::convert::TryFrom<i128> for SizeInt {
317 type Error = crate::types::bounded_integer::BoundedIntegerError;
318 fn try_from(value: i128) -> Result<Self, Self::Error> {
319 crate::types::bounded_integer::BoundedInteger::new(value)
320 }
321}
322impl ::serde::Serialize for SizeInt {
323 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
324 where
325 S: ::serde::Serializer,
326 {
327 crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
328 }
329}
330impl<'de> ::serde::Deserialize<'de> for SizeInt {
331 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
332 where
333 D: ::serde::Deserializer<'de>,
334 {
335 crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
336 }
337}
338#[derive(Debug, Clone, PartialEq, PartialOrd)]
339pub struct TargetSizeStr {
340 value: String,
341}
342impl crate::types::bounded_string::BoundedString for TargetSizeStr {
343 const MIN_LENGTH: Option<usize> = None::<usize>;
344 const MAX_LENGTH: Option<usize> = None::<usize>;
345 const DEFAULT: Option<&'static str> = None::<&'static str>;
346 const PATTERN: Option<&'static str> = Some("^(\\d+(\\.\\d+)?)([KMGT])?$");
347 const TYPE_DESCRIPTION: &'static str =
348 "a string with pattern r\"^(\\d+(\\.\\d+)?)([KMGT])?$\" and no length constraints";
349 fn get_value(&self) -> &str {
350 &self.value
351 }
352 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
353 Self::validate(&value)?;
354 Ok(Self { value })
355 }
356}
357impl std::convert::TryFrom<String> for TargetSizeStr {
358 type Error = crate::types::bounded_string::BoundedStringError;
359 fn try_from(value: String) -> Result<Self, Self::Error> {
360 crate::types::bounded_string::BoundedString::new(value)
361 }
362}
363impl ::serde::Serialize for TargetSizeStr {
364 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
365 where
366 S: ::serde::Serializer,
367 {
368 crate::types::bounded_string::serialize_bounded_string(self, serializer)
369 }
370}
371impl<'de> ::serde::Deserialize<'de> for TargetSizeStr {
372 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
373 where
374 D: ::serde::Deserializer<'de>,
375 {
376 crate::types::bounded_string::deserialize_bounded_string(deserializer)
377 }
378}
379impl<T> NameClient<T>
380where
381 T: crate::client::Client,
382{
383 pub fn status(&self) -> status::StatusClient<T> {
384 status::StatusClient::<T>::new(self.client.clone(), &self.path)
385 }
386}