1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetEventErrorsError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetEventHealthError {
29 Status503(models::HealthReport),
30 UnknownValue(serde_json::Value),
31}
32
33#[derive(Debug, Clone, Serialize, Deserialize)]
35#[serde(untagged)]
36pub enum GetEventInsightsEventsError {
37 UnknownValue(serde_json::Value),
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum GetEventInsightsHealthError {
44 UnknownValue(serde_json::Value),
45}
46
47#[derive(Debug, Clone, Serialize, Deserialize)]
49#[serde(untagged)]
50pub enum GetEventOverviewError {
51 UnknownValue(serde_json::Value),
52}
53
54#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum GetEventTagPeriodJsError {
58 UnknownValue(serde_json::Value),
59}
60
61#[derive(Debug, Clone, Serialize, Deserialize)]
63#[serde(untagged)]
64pub enum GetEventTimeseriesError {
65 UnknownValue(serde_json::Value),
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
70#[serde(untagged)]
71pub enum GetEventTopError {
72 UnknownValue(serde_json::Value),
73}
74
75#[derive(Debug, Clone, Serialize, Deserialize)]
77#[serde(untagged)]
78pub enum PostEventError {
79 UnknownValue(serde_json::Value),
80}
81
82#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum PostEventByProjectEnvelopeError {
86 UnknownValue(serde_json::Value),
87}
88
89#[derive(Debug, Clone, Serialize, Deserialize)]
91#[serde(untagged)]
92pub enum PostEventByProjectStoreError {
93 UnknownValue(serde_json::Value),
94}
95
96#[derive(Debug, Clone, Serialize, Deserialize)]
98#[serde(untagged)]
99pub enum PostEventReplayError {
100 UnknownValue(serde_json::Value),
101}
102
103
104pub async fn get_event_errors(configuration: &configuration::Configuration, limit: Option<i32>) -> Result<models::ErrorList, Error<GetEventErrorsError>> {
106 let p_limit = limit;
108
109 let uri_str = format!("{}/v1/event/errors", configuration.base_path);
110 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
111
112 if let Some(ref param_value) = p_limit {
113 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
114 }
115 if let Some(ref user_agent) = configuration.user_agent {
116 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
117 }
118 if let Some(ref token) = configuration.bearer_access_token {
119 req_builder = req_builder.bearer_auth(token.to_owned());
120 };
121
122 let req = req_builder.build()?;
123 let resp = configuration.client.execute(req).await?;
124
125 let status = resp.status();
126 let content_type = resp
127 .headers()
128 .get("content-type")
129 .and_then(|v| v.to_str().ok())
130 .unwrap_or("application/octet-stream");
131 let content_type = super::ContentType::from(content_type);
132
133 if !status.is_client_error() && !status.is_server_error() {
134 let content = resp.text().await?;
135 match content_type {
136 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
137 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ErrorList`"))),
138 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::ErrorList`")))),
139 }
140 } else {
141 let content = resp.text().await?;
142 let entity: Option<GetEventErrorsError> = serde_json::from_str(&content).ok();
143 Err(Error::ResponseError(ResponseContent { status, content, entity }))
144 }
145}
146
147pub async fn get_event_health(configuration: &configuration::Configuration, ) -> Result<models::HealthReport, Error<GetEventHealthError>> {
149
150 let uri_str = format!("{}/v1/event/health", configuration.base_path);
151 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
152
153 if let Some(ref user_agent) = configuration.user_agent {
154 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
155 }
156 if let Some(ref token) = configuration.bearer_access_token {
157 req_builder = req_builder.bearer_auth(token.to_owned());
158 };
159
160 let req = req_builder.build()?;
161 let resp = configuration.client.execute(req).await?;
162
163 let status = resp.status();
164 let content_type = resp
165 .headers()
166 .get("content-type")
167 .and_then(|v| v.to_str().ok())
168 .unwrap_or("application/octet-stream");
169 let content_type = super::ContentType::from(content_type);
170
171 if !status.is_client_error() && !status.is_server_error() {
172 let content = resp.text().await?;
173 match content_type {
174 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
175 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::HealthReport`"))),
176 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::HealthReport`")))),
177 }
178 } else {
179 let content = resp.text().await?;
180 let entity: Option<GetEventHealthError> = serde_json::from_str(&content).ok();
181 Err(Error::ResponseError(ResponseContent { status, content, entity }))
182 }
183}
184
185pub async fn get_event_insights_events(configuration: &configuration::Configuration, limit: Option<i32>) -> Result<models::EventList, Error<GetEventInsightsEventsError>> {
187 let p_limit = limit;
189
190 let uri_str = format!("{}/v1/event/insights/events", configuration.base_path);
191 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
192
193 if let Some(ref param_value) = p_limit {
194 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
195 }
196 if let Some(ref user_agent) = configuration.user_agent {
197 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
198 }
199 if let Some(ref token) = configuration.bearer_access_token {
200 req_builder = req_builder.bearer_auth(token.to_owned());
201 };
202
203 let req = req_builder.build()?;
204 let resp = configuration.client.execute(req).await?;
205
206 let status = resp.status();
207 let content_type = resp
208 .headers()
209 .get("content-type")
210 .and_then(|v| v.to_str().ok())
211 .unwrap_or("application/octet-stream");
212 let content_type = super::ContentType::from(content_type);
213
214 if !status.is_client_error() && !status.is_server_error() {
215 let content = resp.text().await?;
216 match content_type {
217 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
218 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EventList`"))),
219 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::EventList`")))),
220 }
221 } else {
222 let content = resp.text().await?;
223 let entity: Option<GetEventInsightsEventsError> = serde_json::from_str(&content).ok();
224 Err(Error::ResponseError(ResponseContent { status, content, entity }))
225 }
226}
227
228pub async fn get_event_insights_health(configuration: &configuration::Configuration, ) -> Result<models::InsightsStatus, Error<GetEventInsightsHealthError>> {
230
231 let uri_str = format!("{}/v1/event/insights/health", configuration.base_path);
232 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
233
234 if let Some(ref user_agent) = configuration.user_agent {
235 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
236 }
237 if let Some(ref token) = configuration.bearer_access_token {
238 req_builder = req_builder.bearer_auth(token.to_owned());
239 };
240
241 let req = req_builder.build()?;
242 let resp = configuration.client.execute(req).await?;
243
244 let status = resp.status();
245 let content_type = resp
246 .headers()
247 .get("content-type")
248 .and_then(|v| v.to_str().ok())
249 .unwrap_or("application/octet-stream");
250 let content_type = super::ContentType::from(content_type);
251
252 if !status.is_client_error() && !status.is_server_error() {
253 let content = resp.text().await?;
254 match content_type {
255 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
256 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::InsightsStatus`"))),
257 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::InsightsStatus`")))),
258 }
259 } else {
260 let content = resp.text().await?;
261 let entity: Option<GetEventInsightsHealthError> = serde_json::from_str(&content).ok();
262 Err(Error::ResponseError(ResponseContent { status, content, entity }))
263 }
264}
265
266pub async fn get_event_overview(configuration: &configuration::Configuration, range: Option<&str>, start: Option<&str>, end: Option<&str>) -> Result<models::Overview, Error<GetEventOverviewError>> {
268 let p_range = range;
270 let p_start = start;
271 let p_end = end;
272
273 let uri_str = format!("{}/v1/event/overview", configuration.base_path);
274 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
275
276 if let Some(ref param_value) = p_range {
277 req_builder = req_builder.query(&[("range", ¶m_value.to_string())]);
278 }
279 if let Some(ref param_value) = p_start {
280 req_builder = req_builder.query(&[("start", ¶m_value.to_string())]);
281 }
282 if let Some(ref param_value) = p_end {
283 req_builder = req_builder.query(&[("end", ¶m_value.to_string())]);
284 }
285 if let Some(ref user_agent) = configuration.user_agent {
286 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
287 }
288 if let Some(ref token) = configuration.bearer_access_token {
289 req_builder = req_builder.bearer_auth(token.to_owned());
290 };
291
292 let req = req_builder.build()?;
293 let resp = configuration.client.execute(req).await?;
294
295 let status = resp.status();
296 let content_type = resp
297 .headers()
298 .get("content-type")
299 .and_then(|v| v.to_str().ok())
300 .unwrap_or("application/octet-stream");
301 let content_type = super::ContentType::from(content_type);
302
303 if !status.is_client_error() && !status.is_server_error() {
304 let content = resp.text().await?;
305 match content_type {
306 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
307 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Overview`"))),
308 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::Overview`")))),
309 }
310 } else {
311 let content = resp.text().await?;
312 let entity: Option<GetEventOverviewError> = serde_json::from_str(&content).ok();
313 Err(Error::ResponseError(ResponseContent { status, content, entity }))
314 }
315}
316
317pub async fn get_event_tag_period_js(configuration: &configuration::Configuration, ) -> Result<reqwest::Response, Error<GetEventTagPeriodJsError>> {
319
320 let uri_str = format!("{}/v1/event/tag.js", configuration.base_path);
321 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
322
323 if let Some(ref user_agent) = configuration.user_agent {
324 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
325 }
326 if let Some(ref token) = configuration.bearer_access_token {
327 req_builder = req_builder.bearer_auth(token.to_owned());
328 };
329
330 let req = req_builder.build()?;
331 let resp = configuration.client.execute(req).await?;
332
333 let status = resp.status();
334
335 if !status.is_client_error() && !status.is_server_error() {
336 Ok(resp)
337 } else {
338 let content = resp.text().await?;
339 let entity: Option<GetEventTagPeriodJsError> = serde_json::from_str(&content).ok();
340 Err(Error::ResponseError(ResponseContent { status, content, entity }))
341 }
342}
343
344pub async fn get_event_timeseries(configuration: &configuration::Configuration, range: Option<&str>, start: Option<&str>, end: Option<&str>) -> Result<models::Timeseries, Error<GetEventTimeseriesError>> {
346 let p_range = range;
348 let p_start = start;
349 let p_end = end;
350
351 let uri_str = format!("{}/v1/event/timeseries", configuration.base_path);
352 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
353
354 if let Some(ref param_value) = p_range {
355 req_builder = req_builder.query(&[("range", ¶m_value.to_string())]);
356 }
357 if let Some(ref param_value) = p_start {
358 req_builder = req_builder.query(&[("start", ¶m_value.to_string())]);
359 }
360 if let Some(ref param_value) = p_end {
361 req_builder = req_builder.query(&[("end", ¶m_value.to_string())]);
362 }
363 if let Some(ref user_agent) = configuration.user_agent {
364 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
365 }
366 if let Some(ref token) = configuration.bearer_access_token {
367 req_builder = req_builder.bearer_auth(token.to_owned());
368 };
369
370 let req = req_builder.build()?;
371 let resp = configuration.client.execute(req).await?;
372
373 let status = resp.status();
374 let content_type = resp
375 .headers()
376 .get("content-type")
377 .and_then(|v| v.to_str().ok())
378 .unwrap_or("application/octet-stream");
379 let content_type = super::ContentType::from(content_type);
380
381 if !status.is_client_error() && !status.is_server_error() {
382 let content = resp.text().await?;
383 match content_type {
384 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
385 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Timeseries`"))),
386 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::Timeseries`")))),
387 }
388 } else {
389 let content = resp.text().await?;
390 let entity: Option<GetEventTimeseriesError> = serde_json::from_str(&content).ok();
391 Err(Error::ResponseError(ResponseContent { status, content, entity }))
392 }
393}
394
395pub async fn get_event_top(configuration: &configuration::Configuration, range: Option<&str>, start: Option<&str>, end: Option<&str>, limit: Option<i32>) -> Result<models::Top, Error<GetEventTopError>> {
397 let p_range = range;
399 let p_start = start;
400 let p_end = end;
401 let p_limit = limit;
402
403 let uri_str = format!("{}/v1/event/top", configuration.base_path);
404 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
405
406 if let Some(ref param_value) = p_range {
407 req_builder = req_builder.query(&[("range", ¶m_value.to_string())]);
408 }
409 if let Some(ref param_value) = p_start {
410 req_builder = req_builder.query(&[("start", ¶m_value.to_string())]);
411 }
412 if let Some(ref param_value) = p_end {
413 req_builder = req_builder.query(&[("end", ¶m_value.to_string())]);
414 }
415 if let Some(ref param_value) = p_limit {
416 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
417 }
418 if let Some(ref user_agent) = configuration.user_agent {
419 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
420 }
421 if let Some(ref token) = configuration.bearer_access_token {
422 req_builder = req_builder.bearer_auth(token.to_owned());
423 };
424
425 let req = req_builder.build()?;
426 let resp = configuration.client.execute(req).await?;
427
428 let status = resp.status();
429 let content_type = resp
430 .headers()
431 .get("content-type")
432 .and_then(|v| v.to_str().ok())
433 .unwrap_or("application/octet-stream");
434 let content_type = super::ContentType::from(content_type);
435
436 if !status.is_client_error() && !status.is_server_error() {
437 let content = resp.text().await?;
438 match content_type {
439 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
440 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Top`"))),
441 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::Top`")))),
442 }
443 } else {
444 let content = resp.text().await?;
445 let entity: Option<GetEventTopError> = serde_json::from_str(&content).ok();
446 Err(Error::ResponseError(ResponseContent { status, content, entity }))
447 }
448}
449
450pub async fn post_event(configuration: &configuration::Configuration, post_event_request: Option<models::PostEventRequest>) -> Result<models::CaptureResult, Error<PostEventError>> {
452 let p_post_event_request = post_event_request;
454
455 let uri_str = format!("{}/v1/event", configuration.base_path);
456 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
457
458 if let Some(ref user_agent) = configuration.user_agent {
459 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
460 }
461 if let Some(ref token) = configuration.bearer_access_token {
462 req_builder = req_builder.bearer_auth(token.to_owned());
463 };
464 req_builder = req_builder.json(&p_post_event_request);
465
466 let req = req_builder.build()?;
467 let resp = configuration.client.execute(req).await?;
468
469 let status = resp.status();
470 let content_type = resp
471 .headers()
472 .get("content-type")
473 .and_then(|v| v.to_str().ok())
474 .unwrap_or("application/octet-stream");
475 let content_type = super::ContentType::from(content_type);
476
477 if !status.is_client_error() && !status.is_server_error() {
478 let content = resp.text().await?;
479 match content_type {
480 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
481 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CaptureResult`"))),
482 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::CaptureResult`")))),
483 }
484 } else {
485 let content = resp.text().await?;
486 let entity: Option<PostEventError> = serde_json::from_str(&content).ok();
487 Err(Error::ResponseError(ResponseContent { status, content, entity }))
488 }
489}
490
491pub async fn post_event_by_project_envelope(configuration: &configuration::Configuration, project: &str, body: Option<Vec<u8>>) -> Result<(), Error<PostEventByProjectEnvelopeError>> {
493 let p_project = project;
495 let p_body = body;
496
497 let uri_str = format!("{}/v1/event/{project}/envelope", configuration.base_path, project=crate::apis::urlencode(p_project));
498 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
499
500 if let Some(ref user_agent) = configuration.user_agent {
501 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
502 }
503 if let Some(ref token) = configuration.bearer_access_token {
504 req_builder = req_builder.bearer_auth(token.to_owned());
505 };
506 if let Some(body) = p_body {
507 req_builder = req_builder.body(body);
508 }
509
510 let req = req_builder.build()?;
511 let resp = configuration.client.execute(req).await?;
512
513 let status = resp.status();
514
515 if !status.is_client_error() && !status.is_server_error() {
516 Ok(())
517 } else {
518 let content = resp.text().await?;
519 let entity: Option<PostEventByProjectEnvelopeError> = serde_json::from_str(&content).ok();
520 Err(Error::ResponseError(ResponseContent { status, content, entity }))
521 }
522}
523
524pub async fn post_event_by_project_store(configuration: &configuration::Configuration, project: &str, body: Option<Vec<u8>>) -> Result<(), Error<PostEventByProjectStoreError>> {
526 let p_project = project;
528 let p_body = body;
529
530 let uri_str = format!("{}/v1/event/{project}/store", configuration.base_path, project=crate::apis::urlencode(p_project));
531 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
532
533 if let Some(ref user_agent) = configuration.user_agent {
534 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
535 }
536 if let Some(ref token) = configuration.bearer_access_token {
537 req_builder = req_builder.bearer_auth(token.to_owned());
538 };
539 if let Some(body) = p_body {
540 req_builder = req_builder.body(body);
541 }
542
543 let req = req_builder.build()?;
544 let resp = configuration.client.execute(req).await?;
545
546 let status = resp.status();
547
548 if !status.is_client_error() && !status.is_server_error() {
549 Ok(())
550 } else {
551 let content = resp.text().await?;
552 let entity: Option<PostEventByProjectStoreError> = serde_json::from_str(&content).ok();
553 Err(Error::ResponseError(ResponseContent { status, content, entity }))
554 }
555}
556
557pub async fn post_event_replay(configuration: &configuration::Configuration, replay_body: Option<models::ReplayBody>) -> Result<models::CaptureResult, Error<PostEventReplayError>> {
559 let p_replay_body = replay_body;
561
562 let uri_str = format!("{}/v1/event/replay", configuration.base_path);
563 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
564
565 if let Some(ref user_agent) = configuration.user_agent {
566 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
567 }
568 if let Some(ref token) = configuration.bearer_access_token {
569 req_builder = req_builder.bearer_auth(token.to_owned());
570 };
571 req_builder = req_builder.json(&p_replay_body);
572
573 let req = req_builder.build()?;
574 let resp = configuration.client.execute(req).await?;
575
576 let status = resp.status();
577 let content_type = resp
578 .headers()
579 .get("content-type")
580 .and_then(|v| v.to_str().ok())
581 .unwrap_or("application/octet-stream");
582 let content_type = super::ContentType::from(content_type);
583
584 if !status.is_client_error() && !status.is_server_error() {
585 let content = resp.text().await?;
586 match content_type {
587 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
588 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CaptureResult`"))),
589 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::CaptureResult`")))),
590 }
591 } else {
592 let content = resp.text().await?;
593 let entity: Option<PostEventReplayError> = serde_json::from_str(&content).ok();
594 Err(Error::ResponseError(ResponseContent { status, content, entity }))
595 }
596}
597