Skip to main content

proxmox_api/generated/nodes/node/disks/
smart.rs

1#[derive(Debug, Clone)]
2pub struct SmartClient<T> {
3    client: T,
4    path: String,
5}
6impl<T> SmartClient<T>
7where
8    T: crate::client::Client,
9{
10    pub fn new(client: T, parent_path: &str) -> Self {
11        Self {
12            client,
13            path: format!("{}{}", parent_path, "/smart"),
14        }
15    }
16}
17impl<T> SmartClient<T>
18where
19    T: crate::client::Client,
20{
21    #[doc = "Get SMART Health of a disk."]
22    #[doc = ""]
23    #[doc = "Permission check: perm(\"/\", [\"Sys.Audit\"])"]
24    pub async fn get(&self, params: GetParams) -> Result<GetOutput, T::Error> {
25        let path = self.path.to_string();
26        self.client.get(&path, &params).await
27    }
28}
29impl GetOutput {
30    pub fn new(health: String) -> Self {
31        Self {
32            health,
33            text: ::std::default::Default::default(),
34            ty: ::std::default::Default::default(),
35            additional_properties: ::std::default::Default::default(),
36        }
37    }
38}
39#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
40pub struct GetOutput {
41    pub health: String,
42    #[serde(skip_serializing_if = "Option::is_none", default)]
43    pub text: Option<String>,
44    #[serde(rename = "type")]
45    #[serde(skip_serializing_if = "Option::is_none", default)]
46    pub ty: Option<String>,
47    #[serde(
48        flatten,
49        default,
50        skip_serializing_if = "::std::collections::HashMap::is_empty"
51    )]
52    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
53}
54impl GetParams {
55    pub fn new(disk: DiskStr) -> Self {
56        Self {
57            disk,
58            healthonly: ::std::default::Default::default(),
59            additional_properties: ::std::default::Default::default(),
60        }
61    }
62}
63#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
64pub struct GetParams {
65    #[doc = "Block device name"]
66    #[doc = ""]
67    pub disk: DiskStr,
68    #[serde(
69        serialize_with = "crate::types::serialize_bool_optional",
70        deserialize_with = "crate::types::deserialize_bool_optional"
71    )]
72    #[serde(skip_serializing_if = "Option::is_none", default)]
73    #[doc = "If true returns only the health status"]
74    #[doc = ""]
75    pub healthonly: Option<bool>,
76    #[serde(
77        flatten,
78        default,
79        skip_serializing_if = "::std::collections::HashMap::is_empty"
80    )]
81    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
82}
83#[derive(Debug, Clone, PartialEq, PartialOrd)]
84pub struct DiskStr {
85    value: String,
86}
87impl crate::types::bounded_string::BoundedString for DiskStr {
88    const MIN_LENGTH: Option<usize> = None::<usize>;
89    const MAX_LENGTH: Option<usize> = None::<usize>;
90    const DEFAULT: Option<&'static str> = None::<&'static str>;
91    const PATTERN: Option<&'static str> = Some("^/dev/[a-zA-Z0-9\\/]+$");
92    const TYPE_DESCRIPTION: &'static str =
93        "a string with pattern r\"^/dev/[a-zA-Z0-9\\/]+$\" and no length constraints";
94    fn get_value(&self) -> &str {
95        &self.value
96    }
97    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
98        Self::validate(&value)?;
99        Ok(Self { value })
100    }
101}
102impl std::convert::TryFrom<String> for DiskStr {
103    type Error = crate::types::bounded_string::BoundedStringError;
104    fn try_from(value: String) -> Result<Self, Self::Error> {
105        crate::types::bounded_string::BoundedString::new(value)
106    }
107}
108impl ::serde::Serialize for DiskStr {
109    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
110    where
111        S: ::serde::Serializer,
112    {
113        crate::types::bounded_string::serialize_bounded_string(self, serializer)
114    }
115}
116impl<'de> ::serde::Deserialize<'de> for DiskStr {
117    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
118    where
119        D: ::serde::Deserializer<'de>,
120    {
121        crate::types::bounded_string::deserialize_bounded_string(deserializer)
122    }
123}