use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AddAlertAttachmentsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BulkDeleteAlertsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BulkMergeAlertsIntoCaseError {
Status400(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BulkUpdateAlertsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateAlertError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateAlertObservableError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateAlertProcedureError {
Status400(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteAlertError {
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteAlertAttachmentError {
Status401(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DownloadAlertAttachmentError {
Status401(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FollowAlertError {
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAlertByIdError {
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum MergeAlertIntoCaseError {
Status400(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PromoteAlertToCaseError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UnfollowAlertError {
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateAlertError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
pub async fn add_alert_attachments(configuration: &configuration::Configuration, alert_id: &str, x_organisation: Option<&str>, attachments: Option<Vec<std::path::PathBuf>>) -> Result<models::AddAlertAttachments201Response, Error<AddAlertAttachmentsError>> {
let p_alert_id = alert_id;
let p_x_organisation = x_organisation;
let p_attachments = attachments;
let uri_str = format!("{}/v1/alert/{alert_id}/attachments", configuration.base_path, alert_id=crate::apis::urlencode(p_alert_id));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_x_organisation {
req_builder = req_builder.header("X-Organisation", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let mut multipart_form = reqwest::multipart::Form::new();
req_builder = req_builder.multipart(multipart_form);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AddAlertAttachments201Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AddAlertAttachments201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<AddAlertAttachmentsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn bulk_delete_alerts(configuration: &configuration::Configuration, bulk_delete_alerts_request: models::BulkDeleteAlertsRequest, x_organisation: Option<&str>) -> Result<(), Error<BulkDeleteAlertsError>> {
let p_bulk_delete_alerts_request = bulk_delete_alerts_request;
let p_x_organisation = x_organisation;
let uri_str = format!("{}/v1/alert/delete/_bulk", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_x_organisation {
req_builder = req_builder.header("X-Organisation", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_bulk_delete_alerts_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<BulkDeleteAlertsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn bulk_merge_alerts_into_case(configuration: &configuration::Configuration, bulk_merge_alerts_into_case_request: models::BulkMergeAlertsIntoCaseRequest, x_organisation: Option<&str>) -> Result<models::OutputCase, Error<BulkMergeAlertsIntoCaseError>> {
let p_bulk_merge_alerts_into_case_request = bulk_merge_alerts_into_case_request;
let p_x_organisation = x_organisation;
let uri_str = format!("{}/v1/alert/merge/_bulk", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_x_organisation {
req_builder = req_builder.header("X-Organisation", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_bulk_merge_alerts_into_case_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OutputCase`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OutputCase`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<BulkMergeAlertsIntoCaseError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn bulk_update_alerts(configuration: &configuration::Configuration, input_bulk_update_alert: models::InputBulkUpdateAlert, x_organisation: Option<&str>) -> Result<(), Error<BulkUpdateAlertsError>> {
let p_input_bulk_update_alert = input_bulk_update_alert;
let p_x_organisation = x_organisation;
let uri_str = format!("{}/v1/alert/_bulk", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_x_organisation {
req_builder = req_builder.header("X-Organisation", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_input_bulk_update_alert);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<BulkUpdateAlertsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_alert(configuration: &configuration::Configuration, input_alert: models::InputAlert, x_organisation: Option<&str>) -> Result<models::OutputAlert, Error<CreateAlertError>> {
let p_input_alert = input_alert;
let p_x_organisation = x_organisation;
let uri_str = format!("{}/v1/alert", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_x_organisation {
req_builder = req_builder.header("X-Organisation", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_input_alert);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OutputAlert`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OutputAlert`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateAlertError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_alert_observable(configuration: &configuration::Configuration, alert_id: &str, input_observable: models::InputObservable, x_organisation: Option<&str>) -> Result<Vec<models::OutputObservable>, Error<CreateAlertObservableError>> {
let p_alert_id = alert_id;
let p_input_observable = input_observable;
let p_x_organisation = x_organisation;
let uri_str = format!("{}/v1/alert/{alert_id}/observable", configuration.base_path, alert_id=crate::apis::urlencode(p_alert_id));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_x_organisation {
req_builder = req_builder.header("X-Organisation", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_input_observable);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::OutputObservable>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::OutputObservable>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateAlertObservableError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_alert_procedure(configuration: &configuration::Configuration, alert_id: &str, input_procedure: models::InputProcedure, x_organisation: Option<&str>) -> Result<models::OutputProcedure, Error<CreateAlertProcedureError>> {
let p_alert_id = alert_id;
let p_input_procedure = input_procedure;
let p_x_organisation = x_organisation;
let uri_str = format!("{}/v1/alert/{alert_id}/procedure", configuration.base_path, alert_id=crate::apis::urlencode(p_alert_id));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_x_organisation {
req_builder = req_builder.header("X-Organisation", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_input_procedure);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OutputProcedure`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OutputProcedure`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateAlertProcedureError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn delete_alert(configuration: &configuration::Configuration, alert_id: &str, x_organisation: Option<&str>) -> Result<(), Error<DeleteAlertError>> {
let p_alert_id = alert_id;
let p_x_organisation = x_organisation;
let uri_str = format!("{}/v1/alert/{alert_id}", configuration.base_path, alert_id=crate::apis::urlencode(p_alert_id));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_x_organisation {
req_builder = req_builder.header("X-Organisation", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<DeleteAlertError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn delete_alert_attachment(configuration: &configuration::Configuration, alert_id: &str, attachment_id: &str, x_organisation: Option<&str>) -> Result<(), Error<DeleteAlertAttachmentError>> {
let p_alert_id = alert_id;
let p_attachment_id = attachment_id;
let p_x_organisation = x_organisation;
let uri_str = format!("{}/v1/alert/{alert_id}/attachment/{attachment_id}", configuration.base_path, alert_id=crate::apis::urlencode(p_alert_id), attachment_id=crate::apis::urlencode(p_attachment_id));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_x_organisation {
req_builder = req_builder.header("X-Organisation", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<DeleteAlertAttachmentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn download_alert_attachment(configuration: &configuration::Configuration, alert_id: &str, attachment_id: &str, x_organisation: Option<&str>) -> Result<(), Error<DownloadAlertAttachmentError>> {
let p_alert_id = alert_id;
let p_attachment_id = attachment_id;
let p_x_organisation = x_organisation;
let uri_str = format!("{}/v1/alert/{alert_id}/attachment/{attachment_id}/download", configuration.base_path, alert_id=crate::apis::urlencode(p_alert_id), attachment_id=crate::apis::urlencode(p_attachment_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_x_organisation {
req_builder = req_builder.header("X-Organisation", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<DownloadAlertAttachmentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn follow_alert(configuration: &configuration::Configuration, alert_id: &str, x_organisation: Option<&str>) -> Result<(), Error<FollowAlertError>> {
let p_alert_id = alert_id;
let p_x_organisation = x_organisation;
let uri_str = format!("{}/v1/alert/{alert_id}/follow", configuration.base_path, alert_id=crate::apis::urlencode(p_alert_id));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_x_organisation {
req_builder = req_builder.header("X-Organisation", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<FollowAlertError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_alert_by_id(configuration: &configuration::Configuration, alert_id: &str, x_organisation: Option<&str>) -> Result<models::OutputAlert, Error<GetAlertByIdError>> {
let p_alert_id = alert_id;
let p_x_organisation = x_organisation;
let uri_str = format!("{}/v1/alert/{alert_id}", configuration.base_path, alert_id=crate::apis::urlencode(p_alert_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_x_organisation {
req_builder = req_builder.header("X-Organisation", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OutputAlert`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OutputAlert`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetAlertByIdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn merge_alert_into_case(configuration: &configuration::Configuration, alert_id: &str, case_id: &str, x_organisation: Option<&str>) -> Result<models::OutputCase, Error<MergeAlertIntoCaseError>> {
let p_alert_id = alert_id;
let p_case_id = case_id;
let p_x_organisation = x_organisation;
let uri_str = format!("{}/v1/alert/{alert_id}/merge/{case_id}", configuration.base_path, alert_id=crate::apis::urlencode(p_alert_id), case_id=p_case_id.to_string());
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_x_organisation {
req_builder = req_builder.header("X-Organisation", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OutputCase`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OutputCase`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<MergeAlertIntoCaseError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn promote_alert_to_case(configuration: &configuration::Configuration, alert_id: &str, x_organisation: Option<&str>, input_promote_alert: Option<models::InputPromoteAlert>) -> Result<models::OutputCase, Error<PromoteAlertToCaseError>> {
let p_alert_id = alert_id;
let p_x_organisation = x_organisation;
let p_input_promote_alert = input_promote_alert;
let uri_str = format!("{}/v1/alert/{alert_id}/case", configuration.base_path, alert_id=crate::apis::urlencode(p_alert_id));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_x_organisation {
req_builder = req_builder.header("X-Organisation", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_input_promote_alert);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OutputCase`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OutputCase`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PromoteAlertToCaseError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn unfollow_alert(configuration: &configuration::Configuration, alert_id: &str, x_organisation: Option<&str>) -> Result<(), Error<UnfollowAlertError>> {
let p_alert_id = alert_id;
let p_x_organisation = x_organisation;
let uri_str = format!("{}/v1/alert/{alert_id}/unfollow", configuration.base_path, alert_id=crate::apis::urlencode(p_alert_id));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_x_organisation {
req_builder = req_builder.header("X-Organisation", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<UnfollowAlertError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn update_alert(configuration: &configuration::Configuration, alert_id: &str, input_update_alert: models::InputUpdateAlert, x_organisation: Option<&str>) -> Result<(), Error<UpdateAlertError>> {
let p_alert_id = alert_id;
let p_input_update_alert = input_update_alert;
let p_x_organisation = x_organisation;
let uri_str = format!("{}/v1/alert/{alert_id}", configuration.base_path, alert_id=crate::apis::urlencode(p_alert_id));
let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_x_organisation {
req_builder = req_builder.header("X-Organisation", param_value.to_string());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_input_update_alert);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<UpdateAlertError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}