clientapi-pve 2026.5.24

Generated from apidoc.js. NOT an official Proxmox specification. See https://pve.proxmox.com/pve-docs/api-viewer/ for the upstream documentation.
Documentation
/*
 * Proxmox Virtual Environment API
 *
 * Generated from apidoc.js. NOT an official Proxmox specification. See https://pve.proxmox.com/pve-docs/api-viewer/ for the upstream documentation.
 *
 * The version of the OpenAPI document: 9.x
 * 
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct PveNetConfig {

    /// Bridge to attach the network device to.
    #[serde(rename = "bridge", skip_serializing_if = "Option::is_none")]
    pub bridge: Option<String>,

    /// Controls whether this interface's firewall rules should be used.
    #[serde(rename = "firewall", skip_serializing_if = "Option::is_none")]
    pub firewall: Option<models::PveBoolean>,

    /// Default gateway for IPv4 traffic.
    #[serde(rename = "gw", skip_serializing_if = "Option::is_none")]
    pub gw: Option<String>,

    /// Default gateway for IPv6 traffic.
    #[serde(rename = "gw6", skip_serializing_if = "Option::is_none")]
    pub gw6: Option<String>,

    /// Whether this interface's IP configuration should be managed by the host. When enabled, the host (rather than the container) is responsible for the interface's IP configuration. The container should not run its own DHCP client or network manager on this interface. This is useful for containers that lack an internal network management stack, like many application containers.
    #[serde(rename = "host-managed", skip_serializing_if = "Option::is_none")]
    pub host_managed: Option<models::PveBoolean>,

    /// A common MAC address with the I/G (Individual/Group) bit not set.
    #[serde(rename = "hwaddr", skip_serializing_if = "Option::is_none")]
    pub hwaddr: Option<String>,

    /// IPv4 address in CIDR format.
    #[serde(rename = "ip", skip_serializing_if = "Option::is_none")]
    pub ip: Option<String>,

    /// IPv6 address in CIDR format.
    #[serde(rename = "ip6", skip_serializing_if = "Option::is_none")]
    pub ip6: Option<String>,

    /// Whether this interface should be disconnected (like pulling the plug).
    #[serde(rename = "link_down", skip_serializing_if = "Option::is_none")]
    pub link_down: Option<models::PveBoolean>,

    /// Maximum transfer unit of the interface. (lxc.network.mtu)
    #[serde(rename = "mtu", skip_serializing_if = "Option::is_none")]
    pub mtu: Option<i32>,

    /// Name of the network device as seen from inside the container. (lxc.network.name)
    #[serde(rename = "name")]
    pub name: String,

    /// Apply rate limiting to the interface
    #[serde(rename = "rate", skip_serializing_if = "Option::is_none")]
    pub rate: Option<f64>,

    /// VLAN tag for this interface.
    #[serde(rename = "tag", skip_serializing_if = "Option::is_none")]
    pub tag: Option<i32>,

    /// VLAN ids to pass through the interface
    #[serde(rename = "trunks", skip_serializing_if = "Option::is_none")]
    pub trunks: Option<String>,

    /// Network interface type.
    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
    pub r#type: Option<models::PveLxcTypeEnum>,


}

impl PveNetConfig {
    pub fn new(name: String) -> PveNetConfig {
        PveNetConfig {
            
            bridge: None,
            
            firewall: None,
            
            gw: None,
            
            gw6: None,
            
            host_managed: None,
            
            hwaddr: None,
            
            ip: None,
            
            ip6: None,
            
            link_down: None,
            
            mtu: None,
            
            name,
            
            rate: None,
            
            tag: None,
            
            trunks: None,
            
            r#type: None,
            
        }
    }
}


impl PveNetConfig {
    /// Serialise this PveNetConfig into Proxmox's CLI-style shorthand
    /// string (`key=value,…`). The property marked `x-pve-default-key`
    /// is emitted positionally without a `key=` prefix; aliases collapse
    /// multiple property names to the same wire key.
    ///
    /// Example: `PveNetConfig `
    /// → `"virtio,bridge=vmbr0"`
    pub fn to_shorthand(&self) -> String {
        let mut parts: Vec<String> = Vec::new();
        
        
        
        if let Some(ref v) = self.bridge {
            parts.push(format!("bridge={}", v));
        }
        
        
        if let Some(ref v) = self.firewall {
            parts.push(format!("firewall={}", v));
        }
        
        
        if let Some(ref v) = self.gw {
            parts.push(format!("gw={}", v));
        }
        
        
        if let Some(ref v) = self.gw6 {
            parts.push(format!("gw6={}", v));
        }
        
        
        if let Some(ref v) = self.host_managed {
            parts.push(format!("host-managed={}", v));
        }
        
        
        if let Some(ref v) = self.hwaddr {
            parts.push(format!("hwaddr={}", v));
        }
        
        
        if let Some(ref v) = self.ip {
            parts.push(format!("ip={}", v));
        }
        
        
        if let Some(ref v) = self.ip6 {
            parts.push(format!("ip6={}", v));
        }
        
        
        if let Some(ref v) = self.link_down {
            parts.push(format!("link_down={}", v));
        }
        
        
        if let Some(ref v) = self.mtu {
            parts.push(format!("mtu={}", v));
        }
        
        
        parts.push(format!("name={}", self.name));
        
        
        
        if let Some(ref v) = self.rate {
            parts.push(format!("rate={}", v));
        }
        
        
        if let Some(ref v) = self.tag {
            parts.push(format!("tag={}", v));
        }
        
        
        if let Some(ref v) = self.trunks {
            parts.push(format!("trunks={}", v));
        }
        
        
        if let Some(ref v) = self.r#type {
            parts.push(format!("type={}", v));
        }
        
        parts.join(",")
    }
}