proxmox_api/generated/nodes/node/
storage.rs1pub mod storage;
2#[derive(Debug, Clone)]
3pub struct StorageClient<T> {
4 client: T,
5 path: String,
6}
7impl<T> StorageClient<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, "/storage"),
15 }
16 }
17}
18impl<T> StorageClient<T>
19where
20 T: crate::client::Client,
21{
22 #[doc = "Get status for all datastores."]
23 #[doc = ""]
24 #[doc = "Only list entries where you have 'Datastore.Audit' or 'Datastore.AllocateSpace' permissions on '/storage/\\<storage\\>'"]
25 pub async fn get(&self, params: GetParams) -> Result<Vec<GetOutputItems>, T::Error> {
26 let path = self.path.to_string();
27 let optional_vec: Option<Vec<GetOutputItems>> = self.client.get(&path, ¶ms).await?;
28 Ok(optional_vec.unwrap_or_default())
29 }
30}
31impl FormatsGetOutputItemsFormats {
32 pub fn new(default: Default, supported: Vec<Supported>) -> Self {
33 Self {
34 default,
35 supported,
36 additional_properties: ::std::default::Default::default(),
37 }
38 }
39}
40#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
41pub struct FormatsGetOutputItemsFormats {
42 #[doc = "The default format of the storage."]
43 #[doc = ""]
44 pub default: Default,
45 #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
46 #[doc = "The list of supported formats"]
47 #[doc = ""]
48 pub supported: Vec<Supported>,
49 #[serde(
50 flatten,
51 default,
52 skip_serializing_if = "::std::collections::HashMap::is_empty"
53 )]
54 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
55}
56impl GetOutputItems {
57 pub fn new(content: String, storage: String, ty: String) -> Self {
58 Self {
59 content,
60 storage,
61 ty,
62 active: ::std::default::Default::default(),
63 avail: ::std::default::Default::default(),
64 enabled: ::std::default::Default::default(),
65 formats: ::std::default::Default::default(),
66 select_existing: ::std::default::Default::default(),
67 shared: ::std::default::Default::default(),
68 total: ::std::default::Default::default(),
69 used: ::std::default::Default::default(),
70 used_fraction: ::std::default::Default::default(),
71 additional_properties: ::std::default::Default::default(),
72 }
73 }
74}
75#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
76pub struct GetOutputItems {
77 #[serde(
78 serialize_with = "crate::types::serialize_bool_optional",
79 deserialize_with = "crate::types::deserialize_bool_optional"
80 )]
81 #[serde(skip_serializing_if = "Option::is_none", default)]
82 #[doc = "Set when storage is accessible."]
83 #[doc = ""]
84 pub active: Option<bool>,
85 #[serde(
86 serialize_with = "crate::types::serialize_int_optional",
87 deserialize_with = "crate::types::deserialize_int_optional"
88 )]
89 #[serde(skip_serializing_if = "Option::is_none", default)]
90 #[doc = "Available storage space in bytes."]
91 #[doc = ""]
92 pub avail: Option<i64>,
93 #[doc = "Allowed storage content types."]
94 #[doc = ""]
95 pub content: String,
96 #[serde(
97 serialize_with = "crate::types::serialize_bool_optional",
98 deserialize_with = "crate::types::deserialize_bool_optional"
99 )]
100 #[serde(skip_serializing_if = "Option::is_none", default)]
101 #[doc = "Set when storage is enabled (not disabled)."]
102 #[doc = ""]
103 pub enabled: Option<bool>,
104 #[serde(skip_serializing_if = "Option::is_none", default)]
105 #[doc = "Lists the supported and default format. Use 'formats' instead. Only included if 'format' parameter is set."]
106 #[doc = ""]
107 pub formats: Option<FormatsGetOutputItemsFormats>,
108 #[serde(
109 serialize_with = "crate::types::serialize_bool_optional",
110 deserialize_with = "crate::types::deserialize_bool_optional"
111 )]
112 #[serde(skip_serializing_if = "Option::is_none", default)]
113 #[doc = "Instead of creating new volumes, one must select one that is already existing. Only included if 'format' parameter is set."]
114 #[doc = ""]
115 pub select_existing: Option<bool>,
116 #[serde(
117 serialize_with = "crate::types::serialize_bool_optional",
118 deserialize_with = "crate::types::deserialize_bool_optional"
119 )]
120 #[serde(skip_serializing_if = "Option::is_none", default)]
121 #[doc = "Shared flag from storage configuration."]
122 #[doc = ""]
123 pub shared: Option<bool>,
124 #[doc = "The storage identifier."]
125 #[doc = ""]
126 pub storage: String,
127 #[serde(
128 serialize_with = "crate::types::serialize_int_optional",
129 deserialize_with = "crate::types::deserialize_int_optional"
130 )]
131 #[serde(skip_serializing_if = "Option::is_none", default)]
132 #[doc = "Total storage space in bytes."]
133 #[doc = ""]
134 pub total: Option<i64>,
135 #[serde(rename = "type")]
136 #[doc = "Storage type."]
137 #[doc = ""]
138 pub ty: String,
139 #[serde(
140 serialize_with = "crate::types::serialize_int_optional",
141 deserialize_with = "crate::types::deserialize_int_optional"
142 )]
143 #[serde(skip_serializing_if = "Option::is_none", default)]
144 #[doc = "Used storage space in bytes."]
145 #[doc = ""]
146 pub used: Option<i64>,
147 #[serde(
148 serialize_with = "crate::types::serialize_number_optional",
149 deserialize_with = "crate::types::deserialize_number_optional"
150 )]
151 #[serde(skip_serializing_if = "Option::is_none", default)]
152 #[doc = "Used fraction (used/total)."]
153 #[doc = ""]
154 pub used_fraction: Option<f64>,
155 #[serde(
156 flatten,
157 default,
158 skip_serializing_if = "::std::collections::HashMap::is_empty"
159 )]
160 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
161}
162#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
163pub struct GetParams {
164 #[serde(skip_serializing_if = "Option::is_none", default)]
165 #[doc = "Only list stores which support this content type."]
166 #[doc = ""]
167 pub content: Option<String>,
168 #[serde(
169 serialize_with = "crate::types::serialize_bool_optional",
170 deserialize_with = "crate::types::deserialize_bool_optional"
171 )]
172 #[serde(skip_serializing_if = "Option::is_none", default)]
173 #[doc = "Only list stores which are enabled (not disabled in config)."]
174 #[doc = ""]
175 pub enabled: Option<bool>,
176 #[serde(
177 serialize_with = "crate::types::serialize_bool_optional",
178 deserialize_with = "crate::types::deserialize_bool_optional"
179 )]
180 #[serde(skip_serializing_if = "Option::is_none", default)]
181 #[doc = "Include information about formats"]
182 #[doc = ""]
183 pub format: Option<bool>,
184 #[serde(skip_serializing_if = "Option::is_none", default)]
185 #[doc = "Only list status for specified storage"]
186 #[doc = ""]
187 pub storage: Option<String>,
188 #[serde(skip_serializing_if = "Option::is_none", default)]
189 #[doc = "If target is different to 'node', we only lists shared storages which content is accessible on this 'node' and the specified 'target' node."]
190 #[doc = ""]
191 pub target: Option<String>,
192 #[serde(
193 flatten,
194 default,
195 skip_serializing_if = "::std::collections::HashMap::is_empty"
196 )]
197 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
198}
199#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
200#[doc = "The default format of the storage."]
201#[doc = ""]
202pub enum Default {
203 #[serde(rename = "qcow2")]
204 Qcow2,
205 #[serde(rename = "raw")]
206 Raw,
207 #[serde(rename = "subvol")]
208 Subvol,
209 #[serde(rename = "vmdk")]
210 Vmdk,
211}
212impl TryFrom<&str> for Default {
213 type Error = String;
214 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
215 match value {
216 "qcow2" => Ok(Self::Qcow2),
217 "raw" => Ok(Self::Raw),
218 "subvol" => Ok(Self::Subvol),
219 "vmdk" => Ok(Self::Vmdk),
220 v => Err(format!("Unknown variant {v}")),
221 }
222 }
223}
224#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
225pub enum Supported {
226 #[serde(rename = "qcow2")]
227 Qcow2,
228 #[serde(rename = "raw")]
229 Raw,
230 #[serde(rename = "subvol")]
231 Subvol,
232 #[serde(rename = "vmdk")]
233 Vmdk,
234}
235impl TryFrom<&str> for Supported {
236 type Error = String;
237 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
238 match value {
239 "qcow2" => Ok(Self::Qcow2),
240 "raw" => Ok(Self::Raw),
241 "subvol" => Ok(Self::Subvol),
242 "vmdk" => Ok(Self::Vmdk),
243 v => Err(format!("Unknown variant {v}")),
244 }
245 }
246}
247impl<T> StorageClient<T>
248where
249 T: crate::client::Client,
250{
251 pub fn storage(&self, storage: &str) -> storage::StorageClient<T> {
252 storage::StorageClient::<T>::new(self.client.clone(), &self.path, storage)
253 }
254}