1use nanocl_error::http_client::HttpClientResult;
2
3use nanocl_stubs::node::Node;
4
5use super::http_client::NanocldClient;
6
7impl NanocldClient {
8 const NODE_PATH: &'static str = "/nodes";
10
11 pub async fn list_node(&self) -> HttpClientResult<Vec<Node>> {
23 let res = self.send_get(Self::NODE_PATH, None::<String>).await?;
24 Self::res_json(res).await
25 }
26}
27
28#[cfg(test)]
29mod tests {
30 use crate::ConnectOpts;
31
32 use super::*;
33
34 #[ntex::test]
35 async fn basic() {
36 let client = NanocldClient::connect_to(&ConnectOpts {
37 url: "http://nanocl.internal:8585".into(),
38 ..Default::default()
39 })
40 .expect("Failed to create a nanocl client");
41 let node = client.list_node().await;
42 assert!(node.is_ok());
43 }
44}