Skip to main content

zai_rs/knowledge/
document_image_list.rs

1use super::types::DocumentImageListResponse;
2use crate::client::ZaiClient;
3
4/// Retrieve parsed image index-url mapping for a document (POST, no body)
5///
6/// Credentials and transport live on the [`ZaiClient`], passed to
7/// [`send_via`](Self::send_via).
8pub struct DocumentImageListRequest {
9    document_id: String,
10}
11
12impl DocumentImageListRequest {
13    /// Create a new request with the target document id
14    pub fn new(document_id: impl Into<String>) -> Self {
15        Self {
16            document_id: document_id.into(),
17        }
18    }
19
20    /// Send the POST request via a [`ZaiClient`] and parse the typed response.
21    pub async fn send_via(
22        &self,
23        client: &ZaiClient,
24    ) -> crate::ZaiResult<DocumentImageListResponse> {
25        crate::client::validation::require_non_blank(&self.document_id, "document_id")?;
26        let route = crate::client::routes::DOCUMENTS_IMAGES;
27        let url = client
28            .endpoints()
29            .resolve_route(route, &[&self.document_id])?;
30        client
31            .send_empty::<DocumentImageListResponse>(route.method(), url)
32            .await
33    }
34}