Skip to main content

zai_rs/knowledge/
delete.rs

1use crate::client::ZaiClient;
2
3use super::types::KnowledgeOperationResponse;
4
5/// Knowledge delete request (DELETE /llm-application/open/knowledge/{id})
6///
7/// Credentials and transport live on the [`ZaiClient`], passed to
8/// [`send_via`](Self::send_via).
9pub struct KnowledgeDeleteRequest {
10    id: String,
11}
12
13impl KnowledgeDeleteRequest {
14    /// Build a delete request with target id.
15    pub fn new(id: impl Into<String>) -> Self {
16        Self { id: id.into() }
17    }
18
19    /// Send via a [`ZaiClient`] and parse the typed response.
20    pub async fn send_via(&self, client: &ZaiClient) -> crate::ZaiResult<KnowledgeDeleteResponse> {
21        crate::client::validation::require_non_blank(&self.id, "knowledge_id")?;
22        let route = crate::client::routes::KNOWLEDGE_DELETE;
23        let url = client.endpoints().resolve_route(route, &[&self.id])?;
24        client
25            .send_empty::<KnowledgeDeleteResponse>(route.method(), url)
26            .await
27    }
28}
29
30/// Delete response envelope without data.
31pub type KnowledgeDeleteResponse = KnowledgeOperationResponse;