proxmox_api/generated/nodes/node/disks/
directory.rs1pub mod name;
2#[derive(Debug, Clone)]
3pub struct DirectoryClient<T> {
4 client: T,
5 path: String,
6}
7impl<T> DirectoryClient<T>
8where
9 T: crate::client::Client,
10{
11 pub fn new(client: T, parent_path: &str) -> Self {
12 Self {
13 client,
14 path: format!("{}{}", parent_path, "/directory"),
15 }
16 }
17}
18impl<T> DirectoryClient<T>
19where
20 T: crate::client::Client,
21{
22 #[doc = "PVE Managed Directory storages."]
23 #[doc = ""]
24 #[doc = "Permission check: perm(\"/\", [\"Sys.Audit\"])"]
25 pub async fn get(&self) -> Result<Vec<GetOutputItems>, T::Error> {
26 let path = self.path.to_string();
27 let optional_vec: Option<Vec<GetOutputItems>> = self.client.get(&path, &()).await?;
28 Ok(optional_vec.unwrap_or_default())
29 }
30}
31impl<T> DirectoryClient<T>
32where
33 T: crate::client::Client,
34{
35 #[doc = "Create a Filesystem on an unused disk. Will be mounted under '/mnt/pve/NAME'."]
36 #[doc = ""]
37 #[doc = "Permission check: perm(\"/\", [\"Sys.Modify\"])"]
38 #[doc = "Requires additionally 'Datastore.Allocate' on /storage when setting 'add_storage'"]
39 pub async fn post(&self, params: PostParams) -> Result<String, T::Error> {
40 let path = self.path.to_string();
41 self.client.post(&path, ¶ms).await
42 }
43}
44impl GetOutputItems {
45 pub fn new(
46 device: String,
47 options: String,
48 path: String,
49 ty: String,
50 unitfile: String,
51 ) -> Self {
52 Self {
53 device,
54 options,
55 path,
56 ty,
57 unitfile,
58 additional_properties: ::std::default::Default::default(),
59 }
60 }
61}
62#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
63pub struct GetOutputItems {
64 #[doc = "The mounted device."]
65 #[doc = ""]
66 pub device: String,
67 #[doc = "The mount options."]
68 #[doc = ""]
69 pub options: String,
70 #[doc = "The mount path."]
71 #[doc = ""]
72 pub path: String,
73 #[serde(rename = "type")]
74 #[doc = "The filesystem type."]
75 #[doc = ""]
76 pub ty: String,
77 #[doc = "The path of the mount unit."]
78 #[doc = ""]
79 pub unitfile: String,
80 #[serde(
81 flatten,
82 default,
83 skip_serializing_if = "::std::collections::HashMap::is_empty"
84 )]
85 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
86}
87impl PostParams {
88 pub fn new(device: String, name: String) -> Self {
89 Self {
90 device,
91 name,
92 add_storage: ::std::default::Default::default(),
93 filesystem: ::std::default::Default::default(),
94 additional_properties: ::std::default::Default::default(),
95 }
96 }
97}
98#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
99pub struct PostParams {
100 #[serde(
101 serialize_with = "crate::types::serialize_bool_optional",
102 deserialize_with = "crate::types::deserialize_bool_optional"
103 )]
104 #[serde(skip_serializing_if = "Option::is_none", default)]
105 #[doc = "Configure storage using the directory."]
106 #[doc = ""]
107 pub add_storage: Option<bool>,
108 #[doc = "The block device you want to create the filesystem on."]
109 #[doc = ""]
110 pub device: String,
111 #[serde(skip_serializing_if = "Option::is_none", default)]
112 #[doc = "The desired filesystem."]
113 #[doc = ""]
114 pub filesystem: Option<Filesystem>,
115 #[doc = "The storage identifier."]
116 #[doc = ""]
117 pub name: String,
118 #[serde(
119 flatten,
120 default,
121 skip_serializing_if = "::std::collections::HashMap::is_empty"
122 )]
123 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
124}
125#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq, Default)]
126#[doc = "The desired filesystem."]
127#[doc = ""]
128pub enum Filesystem {
129 #[serde(rename = "ext4")]
130 #[default]
131 Ext4,
132 #[serde(rename = "xfs")]
133 Xfs,
134}
135impl TryFrom<&str> for Filesystem {
136 type Error = String;
137 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
138 match value {
139 "ext4" => Ok(Self::Ext4),
140 "xfs" => Ok(Self::Xfs),
141 v => Err(format!("Unknown variant {v}")),
142 }
143 }
144}
145impl<T> DirectoryClient<T>
146where
147 T: crate::client::Client,
148{
149 pub fn name(&self, name: &str) -> name::NameClient<T> {
150 name::NameClient::<T>::new(self.client.clone(), &self.path, name)
151 }
152}