submissions-api: add audit events
This commit is contained in:
@@ -263,6 +263,36 @@ impl Context{
|
||||
).await.map_err(Error::Response)?
|
||||
.json().await.map_err(Error::ReqwestJson)
|
||||
}
|
||||
pub async fn get_mapfix_audit_events(&self,config:GetMapfixAuditEventsRequest)->Result<Vec<AuditEventReponse>,Error>{
|
||||
let url_raw=format!("{}/mapfixes/{}/audit-events",self.0.base_url,config.MapfixID);
|
||||
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());
|
||||
}
|
||||
|
||||
response_ok(
|
||||
self.0.get(url).await.map_err(Error::Reqwest)?
|
||||
).await.map_err(Error::Response)?
|
||||
.json().await.map_err(Error::ReqwestJson)
|
||||
}
|
||||
pub async fn get_submission_audit_events(&self,config:GetSubmissionAuditEventsRequest)->Result<Vec<AuditEventReponse>,Error>{
|
||||
let url_raw=format!("{}/submissions/{}/audit-events",self.0.base_url,config.SubmissionID);
|
||||
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());
|
||||
}
|
||||
|
||||
response_ok(
|
||||
self.0.get(url).await.map_err(Error::Reqwest)?
|
||||
).await.map_err(Error::Response)?
|
||||
.json().await.map_err(Error::ReqwestJson)
|
||||
}
|
||||
pub async fn release_submissions(&self,config:ReleaseRequest<'_>)->Result<OperationIDResponse,Error>{
|
||||
let url_raw=format!("{}/release-submissions",self.0.base_url);
|
||||
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
||||
|
||||
@@ -404,6 +404,120 @@ pub struct MapResponse{
|
||||
pub Date:i64,
|
||||
}
|
||||
|
||||
#[allow(nonstandard_style)]
|
||||
#[derive(Clone,Debug)]
|
||||
pub struct GetMapfixAuditEventsRequest{
|
||||
pub Page:u32,
|
||||
pub Limit:u32,
|
||||
pub MapfixID:i64,
|
||||
}
|
||||
|
||||
#[allow(nonstandard_style)]
|
||||
#[derive(Clone,Debug)]
|
||||
pub struct GetSubmissionAuditEventsRequest{
|
||||
pub Page:u32,
|
||||
pub Limit:u32,
|
||||
pub SubmissionID:i64,
|
||||
}
|
||||
|
||||
#[allow(nonstandard_style)]
|
||||
#[derive(Clone,Debug,serde_repr::Deserialize_repr)]
|
||||
#[repr(u32)]
|
||||
pub enum AuditEventType{
|
||||
Action=0,
|
||||
Comment=1,
|
||||
ChangeModel=2,
|
||||
ChangeValidatedModel=3,
|
||||
ChangeDisplayName=4,
|
||||
ChangeCreator=5,
|
||||
Error=6,
|
||||
CheckList=7,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Clone,Debug,serde::Deserialize)]
|
||||
pub struct AuditEventAction{
|
||||
pub target_status:MapfixStatus,
|
||||
}
|
||||
#[derive(Clone,Debug,serde::Deserialize)]
|
||||
pub struct AuditEventComment{
|
||||
pub comment:String,
|
||||
}
|
||||
#[derive(Clone,Debug,serde::Deserialize)]
|
||||
pub struct AuditEventChangeModel{
|
||||
pub old_model_id:u64,
|
||||
pub old_model_version:u64,
|
||||
pub new_model_id:u64,
|
||||
pub new_model_version:u64,
|
||||
}
|
||||
#[derive(Clone,Debug,serde::Deserialize)]
|
||||
pub struct AuditEventChangeValidatedModel{
|
||||
pub validated_model_id:u64,
|
||||
pub validated_model_version:u64,
|
||||
}
|
||||
#[derive(Clone,Debug,serde::Deserialize)]
|
||||
pub struct AuditEventChangeName{
|
||||
pub old_name:String,
|
||||
pub new_name:String,
|
||||
}
|
||||
#[derive(Clone,Debug,serde::Deserialize)]
|
||||
pub struct AuditEventError{
|
||||
pub error:String,
|
||||
}
|
||||
#[derive(Clone,Debug,serde::Deserialize)]
|
||||
pub struct AuditEventCheck{
|
||||
pub name:String,
|
||||
pub summary:String,
|
||||
pub passed:bool,
|
||||
}
|
||||
#[derive(Clone,Debug,serde::Deserialize)]
|
||||
pub struct AuditEventCheckList{
|
||||
pub check_list:Vec<AuditEventCheck>,
|
||||
}
|
||||
|
||||
#[allow(nonstandard_style)]
|
||||
#[derive(Clone,Debug)]
|
||||
pub enum AuditEventData{
|
||||
Action(AuditEventAction),
|
||||
Comment(AuditEventComment),
|
||||
ChangeModel(AuditEventChangeModel),
|
||||
ChangeValidatedModel(AuditEventChangeValidatedModel),
|
||||
ChangeDisplayName(AuditEventChangeName),
|
||||
ChangeCreator(AuditEventChangeName),
|
||||
Error(AuditEventError),
|
||||
CheckList(AuditEventCheckList),
|
||||
}
|
||||
|
||||
#[derive(Clone,Copy,Debug,Hash,Eq,PartialEq,serde::Serialize,serde::Deserialize)]
|
||||
pub struct AuditEventID(pub(crate)i64);
|
||||
|
||||
#[allow(nonstandard_style)]
|
||||
#[derive(Clone,Debug,serde::Deserialize)]
|
||||
pub struct AuditEventReponse{
|
||||
pub ID:AuditEventID,
|
||||
pub Date:i64,
|
||||
pub User:u64,
|
||||
pub Username:String,
|
||||
pub ResourceType:ResourceType,
|
||||
pub ResourceID:ResourceID,
|
||||
pub EventType:AuditEventType,
|
||||
EventData:serde_json::Value,
|
||||
}
|
||||
impl AuditEventReponse{
|
||||
pub fn data(self)->serde_json::Result<AuditEventData>{
|
||||
Ok(match self.EventType{
|
||||
AuditEventType::Action=>AuditEventData::Action(serde_json::from_value(self.EventData)?),
|
||||
AuditEventType::Comment=>AuditEventData::Comment(serde_json::from_value(self.EventData)?),
|
||||
AuditEventType::ChangeModel=>AuditEventData::ChangeModel(serde_json::from_value(self.EventData)?),
|
||||
AuditEventType::ChangeValidatedModel=>AuditEventData::ChangeValidatedModel(serde_json::from_value(self.EventData)?),
|
||||
AuditEventType::ChangeDisplayName=>AuditEventData::ChangeDisplayName(serde_json::from_value(self.EventData)?),
|
||||
AuditEventType::ChangeCreator=>AuditEventData::ChangeCreator(serde_json::from_value(self.EventData)?),
|
||||
AuditEventType::Error=>AuditEventData::Error(serde_json::from_value(self.EventData)?),
|
||||
AuditEventType::CheckList=>AuditEventData::CheckList(serde_json::from_value(self.EventData)?),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(nonstandard_style)]
|
||||
#[derive(Clone,Debug,serde::Serialize)]
|
||||
pub struct Check{
|
||||
@@ -457,6 +571,14 @@ pub struct CreateSubmissionAuditCheckListRequest<'a>{
|
||||
|
||||
#[derive(Clone,Copy,Debug,Hash,Eq,PartialEq,serde::Serialize,serde::Deserialize)]
|
||||
pub struct SubmissionID(pub(crate)i64);
|
||||
impl SubmissionID{
|
||||
pub const fn new(value:i64)->Self{
|
||||
Self(value)
|
||||
}
|
||||
pub const fn value(&self)->i64{
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(nonstandard_style)]
|
||||
#[derive(Clone,Debug)]
|
||||
@@ -510,6 +632,14 @@ pub struct CreateMapfixAuditCheckListRequest<'a>{
|
||||
|
||||
#[derive(Clone,Copy,Debug,Hash,Eq,PartialEq,serde::Serialize,serde::Deserialize)]
|
||||
pub struct MapfixID(pub(crate)i64);
|
||||
impl MapfixID{
|
||||
pub const fn new(value:i64)->Self{
|
||||
Self(value)
|
||||
}
|
||||
pub const fn value(&self)->i64{
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(nonstandard_style)]
|
||||
#[derive(Clone,Debug)]
|
||||
|
||||
Reference in New Issue
Block a user