datadog_api_client/datadogV1/api/
api_synthetics.rs

1// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2// This product includes software developed at Datadog (https://www.datadoghq.com/).
3// Copyright 2019-Present Datadog, Inc.
4use crate::datadog;
5use async_stream::try_stream;
6use flate2::{
7    write::{GzEncoder, ZlibEncoder},
8    Compression,
9};
10use futures_core::stream::Stream;
11use reqwest::header::{HeaderMap, HeaderValue};
12use serde::{Deserialize, Serialize};
13use std::io::Write;
14
15/// GetAPITestLatestResultsOptionalParams is a struct for passing parameters to the method [`SyntheticsAPI::get_api_test_latest_results`]
16#[non_exhaustive]
17#[derive(Clone, Default, Debug)]
18pub struct GetAPITestLatestResultsOptionalParams {
19    /// Timestamp in milliseconds from which to start querying results.
20    pub from_ts: Option<i64>,
21    /// Timestamp in milliseconds up to which to query results.
22    pub to_ts: Option<i64>,
23    /// Locations for which to query results.
24    pub probe_dc: Option<Vec<String>>,
25}
26
27impl GetAPITestLatestResultsOptionalParams {
28    /// Timestamp in milliseconds from which to start querying results.
29    pub fn from_ts(mut self, value: i64) -> Self {
30        self.from_ts = Some(value);
31        self
32    }
33    /// Timestamp in milliseconds up to which to query results.
34    pub fn to_ts(mut self, value: i64) -> Self {
35        self.to_ts = Some(value);
36        self
37    }
38    /// Locations for which to query results.
39    pub fn probe_dc(mut self, value: Vec<String>) -> Self {
40        self.probe_dc = Some(value);
41        self
42    }
43}
44
45/// GetBrowserTestLatestResultsOptionalParams is a struct for passing parameters to the method [`SyntheticsAPI::get_browser_test_latest_results`]
46#[non_exhaustive]
47#[derive(Clone, Default, Debug)]
48pub struct GetBrowserTestLatestResultsOptionalParams {
49    /// Timestamp in milliseconds from which to start querying results.
50    pub from_ts: Option<i64>,
51    /// Timestamp in milliseconds up to which to query results.
52    pub to_ts: Option<i64>,
53    /// Locations for which to query results.
54    pub probe_dc: Option<Vec<String>>,
55}
56
57impl GetBrowserTestLatestResultsOptionalParams {
58    /// Timestamp in milliseconds from which to start querying results.
59    pub fn from_ts(mut self, value: i64) -> Self {
60        self.from_ts = Some(value);
61        self
62    }
63    /// Timestamp in milliseconds up to which to query results.
64    pub fn to_ts(mut self, value: i64) -> Self {
65        self.to_ts = Some(value);
66        self
67    }
68    /// Locations for which to query results.
69    pub fn probe_dc(mut self, value: Vec<String>) -> Self {
70        self.probe_dc = Some(value);
71        self
72    }
73}
74
75/// ListTestsOptionalParams is a struct for passing parameters to the method [`SyntheticsAPI::list_tests`]
76#[non_exhaustive]
77#[derive(Clone, Default, Debug)]
78pub struct ListTestsOptionalParams {
79    /// Used for pagination. The number of tests returned in the page.
80    pub page_size: Option<i64>,
81    /// Used for pagination. Which page you want to retrieve. Starts at zero.
82    pub page_number: Option<i64>,
83}
84
85impl ListTestsOptionalParams {
86    /// Used for pagination. The number of tests returned in the page.
87    pub fn page_size(mut self, value: i64) -> Self {
88        self.page_size = Some(value);
89        self
90    }
91    /// Used for pagination. Which page you want to retrieve. Starts at zero.
92    pub fn page_number(mut self, value: i64) -> Self {
93        self.page_number = Some(value);
94        self
95    }
96}
97
98/// SearchTestsOptionalParams is a struct for passing parameters to the method [`SyntheticsAPI::search_tests`]
99#[non_exhaustive]
100#[derive(Clone, Default, Debug)]
101pub struct SearchTestsOptionalParams {
102    /// The search query.
103    pub text: Option<String>,
104    /// If true, include the full configuration for each test in the response.
105    pub include_full_config: Option<bool>,
106    /// If true, return only facets instead of full test details.
107    pub facets_only: Option<bool>,
108    /// The offset from which to start returning results.
109    pub start: Option<i64>,
110    /// The maximum number of results to return.
111    pub count: Option<i64>,
112    /// The sort order for the results (e.g., `name,asc` or `name,desc`).
113    pub sort: Option<String>,
114}
115
116impl SearchTestsOptionalParams {
117    /// The search query.
118    pub fn text(mut self, value: String) -> Self {
119        self.text = Some(value);
120        self
121    }
122    /// If true, include the full configuration for each test in the response.
123    pub fn include_full_config(mut self, value: bool) -> Self {
124        self.include_full_config = Some(value);
125        self
126    }
127    /// If true, return only facets instead of full test details.
128    pub fn facets_only(mut self, value: bool) -> Self {
129        self.facets_only = Some(value);
130        self
131    }
132    /// The offset from which to start returning results.
133    pub fn start(mut self, value: i64) -> Self {
134        self.start = Some(value);
135        self
136    }
137    /// The maximum number of results to return.
138    pub fn count(mut self, value: i64) -> Self {
139        self.count = Some(value);
140        self
141    }
142    /// The sort order for the results (e.g., `name,asc` or `name,desc`).
143    pub fn sort(mut self, value: String) -> Self {
144        self.sort = Some(value);
145        self
146    }
147}
148
149/// CreateGlobalVariableError is a struct for typed errors of method [`SyntheticsAPI::create_global_variable`]
150#[derive(Debug, Clone, Serialize, Deserialize)]
151#[serde(untagged)]
152pub enum CreateGlobalVariableError {
153    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
154    UnknownValue(serde_json::Value),
155}
156
157/// CreatePrivateLocationError is a struct for typed errors of method [`SyntheticsAPI::create_private_location`]
158#[derive(Debug, Clone, Serialize, Deserialize)]
159#[serde(untagged)]
160pub enum CreatePrivateLocationError {
161    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
162    UnknownValue(serde_json::Value),
163}
164
165/// CreateSyntheticsAPITestError is a struct for typed errors of method [`SyntheticsAPI::create_synthetics_api_test`]
166#[derive(Debug, Clone, Serialize, Deserialize)]
167#[serde(untagged)]
168pub enum CreateSyntheticsAPITestError {
169    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
170    UnknownValue(serde_json::Value),
171}
172
173/// CreateSyntheticsBrowserTestError is a struct for typed errors of method [`SyntheticsAPI::create_synthetics_browser_test`]
174#[derive(Debug, Clone, Serialize, Deserialize)]
175#[serde(untagged)]
176pub enum CreateSyntheticsBrowserTestError {
177    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
178    UnknownValue(serde_json::Value),
179}
180
181/// CreateSyntheticsMobileTestError is a struct for typed errors of method [`SyntheticsAPI::create_synthetics_mobile_test`]
182#[derive(Debug, Clone, Serialize, Deserialize)]
183#[serde(untagged)]
184pub enum CreateSyntheticsMobileTestError {
185    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
186    UnknownValue(serde_json::Value),
187}
188
189/// DeleteGlobalVariableError is a struct for typed errors of method [`SyntheticsAPI::delete_global_variable`]
190#[derive(Debug, Clone, Serialize, Deserialize)]
191#[serde(untagged)]
192pub enum DeleteGlobalVariableError {
193    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
194    UnknownValue(serde_json::Value),
195}
196
197/// DeletePrivateLocationError is a struct for typed errors of method [`SyntheticsAPI::delete_private_location`]
198#[derive(Debug, Clone, Serialize, Deserialize)]
199#[serde(untagged)]
200pub enum DeletePrivateLocationError {
201    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
202    UnknownValue(serde_json::Value),
203}
204
205/// DeleteTestsError is a struct for typed errors of method [`SyntheticsAPI::delete_tests`]
206#[derive(Debug, Clone, Serialize, Deserialize)]
207#[serde(untagged)]
208pub enum DeleteTestsError {
209    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
210    UnknownValue(serde_json::Value),
211}
212
213/// EditGlobalVariableError is a struct for typed errors of method [`SyntheticsAPI::edit_global_variable`]
214#[derive(Debug, Clone, Serialize, Deserialize)]
215#[serde(untagged)]
216pub enum EditGlobalVariableError {
217    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
218    UnknownValue(serde_json::Value),
219}
220
221/// FetchUptimesError is a struct for typed errors of method [`SyntheticsAPI::fetch_uptimes`]
222#[derive(Debug, Clone, Serialize, Deserialize)]
223#[serde(untagged)]
224pub enum FetchUptimesError {
225    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
226    UnknownValue(serde_json::Value),
227}
228
229/// GetAPITestError is a struct for typed errors of method [`SyntheticsAPI::get_api_test`]
230#[derive(Debug, Clone, Serialize, Deserialize)]
231#[serde(untagged)]
232pub enum GetAPITestError {
233    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
234    UnknownValue(serde_json::Value),
235}
236
237/// GetAPITestLatestResultsError is a struct for typed errors of method [`SyntheticsAPI::get_api_test_latest_results`]
238#[derive(Debug, Clone, Serialize, Deserialize)]
239#[serde(untagged)]
240pub enum GetAPITestLatestResultsError {
241    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
242    UnknownValue(serde_json::Value),
243}
244
245/// GetAPITestResultError is a struct for typed errors of method [`SyntheticsAPI::get_api_test_result`]
246#[derive(Debug, Clone, Serialize, Deserialize)]
247#[serde(untagged)]
248pub enum GetAPITestResultError {
249    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
250    UnknownValue(serde_json::Value),
251}
252
253/// GetBrowserTestError is a struct for typed errors of method [`SyntheticsAPI::get_browser_test`]
254#[derive(Debug, Clone, Serialize, Deserialize)]
255#[serde(untagged)]
256pub enum GetBrowserTestError {
257    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
258    UnknownValue(serde_json::Value),
259}
260
261/// GetBrowserTestLatestResultsError is a struct for typed errors of method [`SyntheticsAPI::get_browser_test_latest_results`]
262#[derive(Debug, Clone, Serialize, Deserialize)]
263#[serde(untagged)]
264pub enum GetBrowserTestLatestResultsError {
265    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
266    UnknownValue(serde_json::Value),
267}
268
269/// GetBrowserTestResultError is a struct for typed errors of method [`SyntheticsAPI::get_browser_test_result`]
270#[derive(Debug, Clone, Serialize, Deserialize)]
271#[serde(untagged)]
272pub enum GetBrowserTestResultError {
273    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
274    UnknownValue(serde_json::Value),
275}
276
277/// GetGlobalVariableError is a struct for typed errors of method [`SyntheticsAPI::get_global_variable`]
278#[derive(Debug, Clone, Serialize, Deserialize)]
279#[serde(untagged)]
280pub enum GetGlobalVariableError {
281    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
282    UnknownValue(serde_json::Value),
283}
284
285/// GetMobileTestError is a struct for typed errors of method [`SyntheticsAPI::get_mobile_test`]
286#[derive(Debug, Clone, Serialize, Deserialize)]
287#[serde(untagged)]
288pub enum GetMobileTestError {
289    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
290    UnknownValue(serde_json::Value),
291}
292
293/// GetPrivateLocationError is a struct for typed errors of method [`SyntheticsAPI::get_private_location`]
294#[derive(Debug, Clone, Serialize, Deserialize)]
295#[serde(untagged)]
296pub enum GetPrivateLocationError {
297    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
298    UnknownValue(serde_json::Value),
299}
300
301/// GetSyntheticsCIBatchError is a struct for typed errors of method [`SyntheticsAPI::get_synthetics_ci_batch`]
302#[derive(Debug, Clone, Serialize, Deserialize)]
303#[serde(untagged)]
304pub enum GetSyntheticsCIBatchError {
305    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
306    UnknownValue(serde_json::Value),
307}
308
309/// GetSyntheticsDefaultLocationsError is a struct for typed errors of method [`SyntheticsAPI::get_synthetics_default_locations`]
310#[derive(Debug, Clone, Serialize, Deserialize)]
311#[serde(untagged)]
312pub enum GetSyntheticsDefaultLocationsError {
313    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
314    UnknownValue(serde_json::Value),
315}
316
317/// GetTestError is a struct for typed errors of method [`SyntheticsAPI::get_test`]
318#[derive(Debug, Clone, Serialize, Deserialize)]
319#[serde(untagged)]
320pub enum GetTestError {
321    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
322    UnknownValue(serde_json::Value),
323}
324
325/// ListGlobalVariablesError is a struct for typed errors of method [`SyntheticsAPI::list_global_variables`]
326#[derive(Debug, Clone, Serialize, Deserialize)]
327#[serde(untagged)]
328pub enum ListGlobalVariablesError {
329    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
330    UnknownValue(serde_json::Value),
331}
332
333/// ListLocationsError is a struct for typed errors of method [`SyntheticsAPI::list_locations`]
334#[derive(Debug, Clone, Serialize, Deserialize)]
335#[serde(untagged)]
336pub enum ListLocationsError {
337    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
338    UnknownValue(serde_json::Value),
339}
340
341/// ListTestsError is a struct for typed errors of method [`SyntheticsAPI::list_tests`]
342#[derive(Debug, Clone, Serialize, Deserialize)]
343#[serde(untagged)]
344pub enum ListTestsError {
345    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
346    UnknownValue(serde_json::Value),
347}
348
349/// PatchTestError is a struct for typed errors of method [`SyntheticsAPI::patch_test`]
350#[derive(Debug, Clone, Serialize, Deserialize)]
351#[serde(untagged)]
352pub enum PatchTestError {
353    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
354    UnknownValue(serde_json::Value),
355}
356
357/// SearchTestsError is a struct for typed errors of method [`SyntheticsAPI::search_tests`]
358#[derive(Debug, Clone, Serialize, Deserialize)]
359#[serde(untagged)]
360pub enum SearchTestsError {
361    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
362    UnknownValue(serde_json::Value),
363}
364
365/// TriggerCITestsError is a struct for typed errors of method [`SyntheticsAPI::trigger_ci_tests`]
366#[derive(Debug, Clone, Serialize, Deserialize)]
367#[serde(untagged)]
368pub enum TriggerCITestsError {
369    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
370    UnknownValue(serde_json::Value),
371}
372
373/// TriggerTestsError is a struct for typed errors of method [`SyntheticsAPI::trigger_tests`]
374#[derive(Debug, Clone, Serialize, Deserialize)]
375#[serde(untagged)]
376pub enum TriggerTestsError {
377    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
378    UnknownValue(serde_json::Value),
379}
380
381/// UpdateAPITestError is a struct for typed errors of method [`SyntheticsAPI::update_api_test`]
382#[derive(Debug, Clone, Serialize, Deserialize)]
383#[serde(untagged)]
384pub enum UpdateAPITestError {
385    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
386    UnknownValue(serde_json::Value),
387}
388
389/// UpdateBrowserTestError is a struct for typed errors of method [`SyntheticsAPI::update_browser_test`]
390#[derive(Debug, Clone, Serialize, Deserialize)]
391#[serde(untagged)]
392pub enum UpdateBrowserTestError {
393    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
394    UnknownValue(serde_json::Value),
395}
396
397/// UpdateMobileTestError is a struct for typed errors of method [`SyntheticsAPI::update_mobile_test`]
398#[derive(Debug, Clone, Serialize, Deserialize)]
399#[serde(untagged)]
400pub enum UpdateMobileTestError {
401    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
402    UnknownValue(serde_json::Value),
403}
404
405/// UpdatePrivateLocationError is a struct for typed errors of method [`SyntheticsAPI::update_private_location`]
406#[derive(Debug, Clone, Serialize, Deserialize)]
407#[serde(untagged)]
408pub enum UpdatePrivateLocationError {
409    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
410    UnknownValue(serde_json::Value),
411}
412
413/// UpdateTestPauseStatusError is a struct for typed errors of method [`SyntheticsAPI::update_test_pause_status`]
414#[derive(Debug, Clone, Serialize, Deserialize)]
415#[serde(untagged)]
416pub enum UpdateTestPauseStatusError {
417    APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
418    UnknownValue(serde_json::Value),
419}
420
421/// Datadog Synthetic Monitoring uses simulated user requests and browser rendering to help you ensure uptime,
422/// identify regional issues, and track your application performance. Synthetic tests come in
423/// two different flavors, [API tests](<https://docs.datadoghq.com/synthetics/api_tests/?tab=httptest>)
424/// and [browser tests](<https://docs.datadoghq.com/synthetics/browser_tests>). You can use Datadog's API to
425/// manage both test types programmatically.
426///
427/// For more information, see the [Synthetic Monitoring documentation](<https://docs.datadoghq.com/synthetics/>).
428#[derive(Debug, Clone)]
429pub struct SyntheticsAPI {
430    config: datadog::Configuration,
431    client: reqwest_middleware::ClientWithMiddleware,
432}
433
434impl Default for SyntheticsAPI {
435    fn default() -> Self {
436        Self::with_config(datadog::Configuration::default())
437    }
438}
439
440impl SyntheticsAPI {
441    pub fn new() -> Self {
442        Self::default()
443    }
444    pub fn with_config(config: datadog::Configuration) -> Self {
445        let mut reqwest_client_builder = reqwest::Client::builder();
446
447        if let Some(proxy_url) = &config.proxy_url {
448            let proxy = reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL");
449            reqwest_client_builder = reqwest_client_builder.proxy(proxy);
450        }
451
452        let mut middleware_client_builder =
453            reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap());
454
455        if config.enable_retry {
456            struct RetryableStatus;
457            impl reqwest_retry::RetryableStrategy for RetryableStatus {
458                fn handle(
459                    &self,
460                    res: &Result<reqwest::Response, reqwest_middleware::Error>,
461                ) -> Option<reqwest_retry::Retryable> {
462                    match res {
463                        Ok(success) => reqwest_retry::default_on_request_success(success),
464                        Err(_) => None,
465                    }
466                }
467            }
468            let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder()
469                .build_with_max_retries(config.max_retries);
470
471            let retry_middleware =
472                reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy(
473                    backoff_policy,
474                    RetryableStatus,
475                );
476
477            middleware_client_builder = middleware_client_builder.with(retry_middleware);
478        }
479
480        let client = middleware_client_builder.build();
481
482        Self { config, client }
483    }
484
485    pub fn with_client_and_config(
486        config: datadog::Configuration,
487        client: reqwest_middleware::ClientWithMiddleware,
488    ) -> Self {
489        Self { config, client }
490    }
491
492    /// Create a Synthetic global variable.
493    pub async fn create_global_variable(
494        &self,
495        body: crate::datadogV1::model::SyntheticsGlobalVariableRequest,
496    ) -> Result<
497        crate::datadogV1::model::SyntheticsGlobalVariable,
498        datadog::Error<CreateGlobalVariableError>,
499    > {
500        match self.create_global_variable_with_http_info(body).await {
501            Ok(response_content) => {
502                if let Some(e) = response_content.entity {
503                    Ok(e)
504                } else {
505                    Err(datadog::Error::Serde(serde::de::Error::custom(
506                        "response content was None",
507                    )))
508                }
509            }
510            Err(err) => Err(err),
511        }
512    }
513
514    /// Create a Synthetic global variable.
515    pub async fn create_global_variable_with_http_info(
516        &self,
517        body: crate::datadogV1::model::SyntheticsGlobalVariableRequest,
518    ) -> Result<
519        datadog::ResponseContent<crate::datadogV1::model::SyntheticsGlobalVariable>,
520        datadog::Error<CreateGlobalVariableError>,
521    > {
522        let local_configuration = &self.config;
523        let operation_id = "v1.create_global_variable";
524
525        let local_client = &self.client;
526
527        let local_uri_str = format!(
528            "{}/api/v1/synthetics/variables",
529            local_configuration.get_operation_host(operation_id)
530        );
531        let mut local_req_builder =
532            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
533
534        // build headers
535        let mut headers = HeaderMap::new();
536        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
537        headers.insert("Accept", HeaderValue::from_static("application/json"));
538
539        // build user agent
540        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
541            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
542            Err(e) => {
543                log::warn!("Failed to parse user agent header: {e}, falling back to default");
544                headers.insert(
545                    reqwest::header::USER_AGENT,
546                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
547                )
548            }
549        };
550
551        // build auth
552        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
553            headers.insert(
554                "DD-API-KEY",
555                HeaderValue::from_str(local_key.key.as_str())
556                    .expect("failed to parse DD-API-KEY header"),
557            );
558        };
559        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
560            headers.insert(
561                "DD-APPLICATION-KEY",
562                HeaderValue::from_str(local_key.key.as_str())
563                    .expect("failed to parse DD-APPLICATION-KEY header"),
564            );
565        };
566
567        // build body parameters
568        let output = Vec::new();
569        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
570        if body.serialize(&mut ser).is_ok() {
571            if let Some(content_encoding) = headers.get("Content-Encoding") {
572                match content_encoding.to_str().unwrap_or_default() {
573                    "gzip" => {
574                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
575                        let _ = enc.write_all(ser.into_inner().as_slice());
576                        match enc.finish() {
577                            Ok(buf) => {
578                                local_req_builder = local_req_builder.body(buf);
579                            }
580                            Err(e) => return Err(datadog::Error::Io(e)),
581                        }
582                    }
583                    "deflate" => {
584                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
585                        let _ = enc.write_all(ser.into_inner().as_slice());
586                        match enc.finish() {
587                            Ok(buf) => {
588                                local_req_builder = local_req_builder.body(buf);
589                            }
590                            Err(e) => return Err(datadog::Error::Io(e)),
591                        }
592                    }
593                    "zstd1" => {
594                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
595                        let _ = enc.write_all(ser.into_inner().as_slice());
596                        match enc.finish() {
597                            Ok(buf) => {
598                                local_req_builder = local_req_builder.body(buf);
599                            }
600                            Err(e) => return Err(datadog::Error::Io(e)),
601                        }
602                    }
603                    _ => {
604                        local_req_builder = local_req_builder.body(ser.into_inner());
605                    }
606                }
607            } else {
608                local_req_builder = local_req_builder.body(ser.into_inner());
609            }
610        }
611
612        local_req_builder = local_req_builder.headers(headers);
613        let local_req = local_req_builder.build()?;
614        log::debug!("request content: {:?}", local_req.body());
615        let local_resp = local_client.execute(local_req).await?;
616
617        let local_status = local_resp.status();
618        let local_content = local_resp.text().await?;
619        log::debug!("response content: {}", local_content);
620
621        if !local_status.is_client_error() && !local_status.is_server_error() {
622            match serde_json::from_str::<crate::datadogV1::model::SyntheticsGlobalVariable>(
623                &local_content,
624            ) {
625                Ok(e) => {
626                    return Ok(datadog::ResponseContent {
627                        status: local_status,
628                        content: local_content,
629                        entity: Some(e),
630                    })
631                }
632                Err(e) => return Err(datadog::Error::Serde(e)),
633            };
634        } else {
635            let local_entity: Option<CreateGlobalVariableError> =
636                serde_json::from_str(&local_content).ok();
637            let local_error = datadog::ResponseContent {
638                status: local_status,
639                content: local_content,
640                entity: local_entity,
641            };
642            Err(datadog::Error::ResponseError(local_error))
643        }
644    }
645
646    /// Create a new Synthetic private location.
647    pub async fn create_private_location(
648        &self,
649        body: crate::datadogV1::model::SyntheticsPrivateLocation,
650    ) -> Result<
651        crate::datadogV1::model::SyntheticsPrivateLocationCreationResponse,
652        datadog::Error<CreatePrivateLocationError>,
653    > {
654        match self.create_private_location_with_http_info(body).await {
655            Ok(response_content) => {
656                if let Some(e) = response_content.entity {
657                    Ok(e)
658                } else {
659                    Err(datadog::Error::Serde(serde::de::Error::custom(
660                        "response content was None",
661                    )))
662                }
663            }
664            Err(err) => Err(err),
665        }
666    }
667
668    /// Create a new Synthetic private location.
669    pub async fn create_private_location_with_http_info(
670        &self,
671        body: crate::datadogV1::model::SyntheticsPrivateLocation,
672    ) -> Result<
673        datadog::ResponseContent<
674            crate::datadogV1::model::SyntheticsPrivateLocationCreationResponse,
675        >,
676        datadog::Error<CreatePrivateLocationError>,
677    > {
678        let local_configuration = &self.config;
679        let operation_id = "v1.create_private_location";
680
681        let local_client = &self.client;
682
683        let local_uri_str = format!(
684            "{}/api/v1/synthetics/private-locations",
685            local_configuration.get_operation_host(operation_id)
686        );
687        let mut local_req_builder =
688            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
689
690        // build headers
691        let mut headers = HeaderMap::new();
692        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
693        headers.insert("Accept", HeaderValue::from_static("application/json"));
694
695        // build user agent
696        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
697            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
698            Err(e) => {
699                log::warn!("Failed to parse user agent header: {e}, falling back to default");
700                headers.insert(
701                    reqwest::header::USER_AGENT,
702                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
703                )
704            }
705        };
706
707        // build auth
708        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
709            headers.insert(
710                "DD-API-KEY",
711                HeaderValue::from_str(local_key.key.as_str())
712                    .expect("failed to parse DD-API-KEY header"),
713            );
714        };
715        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
716            headers.insert(
717                "DD-APPLICATION-KEY",
718                HeaderValue::from_str(local_key.key.as_str())
719                    .expect("failed to parse DD-APPLICATION-KEY header"),
720            );
721        };
722
723        // build body parameters
724        let output = Vec::new();
725        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
726        if body.serialize(&mut ser).is_ok() {
727            if let Some(content_encoding) = headers.get("Content-Encoding") {
728                match content_encoding.to_str().unwrap_or_default() {
729                    "gzip" => {
730                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
731                        let _ = enc.write_all(ser.into_inner().as_slice());
732                        match enc.finish() {
733                            Ok(buf) => {
734                                local_req_builder = local_req_builder.body(buf);
735                            }
736                            Err(e) => return Err(datadog::Error::Io(e)),
737                        }
738                    }
739                    "deflate" => {
740                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
741                        let _ = enc.write_all(ser.into_inner().as_slice());
742                        match enc.finish() {
743                            Ok(buf) => {
744                                local_req_builder = local_req_builder.body(buf);
745                            }
746                            Err(e) => return Err(datadog::Error::Io(e)),
747                        }
748                    }
749                    "zstd1" => {
750                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
751                        let _ = enc.write_all(ser.into_inner().as_slice());
752                        match enc.finish() {
753                            Ok(buf) => {
754                                local_req_builder = local_req_builder.body(buf);
755                            }
756                            Err(e) => return Err(datadog::Error::Io(e)),
757                        }
758                    }
759                    _ => {
760                        local_req_builder = local_req_builder.body(ser.into_inner());
761                    }
762                }
763            } else {
764                local_req_builder = local_req_builder.body(ser.into_inner());
765            }
766        }
767
768        local_req_builder = local_req_builder.headers(headers);
769        let local_req = local_req_builder.build()?;
770        log::debug!("request content: {:?}", local_req.body());
771        let local_resp = local_client.execute(local_req).await?;
772
773        let local_status = local_resp.status();
774        let local_content = local_resp.text().await?;
775        log::debug!("response content: {}", local_content);
776
777        if !local_status.is_client_error() && !local_status.is_server_error() {
778            match serde_json::from_str::<
779                crate::datadogV1::model::SyntheticsPrivateLocationCreationResponse,
780            >(&local_content)
781            {
782                Ok(e) => {
783                    return Ok(datadog::ResponseContent {
784                        status: local_status,
785                        content: local_content,
786                        entity: Some(e),
787                    })
788                }
789                Err(e) => return Err(datadog::Error::Serde(e)),
790            };
791        } else {
792            let local_entity: Option<CreatePrivateLocationError> =
793                serde_json::from_str(&local_content).ok();
794            let local_error = datadog::ResponseContent {
795                status: local_status,
796                content: local_content,
797                entity: local_entity,
798            };
799            Err(datadog::Error::ResponseError(local_error))
800        }
801    }
802
803    /// Create a Synthetic API test.
804    pub async fn create_synthetics_api_test(
805        &self,
806        body: crate::datadogV1::model::SyntheticsAPITest,
807    ) -> Result<
808        crate::datadogV1::model::SyntheticsAPITest,
809        datadog::Error<CreateSyntheticsAPITestError>,
810    > {
811        match self.create_synthetics_api_test_with_http_info(body).await {
812            Ok(response_content) => {
813                if let Some(e) = response_content.entity {
814                    Ok(e)
815                } else {
816                    Err(datadog::Error::Serde(serde::de::Error::custom(
817                        "response content was None",
818                    )))
819                }
820            }
821            Err(err) => Err(err),
822        }
823    }
824
825    /// Create a Synthetic API test.
826    pub async fn create_synthetics_api_test_with_http_info(
827        &self,
828        body: crate::datadogV1::model::SyntheticsAPITest,
829    ) -> Result<
830        datadog::ResponseContent<crate::datadogV1::model::SyntheticsAPITest>,
831        datadog::Error<CreateSyntheticsAPITestError>,
832    > {
833        let local_configuration = &self.config;
834        let operation_id = "v1.create_synthetics_api_test";
835
836        let local_client = &self.client;
837
838        let local_uri_str = format!(
839            "{}/api/v1/synthetics/tests/api",
840            local_configuration.get_operation_host(operation_id)
841        );
842        let mut local_req_builder =
843            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
844
845        // build headers
846        let mut headers = HeaderMap::new();
847        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
848        headers.insert("Accept", HeaderValue::from_static("application/json"));
849
850        // build user agent
851        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
852            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
853            Err(e) => {
854                log::warn!("Failed to parse user agent header: {e}, falling back to default");
855                headers.insert(
856                    reqwest::header::USER_AGENT,
857                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
858                )
859            }
860        };
861
862        // build auth
863        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
864            headers.insert(
865                "DD-API-KEY",
866                HeaderValue::from_str(local_key.key.as_str())
867                    .expect("failed to parse DD-API-KEY header"),
868            );
869        };
870        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
871            headers.insert(
872                "DD-APPLICATION-KEY",
873                HeaderValue::from_str(local_key.key.as_str())
874                    .expect("failed to parse DD-APPLICATION-KEY header"),
875            );
876        };
877
878        // build body parameters
879        let output = Vec::new();
880        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
881        if body.serialize(&mut ser).is_ok() {
882            if let Some(content_encoding) = headers.get("Content-Encoding") {
883                match content_encoding.to_str().unwrap_or_default() {
884                    "gzip" => {
885                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
886                        let _ = enc.write_all(ser.into_inner().as_slice());
887                        match enc.finish() {
888                            Ok(buf) => {
889                                local_req_builder = local_req_builder.body(buf);
890                            }
891                            Err(e) => return Err(datadog::Error::Io(e)),
892                        }
893                    }
894                    "deflate" => {
895                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
896                        let _ = enc.write_all(ser.into_inner().as_slice());
897                        match enc.finish() {
898                            Ok(buf) => {
899                                local_req_builder = local_req_builder.body(buf);
900                            }
901                            Err(e) => return Err(datadog::Error::Io(e)),
902                        }
903                    }
904                    "zstd1" => {
905                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
906                        let _ = enc.write_all(ser.into_inner().as_slice());
907                        match enc.finish() {
908                            Ok(buf) => {
909                                local_req_builder = local_req_builder.body(buf);
910                            }
911                            Err(e) => return Err(datadog::Error::Io(e)),
912                        }
913                    }
914                    _ => {
915                        local_req_builder = local_req_builder.body(ser.into_inner());
916                    }
917                }
918            } else {
919                local_req_builder = local_req_builder.body(ser.into_inner());
920            }
921        }
922
923        local_req_builder = local_req_builder.headers(headers);
924        let local_req = local_req_builder.build()?;
925        log::debug!("request content: {:?}", local_req.body());
926        let local_resp = local_client.execute(local_req).await?;
927
928        let local_status = local_resp.status();
929        let local_content = local_resp.text().await?;
930        log::debug!("response content: {}", local_content);
931
932        if !local_status.is_client_error() && !local_status.is_server_error() {
933            match serde_json::from_str::<crate::datadogV1::model::SyntheticsAPITest>(&local_content)
934            {
935                Ok(e) => {
936                    return Ok(datadog::ResponseContent {
937                        status: local_status,
938                        content: local_content,
939                        entity: Some(e),
940                    })
941                }
942                Err(e) => return Err(datadog::Error::Serde(e)),
943            };
944        } else {
945            let local_entity: Option<CreateSyntheticsAPITestError> =
946                serde_json::from_str(&local_content).ok();
947            let local_error = datadog::ResponseContent {
948                status: local_status,
949                content: local_content,
950                entity: local_entity,
951            };
952            Err(datadog::Error::ResponseError(local_error))
953        }
954    }
955
956    /// Create a Synthetic browser test.
957    pub async fn create_synthetics_browser_test(
958        &self,
959        body: crate::datadogV1::model::SyntheticsBrowserTest,
960    ) -> Result<
961        crate::datadogV1::model::SyntheticsBrowserTest,
962        datadog::Error<CreateSyntheticsBrowserTestError>,
963    > {
964        match self
965            .create_synthetics_browser_test_with_http_info(body)
966            .await
967        {
968            Ok(response_content) => {
969                if let Some(e) = response_content.entity {
970                    Ok(e)
971                } else {
972                    Err(datadog::Error::Serde(serde::de::Error::custom(
973                        "response content was None",
974                    )))
975                }
976            }
977            Err(err) => Err(err),
978        }
979    }
980
981    /// Create a Synthetic browser test.
982    pub async fn create_synthetics_browser_test_with_http_info(
983        &self,
984        body: crate::datadogV1::model::SyntheticsBrowserTest,
985    ) -> Result<
986        datadog::ResponseContent<crate::datadogV1::model::SyntheticsBrowserTest>,
987        datadog::Error<CreateSyntheticsBrowserTestError>,
988    > {
989        let local_configuration = &self.config;
990        let operation_id = "v1.create_synthetics_browser_test";
991
992        let local_client = &self.client;
993
994        let local_uri_str = format!(
995            "{}/api/v1/synthetics/tests/browser",
996            local_configuration.get_operation_host(operation_id)
997        );
998        let mut local_req_builder =
999            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
1000
1001        // build headers
1002        let mut headers = HeaderMap::new();
1003        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1004        headers.insert("Accept", HeaderValue::from_static("application/json"));
1005
1006        // build user agent
1007        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1008            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1009            Err(e) => {
1010                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1011                headers.insert(
1012                    reqwest::header::USER_AGENT,
1013                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1014                )
1015            }
1016        };
1017
1018        // build auth
1019        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1020            headers.insert(
1021                "DD-API-KEY",
1022                HeaderValue::from_str(local_key.key.as_str())
1023                    .expect("failed to parse DD-API-KEY header"),
1024            );
1025        };
1026        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1027            headers.insert(
1028                "DD-APPLICATION-KEY",
1029                HeaderValue::from_str(local_key.key.as_str())
1030                    .expect("failed to parse DD-APPLICATION-KEY header"),
1031            );
1032        };
1033
1034        // build body parameters
1035        let output = Vec::new();
1036        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1037        if body.serialize(&mut ser).is_ok() {
1038            if let Some(content_encoding) = headers.get("Content-Encoding") {
1039                match content_encoding.to_str().unwrap_or_default() {
1040                    "gzip" => {
1041                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1042                        let _ = enc.write_all(ser.into_inner().as_slice());
1043                        match enc.finish() {
1044                            Ok(buf) => {
1045                                local_req_builder = local_req_builder.body(buf);
1046                            }
1047                            Err(e) => return Err(datadog::Error::Io(e)),
1048                        }
1049                    }
1050                    "deflate" => {
1051                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1052                        let _ = enc.write_all(ser.into_inner().as_slice());
1053                        match enc.finish() {
1054                            Ok(buf) => {
1055                                local_req_builder = local_req_builder.body(buf);
1056                            }
1057                            Err(e) => return Err(datadog::Error::Io(e)),
1058                        }
1059                    }
1060                    "zstd1" => {
1061                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1062                        let _ = enc.write_all(ser.into_inner().as_slice());
1063                        match enc.finish() {
1064                            Ok(buf) => {
1065                                local_req_builder = local_req_builder.body(buf);
1066                            }
1067                            Err(e) => return Err(datadog::Error::Io(e)),
1068                        }
1069                    }
1070                    _ => {
1071                        local_req_builder = local_req_builder.body(ser.into_inner());
1072                    }
1073                }
1074            } else {
1075                local_req_builder = local_req_builder.body(ser.into_inner());
1076            }
1077        }
1078
1079        local_req_builder = local_req_builder.headers(headers);
1080        let local_req = local_req_builder.build()?;
1081        log::debug!("request content: {:?}", local_req.body());
1082        let local_resp = local_client.execute(local_req).await?;
1083
1084        let local_status = local_resp.status();
1085        let local_content = local_resp.text().await?;
1086        log::debug!("response content: {}", local_content);
1087
1088        if !local_status.is_client_error() && !local_status.is_server_error() {
1089            match serde_json::from_str::<crate::datadogV1::model::SyntheticsBrowserTest>(
1090                &local_content,
1091            ) {
1092                Ok(e) => {
1093                    return Ok(datadog::ResponseContent {
1094                        status: local_status,
1095                        content: local_content,
1096                        entity: Some(e),
1097                    })
1098                }
1099                Err(e) => return Err(datadog::Error::Serde(e)),
1100            };
1101        } else {
1102            let local_entity: Option<CreateSyntheticsBrowserTestError> =
1103                serde_json::from_str(&local_content).ok();
1104            let local_error = datadog::ResponseContent {
1105                status: local_status,
1106                content: local_content,
1107                entity: local_entity,
1108            };
1109            Err(datadog::Error::ResponseError(local_error))
1110        }
1111    }
1112
1113    /// Create a Synthetic mobile test.
1114    pub async fn create_synthetics_mobile_test(
1115        &self,
1116        body: crate::datadogV1::model::SyntheticsMobileTest,
1117    ) -> Result<
1118        crate::datadogV1::model::SyntheticsMobileTest,
1119        datadog::Error<CreateSyntheticsMobileTestError>,
1120    > {
1121        match self
1122            .create_synthetics_mobile_test_with_http_info(body)
1123            .await
1124        {
1125            Ok(response_content) => {
1126                if let Some(e) = response_content.entity {
1127                    Ok(e)
1128                } else {
1129                    Err(datadog::Error::Serde(serde::de::Error::custom(
1130                        "response content was None",
1131                    )))
1132                }
1133            }
1134            Err(err) => Err(err),
1135        }
1136    }
1137
1138    /// Create a Synthetic mobile test.
1139    pub async fn create_synthetics_mobile_test_with_http_info(
1140        &self,
1141        body: crate::datadogV1::model::SyntheticsMobileTest,
1142    ) -> Result<
1143        datadog::ResponseContent<crate::datadogV1::model::SyntheticsMobileTest>,
1144        datadog::Error<CreateSyntheticsMobileTestError>,
1145    > {
1146        let local_configuration = &self.config;
1147        let operation_id = "v1.create_synthetics_mobile_test";
1148
1149        let local_client = &self.client;
1150
1151        let local_uri_str = format!(
1152            "{}/api/v1/synthetics/tests/mobile",
1153            local_configuration.get_operation_host(operation_id)
1154        );
1155        let mut local_req_builder =
1156            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
1157
1158        // build headers
1159        let mut headers = HeaderMap::new();
1160        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1161        headers.insert("Accept", HeaderValue::from_static("application/json"));
1162
1163        // build user agent
1164        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1165            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1166            Err(e) => {
1167                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1168                headers.insert(
1169                    reqwest::header::USER_AGENT,
1170                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1171                )
1172            }
1173        };
1174
1175        // build auth
1176        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1177            headers.insert(
1178                "DD-API-KEY",
1179                HeaderValue::from_str(local_key.key.as_str())
1180                    .expect("failed to parse DD-API-KEY header"),
1181            );
1182        };
1183        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1184            headers.insert(
1185                "DD-APPLICATION-KEY",
1186                HeaderValue::from_str(local_key.key.as_str())
1187                    .expect("failed to parse DD-APPLICATION-KEY header"),
1188            );
1189        };
1190
1191        // build body parameters
1192        let output = Vec::new();
1193        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1194        if body.serialize(&mut ser).is_ok() {
1195            if let Some(content_encoding) = headers.get("Content-Encoding") {
1196                match content_encoding.to_str().unwrap_or_default() {
1197                    "gzip" => {
1198                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1199                        let _ = enc.write_all(ser.into_inner().as_slice());
1200                        match enc.finish() {
1201                            Ok(buf) => {
1202                                local_req_builder = local_req_builder.body(buf);
1203                            }
1204                            Err(e) => return Err(datadog::Error::Io(e)),
1205                        }
1206                    }
1207                    "deflate" => {
1208                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1209                        let _ = enc.write_all(ser.into_inner().as_slice());
1210                        match enc.finish() {
1211                            Ok(buf) => {
1212                                local_req_builder = local_req_builder.body(buf);
1213                            }
1214                            Err(e) => return Err(datadog::Error::Io(e)),
1215                        }
1216                    }
1217                    "zstd1" => {
1218                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1219                        let _ = enc.write_all(ser.into_inner().as_slice());
1220                        match enc.finish() {
1221                            Ok(buf) => {
1222                                local_req_builder = local_req_builder.body(buf);
1223                            }
1224                            Err(e) => return Err(datadog::Error::Io(e)),
1225                        }
1226                    }
1227                    _ => {
1228                        local_req_builder = local_req_builder.body(ser.into_inner());
1229                    }
1230                }
1231            } else {
1232                local_req_builder = local_req_builder.body(ser.into_inner());
1233            }
1234        }
1235
1236        local_req_builder = local_req_builder.headers(headers);
1237        let local_req = local_req_builder.build()?;
1238        log::debug!("request content: {:?}", local_req.body());
1239        let local_resp = local_client.execute(local_req).await?;
1240
1241        let local_status = local_resp.status();
1242        let local_content = local_resp.text().await?;
1243        log::debug!("response content: {}", local_content);
1244
1245        if !local_status.is_client_error() && !local_status.is_server_error() {
1246            match serde_json::from_str::<crate::datadogV1::model::SyntheticsMobileTest>(
1247                &local_content,
1248            ) {
1249                Ok(e) => {
1250                    return Ok(datadog::ResponseContent {
1251                        status: local_status,
1252                        content: local_content,
1253                        entity: Some(e),
1254                    })
1255                }
1256                Err(e) => return Err(datadog::Error::Serde(e)),
1257            };
1258        } else {
1259            let local_entity: Option<CreateSyntheticsMobileTestError> =
1260                serde_json::from_str(&local_content).ok();
1261            let local_error = datadog::ResponseContent {
1262                status: local_status,
1263                content: local_content,
1264                entity: local_entity,
1265            };
1266            Err(datadog::Error::ResponseError(local_error))
1267        }
1268    }
1269
1270    /// Delete a Synthetic global variable.
1271    pub async fn delete_global_variable(
1272        &self,
1273        variable_id: String,
1274    ) -> Result<(), datadog::Error<DeleteGlobalVariableError>> {
1275        match self
1276            .delete_global_variable_with_http_info(variable_id)
1277            .await
1278        {
1279            Ok(_) => Ok(()),
1280            Err(err) => Err(err),
1281        }
1282    }
1283
1284    /// Delete a Synthetic global variable.
1285    pub async fn delete_global_variable_with_http_info(
1286        &self,
1287        variable_id: String,
1288    ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteGlobalVariableError>> {
1289        let local_configuration = &self.config;
1290        let operation_id = "v1.delete_global_variable";
1291
1292        let local_client = &self.client;
1293
1294        let local_uri_str = format!(
1295            "{}/api/v1/synthetics/variables/{variable_id}",
1296            local_configuration.get_operation_host(operation_id),
1297            variable_id = datadog::urlencode(variable_id)
1298        );
1299        let mut local_req_builder =
1300            local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
1301
1302        // build headers
1303        let mut headers = HeaderMap::new();
1304        headers.insert("Accept", HeaderValue::from_static("*/*"));
1305
1306        // build user agent
1307        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1308            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1309            Err(e) => {
1310                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1311                headers.insert(
1312                    reqwest::header::USER_AGENT,
1313                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1314                )
1315            }
1316        };
1317
1318        // build auth
1319        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1320            headers.insert(
1321                "DD-API-KEY",
1322                HeaderValue::from_str(local_key.key.as_str())
1323                    .expect("failed to parse DD-API-KEY header"),
1324            );
1325        };
1326        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1327            headers.insert(
1328                "DD-APPLICATION-KEY",
1329                HeaderValue::from_str(local_key.key.as_str())
1330                    .expect("failed to parse DD-APPLICATION-KEY header"),
1331            );
1332        };
1333
1334        local_req_builder = local_req_builder.headers(headers);
1335        let local_req = local_req_builder.build()?;
1336        log::debug!("request content: {:?}", local_req.body());
1337        let local_resp = local_client.execute(local_req).await?;
1338
1339        let local_status = local_resp.status();
1340        let local_content = local_resp.text().await?;
1341        log::debug!("response content: {}", local_content);
1342
1343        if !local_status.is_client_error() && !local_status.is_server_error() {
1344            Ok(datadog::ResponseContent {
1345                status: local_status,
1346                content: local_content,
1347                entity: None,
1348            })
1349        } else {
1350            let local_entity: Option<DeleteGlobalVariableError> =
1351                serde_json::from_str(&local_content).ok();
1352            let local_error = datadog::ResponseContent {
1353                status: local_status,
1354                content: local_content,
1355                entity: local_entity,
1356            };
1357            Err(datadog::Error::ResponseError(local_error))
1358        }
1359    }
1360
1361    /// Delete a Synthetic private location.
1362    pub async fn delete_private_location(
1363        &self,
1364        location_id: String,
1365    ) -> Result<(), datadog::Error<DeletePrivateLocationError>> {
1366        match self
1367            .delete_private_location_with_http_info(location_id)
1368            .await
1369        {
1370            Ok(_) => Ok(()),
1371            Err(err) => Err(err),
1372        }
1373    }
1374
1375    /// Delete a Synthetic private location.
1376    pub async fn delete_private_location_with_http_info(
1377        &self,
1378        location_id: String,
1379    ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeletePrivateLocationError>> {
1380        let local_configuration = &self.config;
1381        let operation_id = "v1.delete_private_location";
1382
1383        let local_client = &self.client;
1384
1385        let local_uri_str = format!(
1386            "{}/api/v1/synthetics/private-locations/{location_id}",
1387            local_configuration.get_operation_host(operation_id),
1388            location_id = datadog::urlencode(location_id)
1389        );
1390        let mut local_req_builder =
1391            local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
1392
1393        // build headers
1394        let mut headers = HeaderMap::new();
1395        headers.insert("Accept", HeaderValue::from_static("*/*"));
1396
1397        // build user agent
1398        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1399            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1400            Err(e) => {
1401                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1402                headers.insert(
1403                    reqwest::header::USER_AGENT,
1404                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1405                )
1406            }
1407        };
1408
1409        // build auth
1410        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1411            headers.insert(
1412                "DD-API-KEY",
1413                HeaderValue::from_str(local_key.key.as_str())
1414                    .expect("failed to parse DD-API-KEY header"),
1415            );
1416        };
1417        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1418            headers.insert(
1419                "DD-APPLICATION-KEY",
1420                HeaderValue::from_str(local_key.key.as_str())
1421                    .expect("failed to parse DD-APPLICATION-KEY header"),
1422            );
1423        };
1424
1425        local_req_builder = local_req_builder.headers(headers);
1426        let local_req = local_req_builder.build()?;
1427        log::debug!("request content: {:?}", local_req.body());
1428        let local_resp = local_client.execute(local_req).await?;
1429
1430        let local_status = local_resp.status();
1431        let local_content = local_resp.text().await?;
1432        log::debug!("response content: {}", local_content);
1433
1434        if !local_status.is_client_error() && !local_status.is_server_error() {
1435            Ok(datadog::ResponseContent {
1436                status: local_status,
1437                content: local_content,
1438                entity: None,
1439            })
1440        } else {
1441            let local_entity: Option<DeletePrivateLocationError> =
1442                serde_json::from_str(&local_content).ok();
1443            let local_error = datadog::ResponseContent {
1444                status: local_status,
1445                content: local_content,
1446                entity: local_entity,
1447            };
1448            Err(datadog::Error::ResponseError(local_error))
1449        }
1450    }
1451
1452    /// Delete multiple Synthetic tests by ID.
1453    pub async fn delete_tests(
1454        &self,
1455        body: crate::datadogV1::model::SyntheticsDeleteTestsPayload,
1456    ) -> Result<
1457        crate::datadogV1::model::SyntheticsDeleteTestsResponse,
1458        datadog::Error<DeleteTestsError>,
1459    > {
1460        match self.delete_tests_with_http_info(body).await {
1461            Ok(response_content) => {
1462                if let Some(e) = response_content.entity {
1463                    Ok(e)
1464                } else {
1465                    Err(datadog::Error::Serde(serde::de::Error::custom(
1466                        "response content was None",
1467                    )))
1468                }
1469            }
1470            Err(err) => Err(err),
1471        }
1472    }
1473
1474    /// Delete multiple Synthetic tests by ID.
1475    pub async fn delete_tests_with_http_info(
1476        &self,
1477        body: crate::datadogV1::model::SyntheticsDeleteTestsPayload,
1478    ) -> Result<
1479        datadog::ResponseContent<crate::datadogV1::model::SyntheticsDeleteTestsResponse>,
1480        datadog::Error<DeleteTestsError>,
1481    > {
1482        let local_configuration = &self.config;
1483        let operation_id = "v1.delete_tests";
1484
1485        let local_client = &self.client;
1486
1487        let local_uri_str = format!(
1488            "{}/api/v1/synthetics/tests/delete",
1489            local_configuration.get_operation_host(operation_id)
1490        );
1491        let mut local_req_builder =
1492            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
1493
1494        // build headers
1495        let mut headers = HeaderMap::new();
1496        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1497        headers.insert("Accept", HeaderValue::from_static("application/json"));
1498
1499        // build user agent
1500        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1501            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1502            Err(e) => {
1503                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1504                headers.insert(
1505                    reqwest::header::USER_AGENT,
1506                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1507                )
1508            }
1509        };
1510
1511        // build auth
1512        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1513            headers.insert(
1514                "DD-API-KEY",
1515                HeaderValue::from_str(local_key.key.as_str())
1516                    .expect("failed to parse DD-API-KEY header"),
1517            );
1518        };
1519        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1520            headers.insert(
1521                "DD-APPLICATION-KEY",
1522                HeaderValue::from_str(local_key.key.as_str())
1523                    .expect("failed to parse DD-APPLICATION-KEY header"),
1524            );
1525        };
1526
1527        // build body parameters
1528        let output = Vec::new();
1529        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1530        if body.serialize(&mut ser).is_ok() {
1531            if let Some(content_encoding) = headers.get("Content-Encoding") {
1532                match content_encoding.to_str().unwrap_or_default() {
1533                    "gzip" => {
1534                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1535                        let _ = enc.write_all(ser.into_inner().as_slice());
1536                        match enc.finish() {
1537                            Ok(buf) => {
1538                                local_req_builder = local_req_builder.body(buf);
1539                            }
1540                            Err(e) => return Err(datadog::Error::Io(e)),
1541                        }
1542                    }
1543                    "deflate" => {
1544                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1545                        let _ = enc.write_all(ser.into_inner().as_slice());
1546                        match enc.finish() {
1547                            Ok(buf) => {
1548                                local_req_builder = local_req_builder.body(buf);
1549                            }
1550                            Err(e) => return Err(datadog::Error::Io(e)),
1551                        }
1552                    }
1553                    "zstd1" => {
1554                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1555                        let _ = enc.write_all(ser.into_inner().as_slice());
1556                        match enc.finish() {
1557                            Ok(buf) => {
1558                                local_req_builder = local_req_builder.body(buf);
1559                            }
1560                            Err(e) => return Err(datadog::Error::Io(e)),
1561                        }
1562                    }
1563                    _ => {
1564                        local_req_builder = local_req_builder.body(ser.into_inner());
1565                    }
1566                }
1567            } else {
1568                local_req_builder = local_req_builder.body(ser.into_inner());
1569            }
1570        }
1571
1572        local_req_builder = local_req_builder.headers(headers);
1573        let local_req = local_req_builder.build()?;
1574        log::debug!("request content: {:?}", local_req.body());
1575        let local_resp = local_client.execute(local_req).await?;
1576
1577        let local_status = local_resp.status();
1578        let local_content = local_resp.text().await?;
1579        log::debug!("response content: {}", local_content);
1580
1581        if !local_status.is_client_error() && !local_status.is_server_error() {
1582            match serde_json::from_str::<crate::datadogV1::model::SyntheticsDeleteTestsResponse>(
1583                &local_content,
1584            ) {
1585                Ok(e) => {
1586                    return Ok(datadog::ResponseContent {
1587                        status: local_status,
1588                        content: local_content,
1589                        entity: Some(e),
1590                    })
1591                }
1592                Err(e) => return Err(datadog::Error::Serde(e)),
1593            };
1594        } else {
1595            let local_entity: Option<DeleteTestsError> = serde_json::from_str(&local_content).ok();
1596            let local_error = datadog::ResponseContent {
1597                status: local_status,
1598                content: local_content,
1599                entity: local_entity,
1600            };
1601            Err(datadog::Error::ResponseError(local_error))
1602        }
1603    }
1604
1605    /// Edit a Synthetic global variable.
1606    pub async fn edit_global_variable(
1607        &self,
1608        variable_id: String,
1609        body: crate::datadogV1::model::SyntheticsGlobalVariableRequest,
1610    ) -> Result<
1611        crate::datadogV1::model::SyntheticsGlobalVariable,
1612        datadog::Error<EditGlobalVariableError>,
1613    > {
1614        match self
1615            .edit_global_variable_with_http_info(variable_id, body)
1616            .await
1617        {
1618            Ok(response_content) => {
1619                if let Some(e) = response_content.entity {
1620                    Ok(e)
1621                } else {
1622                    Err(datadog::Error::Serde(serde::de::Error::custom(
1623                        "response content was None",
1624                    )))
1625                }
1626            }
1627            Err(err) => Err(err),
1628        }
1629    }
1630
1631    /// Edit a Synthetic global variable.
1632    pub async fn edit_global_variable_with_http_info(
1633        &self,
1634        variable_id: String,
1635        body: crate::datadogV1::model::SyntheticsGlobalVariableRequest,
1636    ) -> Result<
1637        datadog::ResponseContent<crate::datadogV1::model::SyntheticsGlobalVariable>,
1638        datadog::Error<EditGlobalVariableError>,
1639    > {
1640        let local_configuration = &self.config;
1641        let operation_id = "v1.edit_global_variable";
1642
1643        let local_client = &self.client;
1644
1645        let local_uri_str = format!(
1646            "{}/api/v1/synthetics/variables/{variable_id}",
1647            local_configuration.get_operation_host(operation_id),
1648            variable_id = datadog::urlencode(variable_id)
1649        );
1650        let mut local_req_builder =
1651            local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
1652
1653        // build headers
1654        let mut headers = HeaderMap::new();
1655        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1656        headers.insert("Accept", HeaderValue::from_static("application/json"));
1657
1658        // build user agent
1659        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1660            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1661            Err(e) => {
1662                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1663                headers.insert(
1664                    reqwest::header::USER_AGENT,
1665                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1666                )
1667            }
1668        };
1669
1670        // build auth
1671        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1672            headers.insert(
1673                "DD-API-KEY",
1674                HeaderValue::from_str(local_key.key.as_str())
1675                    .expect("failed to parse DD-API-KEY header"),
1676            );
1677        };
1678        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1679            headers.insert(
1680                "DD-APPLICATION-KEY",
1681                HeaderValue::from_str(local_key.key.as_str())
1682                    .expect("failed to parse DD-APPLICATION-KEY header"),
1683            );
1684        };
1685
1686        // build body parameters
1687        let output = Vec::new();
1688        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1689        if body.serialize(&mut ser).is_ok() {
1690            if let Some(content_encoding) = headers.get("Content-Encoding") {
1691                match content_encoding.to_str().unwrap_or_default() {
1692                    "gzip" => {
1693                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1694                        let _ = enc.write_all(ser.into_inner().as_slice());
1695                        match enc.finish() {
1696                            Ok(buf) => {
1697                                local_req_builder = local_req_builder.body(buf);
1698                            }
1699                            Err(e) => return Err(datadog::Error::Io(e)),
1700                        }
1701                    }
1702                    "deflate" => {
1703                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1704                        let _ = enc.write_all(ser.into_inner().as_slice());
1705                        match enc.finish() {
1706                            Ok(buf) => {
1707                                local_req_builder = local_req_builder.body(buf);
1708                            }
1709                            Err(e) => return Err(datadog::Error::Io(e)),
1710                        }
1711                    }
1712                    "zstd1" => {
1713                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1714                        let _ = enc.write_all(ser.into_inner().as_slice());
1715                        match enc.finish() {
1716                            Ok(buf) => {
1717                                local_req_builder = local_req_builder.body(buf);
1718                            }
1719                            Err(e) => return Err(datadog::Error::Io(e)),
1720                        }
1721                    }
1722                    _ => {
1723                        local_req_builder = local_req_builder.body(ser.into_inner());
1724                    }
1725                }
1726            } else {
1727                local_req_builder = local_req_builder.body(ser.into_inner());
1728            }
1729        }
1730
1731        local_req_builder = local_req_builder.headers(headers);
1732        let local_req = local_req_builder.build()?;
1733        log::debug!("request content: {:?}", local_req.body());
1734        let local_resp = local_client.execute(local_req).await?;
1735
1736        let local_status = local_resp.status();
1737        let local_content = local_resp.text().await?;
1738        log::debug!("response content: {}", local_content);
1739
1740        if !local_status.is_client_error() && !local_status.is_server_error() {
1741            match serde_json::from_str::<crate::datadogV1::model::SyntheticsGlobalVariable>(
1742                &local_content,
1743            ) {
1744                Ok(e) => {
1745                    return Ok(datadog::ResponseContent {
1746                        status: local_status,
1747                        content: local_content,
1748                        entity: Some(e),
1749                    })
1750                }
1751                Err(e) => return Err(datadog::Error::Serde(e)),
1752            };
1753        } else {
1754            let local_entity: Option<EditGlobalVariableError> =
1755                serde_json::from_str(&local_content).ok();
1756            let local_error = datadog::ResponseContent {
1757                status: local_status,
1758                content: local_content,
1759                entity: local_entity,
1760            };
1761            Err(datadog::Error::ResponseError(local_error))
1762        }
1763    }
1764
1765    /// Fetch uptime for multiple Synthetic tests by ID.
1766    pub async fn fetch_uptimes(
1767        &self,
1768        body: crate::datadogV1::model::SyntheticsFetchUptimesPayload,
1769    ) -> Result<Vec<crate::datadogV1::model::SyntheticsTestUptime>, datadog::Error<FetchUptimesError>>
1770    {
1771        match self.fetch_uptimes_with_http_info(body).await {
1772            Ok(response_content) => {
1773                if let Some(e) = response_content.entity {
1774                    Ok(e)
1775                } else {
1776                    Err(datadog::Error::Serde(serde::de::Error::custom(
1777                        "response content was None",
1778                    )))
1779                }
1780            }
1781            Err(err) => Err(err),
1782        }
1783    }
1784
1785    /// Fetch uptime for multiple Synthetic tests by ID.
1786    pub async fn fetch_uptimes_with_http_info(
1787        &self,
1788        body: crate::datadogV1::model::SyntheticsFetchUptimesPayload,
1789    ) -> Result<
1790        datadog::ResponseContent<Vec<crate::datadogV1::model::SyntheticsTestUptime>>,
1791        datadog::Error<FetchUptimesError>,
1792    > {
1793        let local_configuration = &self.config;
1794        let operation_id = "v1.fetch_uptimes";
1795
1796        let local_client = &self.client;
1797
1798        let local_uri_str = format!(
1799            "{}/api/v1/synthetics/tests/uptimes",
1800            local_configuration.get_operation_host(operation_id)
1801        );
1802        let mut local_req_builder =
1803            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
1804
1805        // build headers
1806        let mut headers = HeaderMap::new();
1807        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1808        headers.insert("Accept", HeaderValue::from_static("application/json"));
1809
1810        // build user agent
1811        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1812            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1813            Err(e) => {
1814                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1815                headers.insert(
1816                    reqwest::header::USER_AGENT,
1817                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1818                )
1819            }
1820        };
1821
1822        // build auth
1823        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1824            headers.insert(
1825                "DD-API-KEY",
1826                HeaderValue::from_str(local_key.key.as_str())
1827                    .expect("failed to parse DD-API-KEY header"),
1828            );
1829        };
1830        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1831            headers.insert(
1832                "DD-APPLICATION-KEY",
1833                HeaderValue::from_str(local_key.key.as_str())
1834                    .expect("failed to parse DD-APPLICATION-KEY header"),
1835            );
1836        };
1837
1838        // build body parameters
1839        let output = Vec::new();
1840        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1841        if body.serialize(&mut ser).is_ok() {
1842            if let Some(content_encoding) = headers.get("Content-Encoding") {
1843                match content_encoding.to_str().unwrap_or_default() {
1844                    "gzip" => {
1845                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1846                        let _ = enc.write_all(ser.into_inner().as_slice());
1847                        match enc.finish() {
1848                            Ok(buf) => {
1849                                local_req_builder = local_req_builder.body(buf);
1850                            }
1851                            Err(e) => return Err(datadog::Error::Io(e)),
1852                        }
1853                    }
1854                    "deflate" => {
1855                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1856                        let _ = enc.write_all(ser.into_inner().as_slice());
1857                        match enc.finish() {
1858                            Ok(buf) => {
1859                                local_req_builder = local_req_builder.body(buf);
1860                            }
1861                            Err(e) => return Err(datadog::Error::Io(e)),
1862                        }
1863                    }
1864                    "zstd1" => {
1865                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1866                        let _ = enc.write_all(ser.into_inner().as_slice());
1867                        match enc.finish() {
1868                            Ok(buf) => {
1869                                local_req_builder = local_req_builder.body(buf);
1870                            }
1871                            Err(e) => return Err(datadog::Error::Io(e)),
1872                        }
1873                    }
1874                    _ => {
1875                        local_req_builder = local_req_builder.body(ser.into_inner());
1876                    }
1877                }
1878            } else {
1879                local_req_builder = local_req_builder.body(ser.into_inner());
1880            }
1881        }
1882
1883        local_req_builder = local_req_builder.headers(headers);
1884        let local_req = local_req_builder.build()?;
1885        log::debug!("request content: {:?}", local_req.body());
1886        let local_resp = local_client.execute(local_req).await?;
1887
1888        let local_status = local_resp.status();
1889        let local_content = local_resp.text().await?;
1890        log::debug!("response content: {}", local_content);
1891
1892        if !local_status.is_client_error() && !local_status.is_server_error() {
1893            match serde_json::from_str::<Vec<crate::datadogV1::model::SyntheticsTestUptime>>(
1894                &local_content,
1895            ) {
1896                Ok(e) => {
1897                    return Ok(datadog::ResponseContent {
1898                        status: local_status,
1899                        content: local_content,
1900                        entity: Some(e),
1901                    })
1902                }
1903                Err(e) => return Err(datadog::Error::Serde(e)),
1904            };
1905        } else {
1906            let local_entity: Option<FetchUptimesError> = serde_json::from_str(&local_content).ok();
1907            let local_error = datadog::ResponseContent {
1908                status: local_status,
1909                content: local_content,
1910                entity: local_entity,
1911            };
1912            Err(datadog::Error::ResponseError(local_error))
1913        }
1914    }
1915
1916    /// Get the detailed configuration associated with
1917    /// a Synthetic API test.
1918    pub async fn get_api_test(
1919        &self,
1920        public_id: String,
1921    ) -> Result<crate::datadogV1::model::SyntheticsAPITest, datadog::Error<GetAPITestError>> {
1922        match self.get_api_test_with_http_info(public_id).await {
1923            Ok(response_content) => {
1924                if let Some(e) = response_content.entity {
1925                    Ok(e)
1926                } else {
1927                    Err(datadog::Error::Serde(serde::de::Error::custom(
1928                        "response content was None",
1929                    )))
1930                }
1931            }
1932            Err(err) => Err(err),
1933        }
1934    }
1935
1936    /// Get the detailed configuration associated with
1937    /// a Synthetic API test.
1938    pub async fn get_api_test_with_http_info(
1939        &self,
1940        public_id: String,
1941    ) -> Result<
1942        datadog::ResponseContent<crate::datadogV1::model::SyntheticsAPITest>,
1943        datadog::Error<GetAPITestError>,
1944    > {
1945        let local_configuration = &self.config;
1946        let operation_id = "v1.get_api_test";
1947
1948        let local_client = &self.client;
1949
1950        let local_uri_str = format!(
1951            "{}/api/v1/synthetics/tests/api/{public_id}",
1952            local_configuration.get_operation_host(operation_id),
1953            public_id = datadog::urlencode(public_id)
1954        );
1955        let mut local_req_builder =
1956            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1957
1958        // build headers
1959        let mut headers = HeaderMap::new();
1960        headers.insert("Accept", HeaderValue::from_static("application/json"));
1961
1962        // build user agent
1963        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1964            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1965            Err(e) => {
1966                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1967                headers.insert(
1968                    reqwest::header::USER_AGENT,
1969                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1970                )
1971            }
1972        };
1973
1974        // build auth
1975        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1976            headers.insert(
1977                "DD-API-KEY",
1978                HeaderValue::from_str(local_key.key.as_str())
1979                    .expect("failed to parse DD-API-KEY header"),
1980            );
1981        };
1982        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1983            headers.insert(
1984                "DD-APPLICATION-KEY",
1985                HeaderValue::from_str(local_key.key.as_str())
1986                    .expect("failed to parse DD-APPLICATION-KEY header"),
1987            );
1988        };
1989
1990        local_req_builder = local_req_builder.headers(headers);
1991        let local_req = local_req_builder.build()?;
1992        log::debug!("request content: {:?}", local_req.body());
1993        let local_resp = local_client.execute(local_req).await?;
1994
1995        let local_status = local_resp.status();
1996        let local_content = local_resp.text().await?;
1997        log::debug!("response content: {}", local_content);
1998
1999        if !local_status.is_client_error() && !local_status.is_server_error() {
2000            match serde_json::from_str::<crate::datadogV1::model::SyntheticsAPITest>(&local_content)
2001            {
2002                Ok(e) => {
2003                    return Ok(datadog::ResponseContent {
2004                        status: local_status,
2005                        content: local_content,
2006                        entity: Some(e),
2007                    })
2008                }
2009                Err(e) => return Err(datadog::Error::Serde(e)),
2010            };
2011        } else {
2012            let local_entity: Option<GetAPITestError> = serde_json::from_str(&local_content).ok();
2013            let local_error = datadog::ResponseContent {
2014                status: local_status,
2015                content: local_content,
2016                entity: local_entity,
2017            };
2018            Err(datadog::Error::ResponseError(local_error))
2019        }
2020    }
2021
2022    /// Get the last 150 test results summaries for a given Synthetic API test.
2023    pub async fn get_api_test_latest_results(
2024        &self,
2025        public_id: String,
2026        params: GetAPITestLatestResultsOptionalParams,
2027    ) -> Result<
2028        crate::datadogV1::model::SyntheticsGetAPITestLatestResultsResponse,
2029        datadog::Error<GetAPITestLatestResultsError>,
2030    > {
2031        match self
2032            .get_api_test_latest_results_with_http_info(public_id, params)
2033            .await
2034        {
2035            Ok(response_content) => {
2036                if let Some(e) = response_content.entity {
2037                    Ok(e)
2038                } else {
2039                    Err(datadog::Error::Serde(serde::de::Error::custom(
2040                        "response content was None",
2041                    )))
2042                }
2043            }
2044            Err(err) => Err(err),
2045        }
2046    }
2047
2048    /// Get the last 150 test results summaries for a given Synthetic API test.
2049    pub async fn get_api_test_latest_results_with_http_info(
2050        &self,
2051        public_id: String,
2052        params: GetAPITestLatestResultsOptionalParams,
2053    ) -> Result<
2054        datadog::ResponseContent<
2055            crate::datadogV1::model::SyntheticsGetAPITestLatestResultsResponse,
2056        >,
2057        datadog::Error<GetAPITestLatestResultsError>,
2058    > {
2059        let local_configuration = &self.config;
2060        let operation_id = "v1.get_api_test_latest_results";
2061
2062        // unbox and build optional parameters
2063        let from_ts = params.from_ts;
2064        let to_ts = params.to_ts;
2065        let probe_dc = params.probe_dc;
2066
2067        let local_client = &self.client;
2068
2069        let local_uri_str = format!(
2070            "{}/api/v1/synthetics/tests/{public_id}/results",
2071            local_configuration.get_operation_host(operation_id),
2072            public_id = datadog::urlencode(public_id)
2073        );
2074        let mut local_req_builder =
2075            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2076
2077        if let Some(ref local_query_param) = from_ts {
2078            local_req_builder =
2079                local_req_builder.query(&[("from_ts", &local_query_param.to_string())]);
2080        };
2081        if let Some(ref local_query_param) = to_ts {
2082            local_req_builder =
2083                local_req_builder.query(&[("to_ts", &local_query_param.to_string())]);
2084        };
2085        if let Some(ref local) = probe_dc {
2086            for param in local {
2087                local_req_builder = local_req_builder.query(&[("probe_dc", &param.to_string())]);
2088            }
2089        };
2090
2091        // build headers
2092        let mut headers = HeaderMap::new();
2093        headers.insert("Accept", HeaderValue::from_static("application/json"));
2094
2095        // build user agent
2096        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2097            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2098            Err(e) => {
2099                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2100                headers.insert(
2101                    reqwest::header::USER_AGENT,
2102                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2103                )
2104            }
2105        };
2106
2107        // build auth
2108        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2109            headers.insert(
2110                "DD-API-KEY",
2111                HeaderValue::from_str(local_key.key.as_str())
2112                    .expect("failed to parse DD-API-KEY header"),
2113            );
2114        };
2115        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2116            headers.insert(
2117                "DD-APPLICATION-KEY",
2118                HeaderValue::from_str(local_key.key.as_str())
2119                    .expect("failed to parse DD-APPLICATION-KEY header"),
2120            );
2121        };
2122
2123        local_req_builder = local_req_builder.headers(headers);
2124        let local_req = local_req_builder.build()?;
2125        log::debug!("request content: {:?}", local_req.body());
2126        let local_resp = local_client.execute(local_req).await?;
2127
2128        let local_status = local_resp.status();
2129        let local_content = local_resp.text().await?;
2130        log::debug!("response content: {}", local_content);
2131
2132        if !local_status.is_client_error() && !local_status.is_server_error() {
2133            match serde_json::from_str::<
2134                crate::datadogV1::model::SyntheticsGetAPITestLatestResultsResponse,
2135            >(&local_content)
2136            {
2137                Ok(e) => {
2138                    return Ok(datadog::ResponseContent {
2139                        status: local_status,
2140                        content: local_content,
2141                        entity: Some(e),
2142                    })
2143                }
2144                Err(e) => return Err(datadog::Error::Serde(e)),
2145            };
2146        } else {
2147            let local_entity: Option<GetAPITestLatestResultsError> =
2148                serde_json::from_str(&local_content).ok();
2149            let local_error = datadog::ResponseContent {
2150                status: local_status,
2151                content: local_content,
2152                entity: local_entity,
2153            };
2154            Err(datadog::Error::ResponseError(local_error))
2155        }
2156    }
2157
2158    /// Get a specific full result from a given Synthetic API test.
2159    pub async fn get_api_test_result(
2160        &self,
2161        public_id: String,
2162        result_id: String,
2163    ) -> Result<
2164        crate::datadogV1::model::SyntheticsAPITestResultFull,
2165        datadog::Error<GetAPITestResultError>,
2166    > {
2167        match self
2168            .get_api_test_result_with_http_info(public_id, result_id)
2169            .await
2170        {
2171            Ok(response_content) => {
2172                if let Some(e) = response_content.entity {
2173                    Ok(e)
2174                } else {
2175                    Err(datadog::Error::Serde(serde::de::Error::custom(
2176                        "response content was None",
2177                    )))
2178                }
2179            }
2180            Err(err) => Err(err),
2181        }
2182    }
2183
2184    /// Get a specific full result from a given Synthetic API test.
2185    pub async fn get_api_test_result_with_http_info(
2186        &self,
2187        public_id: String,
2188        result_id: String,
2189    ) -> Result<
2190        datadog::ResponseContent<crate::datadogV1::model::SyntheticsAPITestResultFull>,
2191        datadog::Error<GetAPITestResultError>,
2192    > {
2193        let local_configuration = &self.config;
2194        let operation_id = "v1.get_api_test_result";
2195
2196        let local_client = &self.client;
2197
2198        let local_uri_str = format!(
2199            "{}/api/v1/synthetics/tests/{public_id}/results/{result_id}",
2200            local_configuration.get_operation_host(operation_id),
2201            public_id = datadog::urlencode(public_id),
2202            result_id = datadog::urlencode(result_id)
2203        );
2204        let mut local_req_builder =
2205            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2206
2207        // build headers
2208        let mut headers = HeaderMap::new();
2209        headers.insert("Accept", HeaderValue::from_static("application/json"));
2210
2211        // build user agent
2212        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2213            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2214            Err(e) => {
2215                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2216                headers.insert(
2217                    reqwest::header::USER_AGENT,
2218                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2219                )
2220            }
2221        };
2222
2223        // build auth
2224        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2225            headers.insert(
2226                "DD-API-KEY",
2227                HeaderValue::from_str(local_key.key.as_str())
2228                    .expect("failed to parse DD-API-KEY header"),
2229            );
2230        };
2231        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2232            headers.insert(
2233                "DD-APPLICATION-KEY",
2234                HeaderValue::from_str(local_key.key.as_str())
2235                    .expect("failed to parse DD-APPLICATION-KEY header"),
2236            );
2237        };
2238
2239        local_req_builder = local_req_builder.headers(headers);
2240        let local_req = local_req_builder.build()?;
2241        log::debug!("request content: {:?}", local_req.body());
2242        let local_resp = local_client.execute(local_req).await?;
2243
2244        let local_status = local_resp.status();
2245        let local_content = local_resp.text().await?;
2246        log::debug!("response content: {}", local_content);
2247
2248        if !local_status.is_client_error() && !local_status.is_server_error() {
2249            match serde_json::from_str::<crate::datadogV1::model::SyntheticsAPITestResultFull>(
2250                &local_content,
2251            ) {
2252                Ok(e) => {
2253                    return Ok(datadog::ResponseContent {
2254                        status: local_status,
2255                        content: local_content,
2256                        entity: Some(e),
2257                    })
2258                }
2259                Err(e) => return Err(datadog::Error::Serde(e)),
2260            };
2261        } else {
2262            let local_entity: Option<GetAPITestResultError> =
2263                serde_json::from_str(&local_content).ok();
2264            let local_error = datadog::ResponseContent {
2265                status: local_status,
2266                content: local_content,
2267                entity: local_entity,
2268            };
2269            Err(datadog::Error::ResponseError(local_error))
2270        }
2271    }
2272
2273    /// Get the detailed configuration (including steps) associated with
2274    /// a Synthetic browser test.
2275    pub async fn get_browser_test(
2276        &self,
2277        public_id: String,
2278    ) -> Result<crate::datadogV1::model::SyntheticsBrowserTest, datadog::Error<GetBrowserTestError>>
2279    {
2280        match self.get_browser_test_with_http_info(public_id).await {
2281            Ok(response_content) => {
2282                if let Some(e) = response_content.entity {
2283                    Ok(e)
2284                } else {
2285                    Err(datadog::Error::Serde(serde::de::Error::custom(
2286                        "response content was None",
2287                    )))
2288                }
2289            }
2290            Err(err) => Err(err),
2291        }
2292    }
2293
2294    /// Get the detailed configuration (including steps) associated with
2295    /// a Synthetic browser test.
2296    pub async fn get_browser_test_with_http_info(
2297        &self,
2298        public_id: String,
2299    ) -> Result<
2300        datadog::ResponseContent<crate::datadogV1::model::SyntheticsBrowserTest>,
2301        datadog::Error<GetBrowserTestError>,
2302    > {
2303        let local_configuration = &self.config;
2304        let operation_id = "v1.get_browser_test";
2305
2306        let local_client = &self.client;
2307
2308        let local_uri_str = format!(
2309            "{}/api/v1/synthetics/tests/browser/{public_id}",
2310            local_configuration.get_operation_host(operation_id),
2311            public_id = datadog::urlencode(public_id)
2312        );
2313        let mut local_req_builder =
2314            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2315
2316        // build headers
2317        let mut headers = HeaderMap::new();
2318        headers.insert("Accept", HeaderValue::from_static("application/json"));
2319
2320        // build user agent
2321        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2322            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2323            Err(e) => {
2324                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2325                headers.insert(
2326                    reqwest::header::USER_AGENT,
2327                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2328                )
2329            }
2330        };
2331
2332        // build auth
2333        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2334            headers.insert(
2335                "DD-API-KEY",
2336                HeaderValue::from_str(local_key.key.as_str())
2337                    .expect("failed to parse DD-API-KEY header"),
2338            );
2339        };
2340        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2341            headers.insert(
2342                "DD-APPLICATION-KEY",
2343                HeaderValue::from_str(local_key.key.as_str())
2344                    .expect("failed to parse DD-APPLICATION-KEY header"),
2345            );
2346        };
2347
2348        local_req_builder = local_req_builder.headers(headers);
2349        let local_req = local_req_builder.build()?;
2350        log::debug!("request content: {:?}", local_req.body());
2351        let local_resp = local_client.execute(local_req).await?;
2352
2353        let local_status = local_resp.status();
2354        let local_content = local_resp.text().await?;
2355        log::debug!("response content: {}", local_content);
2356
2357        if !local_status.is_client_error() && !local_status.is_server_error() {
2358            match serde_json::from_str::<crate::datadogV1::model::SyntheticsBrowserTest>(
2359                &local_content,
2360            ) {
2361                Ok(e) => {
2362                    return Ok(datadog::ResponseContent {
2363                        status: local_status,
2364                        content: local_content,
2365                        entity: Some(e),
2366                    })
2367                }
2368                Err(e) => return Err(datadog::Error::Serde(e)),
2369            };
2370        } else {
2371            let local_entity: Option<GetBrowserTestError> =
2372                serde_json::from_str(&local_content).ok();
2373            let local_error = datadog::ResponseContent {
2374                status: local_status,
2375                content: local_content,
2376                entity: local_entity,
2377            };
2378            Err(datadog::Error::ResponseError(local_error))
2379        }
2380    }
2381
2382    /// Get the last 150 test results summaries for a given Synthetic browser test.
2383    pub async fn get_browser_test_latest_results(
2384        &self,
2385        public_id: String,
2386        params: GetBrowserTestLatestResultsOptionalParams,
2387    ) -> Result<
2388        crate::datadogV1::model::SyntheticsGetBrowserTestLatestResultsResponse,
2389        datadog::Error<GetBrowserTestLatestResultsError>,
2390    > {
2391        match self
2392            .get_browser_test_latest_results_with_http_info(public_id, params)
2393            .await
2394        {
2395            Ok(response_content) => {
2396                if let Some(e) = response_content.entity {
2397                    Ok(e)
2398                } else {
2399                    Err(datadog::Error::Serde(serde::de::Error::custom(
2400                        "response content was None",
2401                    )))
2402                }
2403            }
2404            Err(err) => Err(err),
2405        }
2406    }
2407
2408    /// Get the last 150 test results summaries for a given Synthetic browser test.
2409    pub async fn get_browser_test_latest_results_with_http_info(
2410        &self,
2411        public_id: String,
2412        params: GetBrowserTestLatestResultsOptionalParams,
2413    ) -> Result<
2414        datadog::ResponseContent<
2415            crate::datadogV1::model::SyntheticsGetBrowserTestLatestResultsResponse,
2416        >,
2417        datadog::Error<GetBrowserTestLatestResultsError>,
2418    > {
2419        let local_configuration = &self.config;
2420        let operation_id = "v1.get_browser_test_latest_results";
2421
2422        // unbox and build optional parameters
2423        let from_ts = params.from_ts;
2424        let to_ts = params.to_ts;
2425        let probe_dc = params.probe_dc;
2426
2427        let local_client = &self.client;
2428
2429        let local_uri_str = format!(
2430            "{}/api/v1/synthetics/tests/browser/{public_id}/results",
2431            local_configuration.get_operation_host(operation_id),
2432            public_id = datadog::urlencode(public_id)
2433        );
2434        let mut local_req_builder =
2435            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2436
2437        if let Some(ref local_query_param) = from_ts {
2438            local_req_builder =
2439                local_req_builder.query(&[("from_ts", &local_query_param.to_string())]);
2440        };
2441        if let Some(ref local_query_param) = to_ts {
2442            local_req_builder =
2443                local_req_builder.query(&[("to_ts", &local_query_param.to_string())]);
2444        };
2445        if let Some(ref local) = probe_dc {
2446            for param in local {
2447                local_req_builder = local_req_builder.query(&[("probe_dc", &param.to_string())]);
2448            }
2449        };
2450
2451        // build headers
2452        let mut headers = HeaderMap::new();
2453        headers.insert("Accept", HeaderValue::from_static("application/json"));
2454
2455        // build user agent
2456        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2457            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2458            Err(e) => {
2459                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2460                headers.insert(
2461                    reqwest::header::USER_AGENT,
2462                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2463                )
2464            }
2465        };
2466
2467        // build auth
2468        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2469            headers.insert(
2470                "DD-API-KEY",
2471                HeaderValue::from_str(local_key.key.as_str())
2472                    .expect("failed to parse DD-API-KEY header"),
2473            );
2474        };
2475        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2476            headers.insert(
2477                "DD-APPLICATION-KEY",
2478                HeaderValue::from_str(local_key.key.as_str())
2479                    .expect("failed to parse DD-APPLICATION-KEY header"),
2480            );
2481        };
2482
2483        local_req_builder = local_req_builder.headers(headers);
2484        let local_req = local_req_builder.build()?;
2485        log::debug!("request content: {:?}", local_req.body());
2486        let local_resp = local_client.execute(local_req).await?;
2487
2488        let local_status = local_resp.status();
2489        let local_content = local_resp.text().await?;
2490        log::debug!("response content: {}", local_content);
2491
2492        if !local_status.is_client_error() && !local_status.is_server_error() {
2493            match serde_json::from_str::<
2494                crate::datadogV1::model::SyntheticsGetBrowserTestLatestResultsResponse,
2495            >(&local_content)
2496            {
2497                Ok(e) => {
2498                    return Ok(datadog::ResponseContent {
2499                        status: local_status,
2500                        content: local_content,
2501                        entity: Some(e),
2502                    })
2503                }
2504                Err(e) => return Err(datadog::Error::Serde(e)),
2505            };
2506        } else {
2507            let local_entity: Option<GetBrowserTestLatestResultsError> =
2508                serde_json::from_str(&local_content).ok();
2509            let local_error = datadog::ResponseContent {
2510                status: local_status,
2511                content: local_content,
2512                entity: local_entity,
2513            };
2514            Err(datadog::Error::ResponseError(local_error))
2515        }
2516    }
2517
2518    /// Get a specific full result from a given Synthetic browser test.
2519    pub async fn get_browser_test_result(
2520        &self,
2521        public_id: String,
2522        result_id: String,
2523    ) -> Result<
2524        crate::datadogV1::model::SyntheticsBrowserTestResultFull,
2525        datadog::Error<GetBrowserTestResultError>,
2526    > {
2527        match self
2528            .get_browser_test_result_with_http_info(public_id, result_id)
2529            .await
2530        {
2531            Ok(response_content) => {
2532                if let Some(e) = response_content.entity {
2533                    Ok(e)
2534                } else {
2535                    Err(datadog::Error::Serde(serde::de::Error::custom(
2536                        "response content was None",
2537                    )))
2538                }
2539            }
2540            Err(err) => Err(err),
2541        }
2542    }
2543
2544    /// Get a specific full result from a given Synthetic browser test.
2545    pub async fn get_browser_test_result_with_http_info(
2546        &self,
2547        public_id: String,
2548        result_id: String,
2549    ) -> Result<
2550        datadog::ResponseContent<crate::datadogV1::model::SyntheticsBrowserTestResultFull>,
2551        datadog::Error<GetBrowserTestResultError>,
2552    > {
2553        let local_configuration = &self.config;
2554        let operation_id = "v1.get_browser_test_result";
2555
2556        let local_client = &self.client;
2557
2558        let local_uri_str = format!(
2559            "{}/api/v1/synthetics/tests/browser/{public_id}/results/{result_id}",
2560            local_configuration.get_operation_host(operation_id),
2561            public_id = datadog::urlencode(public_id),
2562            result_id = datadog::urlencode(result_id)
2563        );
2564        let mut local_req_builder =
2565            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2566
2567        // build headers
2568        let mut headers = HeaderMap::new();
2569        headers.insert("Accept", HeaderValue::from_static("application/json"));
2570
2571        // build user agent
2572        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2573            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2574            Err(e) => {
2575                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2576                headers.insert(
2577                    reqwest::header::USER_AGENT,
2578                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2579                )
2580            }
2581        };
2582
2583        // build auth
2584        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2585            headers.insert(
2586                "DD-API-KEY",
2587                HeaderValue::from_str(local_key.key.as_str())
2588                    .expect("failed to parse DD-API-KEY header"),
2589            );
2590        };
2591        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2592            headers.insert(
2593                "DD-APPLICATION-KEY",
2594                HeaderValue::from_str(local_key.key.as_str())
2595                    .expect("failed to parse DD-APPLICATION-KEY header"),
2596            );
2597        };
2598
2599        local_req_builder = local_req_builder.headers(headers);
2600        let local_req = local_req_builder.build()?;
2601        log::debug!("request content: {:?}", local_req.body());
2602        let local_resp = local_client.execute(local_req).await?;
2603
2604        let local_status = local_resp.status();
2605        let local_content = local_resp.text().await?;
2606        log::debug!("response content: {}", local_content);
2607
2608        if !local_status.is_client_error() && !local_status.is_server_error() {
2609            match serde_json::from_str::<crate::datadogV1::model::SyntheticsBrowserTestResultFull>(
2610                &local_content,
2611            ) {
2612                Ok(e) => {
2613                    return Ok(datadog::ResponseContent {
2614                        status: local_status,
2615                        content: local_content,
2616                        entity: Some(e),
2617                    })
2618                }
2619                Err(e) => return Err(datadog::Error::Serde(e)),
2620            };
2621        } else {
2622            let local_entity: Option<GetBrowserTestResultError> =
2623                serde_json::from_str(&local_content).ok();
2624            let local_error = datadog::ResponseContent {
2625                status: local_status,
2626                content: local_content,
2627                entity: local_entity,
2628            };
2629            Err(datadog::Error::ResponseError(local_error))
2630        }
2631    }
2632
2633    /// Get the detailed configuration of a global variable.
2634    pub async fn get_global_variable(
2635        &self,
2636        variable_id: String,
2637    ) -> Result<
2638        crate::datadogV1::model::SyntheticsGlobalVariable,
2639        datadog::Error<GetGlobalVariableError>,
2640    > {
2641        match self.get_global_variable_with_http_info(variable_id).await {
2642            Ok(response_content) => {
2643                if let Some(e) = response_content.entity {
2644                    Ok(e)
2645                } else {
2646                    Err(datadog::Error::Serde(serde::de::Error::custom(
2647                        "response content was None",
2648                    )))
2649                }
2650            }
2651            Err(err) => Err(err),
2652        }
2653    }
2654
2655    /// Get the detailed configuration of a global variable.
2656    pub async fn get_global_variable_with_http_info(
2657        &self,
2658        variable_id: String,
2659    ) -> Result<
2660        datadog::ResponseContent<crate::datadogV1::model::SyntheticsGlobalVariable>,
2661        datadog::Error<GetGlobalVariableError>,
2662    > {
2663        let local_configuration = &self.config;
2664        let operation_id = "v1.get_global_variable";
2665
2666        let local_client = &self.client;
2667
2668        let local_uri_str = format!(
2669            "{}/api/v1/synthetics/variables/{variable_id}",
2670            local_configuration.get_operation_host(operation_id),
2671            variable_id = datadog::urlencode(variable_id)
2672        );
2673        let mut local_req_builder =
2674            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2675
2676        // build headers
2677        let mut headers = HeaderMap::new();
2678        headers.insert("Accept", HeaderValue::from_static("application/json"));
2679
2680        // build user agent
2681        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2682            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2683            Err(e) => {
2684                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2685                headers.insert(
2686                    reqwest::header::USER_AGENT,
2687                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2688                )
2689            }
2690        };
2691
2692        // build auth
2693        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2694            headers.insert(
2695                "DD-API-KEY",
2696                HeaderValue::from_str(local_key.key.as_str())
2697                    .expect("failed to parse DD-API-KEY header"),
2698            );
2699        };
2700        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2701            headers.insert(
2702                "DD-APPLICATION-KEY",
2703                HeaderValue::from_str(local_key.key.as_str())
2704                    .expect("failed to parse DD-APPLICATION-KEY header"),
2705            );
2706        };
2707
2708        local_req_builder = local_req_builder.headers(headers);
2709        let local_req = local_req_builder.build()?;
2710        log::debug!("request content: {:?}", local_req.body());
2711        let local_resp = local_client.execute(local_req).await?;
2712
2713        let local_status = local_resp.status();
2714        let local_content = local_resp.text().await?;
2715        log::debug!("response content: {}", local_content);
2716
2717        if !local_status.is_client_error() && !local_status.is_server_error() {
2718            match serde_json::from_str::<crate::datadogV1::model::SyntheticsGlobalVariable>(
2719                &local_content,
2720            ) {
2721                Ok(e) => {
2722                    return Ok(datadog::ResponseContent {
2723                        status: local_status,
2724                        content: local_content,
2725                        entity: Some(e),
2726                    })
2727                }
2728                Err(e) => return Err(datadog::Error::Serde(e)),
2729            };
2730        } else {
2731            let local_entity: Option<GetGlobalVariableError> =
2732                serde_json::from_str(&local_content).ok();
2733            let local_error = datadog::ResponseContent {
2734                status: local_status,
2735                content: local_content,
2736                entity: local_entity,
2737            };
2738            Err(datadog::Error::ResponseError(local_error))
2739        }
2740    }
2741
2742    /// Get the detailed configuration associated with
2743    /// a Synthetic Mobile test.
2744    pub async fn get_mobile_test(
2745        &self,
2746        public_id: String,
2747    ) -> Result<crate::datadogV1::model::SyntheticsMobileTest, datadog::Error<GetMobileTestError>>
2748    {
2749        match self.get_mobile_test_with_http_info(public_id).await {
2750            Ok(response_content) => {
2751                if let Some(e) = response_content.entity {
2752                    Ok(e)
2753                } else {
2754                    Err(datadog::Error::Serde(serde::de::Error::custom(
2755                        "response content was None",
2756                    )))
2757                }
2758            }
2759            Err(err) => Err(err),
2760        }
2761    }
2762
2763    /// Get the detailed configuration associated with
2764    /// a Synthetic Mobile test.
2765    pub async fn get_mobile_test_with_http_info(
2766        &self,
2767        public_id: String,
2768    ) -> Result<
2769        datadog::ResponseContent<crate::datadogV1::model::SyntheticsMobileTest>,
2770        datadog::Error<GetMobileTestError>,
2771    > {
2772        let local_configuration = &self.config;
2773        let operation_id = "v1.get_mobile_test";
2774
2775        let local_client = &self.client;
2776
2777        let local_uri_str = format!(
2778            "{}/api/v1/synthetics/tests/mobile/{public_id}",
2779            local_configuration.get_operation_host(operation_id),
2780            public_id = datadog::urlencode(public_id)
2781        );
2782        let mut local_req_builder =
2783            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2784
2785        // build headers
2786        let mut headers = HeaderMap::new();
2787        headers.insert("Accept", HeaderValue::from_static("application/json"));
2788
2789        // build user agent
2790        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2791            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2792            Err(e) => {
2793                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2794                headers.insert(
2795                    reqwest::header::USER_AGENT,
2796                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2797                )
2798            }
2799        };
2800
2801        // build auth
2802        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2803            headers.insert(
2804                "DD-API-KEY",
2805                HeaderValue::from_str(local_key.key.as_str())
2806                    .expect("failed to parse DD-API-KEY header"),
2807            );
2808        };
2809        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2810            headers.insert(
2811                "DD-APPLICATION-KEY",
2812                HeaderValue::from_str(local_key.key.as_str())
2813                    .expect("failed to parse DD-APPLICATION-KEY header"),
2814            );
2815        };
2816
2817        local_req_builder = local_req_builder.headers(headers);
2818        let local_req = local_req_builder.build()?;
2819        log::debug!("request content: {:?}", local_req.body());
2820        let local_resp = local_client.execute(local_req).await?;
2821
2822        let local_status = local_resp.status();
2823        let local_content = local_resp.text().await?;
2824        log::debug!("response content: {}", local_content);
2825
2826        if !local_status.is_client_error() && !local_status.is_server_error() {
2827            match serde_json::from_str::<crate::datadogV1::model::SyntheticsMobileTest>(
2828                &local_content,
2829            ) {
2830                Ok(e) => {
2831                    return Ok(datadog::ResponseContent {
2832                        status: local_status,
2833                        content: local_content,
2834                        entity: Some(e),
2835                    })
2836                }
2837                Err(e) => return Err(datadog::Error::Serde(e)),
2838            };
2839        } else {
2840            let local_entity: Option<GetMobileTestError> =
2841                serde_json::from_str(&local_content).ok();
2842            let local_error = datadog::ResponseContent {
2843                status: local_status,
2844                content: local_content,
2845                entity: local_entity,
2846            };
2847            Err(datadog::Error::ResponseError(local_error))
2848        }
2849    }
2850
2851    /// Get a Synthetic private location.
2852    pub async fn get_private_location(
2853        &self,
2854        location_id: String,
2855    ) -> Result<
2856        crate::datadogV1::model::SyntheticsPrivateLocation,
2857        datadog::Error<GetPrivateLocationError>,
2858    > {
2859        match self.get_private_location_with_http_info(location_id).await {
2860            Ok(response_content) => {
2861                if let Some(e) = response_content.entity {
2862                    Ok(e)
2863                } else {
2864                    Err(datadog::Error::Serde(serde::de::Error::custom(
2865                        "response content was None",
2866                    )))
2867                }
2868            }
2869            Err(err) => Err(err),
2870        }
2871    }
2872
2873    /// Get a Synthetic private location.
2874    pub async fn get_private_location_with_http_info(
2875        &self,
2876        location_id: String,
2877    ) -> Result<
2878        datadog::ResponseContent<crate::datadogV1::model::SyntheticsPrivateLocation>,
2879        datadog::Error<GetPrivateLocationError>,
2880    > {
2881        let local_configuration = &self.config;
2882        let operation_id = "v1.get_private_location";
2883
2884        let local_client = &self.client;
2885
2886        let local_uri_str = format!(
2887            "{}/api/v1/synthetics/private-locations/{location_id}",
2888            local_configuration.get_operation_host(operation_id),
2889            location_id = datadog::urlencode(location_id)
2890        );
2891        let mut local_req_builder =
2892            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2893
2894        // build headers
2895        let mut headers = HeaderMap::new();
2896        headers.insert("Accept", HeaderValue::from_static("application/json"));
2897
2898        // build user agent
2899        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2900            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2901            Err(e) => {
2902                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2903                headers.insert(
2904                    reqwest::header::USER_AGENT,
2905                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2906                )
2907            }
2908        };
2909
2910        // build auth
2911        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2912            headers.insert(
2913                "DD-API-KEY",
2914                HeaderValue::from_str(local_key.key.as_str())
2915                    .expect("failed to parse DD-API-KEY header"),
2916            );
2917        };
2918        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2919            headers.insert(
2920                "DD-APPLICATION-KEY",
2921                HeaderValue::from_str(local_key.key.as_str())
2922                    .expect("failed to parse DD-APPLICATION-KEY header"),
2923            );
2924        };
2925
2926        local_req_builder = local_req_builder.headers(headers);
2927        let local_req = local_req_builder.build()?;
2928        log::debug!("request content: {:?}", local_req.body());
2929        let local_resp = local_client.execute(local_req).await?;
2930
2931        let local_status = local_resp.status();
2932        let local_content = local_resp.text().await?;
2933        log::debug!("response content: {}", local_content);
2934
2935        if !local_status.is_client_error() && !local_status.is_server_error() {
2936            match serde_json::from_str::<crate::datadogV1::model::SyntheticsPrivateLocation>(
2937                &local_content,
2938            ) {
2939                Ok(e) => {
2940                    return Ok(datadog::ResponseContent {
2941                        status: local_status,
2942                        content: local_content,
2943                        entity: Some(e),
2944                    })
2945                }
2946                Err(e) => return Err(datadog::Error::Serde(e)),
2947            };
2948        } else {
2949            let local_entity: Option<GetPrivateLocationError> =
2950                serde_json::from_str(&local_content).ok();
2951            let local_error = datadog::ResponseContent {
2952                status: local_status,
2953                content: local_content,
2954                entity: local_entity,
2955            };
2956            Err(datadog::Error::ResponseError(local_error))
2957        }
2958    }
2959
2960    /// Get a batch's updated details.
2961    pub async fn get_synthetics_ci_batch(
2962        &self,
2963        batch_id: String,
2964    ) -> Result<
2965        crate::datadogV1::model::SyntheticsBatchDetails,
2966        datadog::Error<GetSyntheticsCIBatchError>,
2967    > {
2968        match self.get_synthetics_ci_batch_with_http_info(batch_id).await {
2969            Ok(response_content) => {
2970                if let Some(e) = response_content.entity {
2971                    Ok(e)
2972                } else {
2973                    Err(datadog::Error::Serde(serde::de::Error::custom(
2974                        "response content was None",
2975                    )))
2976                }
2977            }
2978            Err(err) => Err(err),
2979        }
2980    }
2981
2982    /// Get a batch's updated details.
2983    pub async fn get_synthetics_ci_batch_with_http_info(
2984        &self,
2985        batch_id: String,
2986    ) -> Result<
2987        datadog::ResponseContent<crate::datadogV1::model::SyntheticsBatchDetails>,
2988        datadog::Error<GetSyntheticsCIBatchError>,
2989    > {
2990        let local_configuration = &self.config;
2991        let operation_id = "v1.get_synthetics_ci_batch";
2992
2993        let local_client = &self.client;
2994
2995        let local_uri_str = format!(
2996            "{}/api/v1/synthetics/ci/batch/{batch_id}",
2997            local_configuration.get_operation_host(operation_id),
2998            batch_id = datadog::urlencode(batch_id)
2999        );
3000        let mut local_req_builder =
3001            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3002
3003        // build headers
3004        let mut headers = HeaderMap::new();
3005        headers.insert("Accept", HeaderValue::from_static("application/json"));
3006
3007        // build user agent
3008        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3009            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3010            Err(e) => {
3011                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3012                headers.insert(
3013                    reqwest::header::USER_AGENT,
3014                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3015                )
3016            }
3017        };
3018
3019        // build auth
3020        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3021            headers.insert(
3022                "DD-API-KEY",
3023                HeaderValue::from_str(local_key.key.as_str())
3024                    .expect("failed to parse DD-API-KEY header"),
3025            );
3026        };
3027        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3028            headers.insert(
3029                "DD-APPLICATION-KEY",
3030                HeaderValue::from_str(local_key.key.as_str())
3031                    .expect("failed to parse DD-APPLICATION-KEY header"),
3032            );
3033        };
3034
3035        local_req_builder = local_req_builder.headers(headers);
3036        let local_req = local_req_builder.build()?;
3037        log::debug!("request content: {:?}", local_req.body());
3038        let local_resp = local_client.execute(local_req).await?;
3039
3040        let local_status = local_resp.status();
3041        let local_content = local_resp.text().await?;
3042        log::debug!("response content: {}", local_content);
3043
3044        if !local_status.is_client_error() && !local_status.is_server_error() {
3045            match serde_json::from_str::<crate::datadogV1::model::SyntheticsBatchDetails>(
3046                &local_content,
3047            ) {
3048                Ok(e) => {
3049                    return Ok(datadog::ResponseContent {
3050                        status: local_status,
3051                        content: local_content,
3052                        entity: Some(e),
3053                    })
3054                }
3055                Err(e) => return Err(datadog::Error::Serde(e)),
3056            };
3057        } else {
3058            let local_entity: Option<GetSyntheticsCIBatchError> =
3059                serde_json::from_str(&local_content).ok();
3060            let local_error = datadog::ResponseContent {
3061                status: local_status,
3062                content: local_content,
3063                entity: local_entity,
3064            };
3065            Err(datadog::Error::ResponseError(local_error))
3066        }
3067    }
3068
3069    /// Get the default locations settings.
3070    pub async fn get_synthetics_default_locations(
3071        &self,
3072    ) -> Result<Vec<String>, datadog::Error<GetSyntheticsDefaultLocationsError>> {
3073        match self.get_synthetics_default_locations_with_http_info().await {
3074            Ok(response_content) => {
3075                if let Some(e) = response_content.entity {
3076                    Ok(e)
3077                } else {
3078                    Err(datadog::Error::Serde(serde::de::Error::custom(
3079                        "response content was None",
3080                    )))
3081                }
3082            }
3083            Err(err) => Err(err),
3084        }
3085    }
3086
3087    /// Get the default locations settings.
3088    pub async fn get_synthetics_default_locations_with_http_info(
3089        &self,
3090    ) -> Result<
3091        datadog::ResponseContent<Vec<String>>,
3092        datadog::Error<GetSyntheticsDefaultLocationsError>,
3093    > {
3094        let local_configuration = &self.config;
3095        let operation_id = "v1.get_synthetics_default_locations";
3096
3097        let local_client = &self.client;
3098
3099        let local_uri_str = format!(
3100            "{}/api/v1/synthetics/settings/default_locations",
3101            local_configuration.get_operation_host(operation_id)
3102        );
3103        let mut local_req_builder =
3104            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3105
3106        // build headers
3107        let mut headers = HeaderMap::new();
3108        headers.insert("Accept", HeaderValue::from_static("application/json"));
3109
3110        // build user agent
3111        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3112            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3113            Err(e) => {
3114                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3115                headers.insert(
3116                    reqwest::header::USER_AGENT,
3117                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3118                )
3119            }
3120        };
3121
3122        // build auth
3123        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3124            headers.insert(
3125                "DD-API-KEY",
3126                HeaderValue::from_str(local_key.key.as_str())
3127                    .expect("failed to parse DD-API-KEY header"),
3128            );
3129        };
3130        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3131            headers.insert(
3132                "DD-APPLICATION-KEY",
3133                HeaderValue::from_str(local_key.key.as_str())
3134                    .expect("failed to parse DD-APPLICATION-KEY header"),
3135            );
3136        };
3137
3138        local_req_builder = local_req_builder.headers(headers);
3139        let local_req = local_req_builder.build()?;
3140        log::debug!("request content: {:?}", local_req.body());
3141        let local_resp = local_client.execute(local_req).await?;
3142
3143        let local_status = local_resp.status();
3144        let local_content = local_resp.text().await?;
3145        log::debug!("response content: {}", local_content);
3146
3147        if !local_status.is_client_error() && !local_status.is_server_error() {
3148            match serde_json::from_str::<Vec<String>>(&local_content) {
3149                Ok(e) => {
3150                    return Ok(datadog::ResponseContent {
3151                        status: local_status,
3152                        content: local_content,
3153                        entity: Some(e),
3154                    })
3155                }
3156                Err(e) => return Err(datadog::Error::Serde(e)),
3157            };
3158        } else {
3159            let local_entity: Option<GetSyntheticsDefaultLocationsError> =
3160                serde_json::from_str(&local_content).ok();
3161            let local_error = datadog::ResponseContent {
3162                status: local_status,
3163                content: local_content,
3164                entity: local_entity,
3165            };
3166            Err(datadog::Error::ResponseError(local_error))
3167        }
3168    }
3169
3170    /// Get the detailed configuration associated with a Synthetic test.
3171    pub async fn get_test(
3172        &self,
3173        public_id: String,
3174    ) -> Result<crate::datadogV1::model::SyntheticsTestDetails, datadog::Error<GetTestError>> {
3175        match self.get_test_with_http_info(public_id).await {
3176            Ok(response_content) => {
3177                if let Some(e) = response_content.entity {
3178                    Ok(e)
3179                } else {
3180                    Err(datadog::Error::Serde(serde::de::Error::custom(
3181                        "response content was None",
3182                    )))
3183                }
3184            }
3185            Err(err) => Err(err),
3186        }
3187    }
3188
3189    /// Get the detailed configuration associated with a Synthetic test.
3190    pub async fn get_test_with_http_info(
3191        &self,
3192        public_id: String,
3193    ) -> Result<
3194        datadog::ResponseContent<crate::datadogV1::model::SyntheticsTestDetails>,
3195        datadog::Error<GetTestError>,
3196    > {
3197        let local_configuration = &self.config;
3198        let operation_id = "v1.get_test";
3199
3200        let local_client = &self.client;
3201
3202        let local_uri_str = format!(
3203            "{}/api/v1/synthetics/tests/{public_id}",
3204            local_configuration.get_operation_host(operation_id),
3205            public_id = datadog::urlencode(public_id)
3206        );
3207        let mut local_req_builder =
3208            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3209
3210        // build headers
3211        let mut headers = HeaderMap::new();
3212        headers.insert("Accept", HeaderValue::from_static("application/json"));
3213
3214        // build user agent
3215        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3216            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3217            Err(e) => {
3218                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3219                headers.insert(
3220                    reqwest::header::USER_AGENT,
3221                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3222                )
3223            }
3224        };
3225
3226        // build auth
3227        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3228            headers.insert(
3229                "DD-API-KEY",
3230                HeaderValue::from_str(local_key.key.as_str())
3231                    .expect("failed to parse DD-API-KEY header"),
3232            );
3233        };
3234        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3235            headers.insert(
3236                "DD-APPLICATION-KEY",
3237                HeaderValue::from_str(local_key.key.as_str())
3238                    .expect("failed to parse DD-APPLICATION-KEY header"),
3239            );
3240        };
3241
3242        local_req_builder = local_req_builder.headers(headers);
3243        let local_req = local_req_builder.build()?;
3244        log::debug!("request content: {:?}", local_req.body());
3245        let local_resp = local_client.execute(local_req).await?;
3246
3247        let local_status = local_resp.status();
3248        let local_content = local_resp.text().await?;
3249        log::debug!("response content: {}", local_content);
3250
3251        if !local_status.is_client_error() && !local_status.is_server_error() {
3252            match serde_json::from_str::<crate::datadogV1::model::SyntheticsTestDetails>(
3253                &local_content,
3254            ) {
3255                Ok(e) => {
3256                    return Ok(datadog::ResponseContent {
3257                        status: local_status,
3258                        content: local_content,
3259                        entity: Some(e),
3260                    })
3261                }
3262                Err(e) => return Err(datadog::Error::Serde(e)),
3263            };
3264        } else {
3265            let local_entity: Option<GetTestError> = serde_json::from_str(&local_content).ok();
3266            let local_error = datadog::ResponseContent {
3267                status: local_status,
3268                content: local_content,
3269                entity: local_entity,
3270            };
3271            Err(datadog::Error::ResponseError(local_error))
3272        }
3273    }
3274
3275    /// Get the list of all Synthetic global variables.
3276    pub async fn list_global_variables(
3277        &self,
3278    ) -> Result<
3279        crate::datadogV1::model::SyntheticsListGlobalVariablesResponse,
3280        datadog::Error<ListGlobalVariablesError>,
3281    > {
3282        match self.list_global_variables_with_http_info().await {
3283            Ok(response_content) => {
3284                if let Some(e) = response_content.entity {
3285                    Ok(e)
3286                } else {
3287                    Err(datadog::Error::Serde(serde::de::Error::custom(
3288                        "response content was None",
3289                    )))
3290                }
3291            }
3292            Err(err) => Err(err),
3293        }
3294    }
3295
3296    /// Get the list of all Synthetic global variables.
3297    pub async fn list_global_variables_with_http_info(
3298        &self,
3299    ) -> Result<
3300        datadog::ResponseContent<crate::datadogV1::model::SyntheticsListGlobalVariablesResponse>,
3301        datadog::Error<ListGlobalVariablesError>,
3302    > {
3303        let local_configuration = &self.config;
3304        let operation_id = "v1.list_global_variables";
3305
3306        let local_client = &self.client;
3307
3308        let local_uri_str = format!(
3309            "{}/api/v1/synthetics/variables",
3310            local_configuration.get_operation_host(operation_id)
3311        );
3312        let mut local_req_builder =
3313            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3314
3315        // build headers
3316        let mut headers = HeaderMap::new();
3317        headers.insert("Accept", HeaderValue::from_static("application/json"));
3318
3319        // build user agent
3320        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3321            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3322            Err(e) => {
3323                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3324                headers.insert(
3325                    reqwest::header::USER_AGENT,
3326                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3327                )
3328            }
3329        };
3330
3331        // build auth
3332        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3333            headers.insert(
3334                "DD-API-KEY",
3335                HeaderValue::from_str(local_key.key.as_str())
3336                    .expect("failed to parse DD-API-KEY header"),
3337            );
3338        };
3339        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3340            headers.insert(
3341                "DD-APPLICATION-KEY",
3342                HeaderValue::from_str(local_key.key.as_str())
3343                    .expect("failed to parse DD-APPLICATION-KEY header"),
3344            );
3345        };
3346
3347        local_req_builder = local_req_builder.headers(headers);
3348        let local_req = local_req_builder.build()?;
3349        log::debug!("request content: {:?}", local_req.body());
3350        let local_resp = local_client.execute(local_req).await?;
3351
3352        let local_status = local_resp.status();
3353        let local_content = local_resp.text().await?;
3354        log::debug!("response content: {}", local_content);
3355
3356        if !local_status.is_client_error() && !local_status.is_server_error() {
3357            match serde_json::from_str::<
3358                crate::datadogV1::model::SyntheticsListGlobalVariablesResponse,
3359            >(&local_content)
3360            {
3361                Ok(e) => {
3362                    return Ok(datadog::ResponseContent {
3363                        status: local_status,
3364                        content: local_content,
3365                        entity: Some(e),
3366                    })
3367                }
3368                Err(e) => return Err(datadog::Error::Serde(e)),
3369            };
3370        } else {
3371            let local_entity: Option<ListGlobalVariablesError> =
3372                serde_json::from_str(&local_content).ok();
3373            let local_error = datadog::ResponseContent {
3374                status: local_status,
3375                content: local_content,
3376                entity: local_entity,
3377            };
3378            Err(datadog::Error::ResponseError(local_error))
3379        }
3380    }
3381
3382    /// Get the list of public and private locations available for Synthetic
3383    /// tests. No arguments required.
3384    pub async fn list_locations(
3385        &self,
3386    ) -> Result<crate::datadogV1::model::SyntheticsLocations, datadog::Error<ListLocationsError>>
3387    {
3388        match self.list_locations_with_http_info().await {
3389            Ok(response_content) => {
3390                if let Some(e) = response_content.entity {
3391                    Ok(e)
3392                } else {
3393                    Err(datadog::Error::Serde(serde::de::Error::custom(
3394                        "response content was None",
3395                    )))
3396                }
3397            }
3398            Err(err) => Err(err),
3399        }
3400    }
3401
3402    /// Get the list of public and private locations available for Synthetic
3403    /// tests. No arguments required.
3404    pub async fn list_locations_with_http_info(
3405        &self,
3406    ) -> Result<
3407        datadog::ResponseContent<crate::datadogV1::model::SyntheticsLocations>,
3408        datadog::Error<ListLocationsError>,
3409    > {
3410        let local_configuration = &self.config;
3411        let operation_id = "v1.list_locations";
3412
3413        let local_client = &self.client;
3414
3415        let local_uri_str = format!(
3416            "{}/api/v1/synthetics/locations",
3417            local_configuration.get_operation_host(operation_id)
3418        );
3419        let mut local_req_builder =
3420            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3421
3422        // build headers
3423        let mut headers = HeaderMap::new();
3424        headers.insert("Accept", HeaderValue::from_static("application/json"));
3425
3426        // build user agent
3427        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3428            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3429            Err(e) => {
3430                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3431                headers.insert(
3432                    reqwest::header::USER_AGENT,
3433                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3434                )
3435            }
3436        };
3437
3438        // build auth
3439        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3440            headers.insert(
3441                "DD-API-KEY",
3442                HeaderValue::from_str(local_key.key.as_str())
3443                    .expect("failed to parse DD-API-KEY header"),
3444            );
3445        };
3446        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3447            headers.insert(
3448                "DD-APPLICATION-KEY",
3449                HeaderValue::from_str(local_key.key.as_str())
3450                    .expect("failed to parse DD-APPLICATION-KEY header"),
3451            );
3452        };
3453
3454        local_req_builder = local_req_builder.headers(headers);
3455        let local_req = local_req_builder.build()?;
3456        log::debug!("request content: {:?}", local_req.body());
3457        let local_resp = local_client.execute(local_req).await?;
3458
3459        let local_status = local_resp.status();
3460        let local_content = local_resp.text().await?;
3461        log::debug!("response content: {}", local_content);
3462
3463        if !local_status.is_client_error() && !local_status.is_server_error() {
3464            match serde_json::from_str::<crate::datadogV1::model::SyntheticsLocations>(
3465                &local_content,
3466            ) {
3467                Ok(e) => {
3468                    return Ok(datadog::ResponseContent {
3469                        status: local_status,
3470                        content: local_content,
3471                        entity: Some(e),
3472                    })
3473                }
3474                Err(e) => return Err(datadog::Error::Serde(e)),
3475            };
3476        } else {
3477            let local_entity: Option<ListLocationsError> =
3478                serde_json::from_str(&local_content).ok();
3479            let local_error = datadog::ResponseContent {
3480                status: local_status,
3481                content: local_content,
3482                entity: local_entity,
3483            };
3484            Err(datadog::Error::ResponseError(local_error))
3485        }
3486    }
3487
3488    /// Get the list of all Synthetic tests.
3489    pub async fn list_tests(
3490        &self,
3491        params: ListTestsOptionalParams,
3492    ) -> Result<crate::datadogV1::model::SyntheticsListTestsResponse, datadog::Error<ListTestsError>>
3493    {
3494        match self.list_tests_with_http_info(params).await {
3495            Ok(response_content) => {
3496                if let Some(e) = response_content.entity {
3497                    Ok(e)
3498                } else {
3499                    Err(datadog::Error::Serde(serde::de::Error::custom(
3500                        "response content was None",
3501                    )))
3502                }
3503            }
3504            Err(err) => Err(err),
3505        }
3506    }
3507
3508    pub fn list_tests_with_pagination(
3509        &self,
3510        mut params: ListTestsOptionalParams,
3511    ) -> impl Stream<
3512        Item = Result<
3513            crate::datadogV1::model::SyntheticsTestDetails,
3514            datadog::Error<ListTestsError>,
3515        >,
3516    > + '_ {
3517        try_stream! {
3518            let mut page_size: i64 = 100;
3519            if params.page_size.is_none() {
3520                params.page_size = Some(page_size);
3521            } else {
3522                page_size = params.page_size.unwrap().clone();
3523            }
3524            if params.page_number.is_none() {
3525                params.page_number = Some(0);
3526            }
3527            loop {
3528                let resp = self.list_tests(params.clone()).await?;
3529                let Some(tests) = resp.tests else { break };
3530
3531                let r = tests;
3532                let count = r.len();
3533                for team in r {
3534                    yield team;
3535                }
3536
3537                if count < page_size as usize {
3538                    break;
3539                }
3540                params.page_number = Some(params.page_number.unwrap() + 1);
3541            }
3542        }
3543    }
3544
3545    /// Get the list of all Synthetic tests.
3546    pub async fn list_tests_with_http_info(
3547        &self,
3548        params: ListTestsOptionalParams,
3549    ) -> Result<
3550        datadog::ResponseContent<crate::datadogV1::model::SyntheticsListTestsResponse>,
3551        datadog::Error<ListTestsError>,
3552    > {
3553        let local_configuration = &self.config;
3554        let operation_id = "v1.list_tests";
3555
3556        // unbox and build optional parameters
3557        let page_size = params.page_size;
3558        let page_number = params.page_number;
3559
3560        let local_client = &self.client;
3561
3562        let local_uri_str = format!(
3563            "{}/api/v1/synthetics/tests",
3564            local_configuration.get_operation_host(operation_id)
3565        );
3566        let mut local_req_builder =
3567            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3568
3569        if let Some(ref local_query_param) = page_size {
3570            local_req_builder =
3571                local_req_builder.query(&[("page_size", &local_query_param.to_string())]);
3572        };
3573        if let Some(ref local_query_param) = page_number {
3574            local_req_builder =
3575                local_req_builder.query(&[("page_number", &local_query_param.to_string())]);
3576        };
3577
3578        // build headers
3579        let mut headers = HeaderMap::new();
3580        headers.insert("Accept", HeaderValue::from_static("application/json"));
3581
3582        // build user agent
3583        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3584            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3585            Err(e) => {
3586                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3587                headers.insert(
3588                    reqwest::header::USER_AGENT,
3589                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3590                )
3591            }
3592        };
3593
3594        // build auth
3595        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3596            headers.insert(
3597                "DD-API-KEY",
3598                HeaderValue::from_str(local_key.key.as_str())
3599                    .expect("failed to parse DD-API-KEY header"),
3600            );
3601        };
3602        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3603            headers.insert(
3604                "DD-APPLICATION-KEY",
3605                HeaderValue::from_str(local_key.key.as_str())
3606                    .expect("failed to parse DD-APPLICATION-KEY header"),
3607            );
3608        };
3609
3610        local_req_builder = local_req_builder.headers(headers);
3611        let local_req = local_req_builder.build()?;
3612        log::debug!("request content: {:?}", local_req.body());
3613        let local_resp = local_client.execute(local_req).await?;
3614
3615        let local_status = local_resp.status();
3616        let local_content = local_resp.text().await?;
3617        log::debug!("response content: {}", local_content);
3618
3619        if !local_status.is_client_error() && !local_status.is_server_error() {
3620            match serde_json::from_str::<crate::datadogV1::model::SyntheticsListTestsResponse>(
3621                &local_content,
3622            ) {
3623                Ok(e) => {
3624                    return Ok(datadog::ResponseContent {
3625                        status: local_status,
3626                        content: local_content,
3627                        entity: Some(e),
3628                    })
3629                }
3630                Err(e) => return Err(datadog::Error::Serde(e)),
3631            };
3632        } else {
3633            let local_entity: Option<ListTestsError> = serde_json::from_str(&local_content).ok();
3634            let local_error = datadog::ResponseContent {
3635                status: local_status,
3636                content: local_content,
3637                entity: local_entity,
3638            };
3639            Err(datadog::Error::ResponseError(local_error))
3640        }
3641    }
3642
3643    /// Patch the configuration of a Synthetic test with partial data.
3644    pub async fn patch_test(
3645        &self,
3646        public_id: String,
3647        body: crate::datadogV1::model::SyntheticsPatchTestBody,
3648    ) -> Result<crate::datadogV1::model::SyntheticsTestDetails, datadog::Error<PatchTestError>>
3649    {
3650        match self.patch_test_with_http_info(public_id, body).await {
3651            Ok(response_content) => {
3652                if let Some(e) = response_content.entity {
3653                    Ok(e)
3654                } else {
3655                    Err(datadog::Error::Serde(serde::de::Error::custom(
3656                        "response content was None",
3657                    )))
3658                }
3659            }
3660            Err(err) => Err(err),
3661        }
3662    }
3663
3664    /// Patch the configuration of a Synthetic test with partial data.
3665    pub async fn patch_test_with_http_info(
3666        &self,
3667        public_id: String,
3668        body: crate::datadogV1::model::SyntheticsPatchTestBody,
3669    ) -> Result<
3670        datadog::ResponseContent<crate::datadogV1::model::SyntheticsTestDetails>,
3671        datadog::Error<PatchTestError>,
3672    > {
3673        let local_configuration = &self.config;
3674        let operation_id = "v1.patch_test";
3675
3676        let local_client = &self.client;
3677
3678        let local_uri_str = format!(
3679            "{}/api/v1/synthetics/tests/{public_id}",
3680            local_configuration.get_operation_host(operation_id),
3681            public_id = datadog::urlencode(public_id)
3682        );
3683        let mut local_req_builder =
3684            local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
3685
3686        // build headers
3687        let mut headers = HeaderMap::new();
3688        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
3689        headers.insert("Accept", HeaderValue::from_static("application/json"));
3690
3691        // build user agent
3692        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3693            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3694            Err(e) => {
3695                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3696                headers.insert(
3697                    reqwest::header::USER_AGENT,
3698                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3699                )
3700            }
3701        };
3702
3703        // build auth
3704        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3705            headers.insert(
3706                "DD-API-KEY",
3707                HeaderValue::from_str(local_key.key.as_str())
3708                    .expect("failed to parse DD-API-KEY header"),
3709            );
3710        };
3711        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3712            headers.insert(
3713                "DD-APPLICATION-KEY",
3714                HeaderValue::from_str(local_key.key.as_str())
3715                    .expect("failed to parse DD-APPLICATION-KEY header"),
3716            );
3717        };
3718
3719        // build body parameters
3720        let output = Vec::new();
3721        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
3722        if body.serialize(&mut ser).is_ok() {
3723            if let Some(content_encoding) = headers.get("Content-Encoding") {
3724                match content_encoding.to_str().unwrap_or_default() {
3725                    "gzip" => {
3726                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
3727                        let _ = enc.write_all(ser.into_inner().as_slice());
3728                        match enc.finish() {
3729                            Ok(buf) => {
3730                                local_req_builder = local_req_builder.body(buf);
3731                            }
3732                            Err(e) => return Err(datadog::Error::Io(e)),
3733                        }
3734                    }
3735                    "deflate" => {
3736                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
3737                        let _ = enc.write_all(ser.into_inner().as_slice());
3738                        match enc.finish() {
3739                            Ok(buf) => {
3740                                local_req_builder = local_req_builder.body(buf);
3741                            }
3742                            Err(e) => return Err(datadog::Error::Io(e)),
3743                        }
3744                    }
3745                    "zstd1" => {
3746                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
3747                        let _ = enc.write_all(ser.into_inner().as_slice());
3748                        match enc.finish() {
3749                            Ok(buf) => {
3750                                local_req_builder = local_req_builder.body(buf);
3751                            }
3752                            Err(e) => return Err(datadog::Error::Io(e)),
3753                        }
3754                    }
3755                    _ => {
3756                        local_req_builder = local_req_builder.body(ser.into_inner());
3757                    }
3758                }
3759            } else {
3760                local_req_builder = local_req_builder.body(ser.into_inner());
3761            }
3762        }
3763
3764        local_req_builder = local_req_builder.headers(headers);
3765        let local_req = local_req_builder.build()?;
3766        log::debug!("request content: {:?}", local_req.body());
3767        let local_resp = local_client.execute(local_req).await?;
3768
3769        let local_status = local_resp.status();
3770        let local_content = local_resp.text().await?;
3771        log::debug!("response content: {}", local_content);
3772
3773        if !local_status.is_client_error() && !local_status.is_server_error() {
3774            match serde_json::from_str::<crate::datadogV1::model::SyntheticsTestDetails>(
3775                &local_content,
3776            ) {
3777                Ok(e) => {
3778                    return Ok(datadog::ResponseContent {
3779                        status: local_status,
3780                        content: local_content,
3781                        entity: Some(e),
3782                    })
3783                }
3784                Err(e) => return Err(datadog::Error::Serde(e)),
3785            };
3786        } else {
3787            let local_entity: Option<PatchTestError> = serde_json::from_str(&local_content).ok();
3788            let local_error = datadog::ResponseContent {
3789                status: local_status,
3790                content: local_content,
3791                entity: local_entity,
3792            };
3793            Err(datadog::Error::ResponseError(local_error))
3794        }
3795    }
3796
3797    /// Search for Synthetic tests.
3798    pub async fn search_tests(
3799        &self,
3800        params: SearchTestsOptionalParams,
3801    ) -> Result<
3802        crate::datadogV1::model::SyntheticsListTestsResponse,
3803        datadog::Error<SearchTestsError>,
3804    > {
3805        match self.search_tests_with_http_info(params).await {
3806            Ok(response_content) => {
3807                if let Some(e) = response_content.entity {
3808                    Ok(e)
3809                } else {
3810                    Err(datadog::Error::Serde(serde::de::Error::custom(
3811                        "response content was None",
3812                    )))
3813                }
3814            }
3815            Err(err) => Err(err),
3816        }
3817    }
3818
3819    /// Search for Synthetic tests.
3820    pub async fn search_tests_with_http_info(
3821        &self,
3822        params: SearchTestsOptionalParams,
3823    ) -> Result<
3824        datadog::ResponseContent<crate::datadogV1::model::SyntheticsListTestsResponse>,
3825        datadog::Error<SearchTestsError>,
3826    > {
3827        let local_configuration = &self.config;
3828        let operation_id = "v1.search_tests";
3829
3830        // unbox and build optional parameters
3831        let text = params.text;
3832        let include_full_config = params.include_full_config;
3833        let facets_only = params.facets_only;
3834        let start = params.start;
3835        let count = params.count;
3836        let sort = params.sort;
3837
3838        let local_client = &self.client;
3839
3840        let local_uri_str = format!(
3841            "{}/api/v1/synthetics/tests/search",
3842            local_configuration.get_operation_host(operation_id)
3843        );
3844        let mut local_req_builder =
3845            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3846
3847        if let Some(ref local_query_param) = text {
3848            local_req_builder =
3849                local_req_builder.query(&[("text", &local_query_param.to_string())]);
3850        };
3851        if let Some(ref local_query_param) = include_full_config {
3852            local_req_builder =
3853                local_req_builder.query(&[("include_full_config", &local_query_param.to_string())]);
3854        };
3855        if let Some(ref local_query_param) = facets_only {
3856            local_req_builder =
3857                local_req_builder.query(&[("facets_only", &local_query_param.to_string())]);
3858        };
3859        if let Some(ref local_query_param) = start {
3860            local_req_builder =
3861                local_req_builder.query(&[("start", &local_query_param.to_string())]);
3862        };
3863        if let Some(ref local_query_param) = count {
3864            local_req_builder =
3865                local_req_builder.query(&[("count", &local_query_param.to_string())]);
3866        };
3867        if let Some(ref local_query_param) = sort {
3868            local_req_builder =
3869                local_req_builder.query(&[("sort", &local_query_param.to_string())]);
3870        };
3871
3872        // build headers
3873        let mut headers = HeaderMap::new();
3874        headers.insert("Accept", HeaderValue::from_static("application/json"));
3875
3876        // build user agent
3877        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3878            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3879            Err(e) => {
3880                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3881                headers.insert(
3882                    reqwest::header::USER_AGENT,
3883                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3884                )
3885            }
3886        };
3887
3888        // build auth
3889        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3890            headers.insert(
3891                "DD-API-KEY",
3892                HeaderValue::from_str(local_key.key.as_str())
3893                    .expect("failed to parse DD-API-KEY header"),
3894            );
3895        };
3896        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3897            headers.insert(
3898                "DD-APPLICATION-KEY",
3899                HeaderValue::from_str(local_key.key.as_str())
3900                    .expect("failed to parse DD-APPLICATION-KEY header"),
3901            );
3902        };
3903
3904        local_req_builder = local_req_builder.headers(headers);
3905        let local_req = local_req_builder.build()?;
3906        log::debug!("request content: {:?}", local_req.body());
3907        let local_resp = local_client.execute(local_req).await?;
3908
3909        let local_status = local_resp.status();
3910        let local_content = local_resp.text().await?;
3911        log::debug!("response content: {}", local_content);
3912
3913        if !local_status.is_client_error() && !local_status.is_server_error() {
3914            match serde_json::from_str::<crate::datadogV1::model::SyntheticsListTestsResponse>(
3915                &local_content,
3916            ) {
3917                Ok(e) => {
3918                    return Ok(datadog::ResponseContent {
3919                        status: local_status,
3920                        content: local_content,
3921                        entity: Some(e),
3922                    })
3923                }
3924                Err(e) => return Err(datadog::Error::Serde(e)),
3925            };
3926        } else {
3927            let local_entity: Option<SearchTestsError> = serde_json::from_str(&local_content).ok();
3928            let local_error = datadog::ResponseContent {
3929                status: local_status,
3930                content: local_content,
3931                entity: local_entity,
3932            };
3933            Err(datadog::Error::ResponseError(local_error))
3934        }
3935    }
3936
3937    /// Trigger a set of Synthetic tests for continuous integration.
3938    pub async fn trigger_ci_tests(
3939        &self,
3940        body: crate::datadogV1::model::SyntheticsCITestBody,
3941    ) -> Result<
3942        crate::datadogV1::model::SyntheticsTriggerCITestsResponse,
3943        datadog::Error<TriggerCITestsError>,
3944    > {
3945        match self.trigger_ci_tests_with_http_info(body).await {
3946            Ok(response_content) => {
3947                if let Some(e) = response_content.entity {
3948                    Ok(e)
3949                } else {
3950                    Err(datadog::Error::Serde(serde::de::Error::custom(
3951                        "response content was None",
3952                    )))
3953                }
3954            }
3955            Err(err) => Err(err),
3956        }
3957    }
3958
3959    /// Trigger a set of Synthetic tests for continuous integration.
3960    pub async fn trigger_ci_tests_with_http_info(
3961        &self,
3962        body: crate::datadogV1::model::SyntheticsCITestBody,
3963    ) -> Result<
3964        datadog::ResponseContent<crate::datadogV1::model::SyntheticsTriggerCITestsResponse>,
3965        datadog::Error<TriggerCITestsError>,
3966    > {
3967        let local_configuration = &self.config;
3968        let operation_id = "v1.trigger_ci_tests";
3969
3970        let local_client = &self.client;
3971
3972        let local_uri_str = format!(
3973            "{}/api/v1/synthetics/tests/trigger/ci",
3974            local_configuration.get_operation_host(operation_id)
3975        );
3976        let mut local_req_builder =
3977            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
3978
3979        // build headers
3980        let mut headers = HeaderMap::new();
3981        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
3982        headers.insert("Accept", HeaderValue::from_static("application/json"));
3983
3984        // build user agent
3985        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3986            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3987            Err(e) => {
3988                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3989                headers.insert(
3990                    reqwest::header::USER_AGENT,
3991                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3992                )
3993            }
3994        };
3995
3996        // build auth
3997        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3998            headers.insert(
3999                "DD-API-KEY",
4000                HeaderValue::from_str(local_key.key.as_str())
4001                    .expect("failed to parse DD-API-KEY header"),
4002            );
4003        };
4004        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4005            headers.insert(
4006                "DD-APPLICATION-KEY",
4007                HeaderValue::from_str(local_key.key.as_str())
4008                    .expect("failed to parse DD-APPLICATION-KEY header"),
4009            );
4010        };
4011
4012        // build body parameters
4013        let output = Vec::new();
4014        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
4015        if body.serialize(&mut ser).is_ok() {
4016            if let Some(content_encoding) = headers.get("Content-Encoding") {
4017                match content_encoding.to_str().unwrap_or_default() {
4018                    "gzip" => {
4019                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
4020                        let _ = enc.write_all(ser.into_inner().as_slice());
4021                        match enc.finish() {
4022                            Ok(buf) => {
4023                                local_req_builder = local_req_builder.body(buf);
4024                            }
4025                            Err(e) => return Err(datadog::Error::Io(e)),
4026                        }
4027                    }
4028                    "deflate" => {
4029                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
4030                        let _ = enc.write_all(ser.into_inner().as_slice());
4031                        match enc.finish() {
4032                            Ok(buf) => {
4033                                local_req_builder = local_req_builder.body(buf);
4034                            }
4035                            Err(e) => return Err(datadog::Error::Io(e)),
4036                        }
4037                    }
4038                    "zstd1" => {
4039                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
4040                        let _ = enc.write_all(ser.into_inner().as_slice());
4041                        match enc.finish() {
4042                            Ok(buf) => {
4043                                local_req_builder = local_req_builder.body(buf);
4044                            }
4045                            Err(e) => return Err(datadog::Error::Io(e)),
4046                        }
4047                    }
4048                    _ => {
4049                        local_req_builder = local_req_builder.body(ser.into_inner());
4050                    }
4051                }
4052            } else {
4053                local_req_builder = local_req_builder.body(ser.into_inner());
4054            }
4055        }
4056
4057        local_req_builder = local_req_builder.headers(headers);
4058        let local_req = local_req_builder.build()?;
4059        log::debug!("request content: {:?}", local_req.body());
4060        let local_resp = local_client.execute(local_req).await?;
4061
4062        let local_status = local_resp.status();
4063        let local_content = local_resp.text().await?;
4064        log::debug!("response content: {}", local_content);
4065
4066        if !local_status.is_client_error() && !local_status.is_server_error() {
4067            match serde_json::from_str::<crate::datadogV1::model::SyntheticsTriggerCITestsResponse>(
4068                &local_content,
4069            ) {
4070                Ok(e) => {
4071                    return Ok(datadog::ResponseContent {
4072                        status: local_status,
4073                        content: local_content,
4074                        entity: Some(e),
4075                    })
4076                }
4077                Err(e) => return Err(datadog::Error::Serde(e)),
4078            };
4079        } else {
4080            let local_entity: Option<TriggerCITestsError> =
4081                serde_json::from_str(&local_content).ok();
4082            let local_error = datadog::ResponseContent {
4083                status: local_status,
4084                content: local_content,
4085                entity: local_entity,
4086            };
4087            Err(datadog::Error::ResponseError(local_error))
4088        }
4089    }
4090
4091    /// Trigger a set of Synthetic tests.
4092    pub async fn trigger_tests(
4093        &self,
4094        body: crate::datadogV1::model::SyntheticsTriggerBody,
4095    ) -> Result<
4096        crate::datadogV1::model::SyntheticsTriggerCITestsResponse,
4097        datadog::Error<TriggerTestsError>,
4098    > {
4099        match self.trigger_tests_with_http_info(body).await {
4100            Ok(response_content) => {
4101                if let Some(e) = response_content.entity {
4102                    Ok(e)
4103                } else {
4104                    Err(datadog::Error::Serde(serde::de::Error::custom(
4105                        "response content was None",
4106                    )))
4107                }
4108            }
4109            Err(err) => Err(err),
4110        }
4111    }
4112
4113    /// Trigger a set of Synthetic tests.
4114    pub async fn trigger_tests_with_http_info(
4115        &self,
4116        body: crate::datadogV1::model::SyntheticsTriggerBody,
4117    ) -> Result<
4118        datadog::ResponseContent<crate::datadogV1::model::SyntheticsTriggerCITestsResponse>,
4119        datadog::Error<TriggerTestsError>,
4120    > {
4121        let local_configuration = &self.config;
4122        let operation_id = "v1.trigger_tests";
4123
4124        let local_client = &self.client;
4125
4126        let local_uri_str = format!(
4127            "{}/api/v1/synthetics/tests/trigger",
4128            local_configuration.get_operation_host(operation_id)
4129        );
4130        let mut local_req_builder =
4131            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
4132
4133        // build headers
4134        let mut headers = HeaderMap::new();
4135        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
4136        headers.insert("Accept", HeaderValue::from_static("application/json"));
4137
4138        // build user agent
4139        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4140            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4141            Err(e) => {
4142                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4143                headers.insert(
4144                    reqwest::header::USER_AGENT,
4145                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4146                )
4147            }
4148        };
4149
4150        // build auth
4151        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4152            headers.insert(
4153                "DD-API-KEY",
4154                HeaderValue::from_str(local_key.key.as_str())
4155                    .expect("failed to parse DD-API-KEY header"),
4156            );
4157        };
4158        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4159            headers.insert(
4160                "DD-APPLICATION-KEY",
4161                HeaderValue::from_str(local_key.key.as_str())
4162                    .expect("failed to parse DD-APPLICATION-KEY header"),
4163            );
4164        };
4165
4166        // build body parameters
4167        let output = Vec::new();
4168        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
4169        if body.serialize(&mut ser).is_ok() {
4170            if let Some(content_encoding) = headers.get("Content-Encoding") {
4171                match content_encoding.to_str().unwrap_or_default() {
4172                    "gzip" => {
4173                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
4174                        let _ = enc.write_all(ser.into_inner().as_slice());
4175                        match enc.finish() {
4176                            Ok(buf) => {
4177                                local_req_builder = local_req_builder.body(buf);
4178                            }
4179                            Err(e) => return Err(datadog::Error::Io(e)),
4180                        }
4181                    }
4182                    "deflate" => {
4183                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
4184                        let _ = enc.write_all(ser.into_inner().as_slice());
4185                        match enc.finish() {
4186                            Ok(buf) => {
4187                                local_req_builder = local_req_builder.body(buf);
4188                            }
4189                            Err(e) => return Err(datadog::Error::Io(e)),
4190                        }
4191                    }
4192                    "zstd1" => {
4193                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
4194                        let _ = enc.write_all(ser.into_inner().as_slice());
4195                        match enc.finish() {
4196                            Ok(buf) => {
4197                                local_req_builder = local_req_builder.body(buf);
4198                            }
4199                            Err(e) => return Err(datadog::Error::Io(e)),
4200                        }
4201                    }
4202                    _ => {
4203                        local_req_builder = local_req_builder.body(ser.into_inner());
4204                    }
4205                }
4206            } else {
4207                local_req_builder = local_req_builder.body(ser.into_inner());
4208            }
4209        }
4210
4211        local_req_builder = local_req_builder.headers(headers);
4212        let local_req = local_req_builder.build()?;
4213        log::debug!("request content: {:?}", local_req.body());
4214        let local_resp = local_client.execute(local_req).await?;
4215
4216        let local_status = local_resp.status();
4217        let local_content = local_resp.text().await?;
4218        log::debug!("response content: {}", local_content);
4219
4220        if !local_status.is_client_error() && !local_status.is_server_error() {
4221            match serde_json::from_str::<crate::datadogV1::model::SyntheticsTriggerCITestsResponse>(
4222                &local_content,
4223            ) {
4224                Ok(e) => {
4225                    return Ok(datadog::ResponseContent {
4226                        status: local_status,
4227                        content: local_content,
4228                        entity: Some(e),
4229                    })
4230                }
4231                Err(e) => return Err(datadog::Error::Serde(e)),
4232            };
4233        } else {
4234            let local_entity: Option<TriggerTestsError> = serde_json::from_str(&local_content).ok();
4235            let local_error = datadog::ResponseContent {
4236                status: local_status,
4237                content: local_content,
4238                entity: local_entity,
4239            };
4240            Err(datadog::Error::ResponseError(local_error))
4241        }
4242    }
4243
4244    /// Edit the configuration of a Synthetic API test.
4245    pub async fn update_api_test(
4246        &self,
4247        public_id: String,
4248        body: crate::datadogV1::model::SyntheticsAPITest,
4249    ) -> Result<crate::datadogV1::model::SyntheticsAPITest, datadog::Error<UpdateAPITestError>>
4250    {
4251        match self.update_api_test_with_http_info(public_id, body).await {
4252            Ok(response_content) => {
4253                if let Some(e) = response_content.entity {
4254                    Ok(e)
4255                } else {
4256                    Err(datadog::Error::Serde(serde::de::Error::custom(
4257                        "response content was None",
4258                    )))
4259                }
4260            }
4261            Err(err) => Err(err),
4262        }
4263    }
4264
4265    /// Edit the configuration of a Synthetic API test.
4266    pub async fn update_api_test_with_http_info(
4267        &self,
4268        public_id: String,
4269        body: crate::datadogV1::model::SyntheticsAPITest,
4270    ) -> Result<
4271        datadog::ResponseContent<crate::datadogV1::model::SyntheticsAPITest>,
4272        datadog::Error<UpdateAPITestError>,
4273    > {
4274        let local_configuration = &self.config;
4275        let operation_id = "v1.update_api_test";
4276
4277        let local_client = &self.client;
4278
4279        let local_uri_str = format!(
4280            "{}/api/v1/synthetics/tests/api/{public_id}",
4281            local_configuration.get_operation_host(operation_id),
4282            public_id = datadog::urlencode(public_id)
4283        );
4284        let mut local_req_builder =
4285            local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
4286
4287        // build headers
4288        let mut headers = HeaderMap::new();
4289        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
4290        headers.insert("Accept", HeaderValue::from_static("application/json"));
4291
4292        // build user agent
4293        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4294            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4295            Err(e) => {
4296                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4297                headers.insert(
4298                    reqwest::header::USER_AGENT,
4299                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4300                )
4301            }
4302        };
4303
4304        // build auth
4305        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4306            headers.insert(
4307                "DD-API-KEY",
4308                HeaderValue::from_str(local_key.key.as_str())
4309                    .expect("failed to parse DD-API-KEY header"),
4310            );
4311        };
4312        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4313            headers.insert(
4314                "DD-APPLICATION-KEY",
4315                HeaderValue::from_str(local_key.key.as_str())
4316                    .expect("failed to parse DD-APPLICATION-KEY header"),
4317            );
4318        };
4319
4320        // build body parameters
4321        let output = Vec::new();
4322        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
4323        if body.serialize(&mut ser).is_ok() {
4324            if let Some(content_encoding) = headers.get("Content-Encoding") {
4325                match content_encoding.to_str().unwrap_or_default() {
4326                    "gzip" => {
4327                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
4328                        let _ = enc.write_all(ser.into_inner().as_slice());
4329                        match enc.finish() {
4330                            Ok(buf) => {
4331                                local_req_builder = local_req_builder.body(buf);
4332                            }
4333                            Err(e) => return Err(datadog::Error::Io(e)),
4334                        }
4335                    }
4336                    "deflate" => {
4337                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
4338                        let _ = enc.write_all(ser.into_inner().as_slice());
4339                        match enc.finish() {
4340                            Ok(buf) => {
4341                                local_req_builder = local_req_builder.body(buf);
4342                            }
4343                            Err(e) => return Err(datadog::Error::Io(e)),
4344                        }
4345                    }
4346                    "zstd1" => {
4347                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
4348                        let _ = enc.write_all(ser.into_inner().as_slice());
4349                        match enc.finish() {
4350                            Ok(buf) => {
4351                                local_req_builder = local_req_builder.body(buf);
4352                            }
4353                            Err(e) => return Err(datadog::Error::Io(e)),
4354                        }
4355                    }
4356                    _ => {
4357                        local_req_builder = local_req_builder.body(ser.into_inner());
4358                    }
4359                }
4360            } else {
4361                local_req_builder = local_req_builder.body(ser.into_inner());
4362            }
4363        }
4364
4365        local_req_builder = local_req_builder.headers(headers);
4366        let local_req = local_req_builder.build()?;
4367        log::debug!("request content: {:?}", local_req.body());
4368        let local_resp = local_client.execute(local_req).await?;
4369
4370        let local_status = local_resp.status();
4371        let local_content = local_resp.text().await?;
4372        log::debug!("response content: {}", local_content);
4373
4374        if !local_status.is_client_error() && !local_status.is_server_error() {
4375            match serde_json::from_str::<crate::datadogV1::model::SyntheticsAPITest>(&local_content)
4376            {
4377                Ok(e) => {
4378                    return Ok(datadog::ResponseContent {
4379                        status: local_status,
4380                        content: local_content,
4381                        entity: Some(e),
4382                    })
4383                }
4384                Err(e) => return Err(datadog::Error::Serde(e)),
4385            };
4386        } else {
4387            let local_entity: Option<UpdateAPITestError> =
4388                serde_json::from_str(&local_content).ok();
4389            let local_error = datadog::ResponseContent {
4390                status: local_status,
4391                content: local_content,
4392                entity: local_entity,
4393            };
4394            Err(datadog::Error::ResponseError(local_error))
4395        }
4396    }
4397
4398    /// Edit the configuration of a Synthetic browser test.
4399    pub async fn update_browser_test(
4400        &self,
4401        public_id: String,
4402        body: crate::datadogV1::model::SyntheticsBrowserTest,
4403    ) -> Result<
4404        crate::datadogV1::model::SyntheticsBrowserTest,
4405        datadog::Error<UpdateBrowserTestError>,
4406    > {
4407        match self
4408            .update_browser_test_with_http_info(public_id, body)
4409            .await
4410        {
4411            Ok(response_content) => {
4412                if let Some(e) = response_content.entity {
4413                    Ok(e)
4414                } else {
4415                    Err(datadog::Error::Serde(serde::de::Error::custom(
4416                        "response content was None",
4417                    )))
4418                }
4419            }
4420            Err(err) => Err(err),
4421        }
4422    }
4423
4424    /// Edit the configuration of a Synthetic browser test.
4425    pub async fn update_browser_test_with_http_info(
4426        &self,
4427        public_id: String,
4428        body: crate::datadogV1::model::SyntheticsBrowserTest,
4429    ) -> Result<
4430        datadog::ResponseContent<crate::datadogV1::model::SyntheticsBrowserTest>,
4431        datadog::Error<UpdateBrowserTestError>,
4432    > {
4433        let local_configuration = &self.config;
4434        let operation_id = "v1.update_browser_test";
4435
4436        let local_client = &self.client;
4437
4438        let local_uri_str = format!(
4439            "{}/api/v1/synthetics/tests/browser/{public_id}",
4440            local_configuration.get_operation_host(operation_id),
4441            public_id = datadog::urlencode(public_id)
4442        );
4443        let mut local_req_builder =
4444            local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
4445
4446        // build headers
4447        let mut headers = HeaderMap::new();
4448        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
4449        headers.insert("Accept", HeaderValue::from_static("application/json"));
4450
4451        // build user agent
4452        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4453            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4454            Err(e) => {
4455                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4456                headers.insert(
4457                    reqwest::header::USER_AGENT,
4458                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4459                )
4460            }
4461        };
4462
4463        // build auth
4464        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4465            headers.insert(
4466                "DD-API-KEY",
4467                HeaderValue::from_str(local_key.key.as_str())
4468                    .expect("failed to parse DD-API-KEY header"),
4469            );
4470        };
4471        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4472            headers.insert(
4473                "DD-APPLICATION-KEY",
4474                HeaderValue::from_str(local_key.key.as_str())
4475                    .expect("failed to parse DD-APPLICATION-KEY header"),
4476            );
4477        };
4478
4479        // build body parameters
4480        let output = Vec::new();
4481        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
4482        if body.serialize(&mut ser).is_ok() {
4483            if let Some(content_encoding) = headers.get("Content-Encoding") {
4484                match content_encoding.to_str().unwrap_or_default() {
4485                    "gzip" => {
4486                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
4487                        let _ = enc.write_all(ser.into_inner().as_slice());
4488                        match enc.finish() {
4489                            Ok(buf) => {
4490                                local_req_builder = local_req_builder.body(buf);
4491                            }
4492                            Err(e) => return Err(datadog::Error::Io(e)),
4493                        }
4494                    }
4495                    "deflate" => {
4496                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
4497                        let _ = enc.write_all(ser.into_inner().as_slice());
4498                        match enc.finish() {
4499                            Ok(buf) => {
4500                                local_req_builder = local_req_builder.body(buf);
4501                            }
4502                            Err(e) => return Err(datadog::Error::Io(e)),
4503                        }
4504                    }
4505                    "zstd1" => {
4506                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
4507                        let _ = enc.write_all(ser.into_inner().as_slice());
4508                        match enc.finish() {
4509                            Ok(buf) => {
4510                                local_req_builder = local_req_builder.body(buf);
4511                            }
4512                            Err(e) => return Err(datadog::Error::Io(e)),
4513                        }
4514                    }
4515                    _ => {
4516                        local_req_builder = local_req_builder.body(ser.into_inner());
4517                    }
4518                }
4519            } else {
4520                local_req_builder = local_req_builder.body(ser.into_inner());
4521            }
4522        }
4523
4524        local_req_builder = local_req_builder.headers(headers);
4525        let local_req = local_req_builder.build()?;
4526        log::debug!("request content: {:?}", local_req.body());
4527        let local_resp = local_client.execute(local_req).await?;
4528
4529        let local_status = local_resp.status();
4530        let local_content = local_resp.text().await?;
4531        log::debug!("response content: {}", local_content);
4532
4533        if !local_status.is_client_error() && !local_status.is_server_error() {
4534            match serde_json::from_str::<crate::datadogV1::model::SyntheticsBrowserTest>(
4535                &local_content,
4536            ) {
4537                Ok(e) => {
4538                    return Ok(datadog::ResponseContent {
4539                        status: local_status,
4540                        content: local_content,
4541                        entity: Some(e),
4542                    })
4543                }
4544                Err(e) => return Err(datadog::Error::Serde(e)),
4545            };
4546        } else {
4547            let local_entity: Option<UpdateBrowserTestError> =
4548                serde_json::from_str(&local_content).ok();
4549            let local_error = datadog::ResponseContent {
4550                status: local_status,
4551                content: local_content,
4552                entity: local_entity,
4553            };
4554            Err(datadog::Error::ResponseError(local_error))
4555        }
4556    }
4557
4558    /// Edit the configuration of a Synthetic Mobile test.
4559    pub async fn update_mobile_test(
4560        &self,
4561        public_id: String,
4562        body: crate::datadogV1::model::SyntheticsMobileTest,
4563    ) -> Result<crate::datadogV1::model::SyntheticsMobileTest, datadog::Error<UpdateMobileTestError>>
4564    {
4565        match self
4566            .update_mobile_test_with_http_info(public_id, body)
4567            .await
4568        {
4569            Ok(response_content) => {
4570                if let Some(e) = response_content.entity {
4571                    Ok(e)
4572                } else {
4573                    Err(datadog::Error::Serde(serde::de::Error::custom(
4574                        "response content was None",
4575                    )))
4576                }
4577            }
4578            Err(err) => Err(err),
4579        }
4580    }
4581
4582    /// Edit the configuration of a Synthetic Mobile test.
4583    pub async fn update_mobile_test_with_http_info(
4584        &self,
4585        public_id: String,
4586        body: crate::datadogV1::model::SyntheticsMobileTest,
4587    ) -> Result<
4588        datadog::ResponseContent<crate::datadogV1::model::SyntheticsMobileTest>,
4589        datadog::Error<UpdateMobileTestError>,
4590    > {
4591        let local_configuration = &self.config;
4592        let operation_id = "v1.update_mobile_test";
4593
4594        let local_client = &self.client;
4595
4596        let local_uri_str = format!(
4597            "{}/api/v1/synthetics/tests/mobile/{public_id}",
4598            local_configuration.get_operation_host(operation_id),
4599            public_id = datadog::urlencode(public_id)
4600        );
4601        let mut local_req_builder =
4602            local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
4603
4604        // build headers
4605        let mut headers = HeaderMap::new();
4606        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
4607        headers.insert("Accept", HeaderValue::from_static("application/json"));
4608
4609        // build user agent
4610        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4611            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4612            Err(e) => {
4613                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4614                headers.insert(
4615                    reqwest::header::USER_AGENT,
4616                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4617                )
4618            }
4619        };
4620
4621        // build auth
4622        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4623            headers.insert(
4624                "DD-API-KEY",
4625                HeaderValue::from_str(local_key.key.as_str())
4626                    .expect("failed to parse DD-API-KEY header"),
4627            );
4628        };
4629        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4630            headers.insert(
4631                "DD-APPLICATION-KEY",
4632                HeaderValue::from_str(local_key.key.as_str())
4633                    .expect("failed to parse DD-APPLICATION-KEY header"),
4634            );
4635        };
4636
4637        // build body parameters
4638        let output = Vec::new();
4639        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
4640        if body.serialize(&mut ser).is_ok() {
4641            if let Some(content_encoding) = headers.get("Content-Encoding") {
4642                match content_encoding.to_str().unwrap_or_default() {
4643                    "gzip" => {
4644                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
4645                        let _ = enc.write_all(ser.into_inner().as_slice());
4646                        match enc.finish() {
4647                            Ok(buf) => {
4648                                local_req_builder = local_req_builder.body(buf);
4649                            }
4650                            Err(e) => return Err(datadog::Error::Io(e)),
4651                        }
4652                    }
4653                    "deflate" => {
4654                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
4655                        let _ = enc.write_all(ser.into_inner().as_slice());
4656                        match enc.finish() {
4657                            Ok(buf) => {
4658                                local_req_builder = local_req_builder.body(buf);
4659                            }
4660                            Err(e) => return Err(datadog::Error::Io(e)),
4661                        }
4662                    }
4663                    "zstd1" => {
4664                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
4665                        let _ = enc.write_all(ser.into_inner().as_slice());
4666                        match enc.finish() {
4667                            Ok(buf) => {
4668                                local_req_builder = local_req_builder.body(buf);
4669                            }
4670                            Err(e) => return Err(datadog::Error::Io(e)),
4671                        }
4672                    }
4673                    _ => {
4674                        local_req_builder = local_req_builder.body(ser.into_inner());
4675                    }
4676                }
4677            } else {
4678                local_req_builder = local_req_builder.body(ser.into_inner());
4679            }
4680        }
4681
4682        local_req_builder = local_req_builder.headers(headers);
4683        let local_req = local_req_builder.build()?;
4684        log::debug!("request content: {:?}", local_req.body());
4685        let local_resp = local_client.execute(local_req).await?;
4686
4687        let local_status = local_resp.status();
4688        let local_content = local_resp.text().await?;
4689        log::debug!("response content: {}", local_content);
4690
4691        if !local_status.is_client_error() && !local_status.is_server_error() {
4692            match serde_json::from_str::<crate::datadogV1::model::SyntheticsMobileTest>(
4693                &local_content,
4694            ) {
4695                Ok(e) => {
4696                    return Ok(datadog::ResponseContent {
4697                        status: local_status,
4698                        content: local_content,
4699                        entity: Some(e),
4700                    })
4701                }
4702                Err(e) => return Err(datadog::Error::Serde(e)),
4703            };
4704        } else {
4705            let local_entity: Option<UpdateMobileTestError> =
4706                serde_json::from_str(&local_content).ok();
4707            let local_error = datadog::ResponseContent {
4708                status: local_status,
4709                content: local_content,
4710                entity: local_entity,
4711            };
4712            Err(datadog::Error::ResponseError(local_error))
4713        }
4714    }
4715
4716    /// Edit a Synthetic private location.
4717    pub async fn update_private_location(
4718        &self,
4719        location_id: String,
4720        body: crate::datadogV1::model::SyntheticsPrivateLocation,
4721    ) -> Result<
4722        crate::datadogV1::model::SyntheticsPrivateLocation,
4723        datadog::Error<UpdatePrivateLocationError>,
4724    > {
4725        match self
4726            .update_private_location_with_http_info(location_id, body)
4727            .await
4728        {
4729            Ok(response_content) => {
4730                if let Some(e) = response_content.entity {
4731                    Ok(e)
4732                } else {
4733                    Err(datadog::Error::Serde(serde::de::Error::custom(
4734                        "response content was None",
4735                    )))
4736                }
4737            }
4738            Err(err) => Err(err),
4739        }
4740    }
4741
4742    /// Edit a Synthetic private location.
4743    pub async fn update_private_location_with_http_info(
4744        &self,
4745        location_id: String,
4746        body: crate::datadogV1::model::SyntheticsPrivateLocation,
4747    ) -> Result<
4748        datadog::ResponseContent<crate::datadogV1::model::SyntheticsPrivateLocation>,
4749        datadog::Error<UpdatePrivateLocationError>,
4750    > {
4751        let local_configuration = &self.config;
4752        let operation_id = "v1.update_private_location";
4753
4754        let local_client = &self.client;
4755
4756        let local_uri_str = format!(
4757            "{}/api/v1/synthetics/private-locations/{location_id}",
4758            local_configuration.get_operation_host(operation_id),
4759            location_id = datadog::urlencode(location_id)
4760        );
4761        let mut local_req_builder =
4762            local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
4763
4764        // build headers
4765        let mut headers = HeaderMap::new();
4766        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
4767        headers.insert("Accept", HeaderValue::from_static("application/json"));
4768
4769        // build user agent
4770        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4771            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4772            Err(e) => {
4773                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4774                headers.insert(
4775                    reqwest::header::USER_AGENT,
4776                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4777                )
4778            }
4779        };
4780
4781        // build auth
4782        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4783            headers.insert(
4784                "DD-API-KEY",
4785                HeaderValue::from_str(local_key.key.as_str())
4786                    .expect("failed to parse DD-API-KEY header"),
4787            );
4788        };
4789        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4790            headers.insert(
4791                "DD-APPLICATION-KEY",
4792                HeaderValue::from_str(local_key.key.as_str())
4793                    .expect("failed to parse DD-APPLICATION-KEY header"),
4794            );
4795        };
4796
4797        // build body parameters
4798        let output = Vec::new();
4799        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
4800        if body.serialize(&mut ser).is_ok() {
4801            if let Some(content_encoding) = headers.get("Content-Encoding") {
4802                match content_encoding.to_str().unwrap_or_default() {
4803                    "gzip" => {
4804                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
4805                        let _ = enc.write_all(ser.into_inner().as_slice());
4806                        match enc.finish() {
4807                            Ok(buf) => {
4808                                local_req_builder = local_req_builder.body(buf);
4809                            }
4810                            Err(e) => return Err(datadog::Error::Io(e)),
4811                        }
4812                    }
4813                    "deflate" => {
4814                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
4815                        let _ = enc.write_all(ser.into_inner().as_slice());
4816                        match enc.finish() {
4817                            Ok(buf) => {
4818                                local_req_builder = local_req_builder.body(buf);
4819                            }
4820                            Err(e) => return Err(datadog::Error::Io(e)),
4821                        }
4822                    }
4823                    "zstd1" => {
4824                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
4825                        let _ = enc.write_all(ser.into_inner().as_slice());
4826                        match enc.finish() {
4827                            Ok(buf) => {
4828                                local_req_builder = local_req_builder.body(buf);
4829                            }
4830                            Err(e) => return Err(datadog::Error::Io(e)),
4831                        }
4832                    }
4833                    _ => {
4834                        local_req_builder = local_req_builder.body(ser.into_inner());
4835                    }
4836                }
4837            } else {
4838                local_req_builder = local_req_builder.body(ser.into_inner());
4839            }
4840        }
4841
4842        local_req_builder = local_req_builder.headers(headers);
4843        let local_req = local_req_builder.build()?;
4844        log::debug!("request content: {:?}", local_req.body());
4845        let local_resp = local_client.execute(local_req).await?;
4846
4847        let local_status = local_resp.status();
4848        let local_content = local_resp.text().await?;
4849        log::debug!("response content: {}", local_content);
4850
4851        if !local_status.is_client_error() && !local_status.is_server_error() {
4852            match serde_json::from_str::<crate::datadogV1::model::SyntheticsPrivateLocation>(
4853                &local_content,
4854            ) {
4855                Ok(e) => {
4856                    return Ok(datadog::ResponseContent {
4857                        status: local_status,
4858                        content: local_content,
4859                        entity: Some(e),
4860                    })
4861                }
4862                Err(e) => return Err(datadog::Error::Serde(e)),
4863            };
4864        } else {
4865            let local_entity: Option<UpdatePrivateLocationError> =
4866                serde_json::from_str(&local_content).ok();
4867            let local_error = datadog::ResponseContent {
4868                status: local_status,
4869                content: local_content,
4870                entity: local_entity,
4871            };
4872            Err(datadog::Error::ResponseError(local_error))
4873        }
4874    }
4875
4876    /// Pause or start a Synthetic test by changing the status.
4877    pub async fn update_test_pause_status(
4878        &self,
4879        public_id: String,
4880        body: crate::datadogV1::model::SyntheticsUpdateTestPauseStatusPayload,
4881    ) -> Result<bool, datadog::Error<UpdateTestPauseStatusError>> {
4882        match self
4883            .update_test_pause_status_with_http_info(public_id, body)
4884            .await
4885        {
4886            Ok(response_content) => {
4887                if let Some(e) = response_content.entity {
4888                    Ok(e)
4889                } else {
4890                    Err(datadog::Error::Serde(serde::de::Error::custom(
4891                        "response content was None",
4892                    )))
4893                }
4894            }
4895            Err(err) => Err(err),
4896        }
4897    }
4898
4899    /// Pause or start a Synthetic test by changing the status.
4900    pub async fn update_test_pause_status_with_http_info(
4901        &self,
4902        public_id: String,
4903        body: crate::datadogV1::model::SyntheticsUpdateTestPauseStatusPayload,
4904    ) -> Result<datadog::ResponseContent<bool>, datadog::Error<UpdateTestPauseStatusError>> {
4905        let local_configuration = &self.config;
4906        let operation_id = "v1.update_test_pause_status";
4907
4908        let local_client = &self.client;
4909
4910        let local_uri_str = format!(
4911            "{}/api/v1/synthetics/tests/{public_id}/status",
4912            local_configuration.get_operation_host(operation_id),
4913            public_id = datadog::urlencode(public_id)
4914        );
4915        let mut local_req_builder =
4916            local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
4917
4918        // build headers
4919        let mut headers = HeaderMap::new();
4920        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
4921        headers.insert("Accept", HeaderValue::from_static("application/json"));
4922
4923        // build user agent
4924        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4925            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4926            Err(e) => {
4927                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4928                headers.insert(
4929                    reqwest::header::USER_AGENT,
4930                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4931                )
4932            }
4933        };
4934
4935        // build auth
4936        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4937            headers.insert(
4938                "DD-API-KEY",
4939                HeaderValue::from_str(local_key.key.as_str())
4940                    .expect("failed to parse DD-API-KEY header"),
4941            );
4942        };
4943        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4944            headers.insert(
4945                "DD-APPLICATION-KEY",
4946                HeaderValue::from_str(local_key.key.as_str())
4947                    .expect("failed to parse DD-APPLICATION-KEY header"),
4948            );
4949        };
4950
4951        // build body parameters
4952        let output = Vec::new();
4953        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
4954        if body.serialize(&mut ser).is_ok() {
4955            if let Some(content_encoding) = headers.get("Content-Encoding") {
4956                match content_encoding.to_str().unwrap_or_default() {
4957                    "gzip" => {
4958                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
4959                        let _ = enc.write_all(ser.into_inner().as_slice());
4960                        match enc.finish() {
4961                            Ok(buf) => {
4962                                local_req_builder = local_req_builder.body(buf);
4963                            }
4964                            Err(e) => return Err(datadog::Error::Io(e)),
4965                        }
4966                    }
4967                    "deflate" => {
4968                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
4969                        let _ = enc.write_all(ser.into_inner().as_slice());
4970                        match enc.finish() {
4971                            Ok(buf) => {
4972                                local_req_builder = local_req_builder.body(buf);
4973                            }
4974                            Err(e) => return Err(datadog::Error::Io(e)),
4975                        }
4976                    }
4977                    "zstd1" => {
4978                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
4979                        let _ = enc.write_all(ser.into_inner().as_slice());
4980                        match enc.finish() {
4981                            Ok(buf) => {
4982                                local_req_builder = local_req_builder.body(buf);
4983                            }
4984                            Err(e) => return Err(datadog::Error::Io(e)),
4985                        }
4986                    }
4987                    _ => {
4988                        local_req_builder = local_req_builder.body(ser.into_inner());
4989                    }
4990                }
4991            } else {
4992                local_req_builder = local_req_builder.body(ser.into_inner());
4993            }
4994        }
4995
4996        local_req_builder = local_req_builder.headers(headers);
4997        let local_req = local_req_builder.build()?;
4998        log::debug!("request content: {:?}", local_req.body());
4999        let local_resp = local_client.execute(local_req).await?;
5000
5001        let local_status = local_resp.status();
5002        let local_content = local_resp.text().await?;
5003        log::debug!("response content: {}", local_content);
5004
5005        if !local_status.is_client_error() && !local_status.is_server_error() {
5006            match serde_json::from_str::<bool>(&local_content) {
5007                Ok(e) => {
5008                    return Ok(datadog::ResponseContent {
5009                        status: local_status,
5010                        content: local_content,
5011                        entity: Some(e),
5012                    })
5013                }
5014                Err(e) => return Err(datadog::Error::Serde(e)),
5015            };
5016        } else {
5017            let local_entity: Option<UpdateTestPauseStatusError> =
5018                serde_json::from_str(&local_content).ok();
5019            let local_error = datadog::ResponseContent {
5020                status: local_status,
5021                content: local_content,
5022                entity: local_entity,
5023            };
5024            Err(datadog::Error::ResponseError(local_error))
5025        }
5026    }
5027}