Skip to main content

clientapi_pve/models/
pve_dev_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 PveDevConfig {
16
17    /// Deny the container to write to the device
18    #[serde(rename = "deny-write", skip_serializing_if = "Option::is_none")]
19    pub deny_write: Option<models::PveBoolean>,
20
21    /// Group ID to be assigned to the device node
22    #[serde(rename = "gid", skip_serializing_if = "Option::is_none")]
23    pub gid: Option<i64>,
24
25    /// Access mode to be set on the device node
26    #[serde(rename = "mode", skip_serializing_if = "Option::is_none")]
27    pub mode: Option<String>,
28
29    /// Path to the device to pass through to the container
30    #[serde(rename = "path", skip_serializing_if = "Option::is_none")]
31    pub path: Option<String>,
32
33    /// User ID to be assigned to the device node
34    #[serde(rename = "uid", skip_serializing_if = "Option::is_none")]
35    pub uid: Option<i64>,
36
37
38}
39
40impl PveDevConfig {
41    pub fn new() -> PveDevConfig {
42        PveDevConfig {
43            
44            deny_write: None,
45            
46            gid: None,
47            
48            mode: None,
49            
50            path: None,
51            
52            uid: None,
53            
54        }
55    }
56}
57
58
59impl PveDevConfig {
60    /// Serialise this PveDevConfig into Proxmox's CLI-style shorthand
61    /// string (`key=value,…`). The property marked `x-pve-default-key`
62    /// is emitted positionally without a `key=` prefix; aliases collapse
63    /// multiple property names to the same wire key.
64    ///
65    /// Example: `PveDevConfig `
66    /// → `"virtio,bridge=vmbr0"`
67    pub fn to_shorthand(&self) -> String {
68        let mut parts: Vec<String> = Vec::new();
69        
70        
71        if let Some(ref v) = self.path {
72            parts.push(format!("{}", v));
73        }
74        
75        
76        
77        if let Some(ref v) = self.deny_write {
78            parts.push(format!("deny-write={}", v));
79        }
80        
81        
82        if let Some(ref v) = self.gid {
83            parts.push(format!("gid={}", v));
84        }
85        
86        
87        if let Some(ref v) = self.mode {
88            parts.push(format!("mode={}", v));
89        }
90        
91        
92        if let Some(ref v) = self.uid {
93            parts.push(format!("uid={}", v));
94        }
95        
96        parts.join(",")
97    }
98}
99