1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AddAlertAttachmentsError {
22 Status400(models::ErrorResponse),
23 Status401(models::ErrorResponse),
24 UnknownValue(serde_json::Value),
25}
26
27#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(untagged)]
30pub enum BulkDeleteAlertsError {
31 Status400(models::ErrorResponse),
32 Status401(models::ErrorResponse),
33 Status403(models::ErrorResponse),
34 Status500(models::ErrorResponse),
35 UnknownValue(serde_json::Value),
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum BulkMergeAlertsIntoCaseError {
42 Status400(models::ErrorResponse),
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum BulkUpdateAlertsError {
50 Status400(models::ErrorResponse),
51 Status401(models::ErrorResponse),
52 Status403(models::ErrorResponse),
53 Status500(models::ErrorResponse),
54 UnknownValue(serde_json::Value),
55}
56
57#[derive(Debug, Clone, Serialize, Deserialize)]
59#[serde(untagged)]
60pub enum CreateAlertError {
61 Status400(models::ErrorResponse),
62 Status401(models::ErrorResponse),
63 Status403(models::ErrorResponse),
64 Status500(models::ErrorResponse),
65 UnknownValue(serde_json::Value),
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
70#[serde(untagged)]
71pub enum CreateAlertObservableError {
72 Status400(models::ErrorResponse),
73 Status401(models::ErrorResponse),
74 Status403(models::ErrorResponse),
75 Status404(models::ErrorResponse),
76 Status500(models::ErrorResponse),
77 UnknownValue(serde_json::Value),
78}
79
80#[derive(Debug, Clone, Serialize, Deserialize)]
82#[serde(untagged)]
83pub enum CreateAlertProcedureError {
84 Status400(models::ErrorResponse),
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum DeleteAlertError {
92 Status401(models::ErrorResponse),
93 Status403(models::ErrorResponse),
94 Status404(models::ErrorResponse),
95 Status500(models::ErrorResponse),
96 UnknownValue(serde_json::Value),
97}
98
99#[derive(Debug, Clone, Serialize, Deserialize)]
101#[serde(untagged)]
102pub enum DeleteAlertAttachmentError {
103 Status401(models::ErrorResponse),
104 UnknownValue(serde_json::Value),
105}
106
107#[derive(Debug, Clone, Serialize, Deserialize)]
109#[serde(untagged)]
110pub enum DownloadAlertAttachmentError {
111 Status401(models::ErrorResponse),
112 UnknownValue(serde_json::Value),
113}
114
115#[derive(Debug, Clone, Serialize, Deserialize)]
117#[serde(untagged)]
118pub enum FollowAlertError {
119 Status401(models::ErrorResponse),
120 Status403(models::ErrorResponse),
121 Status404(models::ErrorResponse),
122 Status500(models::ErrorResponse),
123 UnknownValue(serde_json::Value),
124}
125
126#[derive(Debug, Clone, Serialize, Deserialize)]
128#[serde(untagged)]
129pub enum GetAlertByIdError {
130 Status401(models::ErrorResponse),
131 Status403(models::ErrorResponse),
132 Status404(models::ErrorResponse),
133 Status500(models::ErrorResponse),
134 UnknownValue(serde_json::Value),
135}
136
137#[derive(Debug, Clone, Serialize, Deserialize)]
139#[serde(untagged)]
140pub enum MergeAlertIntoCaseError {
141 Status400(models::ErrorResponse),
142 UnknownValue(serde_json::Value),
143}
144
145#[derive(Debug, Clone, Serialize, Deserialize)]
147#[serde(untagged)]
148pub enum PromoteAlertToCaseError {
149 Status400(models::ErrorResponse),
150 Status401(models::ErrorResponse),
151 Status403(models::ErrorResponse),
152 Status404(models::ErrorResponse),
153 Status500(models::ErrorResponse),
154 UnknownValue(serde_json::Value),
155}
156
157#[derive(Debug, Clone, Serialize, Deserialize)]
159#[serde(untagged)]
160pub enum UnfollowAlertError {
161 Status401(models::ErrorResponse),
162 Status403(models::ErrorResponse),
163 Status404(models::ErrorResponse),
164 Status500(models::ErrorResponse),
165 UnknownValue(serde_json::Value),
166}
167
168#[derive(Debug, Clone, Serialize, Deserialize)]
170#[serde(untagged)]
171pub enum UpdateAlertError {
172 Status400(models::ErrorResponse),
173 Status401(models::ErrorResponse),
174 Status403(models::ErrorResponse),
175 Status404(models::ErrorResponse),
176 Status500(models::ErrorResponse),
177 UnknownValue(serde_json::Value),
178}
179
180
181pub 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>> {
182 let p_alert_id = alert_id;
184 let p_x_organisation = x_organisation;
185 let p_attachments = attachments;
186
187 let uri_str = format!("{}/v1/alert/{alert_id}/attachments", configuration.base_path, alert_id=crate::apis::urlencode(p_alert_id));
188 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
189
190 if let Some(ref user_agent) = configuration.user_agent {
191 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
192 }
193 if let Some(param_value) = p_x_organisation {
194 req_builder = req_builder.header("X-Organisation", param_value.to_string());
195 }
196 if let Some(ref auth_conf) = configuration.basic_auth {
197 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
198 };
199 if let Some(ref token) = configuration.bearer_access_token {
200 req_builder = req_builder.bearer_auth(token.to_owned());
201 };
202 let mut multipart_form = reqwest::multipart::Form::new();
203 req_builder = req_builder.multipart(multipart_form);
205
206 let req = req_builder.build()?;
207 let resp = configuration.client.execute(req).await?;
208
209 let status = resp.status();
210 let content_type = resp
211 .headers()
212 .get("content-type")
213 .and_then(|v| v.to_str().ok())
214 .unwrap_or("application/octet-stream");
215 let content_type = super::ContentType::from(content_type);
216
217 if !status.is_client_error() && !status.is_server_error() {
218 let content = resp.text().await?;
219 match content_type {
220 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
221 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AddAlertAttachments201Response`"))),
222 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`")))),
223 }
224 } else {
225 let content = resp.text().await?;
226 let entity: Option<AddAlertAttachmentsError> = serde_json::from_str(&content).ok();
227 Err(Error::ResponseError(ResponseContent { status, content, entity }))
228 }
229}
230
231pub async fn bulk_delete_alerts(configuration: &configuration::Configuration, bulk_delete_alerts_request: models::BulkDeleteAlertsRequest, x_organisation: Option<&str>) -> Result<(), Error<BulkDeleteAlertsError>> {
232 let p_bulk_delete_alerts_request = bulk_delete_alerts_request;
234 let p_x_organisation = x_organisation;
235
236 let uri_str = format!("{}/v1/alert/delete/_bulk", configuration.base_path);
237 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
238
239 if let Some(ref user_agent) = configuration.user_agent {
240 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
241 }
242 if let Some(param_value) = p_x_organisation {
243 req_builder = req_builder.header("X-Organisation", param_value.to_string());
244 }
245 if let Some(ref auth_conf) = configuration.basic_auth {
246 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
247 };
248 if let Some(ref token) = configuration.bearer_access_token {
249 req_builder = req_builder.bearer_auth(token.to_owned());
250 };
251 req_builder = req_builder.json(&p_bulk_delete_alerts_request);
252
253 let req = req_builder.build()?;
254 let resp = configuration.client.execute(req).await?;
255
256 let status = resp.status();
257
258 if !status.is_client_error() && !status.is_server_error() {
259 Ok(())
260 } else {
261 let content = resp.text().await?;
262 let entity: Option<BulkDeleteAlertsError> = serde_json::from_str(&content).ok();
263 Err(Error::ResponseError(ResponseContent { status, content, entity }))
264 }
265}
266
267pub 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>> {
268 let p_bulk_merge_alerts_into_case_request = bulk_merge_alerts_into_case_request;
270 let p_x_organisation = x_organisation;
271
272 let uri_str = format!("{}/v1/alert/merge/_bulk", configuration.base_path);
273 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
274
275 if let Some(ref user_agent) = configuration.user_agent {
276 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
277 }
278 if let Some(param_value) = p_x_organisation {
279 req_builder = req_builder.header("X-Organisation", param_value.to_string());
280 }
281 if let Some(ref auth_conf) = configuration.basic_auth {
282 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
283 };
284 if let Some(ref token) = configuration.bearer_access_token {
285 req_builder = req_builder.bearer_auth(token.to_owned());
286 };
287 req_builder = req_builder.json(&p_bulk_merge_alerts_into_case_request);
288
289 let req = req_builder.build()?;
290 let resp = configuration.client.execute(req).await?;
291
292 let status = resp.status();
293 let content_type = resp
294 .headers()
295 .get("content-type")
296 .and_then(|v| v.to_str().ok())
297 .unwrap_or("application/octet-stream");
298 let content_type = super::ContentType::from(content_type);
299
300 if !status.is_client_error() && !status.is_server_error() {
301 let content = resp.text().await?;
302 match content_type {
303 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
304 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OutputCase`"))),
305 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`")))),
306 }
307 } else {
308 let content = resp.text().await?;
309 let entity: Option<BulkMergeAlertsIntoCaseError> = serde_json::from_str(&content).ok();
310 Err(Error::ResponseError(ResponseContent { status, content, entity }))
311 }
312}
313
314pub async fn bulk_update_alerts(configuration: &configuration::Configuration, input_bulk_update_alert: models::InputBulkUpdateAlert, x_organisation: Option<&str>) -> Result<(), Error<BulkUpdateAlertsError>> {
315 let p_input_bulk_update_alert = input_bulk_update_alert;
317 let p_x_organisation = x_organisation;
318
319 let uri_str = format!("{}/v1/alert/_bulk", configuration.base_path);
320 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
321
322 if let Some(ref user_agent) = configuration.user_agent {
323 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
324 }
325 if let Some(param_value) = p_x_organisation {
326 req_builder = req_builder.header("X-Organisation", param_value.to_string());
327 }
328 if let Some(ref auth_conf) = configuration.basic_auth {
329 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
330 };
331 if let Some(ref token) = configuration.bearer_access_token {
332 req_builder = req_builder.bearer_auth(token.to_owned());
333 };
334 req_builder = req_builder.json(&p_input_bulk_update_alert);
335
336 let req = req_builder.build()?;
337 let resp = configuration.client.execute(req).await?;
338
339 let status = resp.status();
340
341 if !status.is_client_error() && !status.is_server_error() {
342 Ok(())
343 } else {
344 let content = resp.text().await?;
345 let entity: Option<BulkUpdateAlertsError> = serde_json::from_str(&content).ok();
346 Err(Error::ResponseError(ResponseContent { status, content, entity }))
347 }
348}
349
350pub async fn create_alert(configuration: &configuration::Configuration, input_alert: models::InputAlert, x_organisation: Option<&str>) -> Result<models::OutputAlert, Error<CreateAlertError>> {
351 let p_input_alert = input_alert;
353 let p_x_organisation = x_organisation;
354
355 let uri_str = format!("{}/v1/alert", configuration.base_path);
356 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
357
358 if let Some(ref user_agent) = configuration.user_agent {
359 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
360 }
361 if let Some(param_value) = p_x_organisation {
362 req_builder = req_builder.header("X-Organisation", param_value.to_string());
363 }
364 if let Some(ref auth_conf) = configuration.basic_auth {
365 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
366 };
367 if let Some(ref token) = configuration.bearer_access_token {
368 req_builder = req_builder.bearer_auth(token.to_owned());
369 };
370 req_builder = req_builder.json(&p_input_alert);
371
372 let req = req_builder.build()?;
373 let resp = configuration.client.execute(req).await?;
374
375 let status = resp.status();
376 let content_type = resp
377 .headers()
378 .get("content-type")
379 .and_then(|v| v.to_str().ok())
380 .unwrap_or("application/octet-stream");
381 let content_type = super::ContentType::from(content_type);
382
383 if !status.is_client_error() && !status.is_server_error() {
384 let content = resp.text().await?;
385 match content_type {
386 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
387 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OutputAlert`"))),
388 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`")))),
389 }
390 } else {
391 let content = resp.text().await?;
392 let entity: Option<CreateAlertError> = serde_json::from_str(&content).ok();
393 Err(Error::ResponseError(ResponseContent { status, content, entity }))
394 }
395}
396
397pub 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>> {
398 let p_alert_id = alert_id;
400 let p_input_observable = input_observable;
401 let p_x_organisation = x_organisation;
402
403 let uri_str = format!("{}/v1/alert/{alert_id}/observable", configuration.base_path, alert_id=crate::apis::urlencode(p_alert_id));
404 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
405
406 if let Some(ref user_agent) = configuration.user_agent {
407 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
408 }
409 if let Some(param_value) = p_x_organisation {
410 req_builder = req_builder.header("X-Organisation", param_value.to_string());
411 }
412 if let Some(ref auth_conf) = configuration.basic_auth {
413 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
414 };
415 if let Some(ref token) = configuration.bearer_access_token {
416 req_builder = req_builder.bearer_auth(token.to_owned());
417 };
418 req_builder = req_builder.json(&p_input_observable);
419
420 let req = req_builder.build()?;
421 let resp = configuration.client.execute(req).await?;
422
423 let status = resp.status();
424 let content_type = resp
425 .headers()
426 .get("content-type")
427 .and_then(|v| v.to_str().ok())
428 .unwrap_or("application/octet-stream");
429 let content_type = super::ContentType::from(content_type);
430
431 if !status.is_client_error() && !status.is_server_error() {
432 let content = resp.text().await?;
433 match content_type {
434 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
435 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::OutputObservable>`"))),
436 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>`")))),
437 }
438 } else {
439 let content = resp.text().await?;
440 let entity: Option<CreateAlertObservableError> = serde_json::from_str(&content).ok();
441 Err(Error::ResponseError(ResponseContent { status, content, entity }))
442 }
443}
444
445pub async fn create_alert_procedure(configuration: &configuration::Configuration, alert_id: &str, input_procedure: models::InputProcedure, x_organisation: Option<&str>) -> Result<models::OutputProcedure, Error<CreateAlertProcedureError>> {
446 let p_alert_id = alert_id;
448 let p_input_procedure = input_procedure;
449 let p_x_organisation = x_organisation;
450
451 let uri_str = format!("{}/v1/alert/{alert_id}/procedure", configuration.base_path, alert_id=crate::apis::urlencode(p_alert_id));
452 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
453
454 if let Some(ref user_agent) = configuration.user_agent {
455 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
456 }
457 if let Some(param_value) = p_x_organisation {
458 req_builder = req_builder.header("X-Organisation", param_value.to_string());
459 }
460 if let Some(ref auth_conf) = configuration.basic_auth {
461 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
462 };
463 if let Some(ref token) = configuration.bearer_access_token {
464 req_builder = req_builder.bearer_auth(token.to_owned());
465 };
466 req_builder = req_builder.json(&p_input_procedure);
467
468 let req = req_builder.build()?;
469 let resp = configuration.client.execute(req).await?;
470
471 let status = resp.status();
472 let content_type = resp
473 .headers()
474 .get("content-type")
475 .and_then(|v| v.to_str().ok())
476 .unwrap_or("application/octet-stream");
477 let content_type = super::ContentType::from(content_type);
478
479 if !status.is_client_error() && !status.is_server_error() {
480 let content = resp.text().await?;
481 match content_type {
482 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
483 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OutputProcedure`"))),
484 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`")))),
485 }
486 } else {
487 let content = resp.text().await?;
488 let entity: Option<CreateAlertProcedureError> = serde_json::from_str(&content).ok();
489 Err(Error::ResponseError(ResponseContent { status, content, entity }))
490 }
491}
492
493pub async fn delete_alert(configuration: &configuration::Configuration, alert_id: &str, x_organisation: Option<&str>) -> Result<(), Error<DeleteAlertError>> {
494 let p_alert_id = alert_id;
496 let p_x_organisation = x_organisation;
497
498 let uri_str = format!("{}/v1/alert/{alert_id}", configuration.base_path, alert_id=crate::apis::urlencode(p_alert_id));
499 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
500
501 if let Some(ref user_agent) = configuration.user_agent {
502 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
503 }
504 if let Some(param_value) = p_x_organisation {
505 req_builder = req_builder.header("X-Organisation", param_value.to_string());
506 }
507 if let Some(ref auth_conf) = configuration.basic_auth {
508 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
509 };
510 if let Some(ref token) = configuration.bearer_access_token {
511 req_builder = req_builder.bearer_auth(token.to_owned());
512 };
513
514 let req = req_builder.build()?;
515 let resp = configuration.client.execute(req).await?;
516
517 let status = resp.status();
518
519 if !status.is_client_error() && !status.is_server_error() {
520 Ok(())
521 } else {
522 let content = resp.text().await?;
523 let entity: Option<DeleteAlertError> = serde_json::from_str(&content).ok();
524 Err(Error::ResponseError(ResponseContent { status, content, entity }))
525 }
526}
527
528pub async fn delete_alert_attachment(configuration: &configuration::Configuration, alert_id: &str, attachment_id: &str, x_organisation: Option<&str>) -> Result<(), Error<DeleteAlertAttachmentError>> {
529 let p_alert_id = alert_id;
531 let p_attachment_id = attachment_id;
532 let p_x_organisation = x_organisation;
533
534 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));
535 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
536
537 if let Some(ref user_agent) = configuration.user_agent {
538 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
539 }
540 if let Some(param_value) = p_x_organisation {
541 req_builder = req_builder.header("X-Organisation", param_value.to_string());
542 }
543 if let Some(ref auth_conf) = configuration.basic_auth {
544 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
545 };
546 if let Some(ref token) = configuration.bearer_access_token {
547 req_builder = req_builder.bearer_auth(token.to_owned());
548 };
549
550 let req = req_builder.build()?;
551 let resp = configuration.client.execute(req).await?;
552
553 let status = resp.status();
554
555 if !status.is_client_error() && !status.is_server_error() {
556 Ok(())
557 } else {
558 let content = resp.text().await?;
559 let entity: Option<DeleteAlertAttachmentError> = serde_json::from_str(&content).ok();
560 Err(Error::ResponseError(ResponseContent { status, content, entity }))
561 }
562}
563
564pub async fn download_alert_attachment(configuration: &configuration::Configuration, alert_id: &str, attachment_id: &str, x_organisation: Option<&str>) -> Result<(), Error<DownloadAlertAttachmentError>> {
565 let p_alert_id = alert_id;
567 let p_attachment_id = attachment_id;
568 let p_x_organisation = x_organisation;
569
570 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));
571 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
572
573 if let Some(ref user_agent) = configuration.user_agent {
574 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
575 }
576 if let Some(param_value) = p_x_organisation {
577 req_builder = req_builder.header("X-Organisation", param_value.to_string());
578 }
579 if let Some(ref auth_conf) = configuration.basic_auth {
580 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
581 };
582 if let Some(ref token) = configuration.bearer_access_token {
583 req_builder = req_builder.bearer_auth(token.to_owned());
584 };
585
586 let req = req_builder.build()?;
587 let resp = configuration.client.execute(req).await?;
588
589 let status = resp.status();
590
591 if !status.is_client_error() && !status.is_server_error() {
592 Ok(())
593 } else {
594 let content = resp.text().await?;
595 let entity: Option<DownloadAlertAttachmentError> = serde_json::from_str(&content).ok();
596 Err(Error::ResponseError(ResponseContent { status, content, entity }))
597 }
598}
599
600pub async fn follow_alert(configuration: &configuration::Configuration, alert_id: &str, x_organisation: Option<&str>) -> Result<(), Error<FollowAlertError>> {
601 let p_alert_id = alert_id;
603 let p_x_organisation = x_organisation;
604
605 let uri_str = format!("{}/v1/alert/{alert_id}/follow", configuration.base_path, alert_id=crate::apis::urlencode(p_alert_id));
606 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
607
608 if let Some(ref user_agent) = configuration.user_agent {
609 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
610 }
611 if let Some(param_value) = p_x_organisation {
612 req_builder = req_builder.header("X-Organisation", param_value.to_string());
613 }
614 if let Some(ref auth_conf) = configuration.basic_auth {
615 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
616 };
617 if let Some(ref token) = configuration.bearer_access_token {
618 req_builder = req_builder.bearer_auth(token.to_owned());
619 };
620
621 let req = req_builder.build()?;
622 let resp = configuration.client.execute(req).await?;
623
624 let status = resp.status();
625
626 if !status.is_client_error() && !status.is_server_error() {
627 Ok(())
628 } else {
629 let content = resp.text().await?;
630 let entity: Option<FollowAlertError> = serde_json::from_str(&content).ok();
631 Err(Error::ResponseError(ResponseContent { status, content, entity }))
632 }
633}
634
635pub async fn get_alert_by_id(configuration: &configuration::Configuration, alert_id: &str, x_organisation: Option<&str>) -> Result<models::OutputAlert, Error<GetAlertByIdError>> {
636 let p_alert_id = alert_id;
638 let p_x_organisation = x_organisation;
639
640 let uri_str = format!("{}/v1/alert/{alert_id}", configuration.base_path, alert_id=crate::apis::urlencode(p_alert_id));
641 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
642
643 if let Some(ref user_agent) = configuration.user_agent {
644 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
645 }
646 if let Some(param_value) = p_x_organisation {
647 req_builder = req_builder.header("X-Organisation", param_value.to_string());
648 }
649 if let Some(ref auth_conf) = configuration.basic_auth {
650 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
651 };
652 if let Some(ref token) = configuration.bearer_access_token {
653 req_builder = req_builder.bearer_auth(token.to_owned());
654 };
655
656 let req = req_builder.build()?;
657 let resp = configuration.client.execute(req).await?;
658
659 let status = resp.status();
660 let content_type = resp
661 .headers()
662 .get("content-type")
663 .and_then(|v| v.to_str().ok())
664 .unwrap_or("application/octet-stream");
665 let content_type = super::ContentType::from(content_type);
666
667 if !status.is_client_error() && !status.is_server_error() {
668 let content = resp.text().await?;
669 match content_type {
670 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
671 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OutputAlert`"))),
672 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`")))),
673 }
674 } else {
675 let content = resp.text().await?;
676 let entity: Option<GetAlertByIdError> = serde_json::from_str(&content).ok();
677 Err(Error::ResponseError(ResponseContent { status, content, entity }))
678 }
679}
680
681pub async fn merge_alert_into_case(configuration: &configuration::Configuration, alert_id: &str, case_id: &str, x_organisation: Option<&str>) -> Result<models::OutputCase, Error<MergeAlertIntoCaseError>> {
682 let p_alert_id = alert_id;
684 let p_case_id = case_id;
685 let p_x_organisation = x_organisation;
686
687 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());
688 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
689
690 if let Some(ref user_agent) = configuration.user_agent {
691 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
692 }
693 if let Some(param_value) = p_x_organisation {
694 req_builder = req_builder.header("X-Organisation", param_value.to_string());
695 }
696 if let Some(ref auth_conf) = configuration.basic_auth {
697 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
698 };
699 if let Some(ref token) = configuration.bearer_access_token {
700 req_builder = req_builder.bearer_auth(token.to_owned());
701 };
702
703 let req = req_builder.build()?;
704 let resp = configuration.client.execute(req).await?;
705
706 let status = resp.status();
707 let content_type = resp
708 .headers()
709 .get("content-type")
710 .and_then(|v| v.to_str().ok())
711 .unwrap_or("application/octet-stream");
712 let content_type = super::ContentType::from(content_type);
713
714 if !status.is_client_error() && !status.is_server_error() {
715 let content = resp.text().await?;
716 match content_type {
717 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
718 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OutputCase`"))),
719 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`")))),
720 }
721 } else {
722 let content = resp.text().await?;
723 let entity: Option<MergeAlertIntoCaseError> = serde_json::from_str(&content).ok();
724 Err(Error::ResponseError(ResponseContent { status, content, entity }))
725 }
726}
727
728pub 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>> {
729 let p_alert_id = alert_id;
731 let p_x_organisation = x_organisation;
732 let p_input_promote_alert = input_promote_alert;
733
734 let uri_str = format!("{}/v1/alert/{alert_id}/case", configuration.base_path, alert_id=crate::apis::urlencode(p_alert_id));
735 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
736
737 if let Some(ref user_agent) = configuration.user_agent {
738 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
739 }
740 if let Some(param_value) = p_x_organisation {
741 req_builder = req_builder.header("X-Organisation", param_value.to_string());
742 }
743 if let Some(ref auth_conf) = configuration.basic_auth {
744 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
745 };
746 if let Some(ref token) = configuration.bearer_access_token {
747 req_builder = req_builder.bearer_auth(token.to_owned());
748 };
749 req_builder = req_builder.json(&p_input_promote_alert);
750
751 let req = req_builder.build()?;
752 let resp = configuration.client.execute(req).await?;
753
754 let status = resp.status();
755 let content_type = resp
756 .headers()
757 .get("content-type")
758 .and_then(|v| v.to_str().ok())
759 .unwrap_or("application/octet-stream");
760 let content_type = super::ContentType::from(content_type);
761
762 if !status.is_client_error() && !status.is_server_error() {
763 let content = resp.text().await?;
764 match content_type {
765 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
766 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OutputCase`"))),
767 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`")))),
768 }
769 } else {
770 let content = resp.text().await?;
771 let entity: Option<PromoteAlertToCaseError> = serde_json::from_str(&content).ok();
772 Err(Error::ResponseError(ResponseContent { status, content, entity }))
773 }
774}
775
776pub async fn unfollow_alert(configuration: &configuration::Configuration, alert_id: &str, x_organisation: Option<&str>) -> Result<(), Error<UnfollowAlertError>> {
777 let p_alert_id = alert_id;
779 let p_x_organisation = x_organisation;
780
781 let uri_str = format!("{}/v1/alert/{alert_id}/unfollow", configuration.base_path, alert_id=crate::apis::urlencode(p_alert_id));
782 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
783
784 if let Some(ref user_agent) = configuration.user_agent {
785 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
786 }
787 if let Some(param_value) = p_x_organisation {
788 req_builder = req_builder.header("X-Organisation", param_value.to_string());
789 }
790 if let Some(ref auth_conf) = configuration.basic_auth {
791 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
792 };
793 if let Some(ref token) = configuration.bearer_access_token {
794 req_builder = req_builder.bearer_auth(token.to_owned());
795 };
796
797 let req = req_builder.build()?;
798 let resp = configuration.client.execute(req).await?;
799
800 let status = resp.status();
801
802 if !status.is_client_error() && !status.is_server_error() {
803 Ok(())
804 } else {
805 let content = resp.text().await?;
806 let entity: Option<UnfollowAlertError> = serde_json::from_str(&content).ok();
807 Err(Error::ResponseError(ResponseContent { status, content, entity }))
808 }
809}
810
811pub async fn update_alert(configuration: &configuration::Configuration, alert_id: &str, input_update_alert: models::InputUpdateAlert, x_organisation: Option<&str>) -> Result<(), Error<UpdateAlertError>> {
812 let p_alert_id = alert_id;
814 let p_input_update_alert = input_update_alert;
815 let p_x_organisation = x_organisation;
816
817 let uri_str = format!("{}/v1/alert/{alert_id}", configuration.base_path, alert_id=crate::apis::urlencode(p_alert_id));
818 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
819
820 if let Some(ref user_agent) = configuration.user_agent {
821 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
822 }
823 if let Some(param_value) = p_x_organisation {
824 req_builder = req_builder.header("X-Organisation", param_value.to_string());
825 }
826 if let Some(ref auth_conf) = configuration.basic_auth {
827 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
828 };
829 if let Some(ref token) = configuration.bearer_access_token {
830 req_builder = req_builder.bearer_auth(token.to_owned());
831 };
832 req_builder = req_builder.json(&p_input_update_alert);
833
834 let req = req_builder.build()?;
835 let resp = configuration.client.execute(req).await?;
836
837 let status = resp.status();
838
839 if !status.is_client_error() && !status.is_server_error() {
840 Ok(())
841 } else {
842 let content = resp.text().await?;
843 let entity: Option<UpdateAlertError> = serde_json::from_str(&content).ok();
844 Err(Error::ResponseError(ResponseContent { status, content, entity }))
845 }
846}
847