authentik_client/apis/
events_api.rs

1/*
2 * authentik
3 *
4 * Making authentication simple.
5 *
6 * The version of the OpenAPI document: 2025.10.2
7 * Contact: hello@goauthentik.io
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16/// struct for typed errors of method [`events_events_actions_list`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum EventsEventsActionsListError {
20    Status400(models::ValidationError),
21    Status403(models::GenericError),
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`events_events_create`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum EventsEventsCreateError {
29    Status400(models::ValidationError),
30    Status403(models::GenericError),
31    UnknownValue(serde_json::Value),
32}
33
34/// struct for typed errors of method [`events_events_destroy`]
35#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum EventsEventsDestroyError {
38    Status400(models::ValidationError),
39    Status403(models::GenericError),
40    UnknownValue(serde_json::Value),
41}
42
43/// struct for typed errors of method [`events_events_list`]
44#[derive(Debug, Clone, Serialize, Deserialize)]
45#[serde(untagged)]
46pub enum EventsEventsListError {
47    Status400(models::ValidationError),
48    Status403(models::GenericError),
49    UnknownValue(serde_json::Value),
50}
51
52/// struct for typed errors of method [`events_events_partial_update`]
53#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum EventsEventsPartialUpdateError {
56    Status400(models::ValidationError),
57    Status403(models::GenericError),
58    UnknownValue(serde_json::Value),
59}
60
61/// struct for typed errors of method [`events_events_retrieve`]
62#[derive(Debug, Clone, Serialize, Deserialize)]
63#[serde(untagged)]
64pub enum EventsEventsRetrieveError {
65    Status400(models::ValidationError),
66    Status403(models::GenericError),
67    UnknownValue(serde_json::Value),
68}
69
70/// struct for typed errors of method [`events_events_top_per_user_list`]
71#[derive(Debug, Clone, Serialize, Deserialize)]
72#[serde(untagged)]
73pub enum EventsEventsTopPerUserListError {
74    Status400(models::ValidationError),
75    Status403(models::GenericError),
76    UnknownValue(serde_json::Value),
77}
78
79/// struct for typed errors of method [`events_events_update`]
80#[derive(Debug, Clone, Serialize, Deserialize)]
81#[serde(untagged)]
82pub enum EventsEventsUpdateError {
83    Status400(models::ValidationError),
84    Status403(models::GenericError),
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`events_events_volume_list`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum EventsEventsVolumeListError {
92    Status400(models::ValidationError),
93    Status403(models::GenericError),
94    UnknownValue(serde_json::Value),
95}
96
97/// struct for typed errors of method [`events_notifications_destroy`]
98#[derive(Debug, Clone, Serialize, Deserialize)]
99#[serde(untagged)]
100pub enum EventsNotificationsDestroyError {
101    Status400(models::ValidationError),
102    Status403(models::GenericError),
103    UnknownValue(serde_json::Value),
104}
105
106/// struct for typed errors of method [`events_notifications_list`]
107#[derive(Debug, Clone, Serialize, Deserialize)]
108#[serde(untagged)]
109pub enum EventsNotificationsListError {
110    Status400(models::ValidationError),
111    Status403(models::GenericError),
112    UnknownValue(serde_json::Value),
113}
114
115/// struct for typed errors of method [`events_notifications_mark_all_seen_create`]
116#[derive(Debug, Clone, Serialize, Deserialize)]
117#[serde(untagged)]
118pub enum EventsNotificationsMarkAllSeenCreateError {
119    Status400(models::ValidationError),
120    Status403(models::GenericError),
121    UnknownValue(serde_json::Value),
122}
123
124/// struct for typed errors of method [`events_notifications_partial_update`]
125#[derive(Debug, Clone, Serialize, Deserialize)]
126#[serde(untagged)]
127pub enum EventsNotificationsPartialUpdateError {
128    Status400(models::ValidationError),
129    Status403(models::GenericError),
130    UnknownValue(serde_json::Value),
131}
132
133/// struct for typed errors of method [`events_notifications_retrieve`]
134#[derive(Debug, Clone, Serialize, Deserialize)]
135#[serde(untagged)]
136pub enum EventsNotificationsRetrieveError {
137    Status400(models::ValidationError),
138    Status403(models::GenericError),
139    UnknownValue(serde_json::Value),
140}
141
142/// struct for typed errors of method [`events_notifications_update`]
143#[derive(Debug, Clone, Serialize, Deserialize)]
144#[serde(untagged)]
145pub enum EventsNotificationsUpdateError {
146    Status400(models::ValidationError),
147    Status403(models::GenericError),
148    UnknownValue(serde_json::Value),
149}
150
151/// struct for typed errors of method [`events_notifications_used_by_list`]
152#[derive(Debug, Clone, Serialize, Deserialize)]
153#[serde(untagged)]
154pub enum EventsNotificationsUsedByListError {
155    Status400(models::ValidationError),
156    Status403(models::GenericError),
157    UnknownValue(serde_json::Value),
158}
159
160/// struct for typed errors of method [`events_rules_create`]
161#[derive(Debug, Clone, Serialize, Deserialize)]
162#[serde(untagged)]
163pub enum EventsRulesCreateError {
164    Status400(models::ValidationError),
165    Status403(models::GenericError),
166    UnknownValue(serde_json::Value),
167}
168
169/// struct for typed errors of method [`events_rules_destroy`]
170#[derive(Debug, Clone, Serialize, Deserialize)]
171#[serde(untagged)]
172pub enum EventsRulesDestroyError {
173    Status400(models::ValidationError),
174    Status403(models::GenericError),
175    UnknownValue(serde_json::Value),
176}
177
178/// struct for typed errors of method [`events_rules_list`]
179#[derive(Debug, Clone, Serialize, Deserialize)]
180#[serde(untagged)]
181pub enum EventsRulesListError {
182    Status400(models::ValidationError),
183    Status403(models::GenericError),
184    UnknownValue(serde_json::Value),
185}
186
187/// struct for typed errors of method [`events_rules_partial_update`]
188#[derive(Debug, Clone, Serialize, Deserialize)]
189#[serde(untagged)]
190pub enum EventsRulesPartialUpdateError {
191    Status400(models::ValidationError),
192    Status403(models::GenericError),
193    UnknownValue(serde_json::Value),
194}
195
196/// struct for typed errors of method [`events_rules_retrieve`]
197#[derive(Debug, Clone, Serialize, Deserialize)]
198#[serde(untagged)]
199pub enum EventsRulesRetrieveError {
200    Status400(models::ValidationError),
201    Status403(models::GenericError),
202    UnknownValue(serde_json::Value),
203}
204
205/// struct for typed errors of method [`events_rules_update`]
206#[derive(Debug, Clone, Serialize, Deserialize)]
207#[serde(untagged)]
208pub enum EventsRulesUpdateError {
209    Status400(models::ValidationError),
210    Status403(models::GenericError),
211    UnknownValue(serde_json::Value),
212}
213
214/// struct for typed errors of method [`events_rules_used_by_list`]
215#[derive(Debug, Clone, Serialize, Deserialize)]
216#[serde(untagged)]
217pub enum EventsRulesUsedByListError {
218    Status400(models::ValidationError),
219    Status403(models::GenericError),
220    UnknownValue(serde_json::Value),
221}
222
223/// struct for typed errors of method [`events_transports_create`]
224#[derive(Debug, Clone, Serialize, Deserialize)]
225#[serde(untagged)]
226pub enum EventsTransportsCreateError {
227    Status400(models::ValidationError),
228    Status403(models::GenericError),
229    UnknownValue(serde_json::Value),
230}
231
232/// struct for typed errors of method [`events_transports_destroy`]
233#[derive(Debug, Clone, Serialize, Deserialize)]
234#[serde(untagged)]
235pub enum EventsTransportsDestroyError {
236    Status400(models::ValidationError),
237    Status403(models::GenericError),
238    UnknownValue(serde_json::Value),
239}
240
241/// struct for typed errors of method [`events_transports_list`]
242#[derive(Debug, Clone, Serialize, Deserialize)]
243#[serde(untagged)]
244pub enum EventsTransportsListError {
245    Status400(models::ValidationError),
246    Status403(models::GenericError),
247    UnknownValue(serde_json::Value),
248}
249
250/// struct for typed errors of method [`events_transports_partial_update`]
251#[derive(Debug, Clone, Serialize, Deserialize)]
252#[serde(untagged)]
253pub enum EventsTransportsPartialUpdateError {
254    Status400(models::ValidationError),
255    Status403(models::GenericError),
256    UnknownValue(serde_json::Value),
257}
258
259/// struct for typed errors of method [`events_transports_retrieve`]
260#[derive(Debug, Clone, Serialize, Deserialize)]
261#[serde(untagged)]
262pub enum EventsTransportsRetrieveError {
263    Status400(models::ValidationError),
264    Status403(models::GenericError),
265    UnknownValue(serde_json::Value),
266}
267
268/// struct for typed errors of method [`events_transports_test_create`]
269#[derive(Debug, Clone, Serialize, Deserialize)]
270#[serde(untagged)]
271pub enum EventsTransportsTestCreateError {
272    Status500(),
273    Status400(models::ValidationError),
274    Status403(models::GenericError),
275    UnknownValue(serde_json::Value),
276}
277
278/// struct for typed errors of method [`events_transports_update`]
279#[derive(Debug, Clone, Serialize, Deserialize)]
280#[serde(untagged)]
281pub enum EventsTransportsUpdateError {
282    Status400(models::ValidationError),
283    Status403(models::GenericError),
284    UnknownValue(serde_json::Value),
285}
286
287/// struct for typed errors of method [`events_transports_used_by_list`]
288#[derive(Debug, Clone, Serialize, Deserialize)]
289#[serde(untagged)]
290pub enum EventsTransportsUsedByListError {
291    Status400(models::ValidationError),
292    Status403(models::GenericError),
293    UnknownValue(serde_json::Value),
294}
295
296/// Get all actions
297pub async fn events_events_actions_list(
298    configuration: &configuration::Configuration,
299) -> Result<Vec<models::TypeCreate>, Error<EventsEventsActionsListError>> {
300    let uri_str = format!("{}/events/events/actions/", configuration.base_path);
301    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
302
303    if let Some(ref user_agent) = configuration.user_agent {
304        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
305    }
306    if let Some(ref token) = configuration.bearer_access_token {
307        req_builder = req_builder.bearer_auth(token.to_owned());
308    };
309
310    let req = req_builder.build()?;
311    let resp = configuration.client.execute(req).await?;
312
313    let status = resp.status();
314    let content_type = resp
315        .headers()
316        .get("content-type")
317        .and_then(|v| v.to_str().ok())
318        .unwrap_or("application/octet-stream");
319    let content_type = super::ContentType::from(content_type);
320
321    if !status.is_client_error() && !status.is_server_error() {
322        let content = resp.text().await?;
323        match content_type {
324            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
325            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::TypeCreate&gt;`"))),
326            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&lt;models::TypeCreate&gt;`")))),
327        }
328    } else {
329        let content = resp.text().await?;
330        let entity: Option<EventsEventsActionsListError> = serde_json::from_str(&content).ok();
331        Err(Error::ResponseError(ResponseContent {
332            status,
333            content,
334            entity,
335        }))
336    }
337}
338
339/// Event Read-Only Viewset
340pub async fn events_events_create(
341    configuration: &configuration::Configuration,
342    event_request: models::EventRequest,
343) -> Result<models::Event, Error<EventsEventsCreateError>> {
344    // add a prefix to parameters to efficiently prevent name collisions
345    let p_body_event_request = event_request;
346
347    let uri_str = format!("{}/events/events/", configuration.base_path);
348    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
349
350    if let Some(ref user_agent) = configuration.user_agent {
351        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
352    }
353    if let Some(ref token) = configuration.bearer_access_token {
354        req_builder = req_builder.bearer_auth(token.to_owned());
355    };
356    req_builder = req_builder.json(&p_body_event_request);
357
358    let req = req_builder.build()?;
359    let resp = configuration.client.execute(req).await?;
360
361    let status = resp.status();
362    let content_type = resp
363        .headers()
364        .get("content-type")
365        .and_then(|v| v.to_str().ok())
366        .unwrap_or("application/octet-stream");
367    let content_type = super::ContentType::from(content_type);
368
369    if !status.is_client_error() && !status.is_server_error() {
370        let content = resp.text().await?;
371        match content_type {
372            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
373            ContentType::Text => {
374                return Err(Error::from(serde_json::Error::custom(
375                    "Received `text/plain` content type response that cannot be converted to `models::Event`",
376                )))
377            }
378            ContentType::Unsupported(unknown_type) => {
379                return Err(Error::from(serde_json::Error::custom(format!(
380                    "Received `{unknown_type}` content type response that cannot be converted to `models::Event`"
381                ))))
382            }
383        }
384    } else {
385        let content = resp.text().await?;
386        let entity: Option<EventsEventsCreateError> = serde_json::from_str(&content).ok();
387        Err(Error::ResponseError(ResponseContent {
388            status,
389            content,
390            entity,
391        }))
392    }
393}
394
395/// Event Read-Only Viewset
396pub async fn events_events_destroy(
397    configuration: &configuration::Configuration,
398    event_uuid: &str,
399) -> Result<(), Error<EventsEventsDestroyError>> {
400    // add a prefix to parameters to efficiently prevent name collisions
401    let p_path_event_uuid = event_uuid;
402
403    let uri_str = format!(
404        "{}/events/events/{event_uuid}/",
405        configuration.base_path,
406        event_uuid = crate::apis::urlencode(p_path_event_uuid)
407    );
408    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
409
410    if let Some(ref user_agent) = configuration.user_agent {
411        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
412    }
413    if let Some(ref token) = configuration.bearer_access_token {
414        req_builder = req_builder.bearer_auth(token.to_owned());
415    };
416
417    let req = req_builder.build()?;
418    let resp = configuration.client.execute(req).await?;
419
420    let status = resp.status();
421
422    if !status.is_client_error() && !status.is_server_error() {
423        Ok(())
424    } else {
425        let content = resp.text().await?;
426        let entity: Option<EventsEventsDestroyError> = serde_json::from_str(&content).ok();
427        Err(Error::ResponseError(ResponseContent {
428            status,
429            content,
430            entity,
431        }))
432    }
433}
434
435/// Event Read-Only Viewset
436pub async fn events_events_list(
437    configuration: &configuration::Configuration,
438    action: Option<&str>,
439    actions: Option<Vec<String>>,
440    brand_name: Option<&str>,
441    client_ip: Option<&str>,
442    context_authorized_app: Option<&str>,
443    context_model_app: Option<&str>,
444    context_model_name: Option<&str>,
445    context_model_pk: Option<&str>,
446    ordering: Option<&str>,
447    page: Option<i32>,
448    page_size: Option<i32>,
449    search: Option<&str>,
450    username: Option<&str>,
451) -> Result<models::PaginatedEventList, Error<EventsEventsListError>> {
452    // add a prefix to parameters to efficiently prevent name collisions
453    let p_query_action = action;
454    let p_query_actions = actions;
455    let p_query_brand_name = brand_name;
456    let p_query_client_ip = client_ip;
457    let p_query_context_authorized_app = context_authorized_app;
458    let p_query_context_model_app = context_model_app;
459    let p_query_context_model_name = context_model_name;
460    let p_query_context_model_pk = context_model_pk;
461    let p_query_ordering = ordering;
462    let p_query_page = page;
463    let p_query_page_size = page_size;
464    let p_query_search = search;
465    let p_query_username = username;
466
467    let uri_str = format!("{}/events/events/", configuration.base_path);
468    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
469
470    if let Some(ref param_value) = p_query_action {
471        req_builder = req_builder.query(&[("action", &param_value.to_string())]);
472    }
473    if let Some(ref param_value) = p_query_actions {
474        req_builder = match "multi" {
475            "multi" => req_builder.query(
476                &param_value
477                    .into_iter()
478                    .map(|p| ("actions".to_owned(), p.to_string()))
479                    .collect::<Vec<(std::string::String, std::string::String)>>(),
480            ),
481            _ => req_builder.query(&[(
482                "actions",
483                &param_value
484                    .into_iter()
485                    .map(|p| p.to_string())
486                    .collect::<Vec<String>>()
487                    .join(",")
488                    .to_string(),
489            )]),
490        };
491    }
492    if let Some(ref param_value) = p_query_brand_name {
493        req_builder = req_builder.query(&[("brand_name", &param_value.to_string())]);
494    }
495    if let Some(ref param_value) = p_query_client_ip {
496        req_builder = req_builder.query(&[("client_ip", &param_value.to_string())]);
497    }
498    if let Some(ref param_value) = p_query_context_authorized_app {
499        req_builder = req_builder.query(&[("context_authorized_app", &param_value.to_string())]);
500    }
501    if let Some(ref param_value) = p_query_context_model_app {
502        req_builder = req_builder.query(&[("context_model_app", &param_value.to_string())]);
503    }
504    if let Some(ref param_value) = p_query_context_model_name {
505        req_builder = req_builder.query(&[("context_model_name", &param_value.to_string())]);
506    }
507    if let Some(ref param_value) = p_query_context_model_pk {
508        req_builder = req_builder.query(&[("context_model_pk", &param_value.to_string())]);
509    }
510    if let Some(ref param_value) = p_query_ordering {
511        req_builder = req_builder.query(&[("ordering", &param_value.to_string())]);
512    }
513    if let Some(ref param_value) = p_query_page {
514        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
515    }
516    if let Some(ref param_value) = p_query_page_size {
517        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
518    }
519    if let Some(ref param_value) = p_query_search {
520        req_builder = req_builder.query(&[("search", &param_value.to_string())]);
521    }
522    if let Some(ref param_value) = p_query_username {
523        req_builder = req_builder.query(&[("username", &param_value.to_string())]);
524    }
525    if let Some(ref user_agent) = configuration.user_agent {
526        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
527    }
528    if let Some(ref token) = configuration.bearer_access_token {
529        req_builder = req_builder.bearer_auth(token.to_owned());
530    };
531
532    let req = req_builder.build()?;
533    let resp = configuration.client.execute(req).await?;
534
535    let status = resp.status();
536    let content_type = resp
537        .headers()
538        .get("content-type")
539        .and_then(|v| v.to_str().ok())
540        .unwrap_or("application/octet-stream");
541    let content_type = super::ContentType::from(content_type);
542
543    if !status.is_client_error() && !status.is_server_error() {
544        let content = resp.text().await?;
545        match content_type {
546            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
547            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedEventList`"))),
548            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::PaginatedEventList`")))),
549        }
550    } else {
551        let content = resp.text().await?;
552        let entity: Option<EventsEventsListError> = serde_json::from_str(&content).ok();
553        Err(Error::ResponseError(ResponseContent {
554            status,
555            content,
556            entity,
557        }))
558    }
559}
560
561/// Event Read-Only Viewset
562pub async fn events_events_partial_update(
563    configuration: &configuration::Configuration,
564    event_uuid: &str,
565    patched_event_request: Option<models::PatchedEventRequest>,
566) -> Result<models::Event, Error<EventsEventsPartialUpdateError>> {
567    // add a prefix to parameters to efficiently prevent name collisions
568    let p_path_event_uuid = event_uuid;
569    let p_body_patched_event_request = patched_event_request;
570
571    let uri_str = format!(
572        "{}/events/events/{event_uuid}/",
573        configuration.base_path,
574        event_uuid = crate::apis::urlencode(p_path_event_uuid)
575    );
576    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
577
578    if let Some(ref user_agent) = configuration.user_agent {
579        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
580    }
581    if let Some(ref token) = configuration.bearer_access_token {
582        req_builder = req_builder.bearer_auth(token.to_owned());
583    };
584    req_builder = req_builder.json(&p_body_patched_event_request);
585
586    let req = req_builder.build()?;
587    let resp = configuration.client.execute(req).await?;
588
589    let status = resp.status();
590    let content_type = resp
591        .headers()
592        .get("content-type")
593        .and_then(|v| v.to_str().ok())
594        .unwrap_or("application/octet-stream");
595    let content_type = super::ContentType::from(content_type);
596
597    if !status.is_client_error() && !status.is_server_error() {
598        let content = resp.text().await?;
599        match content_type {
600            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
601            ContentType::Text => {
602                return Err(Error::from(serde_json::Error::custom(
603                    "Received `text/plain` content type response that cannot be converted to `models::Event`",
604                )))
605            }
606            ContentType::Unsupported(unknown_type) => {
607                return Err(Error::from(serde_json::Error::custom(format!(
608                    "Received `{unknown_type}` content type response that cannot be converted to `models::Event`"
609                ))))
610            }
611        }
612    } else {
613        let content = resp.text().await?;
614        let entity: Option<EventsEventsPartialUpdateError> = serde_json::from_str(&content).ok();
615        Err(Error::ResponseError(ResponseContent {
616            status,
617            content,
618            entity,
619        }))
620    }
621}
622
623/// Event Read-Only Viewset
624pub async fn events_events_retrieve(
625    configuration: &configuration::Configuration,
626    event_uuid: &str,
627) -> Result<models::Event, Error<EventsEventsRetrieveError>> {
628    // add a prefix to parameters to efficiently prevent name collisions
629    let p_path_event_uuid = event_uuid;
630
631    let uri_str = format!(
632        "{}/events/events/{event_uuid}/",
633        configuration.base_path,
634        event_uuid = crate::apis::urlencode(p_path_event_uuid)
635    );
636    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
637
638    if let Some(ref user_agent) = configuration.user_agent {
639        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
640    }
641    if let Some(ref token) = configuration.bearer_access_token {
642        req_builder = req_builder.bearer_auth(token.to_owned());
643    };
644
645    let req = req_builder.build()?;
646    let resp = configuration.client.execute(req).await?;
647
648    let status = resp.status();
649    let content_type = resp
650        .headers()
651        .get("content-type")
652        .and_then(|v| v.to_str().ok())
653        .unwrap_or("application/octet-stream");
654    let content_type = super::ContentType::from(content_type);
655
656    if !status.is_client_error() && !status.is_server_error() {
657        let content = resp.text().await?;
658        match content_type {
659            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
660            ContentType::Text => {
661                return Err(Error::from(serde_json::Error::custom(
662                    "Received `text/plain` content type response that cannot be converted to `models::Event`",
663                )))
664            }
665            ContentType::Unsupported(unknown_type) => {
666                return Err(Error::from(serde_json::Error::custom(format!(
667                    "Received `{unknown_type}` content type response that cannot be converted to `models::Event`"
668                ))))
669            }
670        }
671    } else {
672        let content = resp.text().await?;
673        let entity: Option<EventsEventsRetrieveError> = serde_json::from_str(&content).ok();
674        Err(Error::ResponseError(ResponseContent {
675            status,
676            content,
677            entity,
678        }))
679    }
680}
681
682/// Get the top_n events grouped by user count
683pub async fn events_events_top_per_user_list(
684    configuration: &configuration::Configuration,
685    action: Option<&str>,
686    top_n: Option<i32>,
687) -> Result<Vec<models::EventTopPerUser>, Error<EventsEventsTopPerUserListError>> {
688    // add a prefix to parameters to efficiently prevent name collisions
689    let p_query_action = action;
690    let p_query_top_n = top_n;
691
692    let uri_str = format!("{}/events/events/top_per_user/", configuration.base_path);
693    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
694
695    if let Some(ref param_value) = p_query_action {
696        req_builder = req_builder.query(&[("action", &param_value.to_string())]);
697    }
698    if let Some(ref param_value) = p_query_top_n {
699        req_builder = req_builder.query(&[("top_n", &param_value.to_string())]);
700    }
701    if let Some(ref user_agent) = configuration.user_agent {
702        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
703    }
704    if let Some(ref token) = configuration.bearer_access_token {
705        req_builder = req_builder.bearer_auth(token.to_owned());
706    };
707
708    let req = req_builder.build()?;
709    let resp = configuration.client.execute(req).await?;
710
711    let status = resp.status();
712    let content_type = resp
713        .headers()
714        .get("content-type")
715        .and_then(|v| v.to_str().ok())
716        .unwrap_or("application/octet-stream");
717    let content_type = super::ContentType::from(content_type);
718
719    if !status.is_client_error() && !status.is_server_error() {
720        let content = resp.text().await?;
721        match content_type {
722            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
723            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::EventTopPerUser&gt;`"))),
724            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&lt;models::EventTopPerUser&gt;`")))),
725        }
726    } else {
727        let content = resp.text().await?;
728        let entity: Option<EventsEventsTopPerUserListError> = serde_json::from_str(&content).ok();
729        Err(Error::ResponseError(ResponseContent {
730            status,
731            content,
732            entity,
733        }))
734    }
735}
736
737/// Event Read-Only Viewset
738pub async fn events_events_update(
739    configuration: &configuration::Configuration,
740    event_uuid: &str,
741    event_request: models::EventRequest,
742) -> Result<models::Event, Error<EventsEventsUpdateError>> {
743    // add a prefix to parameters to efficiently prevent name collisions
744    let p_path_event_uuid = event_uuid;
745    let p_body_event_request = event_request;
746
747    let uri_str = format!(
748        "{}/events/events/{event_uuid}/",
749        configuration.base_path,
750        event_uuid = crate::apis::urlencode(p_path_event_uuid)
751    );
752    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
753
754    if let Some(ref user_agent) = configuration.user_agent {
755        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
756    }
757    if let Some(ref token) = configuration.bearer_access_token {
758        req_builder = req_builder.bearer_auth(token.to_owned());
759    };
760    req_builder = req_builder.json(&p_body_event_request);
761
762    let req = req_builder.build()?;
763    let resp = configuration.client.execute(req).await?;
764
765    let status = resp.status();
766    let content_type = resp
767        .headers()
768        .get("content-type")
769        .and_then(|v| v.to_str().ok())
770        .unwrap_or("application/octet-stream");
771    let content_type = super::ContentType::from(content_type);
772
773    if !status.is_client_error() && !status.is_server_error() {
774        let content = resp.text().await?;
775        match content_type {
776            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
777            ContentType::Text => {
778                return Err(Error::from(serde_json::Error::custom(
779                    "Received `text/plain` content type response that cannot be converted to `models::Event`",
780                )))
781            }
782            ContentType::Unsupported(unknown_type) => {
783                return Err(Error::from(serde_json::Error::custom(format!(
784                    "Received `{unknown_type}` content type response that cannot be converted to `models::Event`"
785                ))))
786            }
787        }
788    } else {
789        let content = resp.text().await?;
790        let entity: Option<EventsEventsUpdateError> = serde_json::from_str(&content).ok();
791        Err(Error::ResponseError(ResponseContent {
792            status,
793            content,
794            entity,
795        }))
796    }
797}
798
799/// Get event volume for specified filters and timeframe
800pub async fn events_events_volume_list(
801    configuration: &configuration::Configuration,
802    action: Option<&str>,
803    actions: Option<Vec<String>>,
804    brand_name: Option<&str>,
805    client_ip: Option<&str>,
806    context_authorized_app: Option<&str>,
807    context_model_app: Option<&str>,
808    context_model_name: Option<&str>,
809    context_model_pk: Option<&str>,
810    history_days: Option<f64>,
811    ordering: Option<&str>,
812    search: Option<&str>,
813    username: Option<&str>,
814) -> Result<Vec<models::EventVolume>, Error<EventsEventsVolumeListError>> {
815    // add a prefix to parameters to efficiently prevent name collisions
816    let p_query_action = action;
817    let p_query_actions = actions;
818    let p_query_brand_name = brand_name;
819    let p_query_client_ip = client_ip;
820    let p_query_context_authorized_app = context_authorized_app;
821    let p_query_context_model_app = context_model_app;
822    let p_query_context_model_name = context_model_name;
823    let p_query_context_model_pk = context_model_pk;
824    let p_query_history_days = history_days;
825    let p_query_ordering = ordering;
826    let p_query_search = search;
827    let p_query_username = username;
828
829    let uri_str = format!("{}/events/events/volume/", configuration.base_path);
830    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
831
832    if let Some(ref param_value) = p_query_action {
833        req_builder = req_builder.query(&[("action", &param_value.to_string())]);
834    }
835    if let Some(ref param_value) = p_query_actions {
836        req_builder = match "multi" {
837            "multi" => req_builder.query(
838                &param_value
839                    .into_iter()
840                    .map(|p| ("actions".to_owned(), p.to_string()))
841                    .collect::<Vec<(std::string::String, std::string::String)>>(),
842            ),
843            _ => req_builder.query(&[(
844                "actions",
845                &param_value
846                    .into_iter()
847                    .map(|p| p.to_string())
848                    .collect::<Vec<String>>()
849                    .join(",")
850                    .to_string(),
851            )]),
852        };
853    }
854    if let Some(ref param_value) = p_query_brand_name {
855        req_builder = req_builder.query(&[("brand_name", &param_value.to_string())]);
856    }
857    if let Some(ref param_value) = p_query_client_ip {
858        req_builder = req_builder.query(&[("client_ip", &param_value.to_string())]);
859    }
860    if let Some(ref param_value) = p_query_context_authorized_app {
861        req_builder = req_builder.query(&[("context_authorized_app", &param_value.to_string())]);
862    }
863    if let Some(ref param_value) = p_query_context_model_app {
864        req_builder = req_builder.query(&[("context_model_app", &param_value.to_string())]);
865    }
866    if let Some(ref param_value) = p_query_context_model_name {
867        req_builder = req_builder.query(&[("context_model_name", &param_value.to_string())]);
868    }
869    if let Some(ref param_value) = p_query_context_model_pk {
870        req_builder = req_builder.query(&[("context_model_pk", &param_value.to_string())]);
871    }
872    if let Some(ref param_value) = p_query_history_days {
873        req_builder = req_builder.query(&[("history_days", &param_value.to_string())]);
874    }
875    if let Some(ref param_value) = p_query_ordering {
876        req_builder = req_builder.query(&[("ordering", &param_value.to_string())]);
877    }
878    if let Some(ref param_value) = p_query_search {
879        req_builder = req_builder.query(&[("search", &param_value.to_string())]);
880    }
881    if let Some(ref param_value) = p_query_username {
882        req_builder = req_builder.query(&[("username", &param_value.to_string())]);
883    }
884    if let Some(ref user_agent) = configuration.user_agent {
885        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
886    }
887    if let Some(ref token) = configuration.bearer_access_token {
888        req_builder = req_builder.bearer_auth(token.to_owned());
889    };
890
891    let req = req_builder.build()?;
892    let resp = configuration.client.execute(req).await?;
893
894    let status = resp.status();
895    let content_type = resp
896        .headers()
897        .get("content-type")
898        .and_then(|v| v.to_str().ok())
899        .unwrap_or("application/octet-stream");
900    let content_type = super::ContentType::from(content_type);
901
902    if !status.is_client_error() && !status.is_server_error() {
903        let content = resp.text().await?;
904        match content_type {
905            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
906            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::EventVolume&gt;`"))),
907            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&lt;models::EventVolume&gt;`")))),
908        }
909    } else {
910        let content = resp.text().await?;
911        let entity: Option<EventsEventsVolumeListError> = serde_json::from_str(&content).ok();
912        Err(Error::ResponseError(ResponseContent {
913            status,
914            content,
915            entity,
916        }))
917    }
918}
919
920/// Notification Viewset
921pub async fn events_notifications_destroy(
922    configuration: &configuration::Configuration,
923    uuid: &str,
924) -> Result<(), Error<EventsNotificationsDestroyError>> {
925    // add a prefix to parameters to efficiently prevent name collisions
926    let p_path_uuid = uuid;
927
928    let uri_str = format!(
929        "{}/events/notifications/{uuid}/",
930        configuration.base_path,
931        uuid = crate::apis::urlencode(p_path_uuid)
932    );
933    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
934
935    if let Some(ref user_agent) = configuration.user_agent {
936        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
937    }
938    if let Some(ref token) = configuration.bearer_access_token {
939        req_builder = req_builder.bearer_auth(token.to_owned());
940    };
941
942    let req = req_builder.build()?;
943    let resp = configuration.client.execute(req).await?;
944
945    let status = resp.status();
946
947    if !status.is_client_error() && !status.is_server_error() {
948        Ok(())
949    } else {
950        let content = resp.text().await?;
951        let entity: Option<EventsNotificationsDestroyError> = serde_json::from_str(&content).ok();
952        Err(Error::ResponseError(ResponseContent {
953            status,
954            content,
955            entity,
956        }))
957    }
958}
959
960/// Notification Viewset
961pub async fn events_notifications_list(
962    configuration: &configuration::Configuration,
963    body: Option<&str>,
964    created: Option<String>,
965    event: Option<&str>,
966    ordering: Option<&str>,
967    page: Option<i32>,
968    page_size: Option<i32>,
969    search: Option<&str>,
970    seen: Option<bool>,
971    severity: Option<&str>,
972    user: Option<i32>,
973) -> Result<models::PaginatedNotificationList, Error<EventsNotificationsListError>> {
974    // add a prefix to parameters to efficiently prevent name collisions
975    let p_query_body = body;
976    let p_query_created = created;
977    let p_query_event = event;
978    let p_query_ordering = ordering;
979    let p_query_page = page;
980    let p_query_page_size = page_size;
981    let p_query_search = search;
982    let p_query_seen = seen;
983    let p_query_severity = severity;
984    let p_query_user = user;
985
986    let uri_str = format!("{}/events/notifications/", configuration.base_path);
987    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
988
989    if let Some(ref param_value) = p_query_body {
990        req_builder = req_builder.query(&[("body", &param_value.to_string())]);
991    }
992    if let Some(ref param_value) = p_query_created {
993        req_builder = req_builder.query(&[("created", &param_value.to_string())]);
994    }
995    if let Some(ref param_value) = p_query_event {
996        req_builder = req_builder.query(&[("event", &param_value.to_string())]);
997    }
998    if let Some(ref param_value) = p_query_ordering {
999        req_builder = req_builder.query(&[("ordering", &param_value.to_string())]);
1000    }
1001    if let Some(ref param_value) = p_query_page {
1002        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
1003    }
1004    if let Some(ref param_value) = p_query_page_size {
1005        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
1006    }
1007    if let Some(ref param_value) = p_query_search {
1008        req_builder = req_builder.query(&[("search", &param_value.to_string())]);
1009    }
1010    if let Some(ref param_value) = p_query_seen {
1011        req_builder = req_builder.query(&[("seen", &param_value.to_string())]);
1012    }
1013    if let Some(ref param_value) = p_query_severity {
1014        req_builder = req_builder.query(&[("severity", &param_value.to_string())]);
1015    }
1016    if let Some(ref param_value) = p_query_user {
1017        req_builder = req_builder.query(&[("user", &param_value.to_string())]);
1018    }
1019    if let Some(ref user_agent) = configuration.user_agent {
1020        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1021    }
1022    if let Some(ref token) = configuration.bearer_access_token {
1023        req_builder = req_builder.bearer_auth(token.to_owned());
1024    };
1025
1026    let req = req_builder.build()?;
1027    let resp = configuration.client.execute(req).await?;
1028
1029    let status = resp.status();
1030    let content_type = resp
1031        .headers()
1032        .get("content-type")
1033        .and_then(|v| v.to_str().ok())
1034        .unwrap_or("application/octet-stream");
1035    let content_type = super::ContentType::from(content_type);
1036
1037    if !status.is_client_error() && !status.is_server_error() {
1038        let content = resp.text().await?;
1039        match content_type {
1040            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1041            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedNotificationList`"))),
1042            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::PaginatedNotificationList`")))),
1043        }
1044    } else {
1045        let content = resp.text().await?;
1046        let entity: Option<EventsNotificationsListError> = serde_json::from_str(&content).ok();
1047        Err(Error::ResponseError(ResponseContent {
1048            status,
1049            content,
1050            entity,
1051        }))
1052    }
1053}
1054
1055/// Mark all the user's notifications as seen
1056pub async fn events_notifications_mark_all_seen_create(
1057    configuration: &configuration::Configuration,
1058) -> Result<(), Error<EventsNotificationsMarkAllSeenCreateError>> {
1059    let uri_str = format!("{}/events/notifications/mark_all_seen/", configuration.base_path);
1060    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1061
1062    if let Some(ref user_agent) = configuration.user_agent {
1063        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1064    }
1065    if let Some(ref token) = configuration.bearer_access_token {
1066        req_builder = req_builder.bearer_auth(token.to_owned());
1067    };
1068
1069    let req = req_builder.build()?;
1070    let resp = configuration.client.execute(req).await?;
1071
1072    let status = resp.status();
1073
1074    if !status.is_client_error() && !status.is_server_error() {
1075        Ok(())
1076    } else {
1077        let content = resp.text().await?;
1078        let entity: Option<EventsNotificationsMarkAllSeenCreateError> = serde_json::from_str(&content).ok();
1079        Err(Error::ResponseError(ResponseContent {
1080            status,
1081            content,
1082            entity,
1083        }))
1084    }
1085}
1086
1087/// Notification Viewset
1088pub async fn events_notifications_partial_update(
1089    configuration: &configuration::Configuration,
1090    uuid: &str,
1091    patched_notification_request: Option<models::PatchedNotificationRequest>,
1092) -> Result<models::Notification, Error<EventsNotificationsPartialUpdateError>> {
1093    // add a prefix to parameters to efficiently prevent name collisions
1094    let p_path_uuid = uuid;
1095    let p_body_patched_notification_request = patched_notification_request;
1096
1097    let uri_str = format!(
1098        "{}/events/notifications/{uuid}/",
1099        configuration.base_path,
1100        uuid = crate::apis::urlencode(p_path_uuid)
1101    );
1102    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
1103
1104    if let Some(ref user_agent) = configuration.user_agent {
1105        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1106    }
1107    if let Some(ref token) = configuration.bearer_access_token {
1108        req_builder = req_builder.bearer_auth(token.to_owned());
1109    };
1110    req_builder = req_builder.json(&p_body_patched_notification_request);
1111
1112    let req = req_builder.build()?;
1113    let resp = configuration.client.execute(req).await?;
1114
1115    let status = resp.status();
1116    let content_type = resp
1117        .headers()
1118        .get("content-type")
1119        .and_then(|v| v.to_str().ok())
1120        .unwrap_or("application/octet-stream");
1121    let content_type = super::ContentType::from(content_type);
1122
1123    if !status.is_client_error() && !status.is_server_error() {
1124        let content = resp.text().await?;
1125        match content_type {
1126            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1127            ContentType::Text => {
1128                return Err(Error::from(serde_json::Error::custom(
1129                    "Received `text/plain` content type response that cannot be converted to `models::Notification`",
1130                )))
1131            }
1132            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!(
1133                "Received `{unknown_type}` content type response that cannot be converted to `models::Notification`"
1134            )))),
1135        }
1136    } else {
1137        let content = resp.text().await?;
1138        let entity: Option<EventsNotificationsPartialUpdateError> = serde_json::from_str(&content).ok();
1139        Err(Error::ResponseError(ResponseContent {
1140            status,
1141            content,
1142            entity,
1143        }))
1144    }
1145}
1146
1147/// Notification Viewset
1148pub async fn events_notifications_retrieve(
1149    configuration: &configuration::Configuration,
1150    uuid: &str,
1151) -> Result<models::Notification, Error<EventsNotificationsRetrieveError>> {
1152    // add a prefix to parameters to efficiently prevent name collisions
1153    let p_path_uuid = uuid;
1154
1155    let uri_str = format!(
1156        "{}/events/notifications/{uuid}/",
1157        configuration.base_path,
1158        uuid = crate::apis::urlencode(p_path_uuid)
1159    );
1160    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1161
1162    if let Some(ref user_agent) = configuration.user_agent {
1163        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1164    }
1165    if let Some(ref token) = configuration.bearer_access_token {
1166        req_builder = req_builder.bearer_auth(token.to_owned());
1167    };
1168
1169    let req = req_builder.build()?;
1170    let resp = configuration.client.execute(req).await?;
1171
1172    let status = resp.status();
1173    let content_type = resp
1174        .headers()
1175        .get("content-type")
1176        .and_then(|v| v.to_str().ok())
1177        .unwrap_or("application/octet-stream");
1178    let content_type = super::ContentType::from(content_type);
1179
1180    if !status.is_client_error() && !status.is_server_error() {
1181        let content = resp.text().await?;
1182        match content_type {
1183            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1184            ContentType::Text => {
1185                return Err(Error::from(serde_json::Error::custom(
1186                    "Received `text/plain` content type response that cannot be converted to `models::Notification`",
1187                )))
1188            }
1189            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!(
1190                "Received `{unknown_type}` content type response that cannot be converted to `models::Notification`"
1191            )))),
1192        }
1193    } else {
1194        let content = resp.text().await?;
1195        let entity: Option<EventsNotificationsRetrieveError> = serde_json::from_str(&content).ok();
1196        Err(Error::ResponseError(ResponseContent {
1197            status,
1198            content,
1199            entity,
1200        }))
1201    }
1202}
1203
1204/// Notification Viewset
1205pub async fn events_notifications_update(
1206    configuration: &configuration::Configuration,
1207    uuid: &str,
1208    notification_request: Option<models::NotificationRequest>,
1209) -> Result<models::Notification, Error<EventsNotificationsUpdateError>> {
1210    // add a prefix to parameters to efficiently prevent name collisions
1211    let p_path_uuid = uuid;
1212    let p_body_notification_request = notification_request;
1213
1214    let uri_str = format!(
1215        "{}/events/notifications/{uuid}/",
1216        configuration.base_path,
1217        uuid = crate::apis::urlencode(p_path_uuid)
1218    );
1219    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
1220
1221    if let Some(ref user_agent) = configuration.user_agent {
1222        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1223    }
1224    if let Some(ref token) = configuration.bearer_access_token {
1225        req_builder = req_builder.bearer_auth(token.to_owned());
1226    };
1227    req_builder = req_builder.json(&p_body_notification_request);
1228
1229    let req = req_builder.build()?;
1230    let resp = configuration.client.execute(req).await?;
1231
1232    let status = resp.status();
1233    let content_type = resp
1234        .headers()
1235        .get("content-type")
1236        .and_then(|v| v.to_str().ok())
1237        .unwrap_or("application/octet-stream");
1238    let content_type = super::ContentType::from(content_type);
1239
1240    if !status.is_client_error() && !status.is_server_error() {
1241        let content = resp.text().await?;
1242        match content_type {
1243            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1244            ContentType::Text => {
1245                return Err(Error::from(serde_json::Error::custom(
1246                    "Received `text/plain` content type response that cannot be converted to `models::Notification`",
1247                )))
1248            }
1249            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!(
1250                "Received `{unknown_type}` content type response that cannot be converted to `models::Notification`"
1251            )))),
1252        }
1253    } else {
1254        let content = resp.text().await?;
1255        let entity: Option<EventsNotificationsUpdateError> = serde_json::from_str(&content).ok();
1256        Err(Error::ResponseError(ResponseContent {
1257            status,
1258            content,
1259            entity,
1260        }))
1261    }
1262}
1263
1264/// Get a list of all objects that use this object
1265pub async fn events_notifications_used_by_list(
1266    configuration: &configuration::Configuration,
1267    uuid: &str,
1268) -> Result<Vec<models::UsedBy>, Error<EventsNotificationsUsedByListError>> {
1269    // add a prefix to parameters to efficiently prevent name collisions
1270    let p_path_uuid = uuid;
1271
1272    let uri_str = format!(
1273        "{}/events/notifications/{uuid}/used_by/",
1274        configuration.base_path,
1275        uuid = crate::apis::urlencode(p_path_uuid)
1276    );
1277    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1278
1279    if let Some(ref user_agent) = configuration.user_agent {
1280        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1281    }
1282    if let Some(ref token) = configuration.bearer_access_token {
1283        req_builder = req_builder.bearer_auth(token.to_owned());
1284    };
1285
1286    let req = req_builder.build()?;
1287    let resp = configuration.client.execute(req).await?;
1288
1289    let status = resp.status();
1290    let content_type = resp
1291        .headers()
1292        .get("content-type")
1293        .and_then(|v| v.to_str().ok())
1294        .unwrap_or("application/octet-stream");
1295    let content_type = super::ContentType::from(content_type);
1296
1297    if !status.is_client_error() && !status.is_server_error() {
1298        let content = resp.text().await?;
1299        match content_type {
1300            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1301            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::UsedBy&gt;`"))),
1302            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&lt;models::UsedBy&gt;`")))),
1303        }
1304    } else {
1305        let content = resp.text().await?;
1306        let entity: Option<EventsNotificationsUsedByListError> = serde_json::from_str(&content).ok();
1307        Err(Error::ResponseError(ResponseContent {
1308            status,
1309            content,
1310            entity,
1311        }))
1312    }
1313}
1314
1315/// NotificationRule Viewset
1316pub async fn events_rules_create(
1317    configuration: &configuration::Configuration,
1318    notification_rule_request: models::NotificationRuleRequest,
1319) -> Result<models::NotificationRule, Error<EventsRulesCreateError>> {
1320    // add a prefix to parameters to efficiently prevent name collisions
1321    let p_body_notification_rule_request = notification_rule_request;
1322
1323    let uri_str = format!("{}/events/rules/", configuration.base_path);
1324    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1325
1326    if let Some(ref user_agent) = configuration.user_agent {
1327        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1328    }
1329    if let Some(ref token) = configuration.bearer_access_token {
1330        req_builder = req_builder.bearer_auth(token.to_owned());
1331    };
1332    req_builder = req_builder.json(&p_body_notification_rule_request);
1333
1334    let req = req_builder.build()?;
1335    let resp = configuration.client.execute(req).await?;
1336
1337    let status = resp.status();
1338    let content_type = resp
1339        .headers()
1340        .get("content-type")
1341        .and_then(|v| v.to_str().ok())
1342        .unwrap_or("application/octet-stream");
1343    let content_type = super::ContentType::from(content_type);
1344
1345    if !status.is_client_error() && !status.is_server_error() {
1346        let content = resp.text().await?;
1347        match content_type {
1348            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1349            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NotificationRule`"))),
1350            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::NotificationRule`")))),
1351        }
1352    } else {
1353        let content = resp.text().await?;
1354        let entity: Option<EventsRulesCreateError> = serde_json::from_str(&content).ok();
1355        Err(Error::ResponseError(ResponseContent {
1356            status,
1357            content,
1358            entity,
1359        }))
1360    }
1361}
1362
1363/// NotificationRule Viewset
1364pub async fn events_rules_destroy(
1365    configuration: &configuration::Configuration,
1366    pbm_uuid: &str,
1367) -> Result<(), Error<EventsRulesDestroyError>> {
1368    // add a prefix to parameters to efficiently prevent name collisions
1369    let p_path_pbm_uuid = pbm_uuid;
1370
1371    let uri_str = format!(
1372        "{}/events/rules/{pbm_uuid}/",
1373        configuration.base_path,
1374        pbm_uuid = crate::apis::urlencode(p_path_pbm_uuid)
1375    );
1376    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1377
1378    if let Some(ref user_agent) = configuration.user_agent {
1379        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1380    }
1381    if let Some(ref token) = configuration.bearer_access_token {
1382        req_builder = req_builder.bearer_auth(token.to_owned());
1383    };
1384
1385    let req = req_builder.build()?;
1386    let resp = configuration.client.execute(req).await?;
1387
1388    let status = resp.status();
1389
1390    if !status.is_client_error() && !status.is_server_error() {
1391        Ok(())
1392    } else {
1393        let content = resp.text().await?;
1394        let entity: Option<EventsRulesDestroyError> = serde_json::from_str(&content).ok();
1395        Err(Error::ResponseError(ResponseContent {
1396            status,
1397            content,
1398            entity,
1399        }))
1400    }
1401}
1402
1403/// NotificationRule Viewset
1404pub async fn events_rules_list(
1405    configuration: &configuration::Configuration,
1406    destination_group__name: Option<&str>,
1407    name: Option<&str>,
1408    ordering: Option<&str>,
1409    page: Option<i32>,
1410    page_size: Option<i32>,
1411    search: Option<&str>,
1412    severity: Option<&str>,
1413) -> Result<models::PaginatedNotificationRuleList, Error<EventsRulesListError>> {
1414    // add a prefix to parameters to efficiently prevent name collisions
1415    let p_query_destination_group__name = destination_group__name;
1416    let p_query_name = name;
1417    let p_query_ordering = ordering;
1418    let p_query_page = page;
1419    let p_query_page_size = page_size;
1420    let p_query_search = search;
1421    let p_query_severity = severity;
1422
1423    let uri_str = format!("{}/events/rules/", configuration.base_path);
1424    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1425
1426    if let Some(ref param_value) = p_query_destination_group__name {
1427        req_builder = req_builder.query(&[("destination_group__name", &param_value.to_string())]);
1428    }
1429    if let Some(ref param_value) = p_query_name {
1430        req_builder = req_builder.query(&[("name", &param_value.to_string())]);
1431    }
1432    if let Some(ref param_value) = p_query_ordering {
1433        req_builder = req_builder.query(&[("ordering", &param_value.to_string())]);
1434    }
1435    if let Some(ref param_value) = p_query_page {
1436        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
1437    }
1438    if let Some(ref param_value) = p_query_page_size {
1439        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
1440    }
1441    if let Some(ref param_value) = p_query_search {
1442        req_builder = req_builder.query(&[("search", &param_value.to_string())]);
1443    }
1444    if let Some(ref param_value) = p_query_severity {
1445        req_builder = req_builder.query(&[("severity", &param_value.to_string())]);
1446    }
1447    if let Some(ref user_agent) = configuration.user_agent {
1448        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1449    }
1450    if let Some(ref token) = configuration.bearer_access_token {
1451        req_builder = req_builder.bearer_auth(token.to_owned());
1452    };
1453
1454    let req = req_builder.build()?;
1455    let resp = configuration.client.execute(req).await?;
1456
1457    let status = resp.status();
1458    let content_type = resp
1459        .headers()
1460        .get("content-type")
1461        .and_then(|v| v.to_str().ok())
1462        .unwrap_or("application/octet-stream");
1463    let content_type = super::ContentType::from(content_type);
1464
1465    if !status.is_client_error() && !status.is_server_error() {
1466        let content = resp.text().await?;
1467        match content_type {
1468            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1469            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedNotificationRuleList`"))),
1470            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::PaginatedNotificationRuleList`")))),
1471        }
1472    } else {
1473        let content = resp.text().await?;
1474        let entity: Option<EventsRulesListError> = serde_json::from_str(&content).ok();
1475        Err(Error::ResponseError(ResponseContent {
1476            status,
1477            content,
1478            entity,
1479        }))
1480    }
1481}
1482
1483/// NotificationRule Viewset
1484pub async fn events_rules_partial_update(
1485    configuration: &configuration::Configuration,
1486    pbm_uuid: &str,
1487    patched_notification_rule_request: Option<models::PatchedNotificationRuleRequest>,
1488) -> Result<models::NotificationRule, Error<EventsRulesPartialUpdateError>> {
1489    // add a prefix to parameters to efficiently prevent name collisions
1490    let p_path_pbm_uuid = pbm_uuid;
1491    let p_body_patched_notification_rule_request = patched_notification_rule_request;
1492
1493    let uri_str = format!(
1494        "{}/events/rules/{pbm_uuid}/",
1495        configuration.base_path,
1496        pbm_uuid = crate::apis::urlencode(p_path_pbm_uuid)
1497    );
1498    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
1499
1500    if let Some(ref user_agent) = configuration.user_agent {
1501        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1502    }
1503    if let Some(ref token) = configuration.bearer_access_token {
1504        req_builder = req_builder.bearer_auth(token.to_owned());
1505    };
1506    req_builder = req_builder.json(&p_body_patched_notification_rule_request);
1507
1508    let req = req_builder.build()?;
1509    let resp = configuration.client.execute(req).await?;
1510
1511    let status = resp.status();
1512    let content_type = resp
1513        .headers()
1514        .get("content-type")
1515        .and_then(|v| v.to_str().ok())
1516        .unwrap_or("application/octet-stream");
1517    let content_type = super::ContentType::from(content_type);
1518
1519    if !status.is_client_error() && !status.is_server_error() {
1520        let content = resp.text().await?;
1521        match content_type {
1522            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1523            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NotificationRule`"))),
1524            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::NotificationRule`")))),
1525        }
1526    } else {
1527        let content = resp.text().await?;
1528        let entity: Option<EventsRulesPartialUpdateError> = serde_json::from_str(&content).ok();
1529        Err(Error::ResponseError(ResponseContent {
1530            status,
1531            content,
1532            entity,
1533        }))
1534    }
1535}
1536
1537/// NotificationRule Viewset
1538pub async fn events_rules_retrieve(
1539    configuration: &configuration::Configuration,
1540    pbm_uuid: &str,
1541) -> Result<models::NotificationRule, Error<EventsRulesRetrieveError>> {
1542    // add a prefix to parameters to efficiently prevent name collisions
1543    let p_path_pbm_uuid = pbm_uuid;
1544
1545    let uri_str = format!(
1546        "{}/events/rules/{pbm_uuid}/",
1547        configuration.base_path,
1548        pbm_uuid = crate::apis::urlencode(p_path_pbm_uuid)
1549    );
1550    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1551
1552    if let Some(ref user_agent) = configuration.user_agent {
1553        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1554    }
1555    if let Some(ref token) = configuration.bearer_access_token {
1556        req_builder = req_builder.bearer_auth(token.to_owned());
1557    };
1558
1559    let req = req_builder.build()?;
1560    let resp = configuration.client.execute(req).await?;
1561
1562    let status = resp.status();
1563    let content_type = resp
1564        .headers()
1565        .get("content-type")
1566        .and_then(|v| v.to_str().ok())
1567        .unwrap_or("application/octet-stream");
1568    let content_type = super::ContentType::from(content_type);
1569
1570    if !status.is_client_error() && !status.is_server_error() {
1571        let content = resp.text().await?;
1572        match content_type {
1573            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1574            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NotificationRule`"))),
1575            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::NotificationRule`")))),
1576        }
1577    } else {
1578        let content = resp.text().await?;
1579        let entity: Option<EventsRulesRetrieveError> = serde_json::from_str(&content).ok();
1580        Err(Error::ResponseError(ResponseContent {
1581            status,
1582            content,
1583            entity,
1584        }))
1585    }
1586}
1587
1588/// NotificationRule Viewset
1589pub async fn events_rules_update(
1590    configuration: &configuration::Configuration,
1591    pbm_uuid: &str,
1592    notification_rule_request: models::NotificationRuleRequest,
1593) -> Result<models::NotificationRule, Error<EventsRulesUpdateError>> {
1594    // add a prefix to parameters to efficiently prevent name collisions
1595    let p_path_pbm_uuid = pbm_uuid;
1596    let p_body_notification_rule_request = notification_rule_request;
1597
1598    let uri_str = format!(
1599        "{}/events/rules/{pbm_uuid}/",
1600        configuration.base_path,
1601        pbm_uuid = crate::apis::urlencode(p_path_pbm_uuid)
1602    );
1603    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
1604
1605    if let Some(ref user_agent) = configuration.user_agent {
1606        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1607    }
1608    if let Some(ref token) = configuration.bearer_access_token {
1609        req_builder = req_builder.bearer_auth(token.to_owned());
1610    };
1611    req_builder = req_builder.json(&p_body_notification_rule_request);
1612
1613    let req = req_builder.build()?;
1614    let resp = configuration.client.execute(req).await?;
1615
1616    let status = resp.status();
1617    let content_type = resp
1618        .headers()
1619        .get("content-type")
1620        .and_then(|v| v.to_str().ok())
1621        .unwrap_or("application/octet-stream");
1622    let content_type = super::ContentType::from(content_type);
1623
1624    if !status.is_client_error() && !status.is_server_error() {
1625        let content = resp.text().await?;
1626        match content_type {
1627            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1628            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NotificationRule`"))),
1629            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::NotificationRule`")))),
1630        }
1631    } else {
1632        let content = resp.text().await?;
1633        let entity: Option<EventsRulesUpdateError> = serde_json::from_str(&content).ok();
1634        Err(Error::ResponseError(ResponseContent {
1635            status,
1636            content,
1637            entity,
1638        }))
1639    }
1640}
1641
1642/// Get a list of all objects that use this object
1643pub async fn events_rules_used_by_list(
1644    configuration: &configuration::Configuration,
1645    pbm_uuid: &str,
1646) -> Result<Vec<models::UsedBy>, Error<EventsRulesUsedByListError>> {
1647    // add a prefix to parameters to efficiently prevent name collisions
1648    let p_path_pbm_uuid = pbm_uuid;
1649
1650    let uri_str = format!(
1651        "{}/events/rules/{pbm_uuid}/used_by/",
1652        configuration.base_path,
1653        pbm_uuid = crate::apis::urlencode(p_path_pbm_uuid)
1654    );
1655    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1656
1657    if let Some(ref user_agent) = configuration.user_agent {
1658        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1659    }
1660    if let Some(ref token) = configuration.bearer_access_token {
1661        req_builder = req_builder.bearer_auth(token.to_owned());
1662    };
1663
1664    let req = req_builder.build()?;
1665    let resp = configuration.client.execute(req).await?;
1666
1667    let status = resp.status();
1668    let content_type = resp
1669        .headers()
1670        .get("content-type")
1671        .and_then(|v| v.to_str().ok())
1672        .unwrap_or("application/octet-stream");
1673    let content_type = super::ContentType::from(content_type);
1674
1675    if !status.is_client_error() && !status.is_server_error() {
1676        let content = resp.text().await?;
1677        match content_type {
1678            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1679            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::UsedBy&gt;`"))),
1680            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&lt;models::UsedBy&gt;`")))),
1681        }
1682    } else {
1683        let content = resp.text().await?;
1684        let entity: Option<EventsRulesUsedByListError> = serde_json::from_str(&content).ok();
1685        Err(Error::ResponseError(ResponseContent {
1686            status,
1687            content,
1688            entity,
1689        }))
1690    }
1691}
1692
1693/// NotificationTransport Viewset
1694pub async fn events_transports_create(
1695    configuration: &configuration::Configuration,
1696    notification_transport_request: models::NotificationTransportRequest,
1697) -> Result<models::NotificationTransport, Error<EventsTransportsCreateError>> {
1698    // add a prefix to parameters to efficiently prevent name collisions
1699    let p_body_notification_transport_request = notification_transport_request;
1700
1701    let uri_str = format!("{}/events/transports/", configuration.base_path);
1702    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1703
1704    if let Some(ref user_agent) = configuration.user_agent {
1705        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1706    }
1707    if let Some(ref token) = configuration.bearer_access_token {
1708        req_builder = req_builder.bearer_auth(token.to_owned());
1709    };
1710    req_builder = req_builder.json(&p_body_notification_transport_request);
1711
1712    let req = req_builder.build()?;
1713    let resp = configuration.client.execute(req).await?;
1714
1715    let status = resp.status();
1716    let content_type = resp
1717        .headers()
1718        .get("content-type")
1719        .and_then(|v| v.to_str().ok())
1720        .unwrap_or("application/octet-stream");
1721    let content_type = super::ContentType::from(content_type);
1722
1723    if !status.is_client_error() && !status.is_server_error() {
1724        let content = resp.text().await?;
1725        match content_type {
1726            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1727            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NotificationTransport`"))),
1728            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::NotificationTransport`")))),
1729        }
1730    } else {
1731        let content = resp.text().await?;
1732        let entity: Option<EventsTransportsCreateError> = serde_json::from_str(&content).ok();
1733        Err(Error::ResponseError(ResponseContent {
1734            status,
1735            content,
1736            entity,
1737        }))
1738    }
1739}
1740
1741/// NotificationTransport Viewset
1742pub async fn events_transports_destroy(
1743    configuration: &configuration::Configuration,
1744    uuid: &str,
1745) -> Result<(), Error<EventsTransportsDestroyError>> {
1746    // add a prefix to parameters to efficiently prevent name collisions
1747    let p_path_uuid = uuid;
1748
1749    let uri_str = format!(
1750        "{}/events/transports/{uuid}/",
1751        configuration.base_path,
1752        uuid = crate::apis::urlencode(p_path_uuid)
1753    );
1754    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1755
1756    if let Some(ref user_agent) = configuration.user_agent {
1757        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1758    }
1759    if let Some(ref token) = configuration.bearer_access_token {
1760        req_builder = req_builder.bearer_auth(token.to_owned());
1761    };
1762
1763    let req = req_builder.build()?;
1764    let resp = configuration.client.execute(req).await?;
1765
1766    let status = resp.status();
1767
1768    if !status.is_client_error() && !status.is_server_error() {
1769        Ok(())
1770    } else {
1771        let content = resp.text().await?;
1772        let entity: Option<EventsTransportsDestroyError> = serde_json::from_str(&content).ok();
1773        Err(Error::ResponseError(ResponseContent {
1774            status,
1775            content,
1776            entity,
1777        }))
1778    }
1779}
1780
1781/// NotificationTransport Viewset
1782pub async fn events_transports_list(
1783    configuration: &configuration::Configuration,
1784    mode: Option<&str>,
1785    name: Option<&str>,
1786    ordering: Option<&str>,
1787    page: Option<i32>,
1788    page_size: Option<i32>,
1789    search: Option<&str>,
1790    send_once: Option<bool>,
1791    webhook_url: Option<&str>,
1792) -> Result<models::PaginatedNotificationTransportList, Error<EventsTransportsListError>> {
1793    // add a prefix to parameters to efficiently prevent name collisions
1794    let p_query_mode = mode;
1795    let p_query_name = name;
1796    let p_query_ordering = ordering;
1797    let p_query_page = page;
1798    let p_query_page_size = page_size;
1799    let p_query_search = search;
1800    let p_query_send_once = send_once;
1801    let p_query_webhook_url = webhook_url;
1802
1803    let uri_str = format!("{}/events/transports/", configuration.base_path);
1804    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1805
1806    if let Some(ref param_value) = p_query_mode {
1807        req_builder = req_builder.query(&[("mode", &param_value.to_string())]);
1808    }
1809    if let Some(ref param_value) = p_query_name {
1810        req_builder = req_builder.query(&[("name", &param_value.to_string())]);
1811    }
1812    if let Some(ref param_value) = p_query_ordering {
1813        req_builder = req_builder.query(&[("ordering", &param_value.to_string())]);
1814    }
1815    if let Some(ref param_value) = p_query_page {
1816        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
1817    }
1818    if let Some(ref param_value) = p_query_page_size {
1819        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
1820    }
1821    if let Some(ref param_value) = p_query_search {
1822        req_builder = req_builder.query(&[("search", &param_value.to_string())]);
1823    }
1824    if let Some(ref param_value) = p_query_send_once {
1825        req_builder = req_builder.query(&[("send_once", &param_value.to_string())]);
1826    }
1827    if let Some(ref param_value) = p_query_webhook_url {
1828        req_builder = req_builder.query(&[("webhook_url", &param_value.to_string())]);
1829    }
1830    if let Some(ref user_agent) = configuration.user_agent {
1831        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1832    }
1833    if let Some(ref token) = configuration.bearer_access_token {
1834        req_builder = req_builder.bearer_auth(token.to_owned());
1835    };
1836
1837    let req = req_builder.build()?;
1838    let resp = configuration.client.execute(req).await?;
1839
1840    let status = resp.status();
1841    let content_type = resp
1842        .headers()
1843        .get("content-type")
1844        .and_then(|v| v.to_str().ok())
1845        .unwrap_or("application/octet-stream");
1846    let content_type = super::ContentType::from(content_type);
1847
1848    if !status.is_client_error() && !status.is_server_error() {
1849        let content = resp.text().await?;
1850        match content_type {
1851            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1852            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedNotificationTransportList`"))),
1853            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::PaginatedNotificationTransportList`")))),
1854        }
1855    } else {
1856        let content = resp.text().await?;
1857        let entity: Option<EventsTransportsListError> = serde_json::from_str(&content).ok();
1858        Err(Error::ResponseError(ResponseContent {
1859            status,
1860            content,
1861            entity,
1862        }))
1863    }
1864}
1865
1866/// NotificationTransport Viewset
1867pub async fn events_transports_partial_update(
1868    configuration: &configuration::Configuration,
1869    uuid: &str,
1870    patched_notification_transport_request: Option<models::PatchedNotificationTransportRequest>,
1871) -> Result<models::NotificationTransport, Error<EventsTransportsPartialUpdateError>> {
1872    // add a prefix to parameters to efficiently prevent name collisions
1873    let p_path_uuid = uuid;
1874    let p_body_patched_notification_transport_request = patched_notification_transport_request;
1875
1876    let uri_str = format!(
1877        "{}/events/transports/{uuid}/",
1878        configuration.base_path,
1879        uuid = crate::apis::urlencode(p_path_uuid)
1880    );
1881    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
1882
1883    if let Some(ref user_agent) = configuration.user_agent {
1884        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1885    }
1886    if let Some(ref token) = configuration.bearer_access_token {
1887        req_builder = req_builder.bearer_auth(token.to_owned());
1888    };
1889    req_builder = req_builder.json(&p_body_patched_notification_transport_request);
1890
1891    let req = req_builder.build()?;
1892    let resp = configuration.client.execute(req).await?;
1893
1894    let status = resp.status();
1895    let content_type = resp
1896        .headers()
1897        .get("content-type")
1898        .and_then(|v| v.to_str().ok())
1899        .unwrap_or("application/octet-stream");
1900    let content_type = super::ContentType::from(content_type);
1901
1902    if !status.is_client_error() && !status.is_server_error() {
1903        let content = resp.text().await?;
1904        match content_type {
1905            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1906            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NotificationTransport`"))),
1907            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::NotificationTransport`")))),
1908        }
1909    } else {
1910        let content = resp.text().await?;
1911        let entity: Option<EventsTransportsPartialUpdateError> = serde_json::from_str(&content).ok();
1912        Err(Error::ResponseError(ResponseContent {
1913            status,
1914            content,
1915            entity,
1916        }))
1917    }
1918}
1919
1920/// NotificationTransport Viewset
1921pub async fn events_transports_retrieve(
1922    configuration: &configuration::Configuration,
1923    uuid: &str,
1924) -> Result<models::NotificationTransport, Error<EventsTransportsRetrieveError>> {
1925    // add a prefix to parameters to efficiently prevent name collisions
1926    let p_path_uuid = uuid;
1927
1928    let uri_str = format!(
1929        "{}/events/transports/{uuid}/",
1930        configuration.base_path,
1931        uuid = crate::apis::urlencode(p_path_uuid)
1932    );
1933    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1934
1935    if let Some(ref user_agent) = configuration.user_agent {
1936        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1937    }
1938    if let Some(ref token) = configuration.bearer_access_token {
1939        req_builder = req_builder.bearer_auth(token.to_owned());
1940    };
1941
1942    let req = req_builder.build()?;
1943    let resp = configuration.client.execute(req).await?;
1944
1945    let status = resp.status();
1946    let content_type = resp
1947        .headers()
1948        .get("content-type")
1949        .and_then(|v| v.to_str().ok())
1950        .unwrap_or("application/octet-stream");
1951    let content_type = super::ContentType::from(content_type);
1952
1953    if !status.is_client_error() && !status.is_server_error() {
1954        let content = resp.text().await?;
1955        match content_type {
1956            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1957            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NotificationTransport`"))),
1958            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::NotificationTransport`")))),
1959        }
1960    } else {
1961        let content = resp.text().await?;
1962        let entity: Option<EventsTransportsRetrieveError> = serde_json::from_str(&content).ok();
1963        Err(Error::ResponseError(ResponseContent {
1964            status,
1965            content,
1966            entity,
1967        }))
1968    }
1969}
1970
1971/// Send example notification using selected transport. Requires Modify permissions.
1972pub async fn events_transports_test_create(
1973    configuration: &configuration::Configuration,
1974    uuid: &str,
1975) -> Result<models::NotificationTransportTest, Error<EventsTransportsTestCreateError>> {
1976    // add a prefix to parameters to efficiently prevent name collisions
1977    let p_path_uuid = uuid;
1978
1979    let uri_str = format!(
1980        "{}/events/transports/{uuid}/test/",
1981        configuration.base_path,
1982        uuid = crate::apis::urlencode(p_path_uuid)
1983    );
1984    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1985
1986    if let Some(ref user_agent) = configuration.user_agent {
1987        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1988    }
1989    if let Some(ref token) = configuration.bearer_access_token {
1990        req_builder = req_builder.bearer_auth(token.to_owned());
1991    };
1992
1993    let req = req_builder.build()?;
1994    let resp = configuration.client.execute(req).await?;
1995
1996    let status = resp.status();
1997    let content_type = resp
1998        .headers()
1999        .get("content-type")
2000        .and_then(|v| v.to_str().ok())
2001        .unwrap_or("application/octet-stream");
2002    let content_type = super::ContentType::from(content_type);
2003
2004    if !status.is_client_error() && !status.is_server_error() {
2005        let content = resp.text().await?;
2006        match content_type {
2007            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2008            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NotificationTransportTest`"))),
2009            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::NotificationTransportTest`")))),
2010        }
2011    } else {
2012        let content = resp.text().await?;
2013        let entity: Option<EventsTransportsTestCreateError> = serde_json::from_str(&content).ok();
2014        Err(Error::ResponseError(ResponseContent {
2015            status,
2016            content,
2017            entity,
2018        }))
2019    }
2020}
2021
2022/// NotificationTransport Viewset
2023pub async fn events_transports_update(
2024    configuration: &configuration::Configuration,
2025    uuid: &str,
2026    notification_transport_request: models::NotificationTransportRequest,
2027) -> Result<models::NotificationTransport, Error<EventsTransportsUpdateError>> {
2028    // add a prefix to parameters to efficiently prevent name collisions
2029    let p_path_uuid = uuid;
2030    let p_body_notification_transport_request = notification_transport_request;
2031
2032    let uri_str = format!(
2033        "{}/events/transports/{uuid}/",
2034        configuration.base_path,
2035        uuid = crate::apis::urlencode(p_path_uuid)
2036    );
2037    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
2038
2039    if let Some(ref user_agent) = configuration.user_agent {
2040        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2041    }
2042    if let Some(ref token) = configuration.bearer_access_token {
2043        req_builder = req_builder.bearer_auth(token.to_owned());
2044    };
2045    req_builder = req_builder.json(&p_body_notification_transport_request);
2046
2047    let req = req_builder.build()?;
2048    let resp = configuration.client.execute(req).await?;
2049
2050    let status = resp.status();
2051    let content_type = resp
2052        .headers()
2053        .get("content-type")
2054        .and_then(|v| v.to_str().ok())
2055        .unwrap_or("application/octet-stream");
2056    let content_type = super::ContentType::from(content_type);
2057
2058    if !status.is_client_error() && !status.is_server_error() {
2059        let content = resp.text().await?;
2060        match content_type {
2061            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2062            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NotificationTransport`"))),
2063            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::NotificationTransport`")))),
2064        }
2065    } else {
2066        let content = resp.text().await?;
2067        let entity: Option<EventsTransportsUpdateError> = serde_json::from_str(&content).ok();
2068        Err(Error::ResponseError(ResponseContent {
2069            status,
2070            content,
2071            entity,
2072        }))
2073    }
2074}
2075
2076/// Get a list of all objects that use this object
2077pub async fn events_transports_used_by_list(
2078    configuration: &configuration::Configuration,
2079    uuid: &str,
2080) -> Result<Vec<models::UsedBy>, Error<EventsTransportsUsedByListError>> {
2081    // add a prefix to parameters to efficiently prevent name collisions
2082    let p_path_uuid = uuid;
2083
2084    let uri_str = format!(
2085        "{}/events/transports/{uuid}/used_by/",
2086        configuration.base_path,
2087        uuid = crate::apis::urlencode(p_path_uuid)
2088    );
2089    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2090
2091    if let Some(ref user_agent) = configuration.user_agent {
2092        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2093    }
2094    if let Some(ref token) = configuration.bearer_access_token {
2095        req_builder = req_builder.bearer_auth(token.to_owned());
2096    };
2097
2098    let req = req_builder.build()?;
2099    let resp = configuration.client.execute(req).await?;
2100
2101    let status = resp.status();
2102    let content_type = resp
2103        .headers()
2104        .get("content-type")
2105        .and_then(|v| v.to_str().ok())
2106        .unwrap_or("application/octet-stream");
2107    let content_type = super::ContentType::from(content_type);
2108
2109    if !status.is_client_error() && !status.is_server_error() {
2110        let content = resp.text().await?;
2111        match content_type {
2112            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2113            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::UsedBy&gt;`"))),
2114            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&lt;models::UsedBy&gt;`")))),
2115        }
2116    } else {
2117        let content = resp.text().await?;
2118        let entity: Option<EventsTransportsUsedByListError> = serde_json::from_str(&content).ok();
2119        Err(Error::ResponseError(ResponseContent {
2120            status,
2121            content,
2122            entity,
2123        }))
2124    }
2125}