openai_interface/batches/
cancel.rs1use url::Url;
10
11use crate::{
12 batches::Batch,
13 errors::OapiError,
14 rest::post::{Post, PostNoStream},
15};
16
17#[derive(Debug, Clone, serde::Serialize)]
19pub struct CancelBatchRequest<'a> {
20 #[serde(skip)]
22 pub batch_id: &'a str,
23}
24
25impl Post for CancelBatchRequest<'_> {
26 fn is_streaming(&self) -> bool {
27 false
28 }
29
30 fn build_url(&self, base_url: &str) -> Result<String, OapiError> {
34 let mut url = Url::parse(base_url.trim_end_matches('/')).map_err(OapiError::UrlError)?;
35 url.path_segments_mut()
36 .map_err(|_| OapiError::UrlCannotBeBase(base_url.to_string()))?
37 .push("batches")
38 .push(self.batch_id)
39 .push("cancel");
40 Ok(url.to_string())
41 }
42}
43
44impl PostNoStream for CancelBatchRequest<'_> {
45 type Response = Batch;
46}