Skip to main content

zai_rs/knowledge/
delete.rs

1use crate::client::ZaiClient;
2
3/// Knowledge delete request (DELETE /llm-application/open/knowledge/{id})
4///
5/// Credentials and transport live on the [`ZaiClient`], passed to
6/// [`send_via`](Self::send_via).
7pub struct KnowledgeDeleteRequest {
8    id: String,
9}
10
11impl KnowledgeDeleteRequest {
12    /// Build a delete request with target id.
13    pub fn new(id: impl Into<String>) -> Self {
14        Self { id: id.into() }
15    }
16
17    /// Send via a [`ZaiClient`] and parse the typed response.
18    pub async fn send_via(&self, client: &ZaiClient) -> crate::ZaiResult<KnowledgeDeleteResponse> {
19        let route = crate::client::routes::KNOWLEDGE_DELETE;
20        let url = client.endpoints().resolve_route(route, &[&self.id])?;
21        client
22            .send_empty::<KnowledgeDeleteResponse>(route.method(), url)
23            .await
24    }
25}
26
27/// Delete response envelope without data
28#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, validator::Validate)]
29pub struct KnowledgeDeleteResponse {
30    /// Business status code.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub code: Option<i64>,
33    /// Human-readable message.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub message: Option<String>,
36    /// Server timestamp.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub timestamp: Option<u64>,
39}