Skip to main content

clientapi_pve/models/
lxc_update_vm_request.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 LxcUpdateVmRequest {
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    /// A list of settings you want to delete.
40    pub delete: Option<String>,
41
42    /// Description for the Container. Shown in the web-interface CT's summary. This is saved as comment inside the configuration file.
43    pub description: Option<String>,
44
45    /// Prevent changes if current configuration file has different SHA1 digest. This can be used to prevent concurrent modifications.
46    pub digest: Option<String>,
47
48    /// Command to run as init, optionally with arguments; may start with an absolute path, relative path, or a binary in $PATH.
49    pub entrypoint: Option<String>,
50
51    /// The container runtime environment as NUL-separated list. Replaces any lxc.environment.runtime entries in the config.
52    pub env: Option<String>,
53
54    /// Allow containers access to advanced features.
55    pub features: Option<Box<models::PveFeaturesField>>,
56
57    /// Script that will be executed during various steps in the containers lifetime.
58    pub hookscript: Option<String>,
59
60    /// Set a host name for the container.
61    pub hostname: Option<String>,
62
63    /// Lock/unlock the container.
64    pub lock: Option<models::PveLockEnum>,
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    /// Revert a pending change.
82    pub revert: Option<String>,
83
84    /// Use volume as container root.
85    pub rootfs: Option<Box<models::PveRootfsField>>,
86
87    /// Sets DNS search domains for a container. Create will automatically use the setting from the host if you neither set searchdomain nor nameserver.
88    pub searchdomain: Option<String>,
89
90    /// 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.
91    pub startup: Option<String>,
92
93    /// Amount of SWAP for the container in MB.
94    pub swap: Option<i64>,
95
96    /// Tags of the Container. This is only meta information.
97    pub tags: Option<String>,
98
99    /// Enable/disable Template.
100    pub template: Option<models::PveBoolean>,
101
102    /// 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
103    pub timezone: Option<String>,
104
105    /// Specify the number of tty available to the container
106    pub tty: Option<i32>,
107
108    /// 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.)
109    pub unprivileged: Option<models::PveBoolean>,
110
111    /// Devs family. Wire form: `dev0..dev8`. Serialised by the manual impls below.
112    pub devs: Option<std::collections::HashMap<u32, models::PveDevField>>,
113    /// Mps family. Wire form: `mp0..mp255`. Serialised by the manual impls below.
114    pub mps: Option<std::collections::HashMap<u32, models::PveMpField>>,
115    /// Nets family. Wire form: `net0..net31`. Serialised by the manual impls below.
116    pub nets: Option<std::collections::HashMap<u32, models::PveNetField>>,
117    /// Unuseds family. Wire form: `unused0..unused255`. Serialised by the manual impls below.
118    pub unuseds: Option<std::collections::HashMap<u32, models::PveUnusedField>>,
119}
120
121impl LxcUpdateVmRequest {
122    pub fn new() -> LxcUpdateVmRequest {
123        LxcUpdateVmRequest {
124            
125            arch: None,
126            
127            cmode: None,
128            
129            console: None,
130            
131            cores: None,
132            
133            cpulimit: None,
134            
135            cpuunits: None,
136            
137            debug: None,
138            
139            delete: None,
140            
141            description: None,
142            
143            digest: None,
144            
145            entrypoint: None,
146            
147            env: None,
148            
149            features: None,
150            
151            hookscript: None,
152            
153            hostname: None,
154            
155            lock: None,
156            
157            memory: None,
158            
159            nameserver: None,
160            
161            onboot: None,
162            
163            ostype: None,
164            
165            protection: None,
166            
167            revert: None,
168            
169            rootfs: None,
170            
171            searchdomain: None,
172            
173            startup: None,
174            
175            swap: None,
176            
177            tags: None,
178            
179            template: None,
180            
181            timezone: None,
182            
183            tty: None,
184            
185            unprivileged: None,
186            
187            devs: None,
188            mps: None,
189            nets: None,
190            unuseds: None,
191        }
192    }
193}
194
195
196// Flattens indexed-family maps to/from `<base><idx>` wire keys.
197impl serde::Serialize for LxcUpdateVmRequest {
198    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
199        use serde::ser::Error;
200        let mut map = serde_json::Map::new();
201        
202        {
203            let _v = serde_json::to_value(&self.arch).map_err(Error::custom)?;
204            if !_v.is_null() {
205                map.insert("arch".to_string(), _v);
206            }
207        }
208        
209        {
210            let _v = serde_json::to_value(&self.cmode).map_err(Error::custom)?;
211            if !_v.is_null() {
212                map.insert("cmode".to_string(), _v);
213            }
214        }
215        
216        {
217            let _v = serde_json::to_value(&self.console).map_err(Error::custom)?;
218            if !_v.is_null() {
219                map.insert("console".to_string(), _v);
220            }
221        }
222        
223        {
224            let _v = serde_json::to_value(&self.cores).map_err(Error::custom)?;
225            if !_v.is_null() {
226                map.insert("cores".to_string(), _v);
227            }
228        }
229        
230        {
231            let _v = serde_json::to_value(&self.cpulimit).map_err(Error::custom)?;
232            if !_v.is_null() {
233                map.insert("cpulimit".to_string(), _v);
234            }
235        }
236        
237        {
238            let _v = serde_json::to_value(&self.cpuunits).map_err(Error::custom)?;
239            if !_v.is_null() {
240                map.insert("cpuunits".to_string(), _v);
241            }
242        }
243        
244        {
245            let _v = serde_json::to_value(&self.debug).map_err(Error::custom)?;
246            if !_v.is_null() {
247                map.insert("debug".to_string(), _v);
248            }
249        }
250        
251        {
252            let _v = serde_json::to_value(&self.delete).map_err(Error::custom)?;
253            if !_v.is_null() {
254                map.insert("delete".to_string(), _v);
255            }
256        }
257        
258        {
259            let _v = serde_json::to_value(&self.description).map_err(Error::custom)?;
260            if !_v.is_null() {
261                map.insert("description".to_string(), _v);
262            }
263        }
264        
265        {
266            let _v = serde_json::to_value(&self.digest).map_err(Error::custom)?;
267            if !_v.is_null() {
268                map.insert("digest".to_string(), _v);
269            }
270        }
271        
272        {
273            let _v = serde_json::to_value(&self.entrypoint).map_err(Error::custom)?;
274            if !_v.is_null() {
275                map.insert("entrypoint".to_string(), _v);
276            }
277        }
278        
279        {
280            let _v = serde_json::to_value(&self.env).map_err(Error::custom)?;
281            if !_v.is_null() {
282                map.insert("env".to_string(), _v);
283            }
284        }
285        
286        {
287            let _v = serde_json::to_value(&self.features).map_err(Error::custom)?;
288            if !_v.is_null() {
289                map.insert("features".to_string(), _v);
290            }
291        }
292        
293        {
294            let _v = serde_json::to_value(&self.hookscript).map_err(Error::custom)?;
295            if !_v.is_null() {
296                map.insert("hookscript".to_string(), _v);
297            }
298        }
299        
300        {
301            let _v = serde_json::to_value(&self.hostname).map_err(Error::custom)?;
302            if !_v.is_null() {
303                map.insert("hostname".to_string(), _v);
304            }
305        }
306        
307        {
308            let _v = serde_json::to_value(&self.lock).map_err(Error::custom)?;
309            if !_v.is_null() {
310                map.insert("lock".to_string(), _v);
311            }
312        }
313        
314        {
315            let _v = serde_json::to_value(&self.memory).map_err(Error::custom)?;
316            if !_v.is_null() {
317                map.insert("memory".to_string(), _v);
318            }
319        }
320        
321        {
322            let _v = serde_json::to_value(&self.nameserver).map_err(Error::custom)?;
323            if !_v.is_null() {
324                map.insert("nameserver".to_string(), _v);
325            }
326        }
327        
328        {
329            let _v = serde_json::to_value(&self.onboot).map_err(Error::custom)?;
330            if !_v.is_null() {
331                map.insert("onboot".to_string(), _v);
332            }
333        }
334        
335        {
336            let _v = serde_json::to_value(&self.ostype).map_err(Error::custom)?;
337            if !_v.is_null() {
338                map.insert("ostype".to_string(), _v);
339            }
340        }
341        
342        {
343            let _v = serde_json::to_value(&self.protection).map_err(Error::custom)?;
344            if !_v.is_null() {
345                map.insert("protection".to_string(), _v);
346            }
347        }
348        
349        {
350            let _v = serde_json::to_value(&self.revert).map_err(Error::custom)?;
351            if !_v.is_null() {
352                map.insert("revert".to_string(), _v);
353            }
354        }
355        
356        {
357            let _v = serde_json::to_value(&self.rootfs).map_err(Error::custom)?;
358            if !_v.is_null() {
359                map.insert("rootfs".to_string(), _v);
360            }
361        }
362        
363        {
364            let _v = serde_json::to_value(&self.searchdomain).map_err(Error::custom)?;
365            if !_v.is_null() {
366                map.insert("searchdomain".to_string(), _v);
367            }
368        }
369        
370        {
371            let _v = serde_json::to_value(&self.startup).map_err(Error::custom)?;
372            if !_v.is_null() {
373                map.insert("startup".to_string(), _v);
374            }
375        }
376        
377        {
378            let _v = serde_json::to_value(&self.swap).map_err(Error::custom)?;
379            if !_v.is_null() {
380                map.insert("swap".to_string(), _v);
381            }
382        }
383        
384        {
385            let _v = serde_json::to_value(&self.tags).map_err(Error::custom)?;
386            if !_v.is_null() {
387                map.insert("tags".to_string(), _v);
388            }
389        }
390        
391        {
392            let _v = serde_json::to_value(&self.template).map_err(Error::custom)?;
393            if !_v.is_null() {
394                map.insert("template".to_string(), _v);
395            }
396        }
397        
398        {
399            let _v = serde_json::to_value(&self.timezone).map_err(Error::custom)?;
400            if !_v.is_null() {
401                map.insert("timezone".to_string(), _v);
402            }
403        }
404        
405        {
406            let _v = serde_json::to_value(&self.tty).map_err(Error::custom)?;
407            if !_v.is_null() {
408                map.insert("tty".to_string(), _v);
409            }
410        }
411        
412        {
413            let _v = serde_json::to_value(&self.unprivileged).map_err(Error::custom)?;
414            if !_v.is_null() {
415                map.insert("unprivileged".to_string(), _v);
416            }
417        }
418        
419        if let Some(ref _m) = self.devs {
420            for (_idx, _val) in _m.iter() {
421                map.insert(format!("dev{}", _idx), serde_json::to_value(_val).map_err(Error::custom)?);
422            }
423        }
424        if let Some(ref _m) = self.mps {
425            for (_idx, _val) in _m.iter() {
426                map.insert(format!("mp{}", _idx), serde_json::to_value(_val).map_err(Error::custom)?);
427            }
428        }
429        if let Some(ref _m) = self.nets {
430            for (_idx, _val) in _m.iter() {
431                map.insert(format!("net{}", _idx), serde_json::to_value(_val).map_err(Error::custom)?);
432            }
433        }
434        if let Some(ref _m) = self.unuseds {
435            for (_idx, _val) in _m.iter() {
436                map.insert(format!("unused{}", _idx), serde_json::to_value(_val).map_err(Error::custom)?);
437            }
438        }
439        serde_json::Value::Object(map).serialize(serializer)
440    }
441}
442
443impl<'de> serde::Deserialize<'de> for LxcUpdateVmRequest {
444    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
445        use serde::de::Error;
446        let mut raw: serde_json::Map<String, serde_json::Value> =
447            serde::Deserialize::deserialize(deserializer)?;
448        let mut __devs: std::collections::HashMap<u32, models::PveDevField> = std::collections::HashMap::new();
449        {
450            let _prefix = "dev";
451            let _keys: Vec<String> = raw.keys()
452                .filter(|k| {
453                    if let Some(_suffix) = k.strip_prefix(_prefix) {
454                        !_suffix.is_empty() && _suffix.chars().all(|c| c.is_ascii_digit())
455                    } else {
456                        false
457                    }
458                })
459                .cloned()
460                .collect();
461            for _key in _keys {
462                let _suffix = _key.strip_prefix(_prefix).unwrap();
463                let _idx: u32 = _suffix.parse().map_err(Error::custom)?;
464                let _value = raw.remove(&_key).unwrap();
465                let _item: models::PveDevField = serde_json::from_value(_value).map_err(Error::custom)?;
466                __devs.insert(_idx, _item);
467            }
468        }
469        let mut __mps: std::collections::HashMap<u32, models::PveMpField> = std::collections::HashMap::new();
470        {
471            let _prefix = "mp";
472            let _keys: Vec<String> = raw.keys()
473                .filter(|k| {
474                    if let Some(_suffix) = k.strip_prefix(_prefix) {
475                        !_suffix.is_empty() && _suffix.chars().all(|c| c.is_ascii_digit())
476                    } else {
477                        false
478                    }
479                })
480                .cloned()
481                .collect();
482            for _key in _keys {
483                let _suffix = _key.strip_prefix(_prefix).unwrap();
484                let _idx: u32 = _suffix.parse().map_err(Error::custom)?;
485                let _value = raw.remove(&_key).unwrap();
486                let _item: models::PveMpField = serde_json::from_value(_value).map_err(Error::custom)?;
487                __mps.insert(_idx, _item);
488            }
489        }
490        let mut __nets: std::collections::HashMap<u32, models::PveNetField> = std::collections::HashMap::new();
491        {
492            let _prefix = "net";
493            let _keys: Vec<String> = raw.keys()
494                .filter(|k| {
495                    if let Some(_suffix) = k.strip_prefix(_prefix) {
496                        !_suffix.is_empty() && _suffix.chars().all(|c| c.is_ascii_digit())
497                    } else {
498                        false
499                    }
500                })
501                .cloned()
502                .collect();
503            for _key in _keys {
504                let _suffix = _key.strip_prefix(_prefix).unwrap();
505                let _idx: u32 = _suffix.parse().map_err(Error::custom)?;
506                let _value = raw.remove(&_key).unwrap();
507                let _item: models::PveNetField = serde_json::from_value(_value).map_err(Error::custom)?;
508                __nets.insert(_idx, _item);
509            }
510        }
511        let mut __unuseds: std::collections::HashMap<u32, models::PveUnusedField> = std::collections::HashMap::new();
512        {
513            let _prefix = "unused";
514            let _keys: Vec<String> = raw.keys()
515                .filter(|k| {
516                    if let Some(_suffix) = k.strip_prefix(_prefix) {
517                        !_suffix.is_empty() && _suffix.chars().all(|c| c.is_ascii_digit())
518                    } else {
519                        false
520                    }
521                })
522                .cloned()
523                .collect();
524            for _key in _keys {
525                let _suffix = _key.strip_prefix(_prefix).unwrap();
526                let _idx: u32 = _suffix.parse().map_err(Error::custom)?;
527                let _value = raw.remove(&_key).unwrap();
528                let _item: models::PveUnusedField = serde_json::from_value(_value).map_err(Error::custom)?;
529                __unuseds.insert(_idx, _item);
530            }
531        }
532        Ok(LxcUpdateVmRequest {
533            
534            arch: serde_json::from_value(raw.remove("arch").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
535            
536            cmode: serde_json::from_value(raw.remove("cmode").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
537            
538            console: serde_json::from_value(raw.remove("console").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
539            
540            cores: serde_json::from_value(raw.remove("cores").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
541            
542            cpulimit: serde_json::from_value(raw.remove("cpulimit").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
543            
544            cpuunits: serde_json::from_value(raw.remove("cpuunits").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
545            
546            debug: serde_json::from_value(raw.remove("debug").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
547            
548            delete: serde_json::from_value(raw.remove("delete").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
549            
550            description: serde_json::from_value(raw.remove("description").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
551            
552            digest: serde_json::from_value(raw.remove("digest").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
553            
554            entrypoint: serde_json::from_value(raw.remove("entrypoint").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
555            
556            env: serde_json::from_value(raw.remove("env").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
557            
558            features: serde_json::from_value(raw.remove("features").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
559            
560            hookscript: serde_json::from_value(raw.remove("hookscript").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
561            
562            hostname: serde_json::from_value(raw.remove("hostname").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
563            
564            lock: serde_json::from_value(raw.remove("lock").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
565            
566            memory: serde_json::from_value(raw.remove("memory").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
567            
568            nameserver: serde_json::from_value(raw.remove("nameserver").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
569            
570            onboot: serde_json::from_value(raw.remove("onboot").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
571            
572            ostype: serde_json::from_value(raw.remove("ostype").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
573            
574            protection: serde_json::from_value(raw.remove("protection").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
575            
576            revert: serde_json::from_value(raw.remove("revert").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
577            
578            rootfs: serde_json::from_value(raw.remove("rootfs").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
579            
580            searchdomain: serde_json::from_value(raw.remove("searchdomain").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
581            
582            startup: serde_json::from_value(raw.remove("startup").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
583            
584            swap: serde_json::from_value(raw.remove("swap").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
585            
586            tags: serde_json::from_value(raw.remove("tags").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
587            
588            template: serde_json::from_value(raw.remove("template").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
589            
590            timezone: serde_json::from_value(raw.remove("timezone").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
591            
592            tty: serde_json::from_value(raw.remove("tty").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
593            
594            unprivileged: serde_json::from_value(raw.remove("unprivileged").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
595            
596            devs: if __devs.is_empty() { None } else { Some(__devs) },
597            mps: if __mps.is_empty() { None } else { Some(__mps) },
598            nets: if __nets.is_empty() { None } else { Some(__nets) },
599            unuseds: if __unuseds.is_empty() { None } else { Some(__unuseds) },
600        })
601    }
602}
603
604