validation: update api
This commit is contained in:
parent
621edbdbe0
commit
246b8a7dc8
@ -1,86 +1,4 @@
|
|||||||
use crate::Error;
|
use crate::types::*;
|
||||||
|
|
||||||
#[derive(Clone,Copy,serde::Serialize,serde::Deserialize)]
|
|
||||||
pub struct ScriptID(i64);
|
|
||||||
#[derive(Clone,Copy,serde::Serialize,serde::Deserialize)]
|
|
||||||
pub struct ScriptPolicyID(i64);
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
pub struct GetScriptRequest{
|
|
||||||
pub ScriptID:ScriptID,
|
|
||||||
}
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(serde::Deserialize)]
|
|
||||||
pub struct ScriptResponse{
|
|
||||||
pub ID:i64,
|
|
||||||
pub Name:String,
|
|
||||||
pub Hash:String,
|
|
||||||
pub Source:String,
|
|
||||||
pub SubmissionID:i64,
|
|
||||||
}
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(serde::Serialize)]
|
|
||||||
pub struct CreateScriptRequest<'a>{
|
|
||||||
pub Name:&'a str,
|
|
||||||
pub Source:&'a str,
|
|
||||||
pub SubmissionID:Option<i64>,
|
|
||||||
}
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(serde::Deserialize)]
|
|
||||||
pub struct ScriptIDResponse{
|
|
||||||
pub ID:ScriptID,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(serde_repr::Serialize_repr,serde_repr::Deserialize_repr)]
|
|
||||||
#[repr(i32)]
|
|
||||||
pub enum Policy{
|
|
||||||
None=0, // not yet reviewed
|
|
||||||
Allowed=1,
|
|
||||||
Blocked=2,
|
|
||||||
Delete=3,
|
|
||||||
Replace=4,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct ScriptPolicyHashRequest<'a>{
|
|
||||||
pub hash:&'a str,
|
|
||||||
}
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(serde::Deserialize)]
|
|
||||||
pub struct ScriptPolicyResponse{
|
|
||||||
pub ID:i64,
|
|
||||||
pub FromScriptHash:String,
|
|
||||||
pub ToScriptID:ScriptID,
|
|
||||||
pub Policy:Policy
|
|
||||||
}
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(serde::Serialize)]
|
|
||||||
pub struct CreateScriptPolicyRequest{
|
|
||||||
pub FromScriptID:ScriptID,
|
|
||||||
pub ToScriptID:ScriptID,
|
|
||||||
pub Policy:Policy,
|
|
||||||
}
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(serde::Deserialize)]
|
|
||||||
pub struct ScriptPolicyIDResponse{
|
|
||||||
pub ID:ScriptPolicyID,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(serde::Serialize)]
|
|
||||||
pub struct UpdateScriptPolicyRequest{
|
|
||||||
pub ScriptPolicyID:ScriptPolicyID,
|
|
||||||
pub FromScriptID:Option<ScriptID>,
|
|
||||||
pub ToScriptID:Option<ScriptID>,
|
|
||||||
pub Policy:Option<Policy>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
pub struct ActionSubmissionUploadedRequest{
|
|
||||||
pub SubmissionID:i64,
|
|
||||||
pub TargetAssetID:Option<u64>,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct SubmissionID(pub i64);
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Context(crate::context::Context);
|
pub struct Context(crate::context::Context);
|
||||||
@ -91,51 +9,120 @@ impl Context{
|
|||||||
}
|
}
|
||||||
pub async fn get_script(&self,config:GetScriptRequest)->Result<ScriptResponse,Error>{
|
pub async fn get_script(&self,config:GetScriptRequest)->Result<ScriptResponse,Error>{
|
||||||
let url_raw=format!("{}/scripts/{}",self.0.base_url,config.ScriptID.0);
|
let url_raw=format!("{}/scripts/{}",self.0.base_url,config.ScriptID.0);
|
||||||
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::ParseError)?;
|
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
||||||
|
|
||||||
crate::response_ok(
|
response_ok(
|
||||||
self.0.get(url).await.map_err(Error::Reqwest)?
|
self.0.get(url).await.map_err(Error::Reqwest)?
|
||||||
).await.map_err(Error::Response)?
|
).await.map_err(Error::Response)?
|
||||||
.json().await.map_err(Error::Reqwest)
|
.json().await.map_err(Error::Reqwest)
|
||||||
}
|
}
|
||||||
|
pub async fn get_scripts<'a>(&self,config:GetScriptsRequest<'a>)->Result<Vec<ScriptResponse>,Error>{
|
||||||
|
let url_raw=format!("{}/scripts",self.0.base_url);
|
||||||
|
let mut url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
||||||
|
|
||||||
|
{
|
||||||
|
let mut query_pairs=url.query_pairs_mut();
|
||||||
|
query_pairs.append_pair("Page",config.Page.to_string().as_str());
|
||||||
|
query_pairs.append_pair("Limit",config.Limit.to_string().as_str());
|
||||||
|
if let Some(name)=config.Name{
|
||||||
|
query_pairs.append_pair("Name",name);
|
||||||
|
}
|
||||||
|
if let Some(hash)=config.Hash{
|
||||||
|
query_pairs.append_pair("Hash",hash);
|
||||||
|
}
|
||||||
|
if let Some(source)=config.Source{
|
||||||
|
query_pairs.append_pair("Source",source);
|
||||||
|
}
|
||||||
|
if let Some(submission_id)=config.SubmissionID{
|
||||||
|
query_pairs.append_pair("SubmissionID",submission_id.to_string().as_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
response_ok(
|
||||||
|
self.0.get(url).await.map_err(Error::Reqwest)?
|
||||||
|
).await.map_err(Error::Response)?
|
||||||
|
.json().await.map_err(Error::Reqwest)
|
||||||
|
}
|
||||||
|
pub async fn get_script_from_hash<'a>(&self,config:HashRequest<'a>)->Result<Option<ScriptResponse>,SingleItemError>{
|
||||||
|
let scripts=self.get_scripts(GetScriptsRequest{
|
||||||
|
Page:1,
|
||||||
|
Limit:2,
|
||||||
|
Hash:Some(config.hash),
|
||||||
|
Name:None,
|
||||||
|
Source:None,
|
||||||
|
SubmissionID:None,
|
||||||
|
}).await.map_err(SingleItemError::Other)?;
|
||||||
|
if 1<scripts.len(){
|
||||||
|
return Err(SingleItemError::DuplicateItems);
|
||||||
|
}
|
||||||
|
Ok(scripts.into_iter().next())
|
||||||
|
}
|
||||||
pub async fn create_script<'a>(&self,config:CreateScriptRequest<'a>)->Result<ScriptIDResponse,Error>{
|
pub async fn create_script<'a>(&self,config:CreateScriptRequest<'a>)->Result<ScriptIDResponse,Error>{
|
||||||
let url_raw=format!("{}/scripts",self.0.base_url);
|
let url_raw=format!("{}/scripts",self.0.base_url);
|
||||||
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::ParseError)?;
|
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
||||||
|
|
||||||
let body=serde_json::to_string(&config).map_err(Error::JSON)?;
|
let body=serde_json::to_string(&config).map_err(Error::JSON)?;
|
||||||
|
|
||||||
crate::response_ok(
|
response_ok(
|
||||||
self.0.post(url,body).await.map_err(Error::Reqwest)?
|
self.0.post(url,body).await.map_err(Error::Reqwest)?
|
||||||
).await.map_err(Error::Response)?
|
).await.map_err(Error::Response)?
|
||||||
.json().await.map_err(Error::Reqwest)
|
.json().await.map_err(Error::Reqwest)
|
||||||
}
|
}
|
||||||
pub async fn get_script_policy_from_hash<'a>(&self,config:ScriptPolicyHashRequest<'a>)->Result<ScriptPolicyResponse,Error>{
|
pub async fn get_script_policies<'a>(&self,config:GetScriptPoliciesRequest<'a>)->Result<Vec<ScriptPolicyResponse>,Error>{
|
||||||
let url_raw=format!("{}/script-policy/hash/{}",self.0.base_url,config.hash);
|
let url_raw=format!("{}/script-policy",self.0.base_url);
|
||||||
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::ParseError)?;
|
let mut url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
||||||
|
|
||||||
crate::response_ok(
|
{
|
||||||
|
let mut query_pairs=url.query_pairs_mut();
|
||||||
|
query_pairs.append_pair("Page",config.Page.to_string().as_str());
|
||||||
|
query_pairs.append_pair("Limit",config.Limit.to_string().as_str());
|
||||||
|
if let Some(hash)=config.FromScriptHash{
|
||||||
|
query_pairs.append_pair("FromScriptHash",hash);
|
||||||
|
}
|
||||||
|
if let Some(script_id)=config.ToScriptID{
|
||||||
|
query_pairs.append_pair("ToScriptID",script_id.0.to_string().as_str());
|
||||||
|
}
|
||||||
|
if let Some(policy)=config.Policy{
|
||||||
|
query_pairs.append_pair("Policy",(policy as i32).to_string().as_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
response_ok(
|
||||||
self.0.get(url).await.map_err(Error::Reqwest)?
|
self.0.get(url).await.map_err(Error::Reqwest)?
|
||||||
).await.map_err(Error::Response)?
|
).await.map_err(Error::Response)?
|
||||||
.json().await.map_err(Error::Reqwest)
|
.json().await.map_err(Error::Reqwest)
|
||||||
}
|
}
|
||||||
|
pub async fn get_script_policy_from_hash<'a>(&self,config:HashRequest<'a>)->Result<Option<ScriptPolicyResponse>,SingleItemError>{
|
||||||
|
let policies=self.get_script_policies(GetScriptPoliciesRequest{
|
||||||
|
Page:1,
|
||||||
|
Limit:2,
|
||||||
|
FromScriptHash:Some(config.hash),
|
||||||
|
ToScriptID:None,
|
||||||
|
Policy:None,
|
||||||
|
}).await.map_err(SingleItemError::Other)?;
|
||||||
|
if 1<policies.len(){
|
||||||
|
return Err(SingleItemError::DuplicateItems);
|
||||||
|
}
|
||||||
|
Ok(policies.into_iter().next())
|
||||||
|
}
|
||||||
pub async fn create_script_policy(&self,config:CreateScriptPolicyRequest)->Result<ScriptPolicyIDResponse,Error>{
|
pub async fn create_script_policy(&self,config:CreateScriptPolicyRequest)->Result<ScriptPolicyIDResponse,Error>{
|
||||||
let url_raw=format!("{}/script-policy",self.0.base_url);
|
let url_raw=format!("{}/script-policy",self.0.base_url);
|
||||||
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::ParseError)?;
|
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
||||||
|
|
||||||
let body=serde_json::to_string(&config).map_err(Error::JSON)?;
|
let body=serde_json::to_string(&config).map_err(Error::JSON)?;
|
||||||
|
|
||||||
crate::response_ok(
|
response_ok(
|
||||||
self.0.post(url,body).await.map_err(Error::Reqwest)?
|
self.0.post(url,body).await.map_err(Error::Reqwest)?
|
||||||
).await.map_err(Error::Response)?
|
).await.map_err(Error::Response)?
|
||||||
.json().await.map_err(Error::Reqwest)
|
.json().await.map_err(Error::Reqwest)
|
||||||
}
|
}
|
||||||
pub async fn update_script_policy(&self,config:UpdateScriptPolicyRequest)->Result<(),Error>{
|
pub async fn update_script_policy(&self,config:UpdateScriptPolicyRequest)->Result<(),Error>{
|
||||||
let url_raw=format!("{}/script-policy/id/{}",self.0.base_url,config.ScriptPolicyID.0);
|
let url_raw=format!("{}/script-policy/id/{}",self.0.base_url,config.ScriptPolicyID.0);
|
||||||
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::ParseError)?;
|
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
||||||
|
|
||||||
let body=serde_json::to_string(&config).map_err(Error::JSON)?;
|
let body=serde_json::to_string(&config).map_err(Error::JSON)?;
|
||||||
|
|
||||||
crate::response_ok(
|
response_ok(
|
||||||
self.0.post(url,body).await.map_err(Error::Reqwest)?
|
self.0.post(url,body).await.map_err(Error::Reqwest)?
|
||||||
).await.map_err(Error::Response)?;
|
).await.map_err(Error::Response)?;
|
||||||
|
|
||||||
|
@ -1,84 +1,4 @@
|
|||||||
use crate::Error;
|
use crate::types::*;
|
||||||
|
|
||||||
#[derive(Clone,Copy,serde::Serialize,serde::Deserialize)]
|
|
||||||
pub struct ScriptID(i64);
|
|
||||||
#[derive(Clone,Copy,serde::Serialize,serde::Deserialize)]
|
|
||||||
pub struct ScriptPolicyID(i64);
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
pub struct GetScriptRequest{
|
|
||||||
pub ScriptID:ScriptID,
|
|
||||||
}
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(serde::Deserialize)]
|
|
||||||
pub struct ScriptResponse{
|
|
||||||
pub ID:i64,
|
|
||||||
pub Name:String,
|
|
||||||
pub Hash:String,
|
|
||||||
pub Source:String,
|
|
||||||
pub SubmissionID:i64,
|
|
||||||
}
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(serde::Serialize)]
|
|
||||||
pub struct CreateScriptRequest<'a>{
|
|
||||||
pub Name:&'a str,
|
|
||||||
pub Source:&'a str,
|
|
||||||
pub SubmissionID:Option<i64>,
|
|
||||||
}
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(serde::Deserialize)]
|
|
||||||
pub struct ScriptIDResponse{
|
|
||||||
pub ID:ScriptID,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(serde_repr::Serialize_repr,serde_repr::Deserialize_repr)]
|
|
||||||
#[repr(i32)]
|
|
||||||
pub enum Policy{
|
|
||||||
None=0, // not yet reviewed
|
|
||||||
Allowed=1,
|
|
||||||
Blocked=2,
|
|
||||||
Delete=3,
|
|
||||||
Replace=4,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct ScriptPolicyHashRequest<'a>{
|
|
||||||
pub hash:&'a str,
|
|
||||||
}
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(serde::Deserialize)]
|
|
||||||
pub struct ScriptPolicyResponse{
|
|
||||||
pub ID:i64,
|
|
||||||
pub FromScriptHash:String,
|
|
||||||
pub ToScriptID:ScriptID,
|
|
||||||
pub Policy:Policy
|
|
||||||
}
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(serde::Serialize)]
|
|
||||||
pub struct CreateScriptPolicyRequest{
|
|
||||||
pub FromScriptID:ScriptID,
|
|
||||||
pub ToScriptID:ScriptID,
|
|
||||||
pub Policy:Policy,
|
|
||||||
}
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(serde::Deserialize)]
|
|
||||||
pub struct ScriptPolicyIDResponse{
|
|
||||||
pub ID:ScriptPolicyID,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
pub struct UpdateSubmissionModelRequest{
|
|
||||||
pub SubmissionID:i64,
|
|
||||||
pub ModelID:u64,
|
|
||||||
pub ModelVersion:u64,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
pub struct ActionSubmissionUploadedRequest{
|
|
||||||
pub SubmissionID:i64,
|
|
||||||
pub TargetAssetID:Option<u64>,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct SubmissionID(pub i64);
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Context(crate::context::Context);
|
pub struct Context(crate::context::Context);
|
||||||
@ -88,9 +8,9 @@ macro_rules! action{
|
|||||||
($fname:ident,$action:expr)=>{
|
($fname:ident,$action:expr)=>{
|
||||||
pub async fn $fname(&self,config:SubmissionID)->Result<(),Error>{
|
pub async fn $fname(&self,config:SubmissionID)->Result<(),Error>{
|
||||||
let url_raw=format!(concat!("{}/submissions/{}/status/",$action),self.0.base_url,config.0);
|
let url_raw=format!(concat!("{}/submissions/{}/status/",$action),self.0.base_url,config.0);
|
||||||
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::ParseError)?;
|
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
||||||
|
|
||||||
crate::response_ok(
|
response_ok(
|
||||||
self.0.post_empty_body(url).await.map_err(Error::Reqwest)?
|
self.0.post_empty_body(url).await.map_err(Error::Reqwest)?
|
||||||
).await.map_err(Error::Response)?;
|
).await.map_err(Error::Response)?;
|
||||||
|
|
||||||
@ -104,47 +24,75 @@ impl Context{
|
|||||||
}
|
}
|
||||||
pub async fn get_script(&self,config:GetScriptRequest)->Result<ScriptResponse,Error>{
|
pub async fn get_script(&self,config:GetScriptRequest)->Result<ScriptResponse,Error>{
|
||||||
let url_raw=format!("{}/scripts/{}",self.0.base_url,config.ScriptID.0);
|
let url_raw=format!("{}/scripts/{}",self.0.base_url,config.ScriptID.0);
|
||||||
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::ParseError)?;
|
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
||||||
|
|
||||||
crate::response_ok(
|
response_ok(
|
||||||
self.0.get(url).await.map_err(Error::Reqwest)?
|
self.0.get(url).await.map_err(Error::Reqwest)?
|
||||||
).await.map_err(Error::Response)?
|
).await.map_err(Error::Response)?
|
||||||
.json().await.map_err(Error::Reqwest)
|
.json().await.map_err(Error::Reqwest)
|
||||||
}
|
}
|
||||||
pub async fn create_script<'a>(&self,config:CreateScriptRequest<'a>)->Result<ScriptIDResponse,Error>{
|
pub async fn create_script<'a>(&self,config:CreateScriptRequest<'a>)->Result<ScriptIDResponse,Error>{
|
||||||
let url_raw=format!("{}/scripts",self.0.base_url);
|
let url_raw=format!("{}/scripts",self.0.base_url);
|
||||||
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::ParseError)?;
|
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
||||||
|
|
||||||
let body=serde_json::to_string(&config).map_err(Error::JSON)?;
|
let body=serde_json::to_string(&config).map_err(Error::JSON)?;
|
||||||
|
|
||||||
crate::response_ok(
|
response_ok(
|
||||||
self.0.post(url,body).await.map_err(Error::Reqwest)?
|
self.0.post(url,body).await.map_err(Error::Reqwest)?
|
||||||
).await.map_err(Error::Response)?
|
).await.map_err(Error::Response)?
|
||||||
.json().await.map_err(Error::Reqwest)
|
.json().await.map_err(Error::Reqwest)
|
||||||
}
|
}
|
||||||
pub async fn get_script_policy_from_hash<'a>(&self,config:ScriptPolicyHashRequest<'a>)->Result<ScriptPolicyResponse,Error>{
|
pub async fn get_script_policies<'a>(&self,config:GetScriptPoliciesRequest<'a>)->Result<Vec<ScriptPolicyResponse>,Error>{
|
||||||
let url_raw=format!("{}/script-policy/hash/{}",self.0.base_url,config.hash);
|
let url_raw=format!("{}/script-policy",self.0.base_url);
|
||||||
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::ParseError)?;
|
let mut url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
||||||
|
|
||||||
crate::response_ok(
|
{
|
||||||
|
let mut query_pairs=url.query_pairs_mut();
|
||||||
|
query_pairs.append_pair("Page",config.Page.to_string().as_str());
|
||||||
|
query_pairs.append_pair("Limit",config.Limit.to_string().as_str());
|
||||||
|
if let Some(hash)=config.FromScriptHash{
|
||||||
|
query_pairs.append_pair("FromScriptHash",hash);
|
||||||
|
}
|
||||||
|
if let Some(script_id)=config.ToScriptID{
|
||||||
|
query_pairs.append_pair("ToScriptID",script_id.0.to_string().as_str());
|
||||||
|
}
|
||||||
|
if let Some(policy)=config.Policy{
|
||||||
|
query_pairs.append_pair("Policy",(policy as i32).to_string().as_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
response_ok(
|
||||||
self.0.get(url).await.map_err(Error::Reqwest)?
|
self.0.get(url).await.map_err(Error::Reqwest)?
|
||||||
).await.map_err(Error::Response)?
|
).await.map_err(Error::Response)?
|
||||||
.json().await.map_err(Error::Reqwest)
|
.json().await.map_err(Error::Reqwest)
|
||||||
}
|
}
|
||||||
|
pub async fn get_script_policy_from_hash<'a>(&self,config:HashRequest<'a>)->Result<Option<ScriptPolicyResponse>,SingleItemError>{
|
||||||
|
let policies=self.get_script_policies(GetScriptPoliciesRequest{
|
||||||
|
Page:1,
|
||||||
|
Limit:2,
|
||||||
|
FromScriptHash:Some(config.hash),
|
||||||
|
ToScriptID:None,
|
||||||
|
Policy:None,
|
||||||
|
}).await.map_err(SingleItemError::Other)?;
|
||||||
|
if 1<policies.len(){
|
||||||
|
return Err(SingleItemError::DuplicateItems);
|
||||||
|
}
|
||||||
|
Ok(policies.into_iter().next())
|
||||||
|
}
|
||||||
pub async fn create_script_policy(&self,config:CreateScriptPolicyRequest)->Result<ScriptPolicyIDResponse,Error>{
|
pub async fn create_script_policy(&self,config:CreateScriptPolicyRequest)->Result<ScriptPolicyIDResponse,Error>{
|
||||||
let url_raw=format!("{}/script-policy",self.0.base_url);
|
let url_raw=format!("{}/script-policy",self.0.base_url);
|
||||||
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::ParseError)?;
|
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
||||||
|
|
||||||
let body=serde_json::to_string(&config).map_err(Error::JSON)?;
|
let body=serde_json::to_string(&config).map_err(Error::JSON)?;
|
||||||
|
|
||||||
crate::response_ok(
|
response_ok(
|
||||||
self.0.post(url,body).await.map_err(Error::Reqwest)?
|
self.0.post(url,body).await.map_err(Error::Reqwest)?
|
||||||
).await.map_err(Error::Response)?
|
).await.map_err(Error::Response)?
|
||||||
.json().await.map_err(Error::Reqwest)
|
.json().await.map_err(Error::Reqwest)
|
||||||
}
|
}
|
||||||
pub async fn update_submission_model(&self,config:UpdateSubmissionModelRequest)->Result<(),Error>{
|
pub async fn update_submission_model(&self,config:UpdateSubmissionModelRequest)->Result<(),Error>{
|
||||||
let url_raw=format!("{}/submissions/{}/model",self.0.base_url,config.SubmissionID);
|
let url_raw=format!("{}/submissions/{}/model",self.0.base_url,config.SubmissionID);
|
||||||
let mut url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::ParseError)?;
|
let mut url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
||||||
|
|
||||||
{
|
{
|
||||||
url.query_pairs_mut()
|
url.query_pairs_mut()
|
||||||
@ -152,7 +100,7 @@ impl Context{
|
|||||||
.append_pair("ModelVersion",config.ModelVersion.to_string().as_str());
|
.append_pair("ModelVersion",config.ModelVersion.to_string().as_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
crate::response_ok(
|
response_ok(
|
||||||
self.0.post_empty_body(url).await.map_err(Error::Reqwest)?
|
self.0.post_empty_body(url).await.map_err(Error::Reqwest)?
|
||||||
).await.map_err(Error::Response)?;
|
).await.map_err(Error::Response)?;
|
||||||
|
|
||||||
@ -160,13 +108,13 @@ impl Context{
|
|||||||
}
|
}
|
||||||
pub async fn action_submission_uploaded(&self,config:ActionSubmissionUploadedRequest)->Result<(),Error>{
|
pub async fn action_submission_uploaded(&self,config:ActionSubmissionUploadedRequest)->Result<(),Error>{
|
||||||
let url_raw=format!("{}/submissions/{}/status/validator-uploaded",self.0.base_url,config.SubmissionID);
|
let url_raw=format!("{}/submissions/{}/status/validator-uploaded",self.0.base_url,config.SubmissionID);
|
||||||
let mut url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::ParseError)?;
|
let mut url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
||||||
|
|
||||||
if let Some(target_asset_id)=config.TargetAssetID{
|
if let Some(target_asset_id)=config.TargetAssetID{
|
||||||
url.query_pairs_mut()
|
url.query_pairs_mut()
|
||||||
.append_pair("TargetAssetID",target_asset_id.to_string().as_str());
|
.append_pair("TargetAssetID",target_asset_id.to_string().as_str());
|
||||||
}
|
}
|
||||||
crate::response_ok(
|
response_ok(
|
||||||
self.0.post_empty_body(url).await.map_err(Error::Reqwest)?
|
self.0.post_empty_body(url).await.map_err(Error::Reqwest)?
|
||||||
).await.map_err(Error::Response)?;
|
).await.map_err(Error::Response)?;
|
||||||
|
|
||||||
|
@ -1,61 +1,14 @@
|
|||||||
mod context;
|
mod context;
|
||||||
pub use context::Cookie;
|
pub use context::Cookie;
|
||||||
|
|
||||||
|
pub mod types;
|
||||||
|
|
||||||
#[cfg(feature="internal")]
|
#[cfg(feature="internal")]
|
||||||
pub mod internal;
|
pub mod internal;
|
||||||
|
|
||||||
#[cfg(feature="external")]
|
#[cfg(feature="external")]
|
||||||
pub mod external;
|
pub mod external;
|
||||||
|
|
||||||
//lazy reexport
|
//lazy reexports
|
||||||
|
pub use types::Error;
|
||||||
pub type ReqwestError=reqwest::Error;
|
pub type ReqwestError=reqwest::Error;
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum Error{
|
|
||||||
ParseError(url::ParseError),
|
|
||||||
Reqwest(reqwest::Error),
|
|
||||||
Response(ResponseError),
|
|
||||||
JSON(serde_json::Error),
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for Error{
|
|
||||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
|
||||||
write!(f,"{self:?}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl std::error::Error for Error{}
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct StatusCodeWithUrlAndBody{
|
|
||||||
pub status_code:reqwest::StatusCode,
|
|
||||||
pub url:url::Url,
|
|
||||||
pub body:String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum ResponseError{
|
|
||||||
Reqwest(reqwest::Error),
|
|
||||||
StatusCodeWithUrlAndBody(StatusCodeWithUrlAndBody),
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for ResponseError{
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
write!(f,"{self:?}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl std::error::Error for ResponseError{}
|
|
||||||
// lazy function to draw out meaningful info from http response on failure
|
|
||||||
pub async fn response_ok(response:reqwest::Response)->Result<reqwest::Response,ResponseError>{
|
|
||||||
let status_code=response.status();
|
|
||||||
if status_code.is_success(){
|
|
||||||
Ok(response)
|
|
||||||
}else{
|
|
||||||
let url=response.url().to_owned();
|
|
||||||
let bytes=response.bytes().await.map_err(ResponseError::Reqwest)?;
|
|
||||||
let body=String::from_utf8_lossy(&bytes).to_string();
|
|
||||||
Err(ResponseError::StatusCodeWithUrlAndBody(StatusCodeWithUrlAndBody{
|
|
||||||
status_code,
|
|
||||||
url,
|
|
||||||
body,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
169
validation/api/src/types.rs
Normal file
169
validation/api/src/types.rs
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
#[derive(Debug)]
|
||||||
|
pub enum Error{
|
||||||
|
Parse(url::ParseError),
|
||||||
|
Reqwest(reqwest::Error),
|
||||||
|
Response(ResponseError),
|
||||||
|
JSON(serde_json::Error),
|
||||||
|
}
|
||||||
|
impl std::fmt::Display for Error{
|
||||||
|
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
||||||
|
write!(f,"{self:?}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl std::error::Error for Error{}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum SingleItemError{
|
||||||
|
DuplicateItems,
|
||||||
|
Other(Error),
|
||||||
|
}
|
||||||
|
impl std::fmt::Display for SingleItemError{
|
||||||
|
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
||||||
|
write!(f,"{self:?}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl std::error::Error for SingleItemError{}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct StatusCodeWithUrlAndBody{
|
||||||
|
pub status_code:reqwest::StatusCode,
|
||||||
|
pub url:url::Url,
|
||||||
|
pub body:String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum ResponseError{
|
||||||
|
Reqwest(reqwest::Error),
|
||||||
|
StatusCodeWithUrlAndBody(StatusCodeWithUrlAndBody),
|
||||||
|
}
|
||||||
|
impl std::fmt::Display for ResponseError{
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f,"{self:?}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl std::error::Error for ResponseError{}
|
||||||
|
// lazy function to draw out meaningful info from http response on failure
|
||||||
|
pub async fn response_ok(response:reqwest::Response)->Result<reqwest::Response,ResponseError>{
|
||||||
|
let status_code=response.status();
|
||||||
|
if status_code.is_success(){
|
||||||
|
Ok(response)
|
||||||
|
}else{
|
||||||
|
let url=response.url().to_owned();
|
||||||
|
let bytes=response.bytes().await.map_err(ResponseError::Reqwest)?;
|
||||||
|
let body=String::from_utf8_lossy(&bytes).to_string();
|
||||||
|
Err(ResponseError::StatusCodeWithUrlAndBody(StatusCodeWithUrlAndBody{
|
||||||
|
status_code,
|
||||||
|
url,
|
||||||
|
body,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone,Copy,serde::Serialize,serde::Deserialize)]
|
||||||
|
pub struct ScriptID(pub(crate)i64);
|
||||||
|
#[derive(Clone,Copy,serde::Serialize,serde::Deserialize)]
|
||||||
|
pub struct ScriptPolicyID(pub(crate)i64);
|
||||||
|
|
||||||
|
#[allow(nonstandard_style)]
|
||||||
|
pub struct GetScriptRequest{
|
||||||
|
pub ScriptID:ScriptID,
|
||||||
|
}
|
||||||
|
#[allow(nonstandard_style)]
|
||||||
|
#[derive(serde::Serialize)]
|
||||||
|
pub struct GetScriptsRequest<'a>{
|
||||||
|
pub Page:u32,
|
||||||
|
pub Limit:u32,
|
||||||
|
pub Name:Option<&'a str>,
|
||||||
|
pub Hash:Option<&'a str>,
|
||||||
|
pub Source:Option<&'a str>,
|
||||||
|
pub SubmissionID:Option<i64>,
|
||||||
|
}
|
||||||
|
pub struct HashRequest<'a>{
|
||||||
|
pub hash:&'a str,
|
||||||
|
}
|
||||||
|
#[allow(nonstandard_style)]
|
||||||
|
#[derive(serde::Deserialize)]
|
||||||
|
pub struct ScriptResponse{
|
||||||
|
pub ID:ScriptID,
|
||||||
|
pub Name:String,
|
||||||
|
pub Hash:String,
|
||||||
|
pub Source:String,
|
||||||
|
pub SubmissionID:i64,
|
||||||
|
}
|
||||||
|
#[allow(nonstandard_style)]
|
||||||
|
#[derive(serde::Serialize)]
|
||||||
|
pub struct CreateScriptRequest<'a>{
|
||||||
|
pub Name:&'a str,
|
||||||
|
pub Source:&'a str,
|
||||||
|
pub SubmissionID:Option<i64>,
|
||||||
|
}
|
||||||
|
#[allow(nonstandard_style)]
|
||||||
|
#[derive(serde::Deserialize)]
|
||||||
|
pub struct ScriptIDResponse{
|
||||||
|
pub ID:ScriptID,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(serde_repr::Serialize_repr,serde_repr::Deserialize_repr)]
|
||||||
|
#[repr(i32)]
|
||||||
|
pub enum Policy{
|
||||||
|
None=0, // not yet reviewed
|
||||||
|
Allowed=1,
|
||||||
|
Blocked=2,
|
||||||
|
Delete=3,
|
||||||
|
Replace=4,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(nonstandard_style)]
|
||||||
|
#[derive(serde::Serialize)]
|
||||||
|
pub struct GetScriptPoliciesRequest<'a>{
|
||||||
|
pub Page:u32,
|
||||||
|
pub Limit:u32,
|
||||||
|
pub FromScriptHash:Option<&'a str>,
|
||||||
|
pub ToScriptID:Option<ScriptID>,
|
||||||
|
pub Policy:Option<Policy>,
|
||||||
|
}
|
||||||
|
#[allow(nonstandard_style)]
|
||||||
|
#[derive(serde::Deserialize)]
|
||||||
|
pub struct ScriptPolicyResponse{
|
||||||
|
pub ID:ScriptPolicyID,
|
||||||
|
pub FromScriptHash:String,
|
||||||
|
pub ToScriptID:ScriptID,
|
||||||
|
pub Policy:Policy
|
||||||
|
}
|
||||||
|
#[allow(nonstandard_style)]
|
||||||
|
#[derive(serde::Serialize)]
|
||||||
|
pub struct CreateScriptPolicyRequest{
|
||||||
|
pub FromScriptID:ScriptID,
|
||||||
|
pub ToScriptID:ScriptID,
|
||||||
|
pub Policy:Policy,
|
||||||
|
}
|
||||||
|
#[allow(nonstandard_style)]
|
||||||
|
#[derive(serde::Deserialize)]
|
||||||
|
pub struct ScriptPolicyIDResponse{
|
||||||
|
pub ID:ScriptPolicyID,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(nonstandard_style)]
|
||||||
|
#[derive(serde::Serialize)]
|
||||||
|
pub struct UpdateScriptPolicyRequest{
|
||||||
|
pub ScriptPolicyID:ScriptPolicyID,
|
||||||
|
pub FromScriptID:Option<ScriptID>,
|
||||||
|
pub ToScriptID:Option<ScriptID>,
|
||||||
|
pub Policy:Option<Policy>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(nonstandard_style)]
|
||||||
|
pub struct UpdateSubmissionModelRequest{
|
||||||
|
pub SubmissionID:i64,
|
||||||
|
pub ModelID:u64,
|
||||||
|
pub ModelVersion:u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(nonstandard_style)]
|
||||||
|
pub struct ActionSubmissionUploadedRequest{
|
||||||
|
pub SubmissionID:i64,
|
||||||
|
pub TargetAssetID:Option<u64>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct SubmissionID(pub i64);
|
@ -52,7 +52,7 @@ impl Publisher{
|
|||||||
// that's it, the database entry does not need to be changed.
|
// that's it, the database entry does not need to be changed.
|
||||||
|
|
||||||
// mark submission as uploaded, TargetAssetID is unchanged
|
// mark submission as uploaded, TargetAssetID is unchanged
|
||||||
self.api_internal.action_submission_uploaded(submissions_api::internal::ActionSubmissionUploadedRequest{
|
self.api_internal.action_submission_uploaded(submissions_api::types::ActionSubmissionUploadedRequest{
|
||||||
SubmissionID:publish_info.SubmissionID,
|
SubmissionID:publish_info.SubmissionID,
|
||||||
TargetAssetID:None,
|
TargetAssetID:None,
|
||||||
}).await.map_err(PublishError::ApiActionSubmissionUploaded)?;
|
}).await.map_err(PublishError::ApiActionSubmissionUploaded)?;
|
||||||
|
@ -50,7 +50,7 @@ impl Publisher{
|
|||||||
},model_data).await.map_err(PublishError::Create)?;
|
},model_data).await.map_err(PublishError::Create)?;
|
||||||
|
|
||||||
// note the asset id of the created model for later release, and mark the submission as uploaded
|
// note the asset id of the created model for later release, and mark the submission as uploaded
|
||||||
self.api.action_submission_uploaded(submissions_api::internal::ActionSubmissionUploadedRequest{
|
self.api.action_submission_uploaded(submissions_api::types::ActionSubmissionUploadedRequest{
|
||||||
SubmissionID:publish_info.SubmissionID,
|
SubmissionID:publish_info.SubmissionID,
|
||||||
TargetAssetID:Some(upload_response.AssetId),
|
TargetAssetID:Some(upload_response.AssetId),
|
||||||
}).await.map_err(PublishError::ApiActionSubmissionPublish)?;
|
}).await.map_err(PublishError::ApiActionSubmissionPublish)?;
|
||||||
|
@ -2,8 +2,6 @@ use futures::TryStreamExt;
|
|||||||
|
|
||||||
use crate::nats_types::ValidateRequest;
|
use crate::nats_types::ValidateRequest;
|
||||||
|
|
||||||
use submissions_api::internal::ScriptPolicyResponse;
|
|
||||||
|
|
||||||
const SCRIPT_CONCURRENCY:usize=16;
|
const SCRIPT_CONCURRENCY:usize=16;
|
||||||
|
|
||||||
enum Policy{
|
enum Policy{
|
||||||
@ -19,22 +17,6 @@ struct NamePolicy{
|
|||||||
policy:Policy,
|
policy:Policy,
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is awful
|
|
||||||
fn interpret_get_script_policy_response(reponse:Result<ScriptPolicyResponse,submissions_api::Error>)->Result<Option<ScriptPolicyResponse>,submissions_api::Error>{
|
|
||||||
match reponse{
|
|
||||||
Ok(script_policy)=>Ok(Some(script_policy)),
|
|
||||||
Err(e)=>{
|
|
||||||
if let submissions_api::Error::Response(submissions_api::ResponseError::StatusCodeWithUrlAndBody(s))=&e{
|
|
||||||
if s.status_code.as_u16()==404{
|
|
||||||
// wew we figured out that the resource does not exist
|
|
||||||
return Ok(None);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Err(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ValidateError{
|
pub enum ValidateError{
|
||||||
@ -42,7 +24,7 @@ pub enum ValidateError{
|
|||||||
NotAllowed,
|
NotAllowed,
|
||||||
Get(rbx_asset::cookie::GetError),
|
Get(rbx_asset::cookie::GetError),
|
||||||
ReadDom(ReadDomError),
|
ReadDom(ReadDomError),
|
||||||
ApiGetScriptPolicy(submissions_api::Error),
|
ApiGetScriptPolicy(submissions_api::types::SingleItemError),
|
||||||
ApiGetScript(submissions_api::Error),
|
ApiGetScript(submissions_api::Error),
|
||||||
ApiCreateScript(submissions_api::Error),
|
ApiCreateScript(submissions_api::Error),
|
||||||
ApiCreateScriptPolicy(submissions_api::Error),
|
ApiCreateScriptPolicy(submissions_api::Error),
|
||||||
@ -83,13 +65,13 @@ impl Validator{
|
|||||||
Ok(())=>{
|
Ok(())=>{
|
||||||
// update the submission model status to validated
|
// update the submission model status to validated
|
||||||
self.api.action_submission_validated(
|
self.api.action_submission_validated(
|
||||||
submissions_api::internal::SubmissionID(submission_id)
|
submissions_api::types::SubmissionID(submission_id)
|
||||||
).await.map_err(ValidateError::ApiActionSubmissionValidate)?;
|
).await.map_err(ValidateError::ApiActionSubmissionValidate)?;
|
||||||
},
|
},
|
||||||
Err(_)=>{
|
Err(_)=>{
|
||||||
// update the submission model status to accepted
|
// update the submission model status to accepted
|
||||||
self.api.action_submission_accepted(
|
self.api.action_submission_accepted(
|
||||||
submissions_api::internal::SubmissionID(submission_id)
|
submissions_api::types::SubmissionID(submission_id)
|
||||||
).await.map_err(ValidateError::ApiActionSubmissionValidate)?;
|
).await.map_err(ValidateError::ApiActionSubmissionValidate)?;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -131,21 +113,19 @@ impl Validator{
|
|||||||
let hash=std::hash::Hasher::finish(&hasher);
|
let hash=std::hash::Hasher::finish(&hasher);
|
||||||
|
|
||||||
// fetch the script policy
|
// fetch the script policy
|
||||||
let script_policy=interpret_get_script_policy_response(
|
let script_policy=self.api.get_script_policy_from_hash(submissions_api::types::HashRequest{
|
||||||
self.api.get_script_policy_from_hash(submissions_api::internal::ScriptPolicyHashRequest{
|
hash:format!("{:016x}",hash).as_str(),
|
||||||
hash:format!("{:016x}",hash).as_str(),
|
}).await.map_err(ValidateError::ApiGetScriptPolicy)?;
|
||||||
}).await
|
|
||||||
).map_err(ValidateError::ApiGetScriptPolicy)?;
|
|
||||||
|
|
||||||
// write the policy to the script_map, fetching the replacement code if necessary
|
// write the policy to the script_map, fetching the replacement code if necessary
|
||||||
if let Some(script_policy)=script_policy{
|
if let Some(script_policy)=script_policy{
|
||||||
*policy=match script_policy.Policy{
|
*policy=match script_policy.Policy{
|
||||||
submissions_api::internal::Policy::None=>Policy::None,
|
submissions_api::types::Policy::None=>Policy::None,
|
||||||
submissions_api::internal::Policy::Allowed=>Policy::Allowed,
|
submissions_api::types::Policy::Allowed=>Policy::Allowed,
|
||||||
submissions_api::internal::Policy::Blocked=>Policy::Blocked,
|
submissions_api::types::Policy::Blocked=>Policy::Blocked,
|
||||||
submissions_api::internal::Policy::Delete=>Policy::Delete,
|
submissions_api::types::Policy::Delete=>Policy::Delete,
|
||||||
submissions_api::internal::Policy::Replace=>{
|
submissions_api::types::Policy::Replace=>{
|
||||||
let script=self.api.get_script(submissions_api::internal::GetScriptRequest{
|
let script=self.api.get_script(submissions_api::types::GetScriptRequest{
|
||||||
ScriptID:script_policy.ToScriptID,
|
ScriptID:script_policy.ToScriptID,
|
||||||
}).await.map_err(ValidateError::ApiGetScript)?;
|
}).await.map_err(ValidateError::ApiGetScript)?;
|
||||||
Policy::Replace(script.Source)
|
Policy::Replace(script.Source)
|
||||||
@ -153,17 +133,17 @@ impl Validator{
|
|||||||
};
|
};
|
||||||
}else{
|
}else{
|
||||||
// upload the script
|
// upload the script
|
||||||
let script=self.api.create_script(submissions_api::internal::CreateScriptRequest{
|
let script=self.api.create_script(submissions_api::types::CreateScriptRequest{
|
||||||
Name:name.as_str(),
|
Name:name.as_str(),
|
||||||
Source:source.as_str(),
|
Source:source.as_str(),
|
||||||
SubmissionID:Some(validate_info.SubmissionID),
|
SubmissionID:Some(validate_info.SubmissionID),
|
||||||
}).await.map_err(ValidateError::ApiCreateScript)?;
|
}).await.map_err(ValidateError::ApiCreateScript)?;
|
||||||
|
|
||||||
// create a None policy (pending review by yours truly)
|
// create a None policy (pending review by yours truly)
|
||||||
self.api.create_script_policy(submissions_api::internal::CreateScriptPolicyRequest{
|
self.api.create_script_policy(submissions_api::types::CreateScriptPolicyRequest{
|
||||||
ToScriptID:script.ID,
|
ToScriptID:script.ID,
|
||||||
FromScriptID:script.ID,
|
FromScriptID:script.ID,
|
||||||
Policy:submissions_api::internal::Policy::None,
|
Policy:submissions_api::types::Policy::None,
|
||||||
}).await.map_err(ValidateError::ApiCreateScriptPolicy)?;
|
}).await.map_err(ValidateError::ApiCreateScriptPolicy)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,7 +209,7 @@ impl Validator{
|
|||||||
};
|
};
|
||||||
|
|
||||||
// update the submission to use the validated model
|
// update the submission to use the validated model
|
||||||
self.api.update_submission_model(submissions_api::internal::UpdateSubmissionModelRequest{
|
self.api.update_submission_model(submissions_api::types::UpdateSubmissionModelRequest{
|
||||||
SubmissionID:validate_info.SubmissionID,
|
SubmissionID:validate_info.SubmissionID,
|
||||||
ModelID:model_id,
|
ModelID:model_id,
|
||||||
ModelVersion:1, //TODO
|
ModelVersion:1, //TODO
|
||||||
|
Loading…
Reference in New Issue
Block a user