Skip to main content

zai_rs/batches/
retrieve.rs

1use super::types::BatchItem;
2use crate::{ZaiResult, client::ZaiClient};
3
4/// Retrieve a batch task by ID (GET /paas/v4/batches/{batch_id})
5pub struct BatchGetRequest {
6    batch_id: String,
7}
8
9impl BatchGetRequest {
10    /// Create a new retrieve request with required path parameter `batch_id`.
11    pub fn new(batch_id: impl Into<String>) -> Self {
12        Self {
13            batch_id: batch_id.into(),
14        }
15    }
16
17    /// Send request via a [`ZaiClient`] and parse typed response as a single
18    /// BatchItem
19    pub async fn send_via(&self, client: &ZaiClient) -> ZaiResult<BatchGetResponse> {
20        crate::client::validation::require_non_blank(&self.batch_id, "batch_id")?;
21        let route = crate::client::routes::BATCHES_GET;
22        let url = client.endpoints().resolve_route(route, &[&self.batch_id])?;
23        client
24            .send_empty::<BatchGetResponse>(route.method(), url)
25            .await
26    }
27}
28
29/// Response type: a single Batch object
30pub type BatchGetResponse = BatchItem;