Skip to main content

clientapi_pve/models/
pve_link_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 PveLinkConfig {
16
17    /// Hostname (or IP) of this corosync link address.
18    #[serde(rename = "address")]
19    pub address: String,
20
21    /// The priority for the link when knet is used in 'passive' mode (default). Lower value means higher priority. Only valid for cluster create, ignored on node add.
22    #[serde(rename = "priority", skip_serializing_if = "Option::is_none")]
23    pub priority: Option<i32>,
24
25
26}
27
28impl PveLinkConfig {
29    pub fn new(address: String) -> PveLinkConfig {
30        PveLinkConfig {
31            
32            address,
33            
34            priority: None,
35            
36        }
37    }
38}
39
40
41impl PveLinkConfig {
42    /// Serialise this PveLinkConfig into Proxmox's CLI-style shorthand
43    /// string (`key=value,…`). The property marked `x-pve-default-key`
44    /// is emitted positionally without a `key=` prefix; aliases collapse
45    /// multiple property names to the same wire key.
46    ///
47    /// Example: `PveLinkConfig `
48    /// → `"virtio,bridge=vmbr0"`
49    pub fn to_shorthand(&self) -> String {
50        let mut parts: Vec<String> = Vec::new();
51        
52        
53        parts.push(format!("{}", self.address));
54        
55        
56        
57        
58        if let Some(ref v) = self.priority {
59            parts.push(format!("priority={}", v));
60        }
61        
62        parts.join(",")
63    }
64}
65