mod response;
use response::SearchJobRoot;
pub use response::SubmitRetrohuntJob;
use crate::{
utils::{http_body_post, http_delete, http_get, http_get_with_params, http_post},
VtClient, VtResult,
};
impl VtClient {
pub fn get_retrohunt_jobs(
&self,
limit: Option<&str>,
filter: Option<&str>,
cursor: Option<&str>,
) -> VtResult<SearchJobRoot> {
let url = format!("{}/intelligence/retrohunt_jobs", &self.endpoint);
let mut query_params: Vec<(&str, &str)> = Vec::new();
if let Some(l) = limit {
query_params.push(("limit", l))
}
if let Some(f) = filter {
query_params.push(("filter", f))
}
if let Some(c) = cursor {
query_params.push(("cursor", c))
}
http_get_with_params(
&self.api_key,
&self.user_agent,
&url,
&query_params.as_slice(),
)
}
pub fn get_retrohunt_job(&self, job_id: i32) -> VtResult<SearchJobRoot> {
let url = format!("{}/intelligence/retrohunt_jobs/{}", &self.endpoint, job_id);
http_get(&self.api_key, &self.user_agent, &url)
}
pub fn create_retrohunt_job(&self, data: &SubmitRetrohuntJob) -> VtResult<SubmitRetrohuntJob> {
let url = format!("{}/intelligence/retrohunt_jobs", &self.endpoint);
http_body_post(&self.api_key, &self.user_agent, &url, data)
}
pub fn delete_retrohunt_job(&self, job_id: i32) -> VtResult<String> {
let url = format!("{}/intelligence/retrohunt_jobs/{}", &self.endpoint, job_id);
http_delete(&self.api_key, &self.user_agent, &url)
}
pub fn abort_retrohunt_job(&self, job_id: i32) -> VtResult<String> {
let job_id = job_id.to_string();
let url = format!(
"{}/intelligence/retrohunt_jobs/{}/abort",
&self.endpoint, job_id
);
let form_data = &[("id", job_id.as_str())];
http_post(&self.api_key, &self.user_agent, &url, form_data)
}
}