fundamentum_sdk_api/client/
sdk_api.rs1use std::marker::PhantomData;
4
5use super::{
6 api_version::ApiVersion,
7 config::ClientConfig,
8 devices_api::{DevicesApi, DevicesApiConfig},
9 errors::SdkClientError,
10 provisioning_api::{ProvisioningApi, ProvisioningApiConfig},
11 sdk_client::SdkClient,
12 shelf_devices_api::{ShelfDevicesApi, ShelfDevicesApiConfig},
13};
14use crate::models::general::Status;
15
16pub struct SdkApi<V> {
20 client: SdkClient,
21 _marker: PhantomData<fn() -> V>,
22}
23
24impl<V: ApiVersion> SdkApi<V> {
25 #[must_use]
27 pub fn new(config: ClientConfig) -> Self {
28 let api_version = V::version_str();
29 let client = SdkClient::new(config, api_version);
30 Self {
31 client,
32 _marker: PhantomData,
33 }
34 }
35
36 pub async fn status(&self) -> Result<Status, SdkClientError> {
42 self.client.status().await
43 }
44
45 pub async fn get_openapi_json(&self) -> Result<serde_json::Value, SdkClientError> {
51 self.client.get_openapi_json().await
52 }
53
54 #[must_use]
56 pub fn devices_api<'a>(&'a self, api_config: &'a DevicesApiConfig) -> DevicesApi<'a, V> {
57 DevicesApi::new(&self.client, api_config)
58 }
59
60 #[must_use]
62 pub fn provisioning_api<'a>(
63 &'a self,
64 api_config: &'a ProvisioningApiConfig,
65 ) -> ProvisioningApi<'a, V> {
66 ProvisioningApi::new(&self.client, api_config)
67 }
68
69 #[must_use]
71 pub fn shelf_devices_api<'a>(
72 &'a self,
73 config: &'a ShelfDevicesApiConfig,
74 ) -> ShelfDevicesApi<'a, V> {
75 ShelfDevicesApi::new(&self.client, config)
76 }
77
78 #[must_use]
81 pub const fn get_sdk_client(&self) -> &SdkClient {
82 &self.client
83 }
84}