1pub mod name;
2#[derive(Debug, Clone)]
3pub struct PoolClient<T> {
4 client: T,
5 path: String,
6}
7impl<T> PoolClient<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, "/pool"),
15 }
16 }
17}
18impl<T> PoolClient<T>
19where
20 T: crate::client::Client,
21{
22 #[doc = "List all pools and their settings (which are settable by the POST/PUT endpoints)."]
23 #[doc = ""]
24 #[doc = "Permission check: perm(\"/\", [\"Sys.Audit\", \"Datastore.Audit\"], any)"]
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> PoolClient<T>
32where
33 T: crate::client::Client,
34{
35 #[doc = "Create Ceph pool"]
36 #[doc = ""]
37 #[doc = "Permission check: perm(\"/\", [\"Sys.Modify\"])"]
38 pub async fn post(&self, params: PostParams) -> Result<String, T::Error> {
39 let path = self.path.to_string();
40 self.client.post(&path, ¶ms).await
41 }
42}
43#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
44pub struct ApplicationMetadataGetOutputItemsApplicationMetadata {
45 #[serde(
46 flatten,
47 default,
48 skip_serializing_if = "::std::collections::HashMap::is_empty"
49 )]
50 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
51}
52#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
53pub struct AutoscaleStatusGetOutputItemsAutoscaleStatus {
54 #[serde(
55 flatten,
56 default,
57 skip_serializing_if = "::std::collections::HashMap::is_empty"
58 )]
59 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
60}
61impl GetOutputItems {
62 pub fn new(
63 bytes_used: i64,
64 crush_rule: i64,
65 crush_rule_name: String,
66 min_size: i64,
67 percent_used: f64,
68 pg_num: i64,
69 pool: i64,
70 pool_name: String,
71 size: i64,
72 ty: Type,
73 ) -> Self {
74 Self {
75 bytes_used,
76 crush_rule,
77 crush_rule_name,
78 min_size,
79 percent_used,
80 pg_num,
81 pool,
82 pool_name,
83 size,
84 ty,
85 application_metadata: ::std::default::Default::default(),
86 autoscale_status: ::std::default::Default::default(),
87 pg_autoscale_mode: ::std::default::Default::default(),
88 pg_num_final: ::std::default::Default::default(),
89 pg_num_min: ::std::default::Default::default(),
90 target_size: ::std::default::Default::default(),
91 target_size_ratio: ::std::default::Default::default(),
92 additional_properties: ::std::default::Default::default(),
93 }
94 }
95}
96#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
97pub struct GetOutputItems {
98 #[serde(skip_serializing_if = "Option::is_none", default)]
99 pub application_metadata: Option<ApplicationMetadataGetOutputItemsApplicationMetadata>,
100 #[serde(skip_serializing_if = "Option::is_none", default)]
101 pub autoscale_status: Option<AutoscaleStatusGetOutputItemsAutoscaleStatus>,
102 #[serde(
103 serialize_with = "crate::types::serialize_int",
104 deserialize_with = "crate::types::deserialize_int"
105 )]
106 pub bytes_used: i64,
107 #[serde(
108 serialize_with = "crate::types::serialize_int",
109 deserialize_with = "crate::types::deserialize_int"
110 )]
111 pub crush_rule: i64,
112 pub crush_rule_name: String,
113 #[serde(
114 serialize_with = "crate::types::serialize_int",
115 deserialize_with = "crate::types::deserialize_int"
116 )]
117 pub min_size: i64,
118 #[serde(
119 serialize_with = "crate::types::serialize_number",
120 deserialize_with = "crate::types::deserialize_number"
121 )]
122 pub percent_used: f64,
123 #[serde(skip_serializing_if = "Option::is_none", default)]
124 pub pg_autoscale_mode: Option<String>,
125 #[serde(
126 serialize_with = "crate::types::serialize_int",
127 deserialize_with = "crate::types::deserialize_int"
128 )]
129 pub pg_num: i64,
130 #[serde(
131 serialize_with = "crate::types::serialize_int_optional",
132 deserialize_with = "crate::types::deserialize_int_optional"
133 )]
134 #[serde(skip_serializing_if = "Option::is_none", default)]
135 pub pg_num_final: Option<i64>,
136 #[serde(
137 serialize_with = "crate::types::serialize_int_optional",
138 deserialize_with = "crate::types::deserialize_int_optional"
139 )]
140 #[serde(skip_serializing_if = "Option::is_none", default)]
141 pub pg_num_min: Option<i64>,
142 #[serde(
143 serialize_with = "crate::types::serialize_int",
144 deserialize_with = "crate::types::deserialize_int"
145 )]
146 pub pool: i64,
147 pub pool_name: String,
148 #[serde(
149 serialize_with = "crate::types::serialize_int",
150 deserialize_with = "crate::types::deserialize_int"
151 )]
152 pub size: i64,
153 #[serde(
154 serialize_with = "crate::types::serialize_int_optional",
155 deserialize_with = "crate::types::deserialize_int_optional"
156 )]
157 #[serde(skip_serializing_if = "Option::is_none", default)]
158 pub target_size: Option<i64>,
159 #[serde(
160 serialize_with = "crate::types::serialize_number_optional",
161 deserialize_with = "crate::types::deserialize_number_optional"
162 )]
163 #[serde(skip_serializing_if = "Option::is_none", default)]
164 pub target_size_ratio: Option<f64>,
165 #[serde(rename = "type")]
166 pub ty: Type,
167 #[serde(
168 flatten,
169 default,
170 skip_serializing_if = "::std::collections::HashMap::is_empty"
171 )]
172 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
173}
174impl PostParams {
175 pub fn new(name: NameStr) -> Self {
176 Self {
177 name,
178 add_storages: ::std::default::Default::default(),
179 application: ::std::default::Default::default(),
180 crush_rule: ::std::default::Default::default(),
181 erasure_coding: ::std::default::Default::default(),
182 min_size: ::std::default::Default::default(),
183 pg_autoscale_mode: ::std::default::Default::default(),
184 pg_num: ::std::default::Default::default(),
185 pg_num_min: ::std::default::Default::default(),
186 size: ::std::default::Default::default(),
187 target_size: ::std::default::Default::default(),
188 target_size_ratio: ::std::default::Default::default(),
189 additional_properties: ::std::default::Default::default(),
190 }
191 }
192}
193#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
194pub struct PostParams {
195 #[serde(
196 serialize_with = "crate::types::serialize_bool_optional",
197 deserialize_with = "crate::types::deserialize_bool_optional"
198 )]
199 #[serde(skip_serializing_if = "Option::is_none", default)]
200 #[doc = "Configure VM and CT storage using the new pool."]
201 #[doc = ""]
202 pub add_storages: Option<bool>,
203 #[serde(skip_serializing_if = "Option::is_none", default)]
204 #[doc = "The application of the pool."]
205 #[doc = ""]
206 pub application: Option<Application>,
207 #[serde(skip_serializing_if = "Option::is_none", default)]
208 #[doc = "The rule to use for mapping object placement in the cluster."]
209 #[doc = ""]
210 pub crush_rule: Option<String>,
211 #[serde(rename = "erasure-coding")]
212 #[serde(skip_serializing_if = "Option::is_none", default)]
213 #[doc = "Create an erasure coded pool for RBD with an accompaning replicated pool for metadata storage. With EC, the common ceph options 'size', 'min_size' and 'crush_rule' parameters will be applied to the metadata pool."]
214 #[doc = ""]
215 pub erasure_coding: Option<String>,
216 #[serde(skip_serializing_if = "Option::is_none", default)]
217 #[doc = "Minimum number of replicas per object"]
218 #[doc = ""]
219 pub min_size: Option<MinSizeInt>,
220 #[doc = "The name of the pool. It must be unique."]
221 #[doc = ""]
222 pub name: NameStr,
223 #[serde(skip_serializing_if = "Option::is_none", default)]
224 #[doc = "The automatic PG scaling mode of the pool."]
225 #[doc = ""]
226 pub pg_autoscale_mode: Option<PgAutoscaleMode>,
227 #[serde(skip_serializing_if = "Option::is_none", default)]
228 #[doc = "Number of placement groups."]
229 #[doc = ""]
230 pub pg_num: Option<PgNumInt>,
231 #[serde(skip_serializing_if = "Option::is_none", default)]
232 #[doc = "Minimal number of placement groups."]
233 #[doc = ""]
234 pub pg_num_min: Option<PgNumMinInt>,
235 #[serde(skip_serializing_if = "Option::is_none", default)]
236 #[doc = "Number of replicas per object"]
237 #[doc = ""]
238 pub size: Option<SizeInt>,
239 #[serde(skip_serializing_if = "Option::is_none", default)]
240 #[doc = "The estimated target size of the pool for the PG autoscaler."]
241 #[doc = ""]
242 pub target_size: Option<TargetSizeStr>,
243 #[serde(
244 serialize_with = "crate::types::serialize_number_optional",
245 deserialize_with = "crate::types::deserialize_number_optional"
246 )]
247 #[serde(skip_serializing_if = "Option::is_none", default)]
248 #[doc = "The estimated target ratio of the pool for the PG autoscaler."]
249 #[doc = ""]
250 pub target_size_ratio: Option<f64>,
251 #[serde(
252 flatten,
253 default,
254 skip_serializing_if = "::std::collections::HashMap::is_empty"
255 )]
256 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
257}
258#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq, Default)]
259#[doc = "The application of the pool."]
260#[doc = ""]
261pub enum Application {
262 #[serde(rename = "cephfs")]
263 Cephfs,
264 #[serde(rename = "rbd")]
265 #[default]
266 Rbd,
267 #[serde(rename = "rgw")]
268 Rgw,
269}
270impl TryFrom<&str> for Application {
271 type Error = String;
272 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
273 match value {
274 "cephfs" => Ok(Self::Cephfs),
275 "rbd" => Ok(Self::Rbd),
276 "rgw" => Ok(Self::Rgw),
277 v => Err(format!("Unknown variant {v}")),
278 }
279 }
280}
281#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq, Default)]
282#[doc = "The automatic PG scaling mode of the pool."]
283#[doc = ""]
284pub enum PgAutoscaleMode {
285 #[serde(rename = "off")]
286 Off,
287 #[serde(rename = "on")]
288 On,
289 #[serde(rename = "warn")]
290 #[default]
291 Warn,
292}
293impl TryFrom<&str> for PgAutoscaleMode {
294 type Error = String;
295 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
296 match value {
297 "off" => Ok(Self::Off),
298 "on" => Ok(Self::On),
299 "warn" => Ok(Self::Warn),
300 v => Err(format!("Unknown variant {v}")),
301 }
302 }
303}
304#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
305pub enum Type {
306 #[serde(rename = "erasure")]
307 Erasure,
308 #[serde(rename = "replicated")]
309 Replicated,
310 #[serde(rename = "unknown")]
311 Unknown,
312}
313impl TryFrom<&str> for Type {
314 type Error = String;
315 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
316 match value {
317 "erasure" => Ok(Self::Erasure),
318 "replicated" => Ok(Self::Replicated),
319 "unknown" => Ok(Self::Unknown),
320 v => Err(format!("Unknown variant {v}")),
321 }
322 }
323}
324#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
325pub struct MinSizeInt(i128);
326impl crate::types::bounded_integer::BoundedInteger for MinSizeInt {
327 const MIN: Option<i128> = Some(1i128);
328 const MAX: Option<i128> = Some(7i128);
329 const DEFAULT: Option<i128> = Some(2i128);
330 const TYPE_DESCRIPTION: &'static str = "an integer between 1 and 7";
331 fn get(&self) -> i128 {
332 self.0
333 }
334 fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
335 Self::validate(value)?;
336 Ok(Self(value))
337 }
338}
339impl std::convert::TryFrom<i128> for MinSizeInt {
340 type Error = crate::types::bounded_integer::BoundedIntegerError;
341 fn try_from(value: i128) -> Result<Self, Self::Error> {
342 crate::types::bounded_integer::BoundedInteger::new(value)
343 }
344}
345impl ::serde::Serialize for MinSizeInt {
346 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
347 where
348 S: ::serde::Serializer,
349 {
350 crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
351 }
352}
353impl<'de> ::serde::Deserialize<'de> for MinSizeInt {
354 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
355 where
356 D: ::serde::Deserializer<'de>,
357 {
358 crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
359 }
360}
361#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
362pub struct PgNumInt(i128);
363impl crate::types::bounded_integer::BoundedInteger for PgNumInt {
364 const MIN: Option<i128> = Some(1i128);
365 const MAX: Option<i128> = Some(32768i128);
366 const DEFAULT: Option<i128> = Some(128i128);
367 const TYPE_DESCRIPTION: &'static str = "an integer between 1 and 32768";
368 fn get(&self) -> i128 {
369 self.0
370 }
371 fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
372 Self::validate(value)?;
373 Ok(Self(value))
374 }
375}
376impl std::convert::TryFrom<i128> for PgNumInt {
377 type Error = crate::types::bounded_integer::BoundedIntegerError;
378 fn try_from(value: i128) -> Result<Self, Self::Error> {
379 crate::types::bounded_integer::BoundedInteger::new(value)
380 }
381}
382impl ::serde::Serialize for PgNumInt {
383 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
384 where
385 S: ::serde::Serializer,
386 {
387 crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
388 }
389}
390impl<'de> ::serde::Deserialize<'de> for PgNumInt {
391 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
392 where
393 D: ::serde::Deserializer<'de>,
394 {
395 crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
396 }
397}
398#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
399pub struct PgNumMinInt(i128);
400impl crate::types::bounded_integer::BoundedInteger for PgNumMinInt {
401 const MIN: Option<i128> = None::<i128>;
402 const MAX: Option<i128> = Some(32768i128);
403 const DEFAULT: Option<i128> = None::<i128>;
404 const TYPE_DESCRIPTION: &'static str = "an integer less than or equal to 32768";
405 fn get(&self) -> i128 {
406 self.0
407 }
408 fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
409 Self::validate(value)?;
410 Ok(Self(value))
411 }
412}
413impl std::convert::TryFrom<i128> for PgNumMinInt {
414 type Error = crate::types::bounded_integer::BoundedIntegerError;
415 fn try_from(value: i128) -> Result<Self, Self::Error> {
416 crate::types::bounded_integer::BoundedInteger::new(value)
417 }
418}
419impl ::serde::Serialize for PgNumMinInt {
420 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
421 where
422 S: ::serde::Serializer,
423 {
424 crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
425 }
426}
427impl<'de> ::serde::Deserialize<'de> for PgNumMinInt {
428 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
429 where
430 D: ::serde::Deserializer<'de>,
431 {
432 crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
433 }
434}
435#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
436pub struct SizeInt(i128);
437impl crate::types::bounded_integer::BoundedInteger for SizeInt {
438 const MIN: Option<i128> = Some(1i128);
439 const MAX: Option<i128> = Some(7i128);
440 const DEFAULT: Option<i128> = Some(3i128);
441 const TYPE_DESCRIPTION: &'static str = "an integer between 1 and 7";
442 fn get(&self) -> i128 {
443 self.0
444 }
445 fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
446 Self::validate(value)?;
447 Ok(Self(value))
448 }
449}
450impl std::convert::TryFrom<i128> for SizeInt {
451 type Error = crate::types::bounded_integer::BoundedIntegerError;
452 fn try_from(value: i128) -> Result<Self, Self::Error> {
453 crate::types::bounded_integer::BoundedInteger::new(value)
454 }
455}
456impl ::serde::Serialize for SizeInt {
457 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
458 where
459 S: ::serde::Serializer,
460 {
461 crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
462 }
463}
464impl<'de> ::serde::Deserialize<'de> for SizeInt {
465 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
466 where
467 D: ::serde::Deserializer<'de>,
468 {
469 crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
470 }
471}
472#[derive(Debug, Clone, PartialEq, PartialOrd)]
473pub struct NameStr {
474 value: String,
475}
476impl crate::types::bounded_string::BoundedString for NameStr {
477 const MIN_LENGTH: Option<usize> = None::<usize>;
478 const MAX_LENGTH: Option<usize> = None::<usize>;
479 const DEFAULT: Option<&'static str> = None::<&'static str>;
480 const PATTERN: Option<&'static str> = Some("(?^:^[^:/\\s]+$)");
481 const TYPE_DESCRIPTION: &'static str =
482 "a string with pattern r\"(?^:^[^:/\\s]+$)\" and no length constraints";
483 fn get_value(&self) -> &str {
484 &self.value
485 }
486 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
487 Self::validate(&value)?;
488 Ok(Self { value })
489 }
490}
491impl std::convert::TryFrom<String> for NameStr {
492 type Error = crate::types::bounded_string::BoundedStringError;
493 fn try_from(value: String) -> Result<Self, Self::Error> {
494 crate::types::bounded_string::BoundedString::new(value)
495 }
496}
497impl ::serde::Serialize for NameStr {
498 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
499 where
500 S: ::serde::Serializer,
501 {
502 crate::types::bounded_string::serialize_bounded_string(self, serializer)
503 }
504}
505impl<'de> ::serde::Deserialize<'de> for NameStr {
506 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
507 where
508 D: ::serde::Deserializer<'de>,
509 {
510 crate::types::bounded_string::deserialize_bounded_string(deserializer)
511 }
512}
513#[derive(Debug, Clone, PartialEq, PartialOrd)]
514pub struct TargetSizeStr {
515 value: String,
516}
517impl crate::types::bounded_string::BoundedString for TargetSizeStr {
518 const MIN_LENGTH: Option<usize> = None::<usize>;
519 const MAX_LENGTH: Option<usize> = None::<usize>;
520 const DEFAULT: Option<&'static str> = None::<&'static str>;
521 const PATTERN: Option<&'static str> = Some("^(\\d+(\\.\\d+)?)([KMGT])?$");
522 const TYPE_DESCRIPTION: &'static str =
523 "a string with pattern r\"^(\\d+(\\.\\d+)?)([KMGT])?$\" and no length constraints";
524 fn get_value(&self) -> &str {
525 &self.value
526 }
527 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
528 Self::validate(&value)?;
529 Ok(Self { value })
530 }
531}
532impl std::convert::TryFrom<String> for TargetSizeStr {
533 type Error = crate::types::bounded_string::BoundedStringError;
534 fn try_from(value: String) -> Result<Self, Self::Error> {
535 crate::types::bounded_string::BoundedString::new(value)
536 }
537}
538impl ::serde::Serialize for TargetSizeStr {
539 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
540 where
541 S: ::serde::Serializer,
542 {
543 crate::types::bounded_string::serialize_bounded_string(self, serializer)
544 }
545}
546impl<'de> ::serde::Deserialize<'de> for TargetSizeStr {
547 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
548 where
549 D: ::serde::Deserializer<'de>,
550 {
551 crate::types::bounded_string::deserialize_bounded_string(deserializer)
552 }
553}
554impl<T> PoolClient<T>
555where
556 T: crate::client::Client,
557{
558 pub fn name(&self, name: &str) -> name::NameClient<T> {
559 name::NameClient::<T>::new(self.client.clone(), &self.path, name)
560 }
561}