use url::Url;
use crate::{
errors::OapiError,
fine_tuning::FineTuningJob,
rest::post::{Post, PostNoStream},
};
#[derive(Debug, Clone, serde::Serialize)]
pub struct CancelFineTuningJobRequest<'a> {
#[serde(skip)]
pub job_id: &'a str,
}
impl Post for CancelFineTuningJobRequest<'_> {
fn is_streaming(&self) -> bool {
false
}
fn build_url(&self, base_url: &str) -> Result<String, OapiError> {
let mut url = Url::parse(base_url.trim_end_matches('/')).map_err(OapiError::UrlError)?;
url.path_segments_mut()
.map_err(|_| OapiError::UrlCannotBeBase(base_url.to_string()))?
.push("fine_tuning")
.push("jobs")
.push(self.job_id)
.push("cancel");
Ok(url.to_string())
}
}
impl PostNoStream for CancelFineTuningJobRequest<'_> {
type Response = FineTuningJob;
}