clientapi_pve/models/pve_erasure_coding_config.rs
1/*
2 * Proxmox Virtual Environment API
3 *
4 * Generated from apidoc.js. NOT an official Proxmox specification. See https://pve.proxmox.com/pve-docs/api-viewer/ for the upstream documentation.
5 *
6 * The version of the OpenAPI document: 9.x
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct PveErasureCodingConfig {
16
17 /// CRUSH device class. Will create an erasure coded pool plus a replicated pool for metadata.
18 #[serde(rename = "device-class", skip_serializing_if = "Option::is_none")]
19 pub device_class: Option<String>,
20
21 /// CRUSH failure domain. Default is 'host'. Will create an erasure coded pool plus a replicated pool for metadata.
22 #[serde(rename = "failure-domain", skip_serializing_if = "Option::is_none")]
23 pub failure_domain: Option<String>,
24
25 /// Number of data chunks. Will create an erasure coded pool plus a replicated pool for metadata.
26 #[serde(rename = "k")]
27 pub k: i64,
28
29 /// Number of coding chunks. Will create an erasure coded pool plus a replicated pool for metadata.
30 #[serde(rename = "m")]
31 pub m: i64,
32
33 /// Override the erasure code (EC) profile to use. Will create an erasure coded pool plus a replicated pool for metadata.
34 #[serde(rename = "profile", skip_serializing_if = "Option::is_none")]
35 pub profile: Option<String>,
36
37
38}
39
40impl PveErasureCodingConfig {
41 pub fn new(k: i64, m: i64) -> PveErasureCodingConfig {
42 PveErasureCodingConfig {
43
44 device_class: None,
45
46 failure_domain: None,
47
48 k,
49
50 m,
51
52 profile: None,
53
54 }
55 }
56}
57
58
59impl PveErasureCodingConfig {
60 /// Serialise this PveErasureCodingConfig into Proxmox's CLI-style shorthand
61 /// string (`key=value,…`). The property marked `x-pve-default-key`
62 /// is emitted positionally without a `key=` prefix; aliases collapse
63 /// multiple property names to the same wire key.
64 ///
65 /// Example: `PveErasureCodingConfig `
66 /// → `"virtio,bridge=vmbr0"`
67 pub fn to_shorthand(&self) -> String {
68 let mut parts: Vec<String> = Vec::new();
69
70
71
72 if let Some(ref v) = self.device_class {
73 parts.push(format!("device-class={}", v));
74 }
75
76
77 if let Some(ref v) = self.failure_domain {
78 parts.push(format!("failure-domain={}", v));
79 }
80
81
82 parts.push(format!("k={}", self.k));
83
84
85
86 parts.push(format!("m={}", self.m));
87
88
89
90 if let Some(ref v) = self.profile {
91 parts.push(format!("profile={}", v));
92 }
93
94 parts.join(",")
95 }
96}
97