Skip to main content

clientapi_pve/models/
pve_ide_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 PveIdeConfig {
16
17    /// AIO type to use.
18    #[serde(rename = "aio", skip_serializing_if = "Option::is_none")]
19    pub aio: Option<models::PveAioEnum>,
20
21    /// Whether the drive should be included when making backups.
22    #[serde(rename = "backup", skip_serializing_if = "Option::is_none")]
23    pub backup: Option<models::PveBoolean>,
24
25    /// Maximum r/w speed in bytes per second.
26    #[serde(rename = "bps", skip_serializing_if = "Option::is_none")]
27    pub bps: Option<i64>,
28
29    /// Maximum length of I/O bursts in seconds.
30    #[serde(rename = "bps_max_length", skip_serializing_if = "Option::is_none")]
31    pub bps_max_length: Option<i64>,
32
33    /// Maximum read speed in bytes per second.
34    #[serde(rename = "bps_rd", skip_serializing_if = "Option::is_none")]
35    pub bps_rd: Option<i64>,
36
37    #[serde(rename = "bps_rd_length", skip_serializing_if = "Option::is_none")]
38    pub bps_rd_length: Option<String>,
39
40    /// Maximum length of read I/O bursts in seconds.
41    #[serde(rename = "bps_rd_max_length", skip_serializing_if = "Option::is_none")]
42    pub bps_rd_max_length: Option<i64>,
43
44    /// Maximum write speed in bytes per second.
45    #[serde(rename = "bps_wr", skip_serializing_if = "Option::is_none")]
46    pub bps_wr: Option<i64>,
47
48    #[serde(rename = "bps_wr_length", skip_serializing_if = "Option::is_none")]
49    pub bps_wr_length: Option<String>,
50
51    /// Maximum length of write I/O bursts in seconds.
52    #[serde(rename = "bps_wr_max_length", skip_serializing_if = "Option::is_none")]
53    pub bps_wr_max_length: Option<i64>,
54
55    /// The drive's cache mode
56    #[serde(rename = "cache", skip_serializing_if = "Option::is_none")]
57    pub cache: Option<models::PveCacheEnum>,
58
59    /// Controls whether to detect and try to optimize writes of zeroes.
60    #[serde(rename = "detect_zeroes", skip_serializing_if = "Option::is_none")]
61    pub detect_zeroes: Option<models::PveBoolean>,
62
63    /// Controls whether to pass discard/trim requests to the underlying storage.
64    #[serde(rename = "discard", skip_serializing_if = "Option::is_none")]
65    pub discard: Option<models::PveDiscardEnum>,
66
67    /// The drive's backing volume.
68    #[serde(rename = "file")]
69    pub file: String,
70
71    /// The drive's backing file's data format.
72    #[serde(rename = "format", skip_serializing_if = "Option::is_none")]
73    pub format: Option<models::PveFormatEnum>,
74
75    /// Create a new disk, importing from this source (volume ID or absolute path). When an absolute path is specified, it's up to you to ensure that the source is not actively used by another process during the import!
76    #[serde(rename = "import-from", skip_serializing_if = "Option::is_none")]
77    pub import_from: Option<String>,
78
79    /// Maximum r/w I/O in operations per second.
80    #[serde(rename = "iops", skip_serializing_if = "Option::is_none")]
81    pub iops: Option<i64>,
82
83    /// Maximum unthrottled r/w I/O pool in operations per second.
84    #[serde(rename = "iops_max", skip_serializing_if = "Option::is_none")]
85    pub iops_max: Option<i64>,
86
87    /// Maximum length of I/O bursts in seconds.
88    #[serde(rename = "iops_max_length", skip_serializing_if = "Option::is_none")]
89    pub iops_max_length: Option<i64>,
90
91    /// Maximum read I/O in operations per second.
92    #[serde(rename = "iops_rd", skip_serializing_if = "Option::is_none")]
93    pub iops_rd: Option<i64>,
94
95    #[serde(rename = "iops_rd_length", skip_serializing_if = "Option::is_none")]
96    pub iops_rd_length: Option<String>,
97
98    /// Maximum unthrottled read I/O pool in operations per second.
99    #[serde(rename = "iops_rd_max", skip_serializing_if = "Option::is_none")]
100    pub iops_rd_max: Option<i64>,
101
102    /// Maximum length of read I/O bursts in seconds.
103    #[serde(rename = "iops_rd_max_length", skip_serializing_if = "Option::is_none")]
104    pub iops_rd_max_length: Option<i64>,
105
106    /// Maximum write I/O in operations per second.
107    #[serde(rename = "iops_wr", skip_serializing_if = "Option::is_none")]
108    pub iops_wr: Option<i64>,
109
110    #[serde(rename = "iops_wr_length", skip_serializing_if = "Option::is_none")]
111    pub iops_wr_length: Option<String>,
112
113    /// Maximum unthrottled write I/O pool in operations per second.
114    #[serde(rename = "iops_wr_max", skip_serializing_if = "Option::is_none")]
115    pub iops_wr_max: Option<i64>,
116
117    /// Maximum length of write I/O bursts in seconds.
118    #[serde(rename = "iops_wr_max_length", skip_serializing_if = "Option::is_none")]
119    pub iops_wr_max_length: Option<i64>,
120
121    /// Maximum r/w speed in megabytes per second.
122    #[serde(rename = "mbps", skip_serializing_if = "Option::is_none")]
123    pub mbps: Option<f64>,
124
125    /// Maximum unthrottled r/w pool in megabytes per second.
126    #[serde(rename = "mbps_max", skip_serializing_if = "Option::is_none")]
127    pub mbps_max: Option<f64>,
128
129    /// Maximum read speed in megabytes per second.
130    #[serde(rename = "mbps_rd", skip_serializing_if = "Option::is_none")]
131    pub mbps_rd: Option<f64>,
132
133    /// Maximum unthrottled read pool in megabytes per second.
134    #[serde(rename = "mbps_rd_max", skip_serializing_if = "Option::is_none")]
135    pub mbps_rd_max: Option<f64>,
136
137    /// Maximum write speed in megabytes per second.
138    #[serde(rename = "mbps_wr", skip_serializing_if = "Option::is_none")]
139    pub mbps_wr: Option<f64>,
140
141    /// Maximum unthrottled write pool in megabytes per second.
142    #[serde(rename = "mbps_wr_max", skip_serializing_if = "Option::is_none")]
143    pub mbps_wr_max: Option<f64>,
144
145    /// The drive's media type.
146    #[serde(rename = "media", skip_serializing_if = "Option::is_none")]
147    pub media: Option<models::PveMediaEnum>,
148
149    /// The drive's reported model name, url-encoded, up to 40 bytes long.
150    #[serde(rename = "model", skip_serializing_if = "Option::is_none")]
151    pub model: Option<String>,
152
153    /// Whether the drive should considered for replication jobs.
154    #[serde(rename = "replicate", skip_serializing_if = "Option::is_none")]
155    pub replicate: Option<models::PveBoolean>,
156
157    /// Read error action.
158    #[serde(rename = "rerror", skip_serializing_if = "Option::is_none")]
159    pub rerror: Option<models::PveRerrorEnum>,
160
161    /// The drive's reported serial number, url-encoded, up to 20 bytes long.
162    #[serde(rename = "serial", skip_serializing_if = "Option::is_none")]
163    pub serial: Option<String>,
164
165    /// Mark this locally-managed volume as available on all nodes.  WARNING: This option does not share the volume automatically, it assumes it is shared already!
166    #[serde(rename = "shared", skip_serializing_if = "Option::is_none")]
167    pub shared: Option<models::PveBoolean>,
168
169    /// Disk size. This is purely informational and has no effect.
170    #[serde(rename = "size", skip_serializing_if = "Option::is_none")]
171    pub size: Option<String>,
172
173    /// Controls qemu's snapshot mode feature. If activated, changes made to the disk are temporary and will be discarded when the VM is shutdown.
174    #[serde(rename = "snapshot", skip_serializing_if = "Option::is_none")]
175    pub snapshot: Option<models::PveBoolean>,
176
177    /// Whether to expose this drive as an SSD, rather than a rotational hard disk.
178    #[serde(rename = "ssd", skip_serializing_if = "Option::is_none")]
179    pub ssd: Option<models::PveBoolean>,
180
181    #[serde(rename = "volume", skip_serializing_if = "Option::is_none")]
182    pub volume: Option<String>,
183
184    /// Write error action.
185    #[serde(rename = "werror", skip_serializing_if = "Option::is_none")]
186    pub werror: Option<models::PveWerrorEnum>,
187
188    /// The drive's worldwide name, encoded as 16 bytes hex string, prefixed by '0x'.
189    #[serde(rename = "wwn", skip_serializing_if = "Option::is_none")]
190    pub wwn: Option<String>,
191
192
193}
194
195impl PveIdeConfig {
196    pub fn new(file: String) -> PveIdeConfig {
197        PveIdeConfig {
198            
199            aio: None,
200            
201            backup: None,
202            
203            bps: None,
204            
205            bps_max_length: None,
206            
207            bps_rd: None,
208            
209            bps_rd_length: None,
210            
211            bps_rd_max_length: None,
212            
213            bps_wr: None,
214            
215            bps_wr_length: None,
216            
217            bps_wr_max_length: None,
218            
219            cache: None,
220            
221            detect_zeroes: None,
222            
223            discard: None,
224            
225            file,
226            
227            format: None,
228            
229            import_from: None,
230            
231            iops: None,
232            
233            iops_max: None,
234            
235            iops_max_length: None,
236            
237            iops_rd: None,
238            
239            iops_rd_length: None,
240            
241            iops_rd_max: None,
242            
243            iops_rd_max_length: None,
244            
245            iops_wr: None,
246            
247            iops_wr_length: None,
248            
249            iops_wr_max: None,
250            
251            iops_wr_max_length: None,
252            
253            mbps: None,
254            
255            mbps_max: None,
256            
257            mbps_rd: None,
258            
259            mbps_rd_max: None,
260            
261            mbps_wr: None,
262            
263            mbps_wr_max: None,
264            
265            media: None,
266            
267            model: None,
268            
269            replicate: None,
270            
271            rerror: None,
272            
273            serial: None,
274            
275            shared: None,
276            
277            size: None,
278            
279            snapshot: None,
280            
281            ssd: None,
282            
283            volume: None,
284            
285            werror: None,
286            
287            wwn: None,
288            
289        }
290    }
291}
292
293
294impl PveIdeConfig {
295    /// Serialise this PveIdeConfig into Proxmox's CLI-style shorthand
296    /// string (`key=value,…`). The property marked `x-pve-default-key`
297    /// is emitted positionally without a `key=` prefix; aliases collapse
298    /// multiple property names to the same wire key.
299    ///
300    /// Example: `PveIdeConfig `
301    /// → `"virtio,bridge=vmbr0"`
302    pub fn to_shorthand(&self) -> String {
303        let mut parts: Vec<String> = Vec::new();
304        
305        
306        parts.push(format!("{}", self.file));
307        
308        
309        
310        
311        if let Some(ref v) = self.aio {
312            parts.push(format!("aio={}", v));
313        }
314        
315        
316        if let Some(ref v) = self.backup {
317            parts.push(format!("backup={}", v));
318        }
319        
320        
321        if let Some(ref v) = self.bps {
322            parts.push(format!("bps={}", v));
323        }
324        
325        
326        if let Some(ref v) = self.bps_max_length {
327            parts.push(format!("bps_max_length={}", v));
328        }
329        
330        
331        if let Some(ref v) = self.bps_rd {
332            parts.push(format!("bps_rd={}", v));
333        }
334        
335        
336        if let Some(ref v) = self.bps_rd_length {
337            parts.push(format!("bps_rd_max_length={}", v));
338        }
339        
340        
341        if let Some(ref v) = self.bps_rd_max_length {
342            parts.push(format!("bps_rd_max_length={}", v));
343        }
344        
345        
346        if let Some(ref v) = self.bps_wr {
347            parts.push(format!("bps_wr={}", v));
348        }
349        
350        
351        if let Some(ref v) = self.bps_wr_length {
352            parts.push(format!("bps_wr_max_length={}", v));
353        }
354        
355        
356        if let Some(ref v) = self.bps_wr_max_length {
357            parts.push(format!("bps_wr_max_length={}", v));
358        }
359        
360        
361        if let Some(ref v) = self.cache {
362            parts.push(format!("cache={}", v));
363        }
364        
365        
366        if let Some(ref v) = self.detect_zeroes {
367            parts.push(format!("detect_zeroes={}", v));
368        }
369        
370        
371        if let Some(ref v) = self.discard {
372            parts.push(format!("discard={}", v));
373        }
374        
375        
376        if let Some(ref v) = self.format {
377            parts.push(format!("format={}", v));
378        }
379        
380        
381        if let Some(ref v) = self.import_from {
382            parts.push(format!("import-from={}", v));
383        }
384        
385        
386        if let Some(ref v) = self.iops {
387            parts.push(format!("iops={}", v));
388        }
389        
390        
391        if let Some(ref v) = self.iops_max {
392            parts.push(format!("iops_max={}", v));
393        }
394        
395        
396        if let Some(ref v) = self.iops_max_length {
397            parts.push(format!("iops_max_length={}", v));
398        }
399        
400        
401        if let Some(ref v) = self.iops_rd {
402            parts.push(format!("iops_rd={}", v));
403        }
404        
405        
406        if let Some(ref v) = self.iops_rd_length {
407            parts.push(format!("iops_rd_max_length={}", v));
408        }
409        
410        
411        if let Some(ref v) = self.iops_rd_max {
412            parts.push(format!("iops_rd_max={}", v));
413        }
414        
415        
416        if let Some(ref v) = self.iops_rd_max_length {
417            parts.push(format!("iops_rd_max_length={}", v));
418        }
419        
420        
421        if let Some(ref v) = self.iops_wr {
422            parts.push(format!("iops_wr={}", v));
423        }
424        
425        
426        if let Some(ref v) = self.iops_wr_length {
427            parts.push(format!("iops_wr_max_length={}", v));
428        }
429        
430        
431        if let Some(ref v) = self.iops_wr_max {
432            parts.push(format!("iops_wr_max={}", v));
433        }
434        
435        
436        if let Some(ref v) = self.iops_wr_max_length {
437            parts.push(format!("iops_wr_max_length={}", v));
438        }
439        
440        
441        if let Some(ref v) = self.mbps {
442            parts.push(format!("mbps={}", v));
443        }
444        
445        
446        if let Some(ref v) = self.mbps_max {
447            parts.push(format!("mbps_max={}", v));
448        }
449        
450        
451        if let Some(ref v) = self.mbps_rd {
452            parts.push(format!("mbps_rd={}", v));
453        }
454        
455        
456        if let Some(ref v) = self.mbps_rd_max {
457            parts.push(format!("mbps_rd_max={}", v));
458        }
459        
460        
461        if let Some(ref v) = self.mbps_wr {
462            parts.push(format!("mbps_wr={}", v));
463        }
464        
465        
466        if let Some(ref v) = self.mbps_wr_max {
467            parts.push(format!("mbps_wr_max={}", v));
468        }
469        
470        
471        if let Some(ref v) = self.media {
472            parts.push(format!("media={}", v));
473        }
474        
475        
476        if let Some(ref v) = self.model {
477            parts.push(format!("model={}", v));
478        }
479        
480        
481        if let Some(ref v) = self.replicate {
482            parts.push(format!("replicate={}", v));
483        }
484        
485        
486        if let Some(ref v) = self.rerror {
487            parts.push(format!("rerror={}", v));
488        }
489        
490        
491        if let Some(ref v) = self.serial {
492            parts.push(format!("serial={}", v));
493        }
494        
495        
496        if let Some(ref v) = self.shared {
497            parts.push(format!("shared={}", v));
498        }
499        
500        
501        if let Some(ref v) = self.size {
502            parts.push(format!("size={}", v));
503        }
504        
505        
506        if let Some(ref v) = self.snapshot {
507            parts.push(format!("snapshot={}", v));
508        }
509        
510        
511        if let Some(ref v) = self.ssd {
512            parts.push(format!("ssd={}", v));
513        }
514        
515        
516        if let Some(ref v) = self.volume {
517            parts.push(format!("file={}", v));
518        }
519        
520        
521        if let Some(ref v) = self.werror {
522            parts.push(format!("werror={}", v));
523        }
524        
525        
526        if let Some(ref v) = self.wwn {
527            parts.push(format!("wwn={}", v));
528        }
529        
530        parts.join(",")
531    }
532}
533