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