1pub mod groups;
2pub mod resources;
3pub mod status;
4
5#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
6pub struct GetResponseItem {
7 pub id: String,
8}
9
10#[derive(Debug, Clone)]
11pub struct HaClient<T> {
12 client: T,
13 path: String,
14}
15
16impl<T> HaClient<T>
17where
18 T: Clone,
19{
20 pub fn new(client: T, parent_path: &str) -> Self {
21 Self {
22 client,
23 path: format!("{}/{}", parent_path, "ha"),
24 }
25 }
26
27 pub fn resources(&self) -> resources::ResourcesClient<T> {
28 resources::ResourcesClient::<T>::new(self.client.clone(), &self.path)
29 }
30
31 pub fn groups(&self) -> groups::GroupsClient<T> {
32 groups::GroupsClient::<T>::new(self.client.clone(), &self.path)
33 }
34
35 pub fn status(&self) -> status::StatusClient<T> {
36 status::StatusClient::<T>::new(self.client.clone(), &self.path)
37 }
38}
39impl<T> HaClient<T>
40where
41 T: crate::client::HttpClient,
42{
43 #[doc = "Directory index."]
44 pub fn get(&self) -> Result<Vec<GetResponseItem>, T::Error> {
45 self.client.get(&self.path, &())
46 }
47}
48#[derive(Debug, Clone)]
49pub struct AsyncHaClient<T> {
50 client: T,
51 path: String,
52}
53
54impl<T> AsyncHaClient<T>
55where
56 T: Clone,
57{
58 pub fn new(client: T, parent_path: &str) -> Self {
59 Self {
60 client,
61 path: format!("{}/{}", parent_path, "ha"),
62 }
63 }
64
65 pub fn resources(&self) -> resources::AsyncResourcesClient<T> {
66 resources::AsyncResourcesClient::<T>::new(self.client.clone(), &self.path)
67 }
68
69 pub fn groups(&self) -> groups::AsyncGroupsClient<T> {
70 groups::AsyncGroupsClient::<T>::new(self.client.clone(), &self.path)
71 }
72
73 pub fn status(&self) -> status::AsyncStatusClient<T> {
74 status::AsyncStatusClient::<T>::new(self.client.clone(), &self.path)
75 }
76}
77impl<T> AsyncHaClient<T>
78where
79 T: crate::client::AsyncHttpClient,
80{
81 #[doc = "Directory index."]
82 pub async fn get(&self) -> Result<Vec<GetResponseItem>, T::Error> {
83 self.client.get(&self.path, &()).await
84 }
85}