|
|
@ -3,7 +3,7 @@ use tokio::time::Duration;
|
|
|
|
|
|
|
|
|
|
|
|
use crate::client_api::error::ApiResult;
|
|
|
|
use crate::client_api::error::ApiResult;
|
|
|
|
use crate::client_api::IPCApi;
|
|
|
|
use crate::client_api::IPCApi;
|
|
|
|
use crate::types::repo::{FrontendState, RepositoryMetadata};
|
|
|
|
use crate::types::repo::{FrontendState, RepositoryMetadata, SizeMetadata, SizeType};
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub struct RepoApi {
|
|
|
|
pub struct RepoApi {
|
|
|
@ -28,17 +28,19 @@ impl RepoApi {
|
|
|
|
/// Returns metadata about the repository
|
|
|
|
/// Returns metadata about the repository
|
|
|
|
#[tracing::instrument(level = "debug", skip(self))]
|
|
|
|
#[tracing::instrument(level = "debug", skip(self))]
|
|
|
|
pub async fn get_repo_metadata(&self) -> ApiResult<RepositoryMetadata> {
|
|
|
|
pub async fn get_repo_metadata(&self) -> ApiResult<RepositoryMetadata> {
|
|
|
|
let metadata = self.emit_and_get("repository_metadata", (), Some(Duration::from_secs(30))).await?;
|
|
|
|
self.emit_and_get("repository_metadata", (), Some(Duration::from_secs(3))).await
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Ok(metadata)
|
|
|
|
/// Returns the size of a given type
|
|
|
|
|
|
|
|
#[tracing::instrument(level = "debug", skip(self))]
|
|
|
|
|
|
|
|
pub async fn get_size(&self, size_type: SizeType) -> ApiResult<SizeMetadata> {
|
|
|
|
|
|
|
|
self.emit_and_get("size_metadata", (), Some(Duration::from_secs(30))).await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Returns the state of the frontend that is stored in the repo
|
|
|
|
/// Returns the state of the frontend that is stored in the repo
|
|
|
|
#[tracing::instrument(level = "debug", skip(self))]
|
|
|
|
#[tracing::instrument(level = "debug", skip(self))]
|
|
|
|
pub async fn get_frontend_state(&self) -> ApiResult<FrontendState> {
|
|
|
|
pub async fn get_frontend_state(&self) -> ApiResult<FrontendState> {
|
|
|
|
let state = self.emit_and_get("frontend_state", (), Some(Duration::from_secs(5))).await?;
|
|
|
|
self.emit_and_get("frontend_state", (), Some(Duration::from_secs(5))).await
|
|
|
|
|
|
|
|
|
|
|
|
Ok(state)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Sets the state of the frontend
|
|
|
|
/// Sets the state of the frontend
|
|
|
|