proxmox_api/generated/
nodes.rs1pub mod node;
2#[derive(Debug, Clone)]
3pub struct NodesClient<T> {
4 client: T,
5 path: String,
6}
7impl<T> NodesClient<T>
8where
9 T: crate::client::Client,
10{
11 pub fn new(client: T) -> Self {
12 Self {
13 client,
14 path: "/nodes".to_string(),
15 }
16 }
17}
18impl<T> NodesClient<T>
19where
20 T: crate::client::Client,
21{
22 #[doc = "Cluster node index."]
23 #[doc = ""]
24 pub async fn get(&self) -> Result<Vec<GetOutputItems>, T::Error> {
25 let path = self.path.to_string();
26 let optional_vec: Option<Vec<GetOutputItems>> = self.client.get(&path, &()).await?;
27 Ok(optional_vec.unwrap_or_default())
28 }
29}
30impl GetOutputItems {
31 pub fn new(node: String, status: Status) -> Self {
32 Self {
33 node,
34 status,
35 cpu: ::std::default::Default::default(),
36 level: ::std::default::Default::default(),
37 maxcpu: ::std::default::Default::default(),
38 maxmem: ::std::default::Default::default(),
39 mem: ::std::default::Default::default(),
40 ssl_fingerprint: ::std::default::Default::default(),
41 uptime: ::std::default::Default::default(),
42 additional_properties: ::std::default::Default::default(),
43 }
44 }
45}
46#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
47pub struct GetOutputItems {
48 #[serde(
49 serialize_with = "crate::types::serialize_number_optional",
50 deserialize_with = "crate::types::deserialize_number_optional"
51 )]
52 #[serde(skip_serializing_if = "Option::is_none", default)]
53 #[doc = "CPU utilization."]
54 #[doc = ""]
55 pub cpu: Option<f64>,
56 #[serde(skip_serializing_if = "Option::is_none", default)]
57 #[doc = "Support level."]
58 #[doc = ""]
59 pub level: Option<String>,
60 #[serde(
61 serialize_with = "crate::types::serialize_int_optional",
62 deserialize_with = "crate::types::deserialize_int_optional"
63 )]
64 #[serde(skip_serializing_if = "Option::is_none", default)]
65 #[doc = "Number of available CPUs."]
66 #[doc = ""]
67 pub maxcpu: Option<i64>,
68 #[serde(
69 serialize_with = "crate::types::serialize_int_optional",
70 deserialize_with = "crate::types::deserialize_int_optional"
71 )]
72 #[serde(skip_serializing_if = "Option::is_none", default)]
73 #[doc = "Number of available memory in bytes."]
74 #[doc = ""]
75 pub maxmem: Option<i64>,
76 #[serde(
77 serialize_with = "crate::types::serialize_int_optional",
78 deserialize_with = "crate::types::deserialize_int_optional"
79 )]
80 #[serde(skip_serializing_if = "Option::is_none", default)]
81 #[doc = "Used memory in bytes."]
82 #[doc = ""]
83 pub mem: Option<i64>,
84 #[doc = "The cluster node name."]
85 #[doc = ""]
86 pub node: String,
87 #[serde(skip_serializing_if = "Option::is_none", default)]
88 #[doc = "The SSL fingerprint for the node certificate."]
89 #[doc = ""]
90 pub ssl_fingerprint: Option<String>,
91 #[doc = "Node status."]
92 #[doc = ""]
93 pub status: Status,
94 #[serde(
95 serialize_with = "crate::types::serialize_int_optional",
96 deserialize_with = "crate::types::deserialize_int_optional"
97 )]
98 #[serde(skip_serializing_if = "Option::is_none", default)]
99 #[doc = "Node uptime in seconds."]
100 #[doc = ""]
101 pub uptime: Option<i64>,
102 #[serde(
103 flatten,
104 default,
105 skip_serializing_if = "::std::collections::HashMap::is_empty"
106 )]
107 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
108}
109#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
110#[doc = "Node status."]
111#[doc = ""]
112pub enum Status {
113 #[serde(rename = "offline")]
114 Offline,
115 #[serde(rename = "online")]
116 Online,
117 #[serde(rename = "unknown")]
118 Unknown,
119}
120impl TryFrom<&str> for Status {
121 type Error = String;
122 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
123 match value {
124 "offline" => Ok(Self::Offline),
125 "online" => Ok(Self::Online),
126 "unknown" => Ok(Self::Unknown),
127 v => Err(format!("Unknown variant {v}")),
128 }
129 }
130}
131impl<T> NodesClient<T>
132where
133 T: crate::client::Client,
134{
135 pub fn node(&self, node: &str) -> node::NodeClient<T> {
136 node::NodeClient::<T>::new(self.client.clone(), &self.path, node)
137 }
138}