dtz_observability/apis/
default_api.rs

1/*
2 * DTZ Observability
3 *
4 * a generated client for the DTZ Observability API
5 *
6 * Contact: jens@apimeister.com
7 * Generated by: https://openapi-generator.tech
8 */
9
10
11use reqwest;
12#[allow(unused_imports)]
13use serde::{de::Error as _};
14use crate::{apis::ResponseContent, models};
15#[allow(unused_imports)]
16use super::{Error, ContentType};
17use dtz_config::Configuration;
18
19fn build_url(config: &Configuration) -> String {
20    if let Some(base_path) = &config.base_path {
21        let base = url::Url::parse(base_path).unwrap();
22        let mut target_url = url::Url::parse(crate::apis::SVC_URL).unwrap();
23        let _ = target_url.set_scheme(base.scheme());
24        let _ = target_url.set_port(base.port());
25        let _ = target_url.set_host(Some(base.host_str().unwrap()));
26        format!("{target_url}")
27    } else {
28        crate::apis::SVC_URL.to_string()
29    }
30}
31
32
33/// struct for typed errors of method [`disable`]
34#[derive(Debug, Clone, Serialize, Deserialize)]
35#[serde(untagged)]
36pub enum DisableError {
37    UnknownValue(serde_json::Value),
38}
39
40/// struct for typed errors of method [`enable`]
41#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum EnableError {
44    UnknownValue(serde_json::Value),
45}
46
47/// struct for typed errors of method [`get_build_info`]
48#[derive(Debug, Clone, Serialize, Deserialize)]
49#[serde(untagged)]
50pub enum GetBuildInfoError {
51    UnknownValue(serde_json::Value),
52}
53
54/// struct for typed errors of method [`get_log_activity`]
55#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum GetLogActivityError {
58    UnknownValue(serde_json::Value),
59}
60
61/// struct for typed errors of method [`get_log_attributes`]
62#[derive(Debug, Clone, Serialize, Deserialize)]
63#[serde(untagged)]
64pub enum GetLogAttributesError {
65    UnknownValue(serde_json::Value),
66}
67
68/// struct for typed errors of method [`get_logs`]
69#[derive(Debug, Clone, Serialize, Deserialize)]
70#[serde(untagged)]
71pub enum GetLogsError {
72    UnknownValue(serde_json::Value),
73}
74
75/// struct for typed errors of method [`get_metric_metadata`]
76#[derive(Debug, Clone, Serialize, Deserialize)]
77#[serde(untagged)]
78pub enum GetMetricMetadataError {
79    UnknownValue(serde_json::Value),
80}
81
82/// struct for typed errors of method [`get_stats`]
83#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum GetStatsError {
86    UnknownValue(serde_json::Value),
87}
88
89/// struct for typed errors of method [`list_label_values`]
90#[derive(Debug, Clone, Serialize, Deserialize)]
91#[serde(untagged)]
92pub enum ListLabelValuesError {
93    UnknownValue(serde_json::Value),
94}
95
96/// struct for typed errors of method [`list_labels`]
97#[derive(Debug, Clone, Serialize, Deserialize)]
98#[serde(untagged)]
99pub enum ListLabelsError {
100    UnknownValue(serde_json::Value),
101}
102
103/// struct for typed errors of method [`post_log`]
104#[derive(Debug, Clone, Serialize, Deserialize)]
105#[serde(untagged)]
106pub enum PostLogError {
107    UnknownValue(serde_json::Value),
108}
109
110/// struct for typed errors of method [`post_metric`]
111#[derive(Debug, Clone, Serialize, Deserialize)]
112#[serde(untagged)]
113pub enum PostMetricError {
114    UnknownValue(serde_json::Value),
115}
116
117/// struct for typed errors of method [`post_prometheus`]
118#[derive(Debug, Clone, Serialize, Deserialize)]
119#[serde(untagged)]
120pub enum PostPrometheusError {
121    UnknownValue(serde_json::Value),
122}
123
124/// struct for typed errors of method [`query_log_activity`]
125#[derive(Debug, Clone, Serialize, Deserialize)]
126#[serde(untagged)]
127pub enum QueryLogActivityError {
128    UnknownValue(serde_json::Value),
129}
130
131/// struct for typed errors of method [`query_logs`]
132#[derive(Debug, Clone, Serialize, Deserialize)]
133#[serde(untagged)]
134pub enum QueryLogsError {
135    UnknownValue(serde_json::Value),
136}
137
138
139pub async fn disable(configuration: &Configuration, ) -> Result<(), Error<DisableError>> {
140
141    let uri_str = format!("{}/disable", build_url(configuration));
142    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
143
144    if let Some(ref token) = configuration.oauth_access_token {
145        req_builder = req_builder.bearer_auth(token.to_owned());
146    };
147    if let Some(ref value) = configuration.api_key {
148        req_builder = req_builder.header("X-API-KEY", value);
149    };
150
151    let req = req_builder.build()?;
152    let resp = configuration.client.execute(req).await?;
153
154    let status = resp.status();
155
156    if !status.is_client_error() && !status.is_server_error() {
157        Ok(())
158    } else {
159        let content = resp.text().await?;
160        let entity: Option<DisableError> = serde_json::from_str(&content).ok();
161        Err(Error::ResponseError(ResponseContent { status, content, entity }))
162    }
163}
164
165pub async fn enable(configuration: &Configuration, ) -> Result<(), Error<EnableError>> {
166
167    let uri_str = format!("{}/enable", build_url(configuration));
168    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
169
170    if let Some(ref token) = configuration.oauth_access_token {
171        req_builder = req_builder.bearer_auth(token.to_owned());
172    };
173    if let Some(ref value) = configuration.api_key {
174        req_builder = req_builder.header("X-API-KEY", value);
175    };
176
177    let req = req_builder.build()?;
178    let resp = configuration.client.execute(req).await?;
179
180    let status = resp.status();
181
182    if !status.is_client_error() && !status.is_server_error() {
183        Ok(())
184    } else {
185        let content = resp.text().await?;
186        let entity: Option<EnableError> = serde_json::from_str(&content).ok();
187        Err(Error::ResponseError(ResponseContent { status, content, entity }))
188    }
189}
190
191pub async fn get_build_info(configuration: &Configuration, ) -> Result<models::GetBuildInfo200Response, Error<GetBuildInfoError>> {
192
193    let uri_str = format!("{}/prometheus/api/v1/status/buildinfo", build_url(configuration));
194    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
195
196    if let Some(ref token) = configuration.oauth_access_token {
197        req_builder = req_builder.bearer_auth(token.to_owned());
198    };
199    if let Some(ref value) = configuration.api_key {
200        req_builder = req_builder.header("X-API-KEY", value);
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::GetBuildInfo200Response`"))),
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::GetBuildInfo200Response`")))),
220        }
221    } else {
222        let content = resp.text().await?;
223        let entity: Option<GetBuildInfoError> = serde_json::from_str(&content).ok();
224        Err(Error::ResponseError(ResponseContent { status, content, entity }))
225    }
226}
227
228pub async fn get_log_activity(configuration: &Configuration, ) -> Result<Vec<models::GetLogActivity200ResponseInner>, Error<GetLogActivityError>> {
229
230    let uri_str = format!("{}/log/activity", build_url(configuration));
231    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
232
233    if let Some(ref token) = configuration.oauth_access_token {
234        req_builder = req_builder.bearer_auth(token.to_owned());
235    };
236    if let Some(ref value) = configuration.api_key {
237        req_builder = req_builder.header("X-API-KEY", value);
238    };
239
240    let req = req_builder.build()?;
241    let resp = configuration.client.execute(req).await?;
242
243    let status = resp.status();
244    let content_type = resp
245        .headers()
246        .get("content-type")
247        .and_then(|v| v.to_str().ok())
248        .unwrap_or("application/octet-stream");
249    let content_type = super::ContentType::from(content_type);
250
251    if !status.is_client_error() && !status.is_server_error() {
252        let content = resp.text().await?;
253        match content_type {
254            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
255            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetLogActivity200ResponseInner&gt;`"))),
256            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::GetLogActivity200ResponseInner&gt;`")))),
257        }
258    } else {
259        let content = resp.text().await?;
260        let entity: Option<GetLogActivityError> = serde_json::from_str(&content).ok();
261        Err(Error::ResponseError(ResponseContent { status, content, entity }))
262    }
263}
264
265pub async fn get_log_attributes(configuration: &Configuration, ) -> Result<Vec<models::GetLogAttributes200ResponseInner>, Error<GetLogAttributesError>> {
266
267    let uri_str = format!("{}/log/attribute", build_url(configuration));
268    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
269
270    if let Some(ref token) = configuration.oauth_access_token {
271        req_builder = req_builder.bearer_auth(token.to_owned());
272    };
273    if let Some(ref value) = configuration.api_key {
274        req_builder = req_builder.header("X-API-KEY", value);
275    };
276
277    let req = req_builder.build()?;
278    let resp = configuration.client.execute(req).await?;
279
280    let status = resp.status();
281    let content_type = resp
282        .headers()
283        .get("content-type")
284        .and_then(|v| v.to_str().ok())
285        .unwrap_or("application/octet-stream");
286    let content_type = super::ContentType::from(content_type);
287
288    if !status.is_client_error() && !status.is_server_error() {
289        let content = resp.text().await?;
290        match content_type {
291            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
292            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetLogAttributes200ResponseInner&gt;`"))),
293            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::GetLogAttributes200ResponseInner&gt;`")))),
294        }
295    } else {
296        let content = resp.text().await?;
297        let entity: Option<GetLogAttributesError> = serde_json::from_str(&content).ok();
298        Err(Error::ResponseError(ResponseContent { status, content, entity }))
299    }
300}
301
302pub async fn get_logs(configuration: &Configuration, ) -> Result<Vec<models::DtzLogsInner>, Error<GetLogsError>> {
303
304    let uri_str = format!("{}/log", build_url(configuration));
305    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
306
307    if let Some(ref token) = configuration.oauth_access_token {
308        req_builder = req_builder.bearer_auth(token.to_owned());
309    };
310    if let Some(ref value) = configuration.api_key {
311        req_builder = req_builder.header("X-API-KEY", value);
312    };
313
314    let req = req_builder.build()?;
315    let resp = configuration.client.execute(req).await?;
316
317    let status = resp.status();
318    let content_type = resp
319        .headers()
320        .get("content-type")
321        .and_then(|v| v.to_str().ok())
322        .unwrap_or("application/octet-stream");
323    let content_type = super::ContentType::from(content_type);
324
325    if !status.is_client_error() && !status.is_server_error() {
326        let content = resp.text().await?;
327        match content_type {
328            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
329            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::DtzLogsInner&gt;`"))),
330            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::DtzLogsInner&gt;`")))),
331        }
332    } else {
333        let content = resp.text().await?;
334        let entity: Option<GetLogsError> = serde_json::from_str(&content).ok();
335        Err(Error::ResponseError(ResponseContent { status, content, entity }))
336    }
337}
338
339pub async fn get_metric_metadata(configuration: &Configuration, ) -> Result<models::GetMetricMetadata200Response, Error<GetMetricMetadataError>> {
340
341    let uri_str = format!("{}/prometheus/api/v1/metadata", build_url(configuration));
342    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
343
344    if let Some(ref token) = configuration.oauth_access_token {
345        req_builder = req_builder.bearer_auth(token.to_owned());
346    };
347    if let Some(ref value) = configuration.api_key {
348        req_builder = req_builder.header("X-API-KEY", value);
349    };
350
351    let req = req_builder.build()?;
352    let resp = configuration.client.execute(req).await?;
353
354    let status = resp.status();
355    let content_type = resp
356        .headers()
357        .get("content-type")
358        .and_then(|v| v.to_str().ok())
359        .unwrap_or("application/octet-stream");
360    let content_type = super::ContentType::from(content_type);
361
362    if !status.is_client_error() && !status.is_server_error() {
363        let content = resp.text().await?;
364        match content_type {
365            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
366            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMetricMetadata200Response`"))),
367            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::GetMetricMetadata200Response`")))),
368        }
369    } else {
370        let content = resp.text().await?;
371        let entity: Option<GetMetricMetadataError> = serde_json::from_str(&content).ok();
372        Err(Error::ResponseError(ResponseContent { status, content, entity }))
373    }
374}
375
376pub async fn get_stats(configuration: &Configuration, ) -> Result<models::GetStats200Response, Error<GetStatsError>> {
377
378    let uri_str = format!("{}/stats", build_url(configuration));
379    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
380
381    if let Some(ref token) = configuration.oauth_access_token {
382        req_builder = req_builder.bearer_auth(token.to_owned());
383    };
384    if let Some(ref value) = configuration.api_key {
385        req_builder = req_builder.header("X-API-KEY", value);
386    };
387
388    let req = req_builder.build()?;
389    let resp = configuration.client.execute(req).await?;
390
391    let status = resp.status();
392    let content_type = resp
393        .headers()
394        .get("content-type")
395        .and_then(|v| v.to_str().ok())
396        .unwrap_or("application/octet-stream");
397    let content_type = super::ContentType::from(content_type);
398
399    if !status.is_client_error() && !status.is_server_error() {
400        let content = resp.text().await?;
401        match content_type {
402            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
403            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetStats200Response`"))),
404            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::GetStats200Response`")))),
405        }
406    } else {
407        let content = resp.text().await?;
408        let entity: Option<GetStatsError> = serde_json::from_str(&content).ok();
409        Err(Error::ResponseError(ResponseContent { status, content, entity }))
410    }
411}
412
413pub async fn list_label_values(configuration: &Configuration, label: &str) -> Result<models::ListLabelValues200Response, Error<ListLabelValuesError>> {
414    // add a prefix to parameters to efficiently prevent name collisions
415    let p_label = label;
416
417    let uri_str = format!("{}/prometheus/api/v1/label/{label}/values", build_url(configuration), label=crate::apis::urlencode(p_label));
418    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
419
420    if let Some(ref token) = configuration.oauth_access_token {
421        req_builder = req_builder.bearer_auth(token.to_owned());
422    };
423    if let Some(ref value) = configuration.api_key {
424        req_builder = req_builder.header("X-API-KEY", value);
425    };
426
427    let req = req_builder.build()?;
428    let resp = configuration.client.execute(req).await?;
429
430    let status = resp.status();
431    let content_type = resp
432        .headers()
433        .get("content-type")
434        .and_then(|v| v.to_str().ok())
435        .unwrap_or("application/octet-stream");
436    let content_type = super::ContentType::from(content_type);
437
438    if !status.is_client_error() && !status.is_server_error() {
439        let content = resp.text().await?;
440        match content_type {
441            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
442            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListLabelValues200Response`"))),
443            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::ListLabelValues200Response`")))),
444        }
445    } else {
446        let content = resp.text().await?;
447        let entity: Option<ListLabelValuesError> = serde_json::from_str(&content).ok();
448        Err(Error::ResponseError(ResponseContent { status, content, entity }))
449    }
450}
451
452pub async fn list_labels(configuration: &Configuration, ) -> Result<models::ListLabelValues200Response, Error<ListLabelsError>> {
453
454    let uri_str = format!("{}/prometheus/api/v1/labels", build_url(configuration));
455    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
456
457    if let Some(ref token) = configuration.oauth_access_token {
458        req_builder = req_builder.bearer_auth(token.to_owned());
459    };
460    if let Some(ref value) = configuration.api_key {
461        req_builder = req_builder.header("X-API-KEY", value);
462    };
463
464    let req = req_builder.build()?;
465    let resp = configuration.client.execute(req).await?;
466
467    let status = resp.status();
468    let content_type = resp
469        .headers()
470        .get("content-type")
471        .and_then(|v| v.to_str().ok())
472        .unwrap_or("application/octet-stream");
473    let content_type = super::ContentType::from(content_type);
474
475    if !status.is_client_error() && !status.is_server_error() {
476        let content = resp.text().await?;
477        match content_type {
478            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
479            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListLabelValues200Response`"))),
480            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::ListLabelValues200Response`")))),
481        }
482    } else {
483        let content = resp.text().await?;
484        let entity: Option<ListLabelsError> = serde_json::from_str(&content).ok();
485        Err(Error::ResponseError(ResponseContent { status, content, entity }))
486    }
487}
488
489pub async fn post_log(configuration: &Configuration, post_log_request_inner: Option<Vec<models::PostLogRequestInner>>) -> Result<(), Error<PostLogError>> {
490    // add a prefix to parameters to efficiently prevent name collisions
491    let p_post_log_request_inner = post_log_request_inner;
492
493    let uri_str = format!("{}/log/push", build_url(configuration));
494    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
495
496    if let Some(ref token) = configuration.oauth_access_token {
497        req_builder = req_builder.bearer_auth(token.to_owned());
498    };
499    if let Some(ref value) = configuration.api_key {
500        req_builder = req_builder.header("X-API-KEY", value);
501    };
502    req_builder = req_builder.json(&p_post_log_request_inner);
503
504    let req = req_builder.build()?;
505    let resp = configuration.client.execute(req).await?;
506
507    let status = resp.status();
508
509    if !status.is_client_error() && !status.is_server_error() {
510        Ok(())
511    } else {
512        let content = resp.text().await?;
513        let entity: Option<PostLogError> = serde_json::from_str(&content).ok();
514        Err(Error::ResponseError(ResponseContent { status, content, entity }))
515    }
516}
517
518pub async fn post_metric(configuration: &Configuration, dtz_metric: Option<Vec<models::DtzMetric>>) -> Result<(), Error<PostMetricError>> {
519    // add a prefix to parameters to efficiently prevent name collisions
520    let p_dtz_metric = dtz_metric;
521
522    let uri_str = format!("{}/metric", build_url(configuration));
523    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
524
525    if let Some(ref token) = configuration.oauth_access_token {
526        req_builder = req_builder.bearer_auth(token.to_owned());
527    };
528    if let Some(ref value) = configuration.api_key {
529        req_builder = req_builder.header("X-API-KEY", value);
530    };
531    req_builder = req_builder.json(&p_dtz_metric);
532
533    let req = req_builder.build()?;
534    let resp = configuration.client.execute(req).await?;
535
536    let status = resp.status();
537
538    if !status.is_client_error() && !status.is_server_error() {
539        Ok(())
540    } else {
541        let content = resp.text().await?;
542        let entity: Option<PostMetricError> = serde_json::from_str(&content).ok();
543        Err(Error::ResponseError(ResponseContent { status, content, entity }))
544    }
545}
546
547pub async fn post_prometheus(configuration: &Configuration, body: Option<&str>) -> Result<(), Error<PostPrometheusError>> {
548    // add a prefix to parameters to efficiently prevent name collisions
549    let p_body = body;
550
551    let uri_str = format!("{}/prometheus", build_url(configuration));
552    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
553
554    if let Some(ref token) = configuration.oauth_access_token {
555        req_builder = req_builder.bearer_auth(token.to_owned());
556    };
557    if let Some(ref value) = configuration.api_key {
558        req_builder = req_builder.header("X-API-KEY", value);
559    };
560    req_builder = req_builder.json(&p_body);
561
562    let req = req_builder.build()?;
563    let resp = configuration.client.execute(req).await?;
564
565    let status = resp.status();
566
567    if !status.is_client_error() && !status.is_server_error() {
568        Ok(())
569    } else {
570        let content = resp.text().await?;
571        let entity: Option<PostPrometheusError> = serde_json::from_str(&content).ok();
572        Err(Error::ResponseError(ResponseContent { status, content, entity }))
573    }
574}
575
576pub async fn query_log_activity(configuration: &Configuration, query_logs_request: Option<models::QueryLogsRequest>) -> Result<Vec<models::GetLogActivity200ResponseInner>, Error<QueryLogActivityError>> {
577    // add a prefix to parameters to efficiently prevent name collisions
578    let p_query_logs_request = query_logs_request;
579
580    let uri_str = format!("{}/log/activity", build_url(configuration));
581    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
582
583    if let Some(ref token) = configuration.oauth_access_token {
584        req_builder = req_builder.bearer_auth(token.to_owned());
585    };
586    if let Some(ref value) = configuration.api_key {
587        req_builder = req_builder.header("X-API-KEY", value);
588    };
589    req_builder = req_builder.json(&p_query_logs_request);
590
591    let req = req_builder.build()?;
592    let resp = configuration.client.execute(req).await?;
593
594    let status = resp.status();
595    let content_type = resp
596        .headers()
597        .get("content-type")
598        .and_then(|v| v.to_str().ok())
599        .unwrap_or("application/octet-stream");
600    let content_type = super::ContentType::from(content_type);
601
602    if !status.is_client_error() && !status.is_server_error() {
603        let content = resp.text().await?;
604        match content_type {
605            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
606            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetLogActivity200ResponseInner&gt;`"))),
607            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::GetLogActivity200ResponseInner&gt;`")))),
608        }
609    } else {
610        let content = resp.text().await?;
611        let entity: Option<QueryLogActivityError> = serde_json::from_str(&content).ok();
612        Err(Error::ResponseError(ResponseContent { status, content, entity }))
613    }
614}
615
616pub async fn query_logs(configuration: &Configuration, query_logs_request: Option<models::QueryLogsRequest>) -> Result<Vec<models::DtzLogsInner>, Error<QueryLogsError>> {
617    // add a prefix to parameters to efficiently prevent name collisions
618    let p_query_logs_request = query_logs_request;
619
620    let uri_str = format!("{}/log", build_url(configuration));
621    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
622
623    if let Some(ref token) = configuration.oauth_access_token {
624        req_builder = req_builder.bearer_auth(token.to_owned());
625    };
626    if let Some(ref value) = configuration.api_key {
627        req_builder = req_builder.header("X-API-KEY", value);
628    };
629    req_builder = req_builder.json(&p_query_logs_request);
630
631    let req = req_builder.build()?;
632    let resp = configuration.client.execute(req).await?;
633
634    let status = resp.status();
635    let content_type = resp
636        .headers()
637        .get("content-type")
638        .and_then(|v| v.to_str().ok())
639        .unwrap_or("application/octet-stream");
640    let content_type = super::ContentType::from(content_type);
641
642    if !status.is_client_error() && !status.is_server_error() {
643        let content = resp.text().await?;
644        match content_type {
645            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
646            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::DtzLogsInner&gt;`"))),
647            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::DtzLogsInner&gt;`")))),
648        }
649    } else {
650        let content = resp.text().await?;
651        let entity: Option<QueryLogsError> = serde_json::from_str(&content).ok();
652        Err(Error::ResponseError(ResponseContent { status, content, entity }))
653    }
654}
655