Skip to main content

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