Skip to main content

clientapi_pve/models/
lxc_vm_config_response_data.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)]
15pub struct LxcVmConfigResponseData {
16
17
18    /// OS architecture type.
19    pub arch: Option<models::PveLxcArchEnum>,
20
21    /// Console mode. By default, the console command tries to open a connection to one of the available tty devices. By setting cmode to 'console' it tries to attach to /dev/console instead. If you set cmode to 'shell', it simply invokes a shell inside the container (no login).
22    pub cmode: Option<models::PveCmodeEnum>,
23
24    /// Attach a console device (/dev/console) to the container.
25    pub console: Option<models::PveBoolean>,
26
27    /// The number of cores assigned to the container. A container can use all available cores by default.
28    pub cores: Option<i32>,
29
30    /// Limit of CPU usage.  NOTE: If the computer has 2 CPUs, it has a total of '2' CPU time. Value '0' indicates no CPU limit.
31    pub cpulimit: Option<f64>,
32
33    /// CPU weight for a container. Argument is used in the kernel fair scheduler. The larger the number is, the more CPU time this container gets. Number is relative to the weights of all the other running guests.
34    pub cpuunits: Option<i32>,
35
36    /// Try to be more verbose. For now this only enables debug log-level on start.
37    pub debug: Option<models::PveBoolean>,
38
39    /// Description for the Container. Shown in the web-interface CT's summary. This is saved as comment inside the configuration file.
40    pub description: Option<String>,
41
42    /// SHA1 digest of configuration file. This can be used to prevent concurrent modifications.
43    pub digest: String,
44
45    /// Command to run as init, optionally with arguments; may start with an absolute path, relative path, or a binary in $PATH.
46    pub entrypoint: Option<String>,
47
48    /// The container runtime environment as NUL-separated list. Replaces any lxc.environment.runtime entries in the config.
49    pub env: Option<String>,
50
51    /// Allow containers access to advanced features.
52    pub features: Option<Box<models::PveLxcFeaturesField>>,
53
54    /// Script that will be executed during various steps in the containers lifetime.
55    pub hookscript: Option<String>,
56
57    /// Set a host name for the container.
58    pub hostname: Option<String>,
59
60    /// Lock/unlock the container.
61    pub lock: Option<models::PveLockEnum>,
62
63    /// Array of lxc low-level configurations ([[key1, value1], [key2, value2] ...]).
64    pub lxc: Option<Vec<Vec<String>>>,
65
66    /// Amount of RAM for the container in MB.
67    pub memory: Option<i64>,
68
69    /// Sets DNS server IP address for a container. Create will automatically use the setting from the host if you neither set searchdomain nor nameserver.
70    pub nameserver: Option<String>,
71
72    /// Specifies whether a container will be started during system bootup.
73    pub onboot: Option<models::PveBoolean>,
74
75    /// OS type. This is used to setup configuration inside the container, and corresponds to lxc setup scripts in /usr/share/lxc/config/<ostype>.common.conf. Value 'unmanaged' can be used to skip and OS specific setup.
76    pub ostype: Option<models::PveOstypeEnum>,
77
78    /// Sets the protection flag of the container. This will prevent the CT or CT's disk remove/update operation.
79    pub protection: Option<models::PveBoolean>,
80
81    /// Use volume as container root.
82    pub rootfs: Option<Box<models::PveLxcRootfsField>>,
83
84    /// Sets DNS search domains for a container. Create will automatically use the setting from the host if you neither set searchdomain nor nameserver.
85    pub searchdomain: Option<String>,
86
87    /// Startup and shutdown behavior. Order is a non-negative number defining the general startup order. Shutdown in done with reverse ordering. Additionally you can set the 'up' or 'down' delay in seconds, which specifies a delay to wait before the next VM is started or stopped.
88    pub startup: Option<String>,
89
90    /// Amount of SWAP for the container in MB.
91    pub swap: Option<i64>,
92
93    /// Tags of the Container. This is only meta information.
94    pub tags: Option<String>,
95
96    /// Enable/disable Template.
97    pub template: Option<models::PveBoolean>,
98
99    /// Time zone to use in the container. If option isn't set, then nothing will be done. Can be set to 'host' to match the host time zone, or an arbitrary time zone option from /usr/share/zoneinfo/zone.tab
100    pub timezone: Option<String>,
101
102    /// Specify the number of tty available to the container
103    pub tty: Option<i32>,
104
105    /// Makes the container run as unprivileged user. For creation, the default is 1. For restore, the default is the value from the backup. (Should not be modified manually.)
106    pub unprivileged: Option<models::PveBoolean>,
107
108    /// Devs family. Wire form: `dev0..dev8`. Serialised by the manual impls below.
109    pub devs: Option<std::collections::HashMap<u32, models::PveLxcDevField>>,
110    /// Mps family. Wire form: `mp0..mp255`. Serialised by the manual impls below.
111    pub mps: Option<std::collections::HashMap<u32, models::PveLxcMpField>>,
112    /// Nets family. Wire form: `net0..net31`. Serialised by the manual impls below.
113    pub nets: Option<std::collections::HashMap<u32, models::PveLxcNetField>>,
114    /// Unuseds family. Wire form: `unused0..unused255`. Serialised by the manual impls below.
115    pub unuseds: Option<std::collections::HashMap<u32, models::PveLxcUnusedField>>,
116}
117
118impl LxcVmConfigResponseData {
119    pub fn new(digest: String) -> LxcVmConfigResponseData {
120        LxcVmConfigResponseData {
121            
122            arch: None,
123            
124            cmode: None,
125            
126            console: None,
127            
128            cores: None,
129            
130            cpulimit: None,
131            
132            cpuunits: None,
133            
134            debug: None,
135            
136            description: None,
137            
138            digest,
139            
140            entrypoint: None,
141            
142            env: None,
143            
144            features: None,
145            
146            hookscript: None,
147            
148            hostname: None,
149            
150            lock: None,
151            
152            lxc: None,
153            
154            memory: None,
155            
156            nameserver: None,
157            
158            onboot: None,
159            
160            ostype: None,
161            
162            protection: None,
163            
164            rootfs: None,
165            
166            searchdomain: None,
167            
168            startup: None,
169            
170            swap: None,
171            
172            tags: None,
173            
174            template: None,
175            
176            timezone: None,
177            
178            tty: None,
179            
180            unprivileged: None,
181            
182            devs: None,
183            mps: None,
184            nets: None,
185            unuseds: None,
186        }
187    }
188}
189
190
191// Flattens indexed-family maps to/from `<base><idx>` wire keys.
192impl serde::Serialize for LxcVmConfigResponseData {
193    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
194        use serde::ser::Error;
195        let mut map = serde_json::Map::new();
196        
197        {
198            let _v = serde_json::to_value(&self.arch).map_err(Error::custom)?;
199            if !_v.is_null() {
200                map.insert("arch".to_string(), _v);
201            }
202        }
203        
204        {
205            let _v = serde_json::to_value(&self.cmode).map_err(Error::custom)?;
206            if !_v.is_null() {
207                map.insert("cmode".to_string(), _v);
208            }
209        }
210        
211        {
212            let _v = serde_json::to_value(&self.console).map_err(Error::custom)?;
213            if !_v.is_null() {
214                map.insert("console".to_string(), _v);
215            }
216        }
217        
218        {
219            let _v = serde_json::to_value(&self.cores).map_err(Error::custom)?;
220            if !_v.is_null() {
221                map.insert("cores".to_string(), _v);
222            }
223        }
224        
225        {
226            let _v = serde_json::to_value(&self.cpulimit).map_err(Error::custom)?;
227            if !_v.is_null() {
228                map.insert("cpulimit".to_string(), _v);
229            }
230        }
231        
232        {
233            let _v = serde_json::to_value(&self.cpuunits).map_err(Error::custom)?;
234            if !_v.is_null() {
235                map.insert("cpuunits".to_string(), _v);
236            }
237        }
238        
239        {
240            let _v = serde_json::to_value(&self.debug).map_err(Error::custom)?;
241            if !_v.is_null() {
242                map.insert("debug".to_string(), _v);
243            }
244        }
245        
246        {
247            let _v = serde_json::to_value(&self.description).map_err(Error::custom)?;
248            if !_v.is_null() {
249                map.insert("description".to_string(), _v);
250            }
251        }
252        
253        {
254            let _v = serde_json::to_value(&self.digest).map_err(Error::custom)?;
255            if !_v.is_null() {
256                map.insert("digest".to_string(), _v);
257            }
258        }
259        
260        {
261            let _v = serde_json::to_value(&self.entrypoint).map_err(Error::custom)?;
262            if !_v.is_null() {
263                map.insert("entrypoint".to_string(), _v);
264            }
265        }
266        
267        {
268            let _v = serde_json::to_value(&self.env).map_err(Error::custom)?;
269            if !_v.is_null() {
270                map.insert("env".to_string(), _v);
271            }
272        }
273        
274        {
275            let _v = serde_json::to_value(&self.features).map_err(Error::custom)?;
276            if !_v.is_null() {
277                map.insert("features".to_string(), _v);
278            }
279        }
280        
281        {
282            let _v = serde_json::to_value(&self.hookscript).map_err(Error::custom)?;
283            if !_v.is_null() {
284                map.insert("hookscript".to_string(), _v);
285            }
286        }
287        
288        {
289            let _v = serde_json::to_value(&self.hostname).map_err(Error::custom)?;
290            if !_v.is_null() {
291                map.insert("hostname".to_string(), _v);
292            }
293        }
294        
295        {
296            let _v = serde_json::to_value(&self.lock).map_err(Error::custom)?;
297            if !_v.is_null() {
298                map.insert("lock".to_string(), _v);
299            }
300        }
301        
302        {
303            let _v = serde_json::to_value(&self.lxc).map_err(Error::custom)?;
304            if !_v.is_null() {
305                map.insert("lxc".to_string(), _v);
306            }
307        }
308        
309        {
310            let _v = serde_json::to_value(&self.memory).map_err(Error::custom)?;
311            if !_v.is_null() {
312                map.insert("memory".to_string(), _v);
313            }
314        }
315        
316        {
317            let _v = serde_json::to_value(&self.nameserver).map_err(Error::custom)?;
318            if !_v.is_null() {
319                map.insert("nameserver".to_string(), _v);
320            }
321        }
322        
323        {
324            let _v = serde_json::to_value(&self.onboot).map_err(Error::custom)?;
325            if !_v.is_null() {
326                map.insert("onboot".to_string(), _v);
327            }
328        }
329        
330        {
331            let _v = serde_json::to_value(&self.ostype).map_err(Error::custom)?;
332            if !_v.is_null() {
333                map.insert("ostype".to_string(), _v);
334            }
335        }
336        
337        {
338            let _v = serde_json::to_value(&self.protection).map_err(Error::custom)?;
339            if !_v.is_null() {
340                map.insert("protection".to_string(), _v);
341            }
342        }
343        
344        {
345            let _v = serde_json::to_value(&self.rootfs).map_err(Error::custom)?;
346            if !_v.is_null() {
347                map.insert("rootfs".to_string(), _v);
348            }
349        }
350        
351        {
352            let _v = serde_json::to_value(&self.searchdomain).map_err(Error::custom)?;
353            if !_v.is_null() {
354                map.insert("searchdomain".to_string(), _v);
355            }
356        }
357        
358        {
359            let _v = serde_json::to_value(&self.startup).map_err(Error::custom)?;
360            if !_v.is_null() {
361                map.insert("startup".to_string(), _v);
362            }
363        }
364        
365        {
366            let _v = serde_json::to_value(&self.swap).map_err(Error::custom)?;
367            if !_v.is_null() {
368                map.insert("swap".to_string(), _v);
369            }
370        }
371        
372        {
373            let _v = serde_json::to_value(&self.tags).map_err(Error::custom)?;
374            if !_v.is_null() {
375                map.insert("tags".to_string(), _v);
376            }
377        }
378        
379        {
380            let _v = serde_json::to_value(&self.template).map_err(Error::custom)?;
381            if !_v.is_null() {
382                map.insert("template".to_string(), _v);
383            }
384        }
385        
386        {
387            let _v = serde_json::to_value(&self.timezone).map_err(Error::custom)?;
388            if !_v.is_null() {
389                map.insert("timezone".to_string(), _v);
390            }
391        }
392        
393        {
394            let _v = serde_json::to_value(&self.tty).map_err(Error::custom)?;
395            if !_v.is_null() {
396                map.insert("tty".to_string(), _v);
397            }
398        }
399        
400        {
401            let _v = serde_json::to_value(&self.unprivileged).map_err(Error::custom)?;
402            if !_v.is_null() {
403                map.insert("unprivileged".to_string(), _v);
404            }
405        }
406        
407        if let Some(ref _m) = self.devs {
408            for (_idx, _val) in _m.iter() {
409                map.insert(format!("dev{}", _idx), serde_json::to_value(_val).map_err(Error::custom)?);
410            }
411        }
412        if let Some(ref _m) = self.mps {
413            for (_idx, _val) in _m.iter() {
414                map.insert(format!("mp{}", _idx), serde_json::to_value(_val).map_err(Error::custom)?);
415            }
416        }
417        if let Some(ref _m) = self.nets {
418            for (_idx, _val) in _m.iter() {
419                map.insert(format!("net{}", _idx), serde_json::to_value(_val).map_err(Error::custom)?);
420            }
421        }
422        if let Some(ref _m) = self.unuseds {
423            for (_idx, _val) in _m.iter() {
424                map.insert(format!("unused{}", _idx), serde_json::to_value(_val).map_err(Error::custom)?);
425            }
426        }
427        serde_json::Value::Object(map).serialize(serializer)
428    }
429}
430
431impl<'de> serde::Deserialize<'de> for LxcVmConfigResponseData {
432    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
433        use serde::de::Error;
434        let mut raw: serde_json::Map<String, serde_json::Value> =
435            serde::Deserialize::deserialize(deserializer)?;
436        let mut __devs: std::collections::HashMap<u32, models::PveLxcDevField> = std::collections::HashMap::new();
437        {
438            let _prefix = "dev";
439            let _keys: Vec<String> = raw.keys()
440                .filter(|k| {
441                    if let Some(_suffix) = k.strip_prefix(_prefix) {
442                        !_suffix.is_empty() && _suffix.chars().all(|c| c.is_ascii_digit())
443                    } else {
444                        false
445                    }
446                })
447                .cloned()
448                .collect();
449            for _key in _keys {
450                let _suffix = _key.strip_prefix(_prefix).unwrap();
451                let _idx: u32 = _suffix.parse().map_err(Error::custom)?;
452                let _value = raw.remove(&_key).unwrap();
453                let _item: models::PveLxcDevField = serde_json::from_value(_value).map_err(Error::custom)?;
454                __devs.insert(_idx, _item);
455            }
456        }
457        let mut __mps: std::collections::HashMap<u32, models::PveLxcMpField> = std::collections::HashMap::new();
458        {
459            let _prefix = "mp";
460            let _keys: Vec<String> = raw.keys()
461                .filter(|k| {
462                    if let Some(_suffix) = k.strip_prefix(_prefix) {
463                        !_suffix.is_empty() && _suffix.chars().all(|c| c.is_ascii_digit())
464                    } else {
465                        false
466                    }
467                })
468                .cloned()
469                .collect();
470            for _key in _keys {
471                let _suffix = _key.strip_prefix(_prefix).unwrap();
472                let _idx: u32 = _suffix.parse().map_err(Error::custom)?;
473                let _value = raw.remove(&_key).unwrap();
474                let _item: models::PveLxcMpField = serde_json::from_value(_value).map_err(Error::custom)?;
475                __mps.insert(_idx, _item);
476            }
477        }
478        let mut __nets: std::collections::HashMap<u32, models::PveLxcNetField> = std::collections::HashMap::new();
479        {
480            let _prefix = "net";
481            let _keys: Vec<String> = raw.keys()
482                .filter(|k| {
483                    if let Some(_suffix) = k.strip_prefix(_prefix) {
484                        !_suffix.is_empty() && _suffix.chars().all(|c| c.is_ascii_digit())
485                    } else {
486                        false
487                    }
488                })
489                .cloned()
490                .collect();
491            for _key in _keys {
492                let _suffix = _key.strip_prefix(_prefix).unwrap();
493                let _idx: u32 = _suffix.parse().map_err(Error::custom)?;
494                let _value = raw.remove(&_key).unwrap();
495                let _item: models::PveLxcNetField = serde_json::from_value(_value).map_err(Error::custom)?;
496                __nets.insert(_idx, _item);
497            }
498        }
499        let mut __unuseds: std::collections::HashMap<u32, models::PveLxcUnusedField> = std::collections::HashMap::new();
500        {
501            let _prefix = "unused";
502            let _keys: Vec<String> = raw.keys()
503                .filter(|k| {
504                    if let Some(_suffix) = k.strip_prefix(_prefix) {
505                        !_suffix.is_empty() && _suffix.chars().all(|c| c.is_ascii_digit())
506                    } else {
507                        false
508                    }
509                })
510                .cloned()
511                .collect();
512            for _key in _keys {
513                let _suffix = _key.strip_prefix(_prefix).unwrap();
514                let _idx: u32 = _suffix.parse().map_err(Error::custom)?;
515                let _value = raw.remove(&_key).unwrap();
516                let _item: models::PveLxcUnusedField = serde_json::from_value(_value).map_err(Error::custom)?;
517                __unuseds.insert(_idx, _item);
518            }
519        }
520        Ok(LxcVmConfigResponseData {
521            
522            arch: serde_json::from_value(raw.remove("arch").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
523            
524            cmode: serde_json::from_value(raw.remove("cmode").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
525            
526            console: serde_json::from_value(raw.remove("console").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
527            
528            cores: serde_json::from_value(raw.remove("cores").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
529            
530            cpulimit: serde_json::from_value(raw.remove("cpulimit").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
531            
532            cpuunits: serde_json::from_value(raw.remove("cpuunits").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
533            
534            debug: serde_json::from_value(raw.remove("debug").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
535            
536            description: serde_json::from_value(raw.remove("description").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
537            
538            digest: serde_json::from_value(raw.remove("digest").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
539            
540            entrypoint: serde_json::from_value(raw.remove("entrypoint").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
541            
542            env: serde_json::from_value(raw.remove("env").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
543            
544            features: serde_json::from_value(raw.remove("features").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
545            
546            hookscript: serde_json::from_value(raw.remove("hookscript").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
547            
548            hostname: serde_json::from_value(raw.remove("hostname").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
549            
550            lock: serde_json::from_value(raw.remove("lock").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
551            
552            lxc: serde_json::from_value(raw.remove("lxc").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
553            
554            memory: serde_json::from_value(raw.remove("memory").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
555            
556            nameserver: serde_json::from_value(raw.remove("nameserver").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
557            
558            onboot: serde_json::from_value(raw.remove("onboot").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
559            
560            ostype: serde_json::from_value(raw.remove("ostype").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
561            
562            protection: serde_json::from_value(raw.remove("protection").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
563            
564            rootfs: serde_json::from_value(raw.remove("rootfs").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
565            
566            searchdomain: serde_json::from_value(raw.remove("searchdomain").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
567            
568            startup: serde_json::from_value(raw.remove("startup").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
569            
570            swap: serde_json::from_value(raw.remove("swap").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
571            
572            tags: serde_json::from_value(raw.remove("tags").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
573            
574            template: serde_json::from_value(raw.remove("template").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
575            
576            timezone: serde_json::from_value(raw.remove("timezone").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
577            
578            tty: serde_json::from_value(raw.remove("tty").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
579            
580            unprivileged: serde_json::from_value(raw.remove("unprivileged").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
581            
582            devs: if __devs.is_empty() { None } else { Some(__devs) },
583            mps: if __mps.is_empty() { None } else { Some(__mps) },
584            nets: if __nets.is_empty() { None } else { Some(__nets) },
585            unuseds: if __unuseds.is_empty() { None } else { Some(__unuseds) },
586        })
587    }
588}
589
590