use crate::client::Call;
use crate::error::Result;
use crate::model::system::{
LogDumpResponse, NetworkInterfaceInfo, Status, StatusDevice, StatusFirmware, StatusPower,
StatusSystem, TransportType, VersionInfo,
};
use crate::transport::HttpTransport;
use crate::types::log_name::LogName;
crate::api::endpoint!(
System
);
impl<T: HttpTransport> System<'_, T> {
pub async fn version(&self) -> Result<String> {
let response: VersionInfo = self.client.json(Call::get("version")).await?;
Ok(response.api_semver)
}
pub async fn transport(&self) -> Result<TransportType> {
let response: NetworkInterfaceInfo = self.client.json(Call::get("transport")).await?;
Ok(response.r#type)
}
pub async fn status(&self) -> Result<Status> {
self.client.json(Call::get("status")).await
}
pub async fn status_device(&self) -> Result<StatusDevice> {
self.client.json(Call::get("status/device")).await
}
pub async fn status_firmware(&self) -> Result<StatusFirmware> {
self.client.json(Call::get("status/firmware")).await
}
pub async fn status_system(&self) -> Result<StatusSystem> {
self.client.json(Call::get("status/system")).await
}
pub async fn status_power(&self) -> Result<StatusPower> {
self.client.json(Call::get("status/power")).await
}
pub async fn log_dump(&self, filename: Option<LogName>) -> Result<String> {
let request = Call::post("log_dump").maybe_query("filename", filename);
let response: LogDumpResponse = self.client.json(request).await?;
Ok(response.path)
}
}