Skip to main content

clientapi_pve/models/
nodes_config_set_options_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 NodesConfigSetOptionsRequest {
16
17
18    /// Node specific ACME settings.
19    pub acme: Option<Box<models::PveNodesConfigAcmeField>>,
20
21    /// RAM usage target for ballooning (in percent of total memory)
22    pub ballooning_target: Option<i32>,
23
24    /// A list of settings you want to delete.
25    pub delete: Option<String>,
26
27    /// Description for the Node. Shown in the web-interface node notes panel. This is saved as comment inside the configuration file.
28    pub description: Option<String>,
29
30    /// Prevent changes if current configuration file has different SHA1 digest. This can be used to prevent concurrent modifications.
31    pub digest: Option<String>,
32
33    /// The location of the node. Overrides the default from the datacenter config.
34    pub location: Option<Box<models::PveLocationField>>,
35
36    /// Initial delay in seconds, before starting all the Virtual Guests with on-boot enabled.
37    pub startall_onboot_delay: Option<i32>,
38
39    /// Node specific wake on LAN settings.
40    pub wakeonlan: Option<Box<models::PveNodesConfigWakeonlanField>>,
41
42    /// Acmedomains family. Wire form: `acmedomain0..acmedomain8`. Serialised by the manual impls below.
43    pub acmedomains: Option<std::collections::HashMap<u32, models::PveNodesConfigAcmedomainField>>,
44}
45
46impl NodesConfigSetOptionsRequest {
47    pub fn new() -> NodesConfigSetOptionsRequest {
48        NodesConfigSetOptionsRequest {
49            
50            acme: None,
51            
52            ballooning_target: None,
53            
54            delete: None,
55            
56            description: None,
57            
58            digest: None,
59            
60            location: None,
61            
62            startall_onboot_delay: None,
63            
64            wakeonlan: None,
65            
66            acmedomains: None,
67        }
68    }
69}
70
71
72// Flattens indexed-family maps to/from `<base><idx>` wire keys.
73impl serde::Serialize for NodesConfigSetOptionsRequest {
74    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
75        use serde::ser::Error;
76        let mut map = serde_json::Map::new();
77        
78        {
79            let _v = serde_json::to_value(&self.acme).map_err(Error::custom)?;
80            if !_v.is_null() {
81                map.insert("acme".to_string(), _v);
82            }
83        }
84        
85        {
86            let _v = serde_json::to_value(&self.ballooning_target).map_err(Error::custom)?;
87            if !_v.is_null() {
88                map.insert("ballooning-target".to_string(), _v);
89            }
90        }
91        
92        {
93            let _v = serde_json::to_value(&self.delete).map_err(Error::custom)?;
94            if !_v.is_null() {
95                map.insert("delete".to_string(), _v);
96            }
97        }
98        
99        {
100            let _v = serde_json::to_value(&self.description).map_err(Error::custom)?;
101            if !_v.is_null() {
102                map.insert("description".to_string(), _v);
103            }
104        }
105        
106        {
107            let _v = serde_json::to_value(&self.digest).map_err(Error::custom)?;
108            if !_v.is_null() {
109                map.insert("digest".to_string(), _v);
110            }
111        }
112        
113        {
114            let _v = serde_json::to_value(&self.location).map_err(Error::custom)?;
115            if !_v.is_null() {
116                map.insert("location".to_string(), _v);
117            }
118        }
119        
120        {
121            let _v = serde_json::to_value(&self.startall_onboot_delay).map_err(Error::custom)?;
122            if !_v.is_null() {
123                map.insert("startall-onboot-delay".to_string(), _v);
124            }
125        }
126        
127        {
128            let _v = serde_json::to_value(&self.wakeonlan).map_err(Error::custom)?;
129            if !_v.is_null() {
130                map.insert("wakeonlan".to_string(), _v);
131            }
132        }
133        
134        if let Some(ref _m) = self.acmedomains {
135            for (_idx, _val) in _m.iter() {
136                map.insert(format!("acmedomain{}", _idx), serde_json::to_value(_val).map_err(Error::custom)?);
137            }
138        }
139        serde_json::Value::Object(map).serialize(serializer)
140    }
141}
142
143impl<'de> serde::Deserialize<'de> for NodesConfigSetOptionsRequest {
144    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
145        use serde::de::Error;
146        let mut raw: serde_json::Map<String, serde_json::Value> =
147            serde::Deserialize::deserialize(deserializer)?;
148        let mut __acmedomains: std::collections::HashMap<u32, models::PveNodesConfigAcmedomainField> = std::collections::HashMap::new();
149        {
150            let _prefix = "acmedomain";
151            let _keys: Vec<String> = raw.keys()
152                .filter(|k| {
153                    if let Some(_suffix) = k.strip_prefix(_prefix) {
154                        !_suffix.is_empty() && _suffix.chars().all(|c| c.is_ascii_digit())
155                    } else {
156                        false
157                    }
158                })
159                .cloned()
160                .collect();
161            for _key in _keys {
162                let _suffix = _key.strip_prefix(_prefix).unwrap();
163                let _idx: u32 = _suffix.parse().map_err(Error::custom)?;
164                let _value = raw.remove(&_key).unwrap();
165                let _item: models::PveNodesConfigAcmedomainField = serde_json::from_value(_value).map_err(Error::custom)?;
166                __acmedomains.insert(_idx, _item);
167            }
168        }
169        Ok(NodesConfigSetOptionsRequest {
170            
171            acme: serde_json::from_value(raw.remove("acme").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
172            
173            ballooning_target: serde_json::from_value(raw.remove("ballooning-target").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
174            
175            delete: serde_json::from_value(raw.remove("delete").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
176            
177            description: serde_json::from_value(raw.remove("description").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
178            
179            digest: serde_json::from_value(raw.remove("digest").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
180            
181            location: serde_json::from_value(raw.remove("location").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
182            
183            startall_onboot_delay: serde_json::from_value(raw.remove("startall-onboot-delay").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
184            
185            wakeonlan: serde_json::from_value(raw.remove("wakeonlan").unwrap_or(serde_json::Value::Null)).map_err(Error::custom)?,
186            
187            acmedomains: if __acmedomains.is_empty() { None } else { Some(__acmedomains) },
188        })
189    }
190}
191
192