use crate::client::EdgeQuakeClient;
use crate::error::Result;
use crate::types::workspaces::*;
pub struct WorkspacesResource<'a> {
pub(crate) client: &'a EdgeQuakeClient,
}
impl<'a> WorkspacesResource<'a> {
pub async fn list(&self, tenant_id: &str) -> Result<Vec<WorkspaceInfo>> {
self.client
.get(&format!("/api/v1/tenants/{tenant_id}/workspaces"))
.await
}
pub async fn create(
&self,
tenant_id: &str,
req: &CreateWorkspaceRequest,
) -> Result<WorkspaceInfo> {
self.client
.post(
&format!("/api/v1/tenants/{tenant_id}/workspaces"),
Some(req),
)
.await
}
pub async fn stats(&self, workspace_id: &str) -> Result<WorkspaceStats> {
self.client
.get(&format!("/api/v1/workspaces/{workspace_id}/stats"))
.await
}
pub async fn rebuild(&self, workspace_id: &str) -> Result<RebuildResponse> {
self.client
.post::<(), RebuildResponse>(
&format!("/api/v1/workspaces/{workspace_id}/rebuild"),
None,
)
.await
}
pub async fn get(&self, workspace_id: &str) -> Result<WorkspaceInfo> {
self.client
.get(&format!("/api/v1/workspaces/{workspace_id}"))
.await
}
pub async fn update(
&self,
workspace_id: &str,
body: &serde_json::Value,
) -> Result<WorkspaceInfo> {
self.client
.put(
&format!("/api/v1/workspaces/{workspace_id}"),
Some(body),
)
.await
}
pub async fn delete(&self, workspace_id: &str) -> Result<()> {
self.client
.delete_no_content(&format!("/api/v1/workspaces/{workspace_id}"))
.await
}
pub async fn metrics_history(&self, workspace_id: &str) -> Result<Vec<serde_json::Value>> {
self.client
.get(&format!("/api/v1/workspaces/{workspace_id}/metrics-history"))
.await
}
pub async fn rebuild_embeddings(&self, workspace_id: &str) -> Result<serde_json::Value> {
self.client
.post::<(), serde_json::Value>(
&format!("/api/v1/workspaces/{workspace_id}/rebuild-embeddings"),
None,
)
.await
}
pub async fn rebuild_knowledge_graph(&self, workspace_id: &str) -> Result<serde_json::Value> {
self.client
.post::<(), serde_json::Value>(
&format!("/api/v1/workspaces/{workspace_id}/rebuild-knowledge-graph"),
None,
)
.await
}
pub async fn reprocess_documents(&self, workspace_id: &str) -> Result<serde_json::Value> {
self.client
.post::<(), serde_json::Value>(
&format!("/api/v1/workspaces/{workspace_id}/reprocess-documents"),
None,
)
.await
}
}