/*
* 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 PveRootfsConfig {
/// Explicitly enable or disable ACL support.
#[serde(rename = "acl", skip_serializing_if = "Option::is_none")]
pub acl: Option<models::PveBoolean>,
/// Customize UID/GID mappings that override the container's `lxc.idmap` for this mount point. Accepts a semicolon-separated list of `type:container:disk:range-size` entries. `type` is `u` for UID or `g` for GID. `container` is the first ID as seen inside the container. `disk` is the first corresponding ID on the underlying filesystem. `range-size` is the number of consecutive IDs to map. Unmapped IDs fall back to the container's `lxc.idmap`. Example 1: `u:123:456:1` maps UID 123 in the container to UID 456 on the disk. Files owned by UID 456 on the disk will appear as UID 123 inside the container. Example 2: `g:100:50:5` maps 5 consecutive GIDs, such that GIDs 100-104 in the container are mapped to GIDs 50-54 on the disk. Example 3: `passthrough` identity-maps all UIDs and GIDs, meaning IDs inside the container will match the IDs on the disk.
#[serde(rename = "idmap", skip_serializing_if = "Option::is_none")]
pub idmap: Option<String>,
/// Extra mount options for rootfs/mps.
#[serde(rename = "mountoptions", skip_serializing_if = "Option::is_none")]
pub mountoptions: Option<String>,
/// Enable user quotas inside the container (not supported with zfs subvolumes)
#[serde(rename = "quota", skip_serializing_if = "Option::is_none")]
pub quota: Option<models::PveBoolean>,
/// Will include this volume to a storage replica job.
#[serde(rename = "replicate", skip_serializing_if = "Option::is_none")]
pub replicate: Option<models::PveBoolean>,
/// Read-only mount point
#[serde(rename = "ro", skip_serializing_if = "Option::is_none")]
pub ro: Option<models::PveBoolean>,
/// Mark this non-volume mount point as available on all nodes. WARNING: This option does not share the mount point automatically, it assumes it is shared already!
#[serde(rename = "shared", skip_serializing_if = "Option::is_none")]
pub shared: Option<models::PveBoolean>,
/// Volume size (read only value).
#[serde(rename = "size", skip_serializing_if = "Option::is_none")]
pub size: Option<String>,
/// Volume, device or directory to mount into the container.
#[serde(rename = "volume")]
pub volume: String,
}
impl PveRootfsConfig {
pub fn new(volume: String) -> PveRootfsConfig {
PveRootfsConfig {
acl: None,
idmap: None,
mountoptions: None,
quota: None,
replicate: None,
ro: None,
shared: None,
size: None,
volume,
}
}
}
impl PveRootfsConfig {
/// Serialise this PveRootfsConfig 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: `PveRootfsConfig `
/// → `"virtio,bridge=vmbr0"`
pub fn to_shorthand(&self) -> String {
let mut parts: Vec<String> = Vec::new();
parts.push(format!("{}", self.volume));
if let Some(ref v) = self.acl {
parts.push(format!("acl={}", v));
}
if let Some(ref v) = self.idmap {
parts.push(format!("idmap={}", v));
}
if let Some(ref v) = self.mountoptions {
parts.push(format!("mountoptions={}", v));
}
if let Some(ref v) = self.quota {
parts.push(format!("quota={}", v));
}
if let Some(ref v) = self.replicate {
parts.push(format!("replicate={}", v));
}
if let Some(ref v) = self.ro {
parts.push(format!("ro={}", v));
}
if let Some(ref v) = self.shared {
parts.push(format!("shared={}", v));
}
if let Some(ref v) = self.size {
parts.push(format!("size={}", v));
}
parts.join(",")
}
}