pve/nodes/node/disks/
lvmthin.rs

1pub mod name;
2
3#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
4pub struct GetResponseItem {
5    #[doc = "The name of the thinpool."]
6    pub lv: String,
7    #[doc = "The size of the thinpool in bytes."]
8    pub lv_size: u64,
9    #[doc = "The size of the metadata lv in bytes."]
10    pub metadata_size: u64,
11    #[doc = "The used bytes of the metadata lv."]
12    pub metadata_used: u64,
13    #[doc = "The used bytes of the thinpool."]
14    pub used: u64,
15    #[doc = "The associated volume group."]
16    pub vg: String,
17}
18
19#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
20pub struct PostParameters {
21    #[doc = "Configure storage using the thinpool."]
22    #[serde(
23        skip_serializing_if = "Option::is_none",
24        default,
25        deserialize_with = "crate::common::deserialize_option_bool_lax",
26        serialize_with = "crate::common::serialize_option_bool_as_u64"
27    )]
28    pub add_storage: Option<bool>,
29    #[doc = "The block device you want to create the thinpool on."]
30    pub device: String,
31    #[doc = "The storage identifier."]
32    pub name: String,
33}
34
35#[derive(Debug, Clone)]
36pub struct LvmthinClient<T> {
37    client: T,
38    path: String,
39}
40
41impl<T> LvmthinClient<T>
42where
43    T: Clone,
44{
45    pub fn new(client: T, parent_path: &str) -> Self {
46        Self {
47            client,
48            path: format!("{}/{}", parent_path, "lvmthin"),
49        }
50    }
51
52    pub fn name(&self, name: &str) -> name::NameClient<T> {
53        name::NameClient::<T>::new(self.client.clone(), &self.path, name)
54    }
55}
56impl<T> LvmthinClient<T>
57where
58    T: crate::client::HttpClient,
59{
60    #[doc = "List LVM thinpools"]
61    pub fn get(&self) -> Result<Vec<GetResponseItem>, T::Error> {
62        self.client.get(&self.path, &())
63    }
64
65    #[doc = "Create an LVM thinpool"]
66    pub fn post(&self, parameters: PostParameters) -> Result<String, T::Error> {
67        self.client.post(&self.path, &parameters)
68    }
69}
70#[derive(Debug, Clone)]
71pub struct AsyncLvmthinClient<T> {
72    client: T,
73    path: String,
74}
75
76impl<T> AsyncLvmthinClient<T>
77where
78    T: Clone,
79{
80    pub fn new(client: T, parent_path: &str) -> Self {
81        Self {
82            client,
83            path: format!("{}/{}", parent_path, "lvmthin"),
84        }
85    }
86
87    pub fn name(&self, name: &str) -> name::AsyncNameClient<T> {
88        name::AsyncNameClient::<T>::new(self.client.clone(), &self.path, name)
89    }
90}
91impl<T> AsyncLvmthinClient<T>
92where
93    T: crate::client::AsyncHttpClient,
94{
95    #[doc = "List LVM thinpools"]
96    pub async fn get(&self) -> Result<Vec<GetResponseItem>, T::Error> {
97        self.client.get(&self.path, &()).await
98    }
99
100    #[doc = "Create an LVM thinpool"]
101    pub async fn post(&self, parameters: PostParameters) -> Result<String, T::Error> {
102        self.client.post(&self.path, &parameters).await
103    }
104}