edgequake_sdk/resources/
documents.rs1use crate::client::EdgeQuakeClient;
4use crate::error::Result;
5use crate::types::documents::*;
6use crate::types::operations::DocumentFullLineage;
7
8pub struct DocumentsResource<'a> {
9 pub(crate) client: &'a EdgeQuakeClient,
10}
11
12impl<'a> DocumentsResource<'a> {
13 pub async fn list(&self) -> Result<ListDocumentsResponse> {
15 self.client.get("/api/v1/documents").await
16 }
17
18 pub async fn get(&self, id: &str) -> Result<DocumentSummary> {
20 self.client.get(&format!("/api/v1/documents/{id}")).await
21 }
22
23 pub async fn delete(&self, id: &str) -> Result<()> {
25 self.client.delete_no_content(&format!("/api/v1/documents/{id}")).await
26 }
27
28 pub async fn status(&self, id: &str) -> Result<TrackStatusResponse> {
30 self.client
31 .get(&format!("/api/v1/documents/{id}/status"))
32 .await
33 }
34
35 pub async fn upload_text(&self, body: &serde_json::Value) -> Result<UploadDocumentResponse> {
37 self.client
38 .post("/api/v1/documents/upload/text", Some(body))
39 .await
40 }
41
42 pub async fn scan(&self, req: &ScanRequest) -> Result<ScanResponse> {
44 self.client.post("/api/v1/documents/scan", Some(req)).await
45 }
46
47 pub async fn deletion_impact(&self, id: &str) -> Result<DeletionImpactResponse> {
49 self.client
50 .get(&format!("/api/v1/documents/{id}/deletion-impact"))
51 .await
52 }
53
54 pub async fn track(&self, track_id: &str) -> Result<TrackStatusResponse> {
56 self.client
57 .get(&format!("/api/v1/documents/track/{track_id}"))
58 .await
59 }
60
61 pub async fn get_lineage(&self, id: &str) -> Result<DocumentFullLineage> {
70 self.client
71 .get(&format!("/api/v1/documents/{id}/lineage"))
72 .await
73 }
74
75 pub async fn get_metadata(&self, id: &str) -> Result<serde_json::Value> {
80 self.client
81 .get(&format!("/api/v1/documents/{id}/metadata"))
82 .await
83 }
84
85 pub async fn delete_all(&self) -> Result<serde_json::Value> {
91 self.client.delete("/api/v1/documents").await
92 }
93
94 pub async fn reprocess(&self) -> Result<serde_json::Value> {
96 self.client
97 .post::<(), serde_json::Value>("/api/v1/documents/reprocess", None)
98 .await
99 }
100
101 pub async fn recover_stuck(&self) -> Result<serde_json::Value> {
103 self.client
104 .post::<(), serde_json::Value>("/api/v1/documents/recover-stuck", None)
105 .await
106 }
107
108 pub async fn retry_chunks(&self, id: &str) -> Result<serde_json::Value> {
110 self.client
111 .post::<(), serde_json::Value>(
112 &format!("/api/v1/documents/{id}/retry-chunks"),
113 None,
114 )
115 .await
116 }
117
118 pub async fn failed_chunks(&self, id: &str) -> Result<Vec<serde_json::Value>> {
120 self.client
121 .get(&format!("/api/v1/documents/{id}/failed-chunks"))
122 .await
123 }
124}