Skip to main content

clientapi_pve/models/
pve_location_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 PveLocationConfig {
16
17    /// The latitude of the nodes location in degrees.
18    #[serde(rename = "latitude")]
19    pub latitude: f64,
20
21    /// The longitude of the nodes location in degrees.
22    #[serde(rename = "longitude")]
23    pub longitude: f64,
24
25    /// The name of the location of this node
26    #[serde(rename = "name", skip_serializing_if = "Option::is_none")]
27    pub name: Option<String>,
28
29
30}
31
32impl PveLocationConfig {
33    pub fn new(latitude: f64, longitude: f64) -> PveLocationConfig {
34        PveLocationConfig {
35            
36            latitude,
37            
38            longitude,
39            
40            name: None,
41            
42        }
43    }
44}
45
46
47impl PveLocationConfig {
48    /// Serialise this PveLocationConfig into Proxmox's CLI-style shorthand
49    /// string (`key=value,…`). The property marked `x-pve-default-key`
50    /// is emitted positionally without a `key=` prefix; aliases collapse
51    /// multiple property names to the same wire key.
52    ///
53    /// Example: `PveLocationConfig `
54    /// → `"virtio,bridge=vmbr0"`
55    pub fn to_shorthand(&self) -> String {
56        let mut parts: Vec<String> = Vec::new();
57        
58        
59        
60        parts.push(format!("latitude={}", self.latitude));
61        
62        
63        
64        parts.push(format!("longitude={}", self.longitude));
65        
66        
67        
68        if let Some(ref v) = self.name {
69            parts.push(format!("name={}", v));
70        }
71        
72        parts.join(",")
73    }
74}
75