openai_core/resources/
batches.rs1use http::Method;
4
5use crate::generated::endpoints;
6
7use super::{
8 Batch, BatchCreateRequestBuilder, BatchesResource, JsonRequestBuilder, ListRequestBuilder,
9 encode_path_segment,
10};
11
12impl BatchesResource {
13 pub fn create(&self) -> BatchCreateRequestBuilder {
15 BatchCreateRequestBuilder::new(self.client.clone())
16 }
17
18 pub fn retrieve(&self, batch_id: impl Into<String>) -> JsonRequestBuilder<Batch> {
20 let endpoint = endpoints::batches::BATCHES_RETRIEVE;
21 JsonRequestBuilder::new(
22 self.client.clone(),
23 endpoint.id,
24 Method::GET,
25 endpoint.render(&[("batch_id", &encode_path_segment(batch_id.into()))]),
26 )
27 }
28
29 pub fn list(&self) -> ListRequestBuilder<Batch> {
31 let endpoint = endpoints::batches::BATCHES_LIST;
32 ListRequestBuilder::new(self.client.clone(), endpoint.id, endpoint.template)
33 }
34
35 pub fn cancel(&self, batch_id: impl Into<String>) -> JsonRequestBuilder<Batch> {
37 let endpoint = endpoints::batches::BATCHES_CANCEL;
38 JsonRequestBuilder::new(
39 self.client.clone(),
40 endpoint.id,
41 Method::POST,
42 endpoint.render(&[("batch_id", &encode_path_segment(batch_id.into()))]),
43 )
44 }
45}