rust api: implement update_submission_model
This commit is contained in:
parent
1133e00ccc
commit
b7d04da9e0
@ -48,6 +48,13 @@ pub struct ScriptPolicyResponse{
|
|||||||
pub Policy:Policy
|
pub Policy:Policy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(nonstandard_style)]
|
||||||
|
pub struct UpdateSubmissionModelRequest{
|
||||||
|
pub ID:i64,
|
||||||
|
pub ModelID:u64,
|
||||||
|
pub ModelVersion:u64,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Context{
|
pub struct Context{
|
||||||
base_url:String,
|
base_url:String,
|
||||||
@ -77,9 +84,8 @@ impl Context{
|
|||||||
self.client.get(url)
|
self.client.get(url)
|
||||||
.send().await
|
.send().await
|
||||||
}
|
}
|
||||||
async fn patch(&self,url:impl reqwest::IntoUrl,body:impl Into<reqwest::Body>)->Result<reqwest::Response,reqwest::Error>{
|
async fn patch(&self,url:impl reqwest::IntoUrl)->Result<reqwest::Response,reqwest::Error>{
|
||||||
self.client.patch(url)
|
self.client.patch(url)
|
||||||
.body(body)
|
|
||||||
.send().await
|
.send().await
|
||||||
}
|
}
|
||||||
pub async fn get_script(&self,config:GetScriptRequest)->Result<ScriptResponse,GetError>{
|
pub async fn get_script(&self,config:GetScriptRequest)->Result<ScriptResponse,GetError>{
|
||||||
@ -98,4 +104,19 @@ impl Context{
|
|||||||
.error_for_status().map_err(GetError::Reqwest)?
|
.error_for_status().map_err(GetError::Reqwest)?
|
||||||
.json().await.map_err(GetError::Reqwest)
|
.json().await.map_err(GetError::Reqwest)
|
||||||
}
|
}
|
||||||
|
pub async fn update_submission_model(&self,config:UpdateSubmissionModelRequest)->Result<(),GetError>{
|
||||||
|
let url_raw=format!("{}/submissions/{}/model",self.base_url,config.ID);
|
||||||
|
let mut url=reqwest::Url::parse(url_raw.as_str()).map_err(GetError::ParseError)?;
|
||||||
|
|
||||||
|
{
|
||||||
|
url.query_pairs_mut()
|
||||||
|
.append_pair("ModelID",config.ModelID.to_string().as_str())
|
||||||
|
.append_pair("ModelVersion",config.ModelVersion.to_string().as_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
self.patch(url).await.map_err(GetError::Reqwest)?
|
||||||
|
.error_for_status().map_err(GetError::Reqwest)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user