1use crate::datadog;
5use flate2::{
6 write::{GzEncoder, ZlibEncoder},
7 Compression,
8};
9use reqwest::header::{HeaderMap, HeaderValue};
10use serde::{Deserialize, Serialize};
11use std::io::Write;
12
13#[non_exhaustive]
15#[derive(Clone, Default, Debug)]
16pub struct ListAWSAccountsOptionalParams {
17 pub account_id: Option<String>,
19 pub role_name: Option<String>,
21 pub access_key_id: Option<String>,
23}
24
25impl ListAWSAccountsOptionalParams {
26 pub fn account_id(mut self, value: String) -> Self {
28 self.account_id = Some(value);
29 self
30 }
31 pub fn role_name(mut self, value: String) -> Self {
33 self.role_name = Some(value);
34 self
35 }
36 pub fn access_key_id(mut self, value: String) -> Self {
38 self.access_key_id = Some(value);
39 self
40 }
41}
42
43#[non_exhaustive]
45#[derive(Clone, Default, Debug)]
46pub struct UpdateAWSAccountOptionalParams {
47 pub account_id: Option<String>,
49 pub role_name: Option<String>,
52 pub access_key_id: Option<String>,
55}
56
57impl UpdateAWSAccountOptionalParams {
58 pub fn account_id(mut self, value: String) -> Self {
60 self.account_id = Some(value);
61 self
62 }
63 pub fn role_name(mut self, value: String) -> Self {
66 self.role_name = Some(value);
67 self
68 }
69 pub fn access_key_id(mut self, value: String) -> Self {
72 self.access_key_id = Some(value);
73 self
74 }
75}
76
77#[derive(Debug, Clone, Serialize, Deserialize)]
79#[serde(untagged)]
80pub enum CreateAWSAccountError {
81 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
82 UnknownValue(serde_json::Value),
83}
84
85#[derive(Debug, Clone, Serialize, Deserialize)]
87#[serde(untagged)]
88pub enum CreateAWSEventBridgeSourceError {
89 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
90 UnknownValue(serde_json::Value),
91}
92
93#[derive(Debug, Clone, Serialize, Deserialize)]
95#[serde(untagged)]
96pub enum CreateAWSTagFilterError {
97 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
98 UnknownValue(serde_json::Value),
99}
100
101#[derive(Debug, Clone, Serialize, Deserialize)]
103#[serde(untagged)]
104pub enum CreateNewAWSExternalIDError {
105 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
106 UnknownValue(serde_json::Value),
107}
108
109#[derive(Debug, Clone, Serialize, Deserialize)]
111#[serde(untagged)]
112pub enum DeleteAWSAccountError {
113 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
114 UnknownValue(serde_json::Value),
115}
116
117#[derive(Debug, Clone, Serialize, Deserialize)]
119#[serde(untagged)]
120pub enum DeleteAWSEventBridgeSourceError {
121 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
122 UnknownValue(serde_json::Value),
123}
124
125#[derive(Debug, Clone, Serialize, Deserialize)]
127#[serde(untagged)]
128pub enum DeleteAWSTagFilterError {
129 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
130 UnknownValue(serde_json::Value),
131}
132
133#[derive(Debug, Clone, Serialize, Deserialize)]
135#[serde(untagged)]
136pub enum ListAWSAccountsError {
137 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
138 UnknownValue(serde_json::Value),
139}
140
141#[derive(Debug, Clone, Serialize, Deserialize)]
143#[serde(untagged)]
144pub enum ListAWSEventBridgeSourcesError {
145 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
146 UnknownValue(serde_json::Value),
147}
148
149#[derive(Debug, Clone, Serialize, Deserialize)]
151#[serde(untagged)]
152pub enum ListAWSTagFiltersError {
153 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
154 UnknownValue(serde_json::Value),
155}
156
157#[derive(Debug, Clone, Serialize, Deserialize)]
159#[serde(untagged)]
160pub enum ListAvailableAWSNamespacesError {
161 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
162 UnknownValue(serde_json::Value),
163}
164
165#[derive(Debug, Clone, Serialize, Deserialize)]
167#[serde(untagged)]
168pub enum UpdateAWSAccountError {
169 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
170 UnknownValue(serde_json::Value),
171}
172
173#[derive(Debug, Clone)]
176pub struct AWSIntegrationAPI {
177 config: datadog::Configuration,
178 client: reqwest_middleware::ClientWithMiddleware,
179}
180
181impl Default for AWSIntegrationAPI {
182 fn default() -> Self {
183 Self::with_config(datadog::Configuration::default())
184 }
185}
186
187impl AWSIntegrationAPI {
188 pub fn new() -> Self {
189 Self::default()
190 }
191 pub fn with_config(config: datadog::Configuration) -> Self {
192 let mut reqwest_client_builder = reqwest::Client::builder();
193
194 if let Some(proxy_url) = &config.proxy_url {
195 let proxy = reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL");
196 reqwest_client_builder = reqwest_client_builder.proxy(proxy);
197 }
198
199 let mut middleware_client_builder =
200 reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap());
201
202 if config.enable_retry {
203 struct RetryableStatus;
204 impl reqwest_retry::RetryableStrategy for RetryableStatus {
205 fn handle(
206 &self,
207 res: &Result<reqwest::Response, reqwest_middleware::Error>,
208 ) -> Option<reqwest_retry::Retryable> {
209 match res {
210 Ok(success) => reqwest_retry::default_on_request_success(success),
211 Err(_) => None,
212 }
213 }
214 }
215 let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder()
216 .build_with_max_retries(config.max_retries);
217
218 let retry_middleware =
219 reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy(
220 backoff_policy,
221 RetryableStatus,
222 );
223
224 middleware_client_builder = middleware_client_builder.with(retry_middleware);
225 }
226
227 let client = middleware_client_builder.build();
228
229 Self { config, client }
230 }
231
232 pub fn with_client_and_config(
233 config: datadog::Configuration,
234 client: reqwest_middleware::ClientWithMiddleware,
235 ) -> Self {
236 Self { config, client }
237 }
238
239 pub async fn create_aws_account(
244 &self,
245 body: crate::datadogV1::model::AWSAccount,
246 ) -> Result<
247 crate::datadogV1::model::AWSAccountCreateResponse,
248 datadog::Error<CreateAWSAccountError>,
249 > {
250 match self.create_aws_account_with_http_info(body).await {
251 Ok(response_content) => {
252 if let Some(e) = response_content.entity {
253 Ok(e)
254 } else {
255 Err(datadog::Error::Serde(serde::de::Error::custom(
256 "response content was None",
257 )))
258 }
259 }
260 Err(err) => Err(err),
261 }
262 }
263
264 pub async fn create_aws_account_with_http_info(
269 &self,
270 body: crate::datadogV1::model::AWSAccount,
271 ) -> Result<
272 datadog::ResponseContent<crate::datadogV1::model::AWSAccountCreateResponse>,
273 datadog::Error<CreateAWSAccountError>,
274 > {
275 let local_configuration = &self.config;
276 let operation_id = "v1.create_aws_account";
277
278 let local_client = &self.client;
279
280 let local_uri_str = format!(
281 "{}/api/v1/integration/aws",
282 local_configuration.get_operation_host(operation_id)
283 );
284 let mut local_req_builder =
285 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
286
287 let mut headers = HeaderMap::new();
289 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
290 headers.insert("Accept", HeaderValue::from_static("application/json"));
291
292 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
294 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
295 Err(e) => {
296 log::warn!("Failed to parse user agent header: {e}, falling back to default");
297 headers.insert(
298 reqwest::header::USER_AGENT,
299 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
300 )
301 }
302 };
303
304 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
306 headers.insert(
307 "DD-API-KEY",
308 HeaderValue::from_str(local_key.key.as_str())
309 .expect("failed to parse DD-API-KEY header"),
310 );
311 };
312 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
313 headers.insert(
314 "DD-APPLICATION-KEY",
315 HeaderValue::from_str(local_key.key.as_str())
316 .expect("failed to parse DD-APPLICATION-KEY header"),
317 );
318 };
319
320 let output = Vec::new();
322 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
323 if body.serialize(&mut ser).is_ok() {
324 if let Some(content_encoding) = headers.get("Content-Encoding") {
325 match content_encoding.to_str().unwrap_or_default() {
326 "gzip" => {
327 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
328 let _ = enc.write_all(ser.into_inner().as_slice());
329 match enc.finish() {
330 Ok(buf) => {
331 local_req_builder = local_req_builder.body(buf);
332 }
333 Err(e) => return Err(datadog::Error::Io(e)),
334 }
335 }
336 "deflate" => {
337 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
338 let _ = enc.write_all(ser.into_inner().as_slice());
339 match enc.finish() {
340 Ok(buf) => {
341 local_req_builder = local_req_builder.body(buf);
342 }
343 Err(e) => return Err(datadog::Error::Io(e)),
344 }
345 }
346 "zstd1" => {
347 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
348 let _ = enc.write_all(ser.into_inner().as_slice());
349 match enc.finish() {
350 Ok(buf) => {
351 local_req_builder = local_req_builder.body(buf);
352 }
353 Err(e) => return Err(datadog::Error::Io(e)),
354 }
355 }
356 _ => {
357 local_req_builder = local_req_builder.body(ser.into_inner());
358 }
359 }
360 } else {
361 local_req_builder = local_req_builder.body(ser.into_inner());
362 }
363 }
364
365 local_req_builder = local_req_builder.headers(headers);
366 let local_req = local_req_builder.build()?;
367 log::debug!("request content: {:?}", local_req.body());
368 let local_resp = local_client.execute(local_req).await?;
369
370 let local_status = local_resp.status();
371 let local_content = local_resp.text().await?;
372 log::debug!("response content: {}", local_content);
373
374 if !local_status.is_client_error() && !local_status.is_server_error() {
375 match serde_json::from_str::<crate::datadogV1::model::AWSAccountCreateResponse>(
376 &local_content,
377 ) {
378 Ok(e) => {
379 return Ok(datadog::ResponseContent {
380 status: local_status,
381 content: local_content,
382 entity: Some(e),
383 })
384 }
385 Err(e) => return Err(datadog::Error::Serde(e)),
386 };
387 } else {
388 let local_entity: Option<CreateAWSAccountError> =
389 serde_json::from_str(&local_content).ok();
390 let local_error = datadog::ResponseContent {
391 status: local_status,
392 content: local_content,
393 entity: local_entity,
394 };
395 Err(datadog::Error::ResponseError(local_error))
396 }
397 }
398
399 pub async fn create_aws_event_bridge_source(
401 &self,
402 body: crate::datadogV1::model::AWSEventBridgeCreateRequest,
403 ) -> Result<
404 crate::datadogV1::model::AWSEventBridgeCreateResponse,
405 datadog::Error<CreateAWSEventBridgeSourceError>,
406 > {
407 match self
408 .create_aws_event_bridge_source_with_http_info(body)
409 .await
410 {
411 Ok(response_content) => {
412 if let Some(e) = response_content.entity {
413 Ok(e)
414 } else {
415 Err(datadog::Error::Serde(serde::de::Error::custom(
416 "response content was None",
417 )))
418 }
419 }
420 Err(err) => Err(err),
421 }
422 }
423
424 pub async fn create_aws_event_bridge_source_with_http_info(
426 &self,
427 body: crate::datadogV1::model::AWSEventBridgeCreateRequest,
428 ) -> Result<
429 datadog::ResponseContent<crate::datadogV1::model::AWSEventBridgeCreateResponse>,
430 datadog::Error<CreateAWSEventBridgeSourceError>,
431 > {
432 let local_configuration = &self.config;
433 let operation_id = "v1.create_aws_event_bridge_source";
434
435 let local_client = &self.client;
436
437 let local_uri_str = format!(
438 "{}/api/v1/integration/aws/event_bridge",
439 local_configuration.get_operation_host(operation_id)
440 );
441 let mut local_req_builder =
442 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
443
444 let mut headers = HeaderMap::new();
446 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
447 headers.insert("Accept", HeaderValue::from_static("application/json"));
448
449 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
451 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
452 Err(e) => {
453 log::warn!("Failed to parse user agent header: {e}, falling back to default");
454 headers.insert(
455 reqwest::header::USER_AGENT,
456 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
457 )
458 }
459 };
460
461 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
463 headers.insert(
464 "DD-API-KEY",
465 HeaderValue::from_str(local_key.key.as_str())
466 .expect("failed to parse DD-API-KEY header"),
467 );
468 };
469 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
470 headers.insert(
471 "DD-APPLICATION-KEY",
472 HeaderValue::from_str(local_key.key.as_str())
473 .expect("failed to parse DD-APPLICATION-KEY header"),
474 );
475 };
476
477 let output = Vec::new();
479 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
480 if body.serialize(&mut ser).is_ok() {
481 if let Some(content_encoding) = headers.get("Content-Encoding") {
482 match content_encoding.to_str().unwrap_or_default() {
483 "gzip" => {
484 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
485 let _ = enc.write_all(ser.into_inner().as_slice());
486 match enc.finish() {
487 Ok(buf) => {
488 local_req_builder = local_req_builder.body(buf);
489 }
490 Err(e) => return Err(datadog::Error::Io(e)),
491 }
492 }
493 "deflate" => {
494 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
495 let _ = enc.write_all(ser.into_inner().as_slice());
496 match enc.finish() {
497 Ok(buf) => {
498 local_req_builder = local_req_builder.body(buf);
499 }
500 Err(e) => return Err(datadog::Error::Io(e)),
501 }
502 }
503 "zstd1" => {
504 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
505 let _ = enc.write_all(ser.into_inner().as_slice());
506 match enc.finish() {
507 Ok(buf) => {
508 local_req_builder = local_req_builder.body(buf);
509 }
510 Err(e) => return Err(datadog::Error::Io(e)),
511 }
512 }
513 _ => {
514 local_req_builder = local_req_builder.body(ser.into_inner());
515 }
516 }
517 } else {
518 local_req_builder = local_req_builder.body(ser.into_inner());
519 }
520 }
521
522 local_req_builder = local_req_builder.headers(headers);
523 let local_req = local_req_builder.build()?;
524 log::debug!("request content: {:?}", local_req.body());
525 let local_resp = local_client.execute(local_req).await?;
526
527 let local_status = local_resp.status();
528 let local_content = local_resp.text().await?;
529 log::debug!("response content: {}", local_content);
530
531 if !local_status.is_client_error() && !local_status.is_server_error() {
532 match serde_json::from_str::<crate::datadogV1::model::AWSEventBridgeCreateResponse>(
533 &local_content,
534 ) {
535 Ok(e) => {
536 return Ok(datadog::ResponseContent {
537 status: local_status,
538 content: local_content,
539 entity: Some(e),
540 })
541 }
542 Err(e) => return Err(datadog::Error::Serde(e)),
543 };
544 } else {
545 let local_entity: Option<CreateAWSEventBridgeSourceError> =
546 serde_json::from_str(&local_content).ok();
547 let local_error = datadog::ResponseContent {
548 status: local_status,
549 content: local_content,
550 entity: local_entity,
551 };
552 Err(datadog::Error::ResponseError(local_error))
553 }
554 }
555
556 pub async fn create_aws_tag_filter(
558 &self,
559 body: crate::datadogV1::model::AWSTagFilterCreateRequest,
560 ) -> Result<
561 std::collections::BTreeMap<String, serde_json::Value>,
562 datadog::Error<CreateAWSTagFilterError>,
563 > {
564 match self.create_aws_tag_filter_with_http_info(body).await {
565 Ok(response_content) => {
566 if let Some(e) = response_content.entity {
567 Ok(e)
568 } else {
569 Err(datadog::Error::Serde(serde::de::Error::custom(
570 "response content was None",
571 )))
572 }
573 }
574 Err(err) => Err(err),
575 }
576 }
577
578 pub async fn create_aws_tag_filter_with_http_info(
580 &self,
581 body: crate::datadogV1::model::AWSTagFilterCreateRequest,
582 ) -> Result<
583 datadog::ResponseContent<std::collections::BTreeMap<String, serde_json::Value>>,
584 datadog::Error<CreateAWSTagFilterError>,
585 > {
586 let local_configuration = &self.config;
587 let operation_id = "v1.create_aws_tag_filter";
588
589 let local_client = &self.client;
590
591 let local_uri_str = format!(
592 "{}/api/v1/integration/aws/filtering",
593 local_configuration.get_operation_host(operation_id)
594 );
595 let mut local_req_builder =
596 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
597
598 let mut headers = HeaderMap::new();
600 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
601 headers.insert("Accept", HeaderValue::from_static("application/json"));
602
603 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
605 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
606 Err(e) => {
607 log::warn!("Failed to parse user agent header: {e}, falling back to default");
608 headers.insert(
609 reqwest::header::USER_AGENT,
610 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
611 )
612 }
613 };
614
615 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
617 headers.insert(
618 "DD-API-KEY",
619 HeaderValue::from_str(local_key.key.as_str())
620 .expect("failed to parse DD-API-KEY header"),
621 );
622 };
623 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
624 headers.insert(
625 "DD-APPLICATION-KEY",
626 HeaderValue::from_str(local_key.key.as_str())
627 .expect("failed to parse DD-APPLICATION-KEY header"),
628 );
629 };
630
631 let output = Vec::new();
633 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
634 if body.serialize(&mut ser).is_ok() {
635 if let Some(content_encoding) = headers.get("Content-Encoding") {
636 match content_encoding.to_str().unwrap_or_default() {
637 "gzip" => {
638 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
639 let _ = enc.write_all(ser.into_inner().as_slice());
640 match enc.finish() {
641 Ok(buf) => {
642 local_req_builder = local_req_builder.body(buf);
643 }
644 Err(e) => return Err(datadog::Error::Io(e)),
645 }
646 }
647 "deflate" => {
648 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
649 let _ = enc.write_all(ser.into_inner().as_slice());
650 match enc.finish() {
651 Ok(buf) => {
652 local_req_builder = local_req_builder.body(buf);
653 }
654 Err(e) => return Err(datadog::Error::Io(e)),
655 }
656 }
657 "zstd1" => {
658 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
659 let _ = enc.write_all(ser.into_inner().as_slice());
660 match enc.finish() {
661 Ok(buf) => {
662 local_req_builder = local_req_builder.body(buf);
663 }
664 Err(e) => return Err(datadog::Error::Io(e)),
665 }
666 }
667 _ => {
668 local_req_builder = local_req_builder.body(ser.into_inner());
669 }
670 }
671 } else {
672 local_req_builder = local_req_builder.body(ser.into_inner());
673 }
674 }
675
676 local_req_builder = local_req_builder.headers(headers);
677 let local_req = local_req_builder.build()?;
678 log::debug!("request content: {:?}", local_req.body());
679 let local_resp = local_client.execute(local_req).await?;
680
681 let local_status = local_resp.status();
682 let local_content = local_resp.text().await?;
683 log::debug!("response content: {}", local_content);
684
685 if !local_status.is_client_error() && !local_status.is_server_error() {
686 match serde_json::from_str::<std::collections::BTreeMap<String, serde_json::Value>>(
687 &local_content,
688 ) {
689 Ok(e) => {
690 return Ok(datadog::ResponseContent {
691 status: local_status,
692 content: local_content,
693 entity: Some(e),
694 })
695 }
696 Err(e) => return Err(datadog::Error::Serde(e)),
697 };
698 } else {
699 let local_entity: Option<CreateAWSTagFilterError> =
700 serde_json::from_str(&local_content).ok();
701 let local_error = datadog::ResponseContent {
702 status: local_status,
703 content: local_content,
704 entity: local_entity,
705 };
706 Err(datadog::Error::ResponseError(local_error))
707 }
708 }
709
710 pub async fn create_new_aws_external_id(
712 &self,
713 body: crate::datadogV1::model::AWSAccount,
714 ) -> Result<
715 crate::datadogV1::model::AWSAccountCreateResponse,
716 datadog::Error<CreateNewAWSExternalIDError>,
717 > {
718 match self.create_new_aws_external_id_with_http_info(body).await {
719 Ok(response_content) => {
720 if let Some(e) = response_content.entity {
721 Ok(e)
722 } else {
723 Err(datadog::Error::Serde(serde::de::Error::custom(
724 "response content was None",
725 )))
726 }
727 }
728 Err(err) => Err(err),
729 }
730 }
731
732 pub async fn create_new_aws_external_id_with_http_info(
734 &self,
735 body: crate::datadogV1::model::AWSAccount,
736 ) -> Result<
737 datadog::ResponseContent<crate::datadogV1::model::AWSAccountCreateResponse>,
738 datadog::Error<CreateNewAWSExternalIDError>,
739 > {
740 let local_configuration = &self.config;
741 let operation_id = "v1.create_new_aws_external_id";
742
743 let local_client = &self.client;
744
745 let local_uri_str = format!(
746 "{}/api/v1/integration/aws/generate_new_external_id",
747 local_configuration.get_operation_host(operation_id)
748 );
749 let mut local_req_builder =
750 local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
751
752 let mut headers = HeaderMap::new();
754 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
755 headers.insert("Accept", HeaderValue::from_static("application/json"));
756
757 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
759 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
760 Err(e) => {
761 log::warn!("Failed to parse user agent header: {e}, falling back to default");
762 headers.insert(
763 reqwest::header::USER_AGENT,
764 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
765 )
766 }
767 };
768
769 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
771 headers.insert(
772 "DD-API-KEY",
773 HeaderValue::from_str(local_key.key.as_str())
774 .expect("failed to parse DD-API-KEY header"),
775 );
776 };
777 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
778 headers.insert(
779 "DD-APPLICATION-KEY",
780 HeaderValue::from_str(local_key.key.as_str())
781 .expect("failed to parse DD-APPLICATION-KEY header"),
782 );
783 };
784
785 let output = Vec::new();
787 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
788 if body.serialize(&mut ser).is_ok() {
789 if let Some(content_encoding) = headers.get("Content-Encoding") {
790 match content_encoding.to_str().unwrap_or_default() {
791 "gzip" => {
792 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
793 let _ = enc.write_all(ser.into_inner().as_slice());
794 match enc.finish() {
795 Ok(buf) => {
796 local_req_builder = local_req_builder.body(buf);
797 }
798 Err(e) => return Err(datadog::Error::Io(e)),
799 }
800 }
801 "deflate" => {
802 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
803 let _ = enc.write_all(ser.into_inner().as_slice());
804 match enc.finish() {
805 Ok(buf) => {
806 local_req_builder = local_req_builder.body(buf);
807 }
808 Err(e) => return Err(datadog::Error::Io(e)),
809 }
810 }
811 "zstd1" => {
812 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
813 let _ = enc.write_all(ser.into_inner().as_slice());
814 match enc.finish() {
815 Ok(buf) => {
816 local_req_builder = local_req_builder.body(buf);
817 }
818 Err(e) => return Err(datadog::Error::Io(e)),
819 }
820 }
821 _ => {
822 local_req_builder = local_req_builder.body(ser.into_inner());
823 }
824 }
825 } else {
826 local_req_builder = local_req_builder.body(ser.into_inner());
827 }
828 }
829
830 local_req_builder = local_req_builder.headers(headers);
831 let local_req = local_req_builder.build()?;
832 log::debug!("request content: {:?}", local_req.body());
833 let local_resp = local_client.execute(local_req).await?;
834
835 let local_status = local_resp.status();
836 let local_content = local_resp.text().await?;
837 log::debug!("response content: {}", local_content);
838
839 if !local_status.is_client_error() && !local_status.is_server_error() {
840 match serde_json::from_str::<crate::datadogV1::model::AWSAccountCreateResponse>(
841 &local_content,
842 ) {
843 Ok(e) => {
844 return Ok(datadog::ResponseContent {
845 status: local_status,
846 content: local_content,
847 entity: Some(e),
848 })
849 }
850 Err(e) => return Err(datadog::Error::Serde(e)),
851 };
852 } else {
853 let local_entity: Option<CreateNewAWSExternalIDError> =
854 serde_json::from_str(&local_content).ok();
855 let local_error = datadog::ResponseContent {
856 status: local_status,
857 content: local_content,
858 entity: local_entity,
859 };
860 Err(datadog::Error::ResponseError(local_error))
861 }
862 }
863
864 pub async fn delete_aws_account(
866 &self,
867 body: crate::datadogV1::model::AWSAccountDeleteRequest,
868 ) -> Result<
869 std::collections::BTreeMap<String, serde_json::Value>,
870 datadog::Error<DeleteAWSAccountError>,
871 > {
872 match self.delete_aws_account_with_http_info(body).await {
873 Ok(response_content) => {
874 if let Some(e) = response_content.entity {
875 Ok(e)
876 } else {
877 Err(datadog::Error::Serde(serde::de::Error::custom(
878 "response content was None",
879 )))
880 }
881 }
882 Err(err) => Err(err),
883 }
884 }
885
886 pub async fn delete_aws_account_with_http_info(
888 &self,
889 body: crate::datadogV1::model::AWSAccountDeleteRequest,
890 ) -> Result<
891 datadog::ResponseContent<std::collections::BTreeMap<String, serde_json::Value>>,
892 datadog::Error<DeleteAWSAccountError>,
893 > {
894 let local_configuration = &self.config;
895 let operation_id = "v1.delete_aws_account";
896
897 let local_client = &self.client;
898
899 let local_uri_str = format!(
900 "{}/api/v1/integration/aws",
901 local_configuration.get_operation_host(operation_id)
902 );
903 let mut local_req_builder =
904 local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
905
906 let mut headers = HeaderMap::new();
908 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
909 headers.insert("Accept", HeaderValue::from_static("application/json"));
910
911 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
913 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
914 Err(e) => {
915 log::warn!("Failed to parse user agent header: {e}, falling back to default");
916 headers.insert(
917 reqwest::header::USER_AGENT,
918 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
919 )
920 }
921 };
922
923 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
925 headers.insert(
926 "DD-API-KEY",
927 HeaderValue::from_str(local_key.key.as_str())
928 .expect("failed to parse DD-API-KEY header"),
929 );
930 };
931 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
932 headers.insert(
933 "DD-APPLICATION-KEY",
934 HeaderValue::from_str(local_key.key.as_str())
935 .expect("failed to parse DD-APPLICATION-KEY header"),
936 );
937 };
938
939 let output = Vec::new();
941 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
942 if body.serialize(&mut ser).is_ok() {
943 if let Some(content_encoding) = headers.get("Content-Encoding") {
944 match content_encoding.to_str().unwrap_or_default() {
945 "gzip" => {
946 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
947 let _ = enc.write_all(ser.into_inner().as_slice());
948 match enc.finish() {
949 Ok(buf) => {
950 local_req_builder = local_req_builder.body(buf);
951 }
952 Err(e) => return Err(datadog::Error::Io(e)),
953 }
954 }
955 "deflate" => {
956 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
957 let _ = enc.write_all(ser.into_inner().as_slice());
958 match enc.finish() {
959 Ok(buf) => {
960 local_req_builder = local_req_builder.body(buf);
961 }
962 Err(e) => return Err(datadog::Error::Io(e)),
963 }
964 }
965 "zstd1" => {
966 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
967 let _ = enc.write_all(ser.into_inner().as_slice());
968 match enc.finish() {
969 Ok(buf) => {
970 local_req_builder = local_req_builder.body(buf);
971 }
972 Err(e) => return Err(datadog::Error::Io(e)),
973 }
974 }
975 _ => {
976 local_req_builder = local_req_builder.body(ser.into_inner());
977 }
978 }
979 } else {
980 local_req_builder = local_req_builder.body(ser.into_inner());
981 }
982 }
983
984 local_req_builder = local_req_builder.headers(headers);
985 let local_req = local_req_builder.build()?;
986 log::debug!("request content: {:?}", local_req.body());
987 let local_resp = local_client.execute(local_req).await?;
988
989 let local_status = local_resp.status();
990 let local_content = local_resp.text().await?;
991 log::debug!("response content: {}", local_content);
992
993 if !local_status.is_client_error() && !local_status.is_server_error() {
994 match serde_json::from_str::<std::collections::BTreeMap<String, serde_json::Value>>(
995 &local_content,
996 ) {
997 Ok(e) => {
998 return Ok(datadog::ResponseContent {
999 status: local_status,
1000 content: local_content,
1001 entity: Some(e),
1002 })
1003 }
1004 Err(e) => return Err(datadog::Error::Serde(e)),
1005 };
1006 } else {
1007 let local_entity: Option<DeleteAWSAccountError> =
1008 serde_json::from_str(&local_content).ok();
1009 let local_error = datadog::ResponseContent {
1010 status: local_status,
1011 content: local_content,
1012 entity: local_entity,
1013 };
1014 Err(datadog::Error::ResponseError(local_error))
1015 }
1016 }
1017
1018 pub async fn delete_aws_event_bridge_source(
1020 &self,
1021 body: crate::datadogV1::model::AWSEventBridgeDeleteRequest,
1022 ) -> Result<
1023 crate::datadogV1::model::AWSEventBridgeDeleteResponse,
1024 datadog::Error<DeleteAWSEventBridgeSourceError>,
1025 > {
1026 match self
1027 .delete_aws_event_bridge_source_with_http_info(body)
1028 .await
1029 {
1030 Ok(response_content) => {
1031 if let Some(e) = response_content.entity {
1032 Ok(e)
1033 } else {
1034 Err(datadog::Error::Serde(serde::de::Error::custom(
1035 "response content was None",
1036 )))
1037 }
1038 }
1039 Err(err) => Err(err),
1040 }
1041 }
1042
1043 pub async fn delete_aws_event_bridge_source_with_http_info(
1045 &self,
1046 body: crate::datadogV1::model::AWSEventBridgeDeleteRequest,
1047 ) -> Result<
1048 datadog::ResponseContent<crate::datadogV1::model::AWSEventBridgeDeleteResponse>,
1049 datadog::Error<DeleteAWSEventBridgeSourceError>,
1050 > {
1051 let local_configuration = &self.config;
1052 let operation_id = "v1.delete_aws_event_bridge_source";
1053
1054 let local_client = &self.client;
1055
1056 let local_uri_str = format!(
1057 "{}/api/v1/integration/aws/event_bridge",
1058 local_configuration.get_operation_host(operation_id)
1059 );
1060 let mut local_req_builder =
1061 local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
1062
1063 let mut headers = HeaderMap::new();
1065 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1066 headers.insert("Accept", HeaderValue::from_static("application/json"));
1067
1068 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1070 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1071 Err(e) => {
1072 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1073 headers.insert(
1074 reqwest::header::USER_AGENT,
1075 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1076 )
1077 }
1078 };
1079
1080 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1082 headers.insert(
1083 "DD-API-KEY",
1084 HeaderValue::from_str(local_key.key.as_str())
1085 .expect("failed to parse DD-API-KEY header"),
1086 );
1087 };
1088 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1089 headers.insert(
1090 "DD-APPLICATION-KEY",
1091 HeaderValue::from_str(local_key.key.as_str())
1092 .expect("failed to parse DD-APPLICATION-KEY header"),
1093 );
1094 };
1095
1096 let output = Vec::new();
1098 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1099 if body.serialize(&mut ser).is_ok() {
1100 if let Some(content_encoding) = headers.get("Content-Encoding") {
1101 match content_encoding.to_str().unwrap_or_default() {
1102 "gzip" => {
1103 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1104 let _ = enc.write_all(ser.into_inner().as_slice());
1105 match enc.finish() {
1106 Ok(buf) => {
1107 local_req_builder = local_req_builder.body(buf);
1108 }
1109 Err(e) => return Err(datadog::Error::Io(e)),
1110 }
1111 }
1112 "deflate" => {
1113 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1114 let _ = enc.write_all(ser.into_inner().as_slice());
1115 match enc.finish() {
1116 Ok(buf) => {
1117 local_req_builder = local_req_builder.body(buf);
1118 }
1119 Err(e) => return Err(datadog::Error::Io(e)),
1120 }
1121 }
1122 "zstd1" => {
1123 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1124 let _ = enc.write_all(ser.into_inner().as_slice());
1125 match enc.finish() {
1126 Ok(buf) => {
1127 local_req_builder = local_req_builder.body(buf);
1128 }
1129 Err(e) => return Err(datadog::Error::Io(e)),
1130 }
1131 }
1132 _ => {
1133 local_req_builder = local_req_builder.body(ser.into_inner());
1134 }
1135 }
1136 } else {
1137 local_req_builder = local_req_builder.body(ser.into_inner());
1138 }
1139 }
1140
1141 local_req_builder = local_req_builder.headers(headers);
1142 let local_req = local_req_builder.build()?;
1143 log::debug!("request content: {:?}", local_req.body());
1144 let local_resp = local_client.execute(local_req).await?;
1145
1146 let local_status = local_resp.status();
1147 let local_content = local_resp.text().await?;
1148 log::debug!("response content: {}", local_content);
1149
1150 if !local_status.is_client_error() && !local_status.is_server_error() {
1151 match serde_json::from_str::<crate::datadogV1::model::AWSEventBridgeDeleteResponse>(
1152 &local_content,
1153 ) {
1154 Ok(e) => {
1155 return Ok(datadog::ResponseContent {
1156 status: local_status,
1157 content: local_content,
1158 entity: Some(e),
1159 })
1160 }
1161 Err(e) => return Err(datadog::Error::Serde(e)),
1162 };
1163 } else {
1164 let local_entity: Option<DeleteAWSEventBridgeSourceError> =
1165 serde_json::from_str(&local_content).ok();
1166 let local_error = datadog::ResponseContent {
1167 status: local_status,
1168 content: local_content,
1169 entity: local_entity,
1170 };
1171 Err(datadog::Error::ResponseError(local_error))
1172 }
1173 }
1174
1175 pub async fn delete_aws_tag_filter(
1177 &self,
1178 body: crate::datadogV1::model::AWSTagFilterDeleteRequest,
1179 ) -> Result<
1180 std::collections::BTreeMap<String, serde_json::Value>,
1181 datadog::Error<DeleteAWSTagFilterError>,
1182 > {
1183 match self.delete_aws_tag_filter_with_http_info(body).await {
1184 Ok(response_content) => {
1185 if let Some(e) = response_content.entity {
1186 Ok(e)
1187 } else {
1188 Err(datadog::Error::Serde(serde::de::Error::custom(
1189 "response content was None",
1190 )))
1191 }
1192 }
1193 Err(err) => Err(err),
1194 }
1195 }
1196
1197 pub async fn delete_aws_tag_filter_with_http_info(
1199 &self,
1200 body: crate::datadogV1::model::AWSTagFilterDeleteRequest,
1201 ) -> Result<
1202 datadog::ResponseContent<std::collections::BTreeMap<String, serde_json::Value>>,
1203 datadog::Error<DeleteAWSTagFilterError>,
1204 > {
1205 let local_configuration = &self.config;
1206 let operation_id = "v1.delete_aws_tag_filter";
1207
1208 let local_client = &self.client;
1209
1210 let local_uri_str = format!(
1211 "{}/api/v1/integration/aws/filtering",
1212 local_configuration.get_operation_host(operation_id)
1213 );
1214 let mut local_req_builder =
1215 local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
1216
1217 let mut headers = HeaderMap::new();
1219 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1220 headers.insert("Accept", HeaderValue::from_static("application/json"));
1221
1222 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1224 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1225 Err(e) => {
1226 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1227 headers.insert(
1228 reqwest::header::USER_AGENT,
1229 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1230 )
1231 }
1232 };
1233
1234 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1236 headers.insert(
1237 "DD-API-KEY",
1238 HeaderValue::from_str(local_key.key.as_str())
1239 .expect("failed to parse DD-API-KEY header"),
1240 );
1241 };
1242 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1243 headers.insert(
1244 "DD-APPLICATION-KEY",
1245 HeaderValue::from_str(local_key.key.as_str())
1246 .expect("failed to parse DD-APPLICATION-KEY header"),
1247 );
1248 };
1249
1250 let output = Vec::new();
1252 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1253 if body.serialize(&mut ser).is_ok() {
1254 if let Some(content_encoding) = headers.get("Content-Encoding") {
1255 match content_encoding.to_str().unwrap_or_default() {
1256 "gzip" => {
1257 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1258 let _ = enc.write_all(ser.into_inner().as_slice());
1259 match enc.finish() {
1260 Ok(buf) => {
1261 local_req_builder = local_req_builder.body(buf);
1262 }
1263 Err(e) => return Err(datadog::Error::Io(e)),
1264 }
1265 }
1266 "deflate" => {
1267 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1268 let _ = enc.write_all(ser.into_inner().as_slice());
1269 match enc.finish() {
1270 Ok(buf) => {
1271 local_req_builder = local_req_builder.body(buf);
1272 }
1273 Err(e) => return Err(datadog::Error::Io(e)),
1274 }
1275 }
1276 "zstd1" => {
1277 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1278 let _ = enc.write_all(ser.into_inner().as_slice());
1279 match enc.finish() {
1280 Ok(buf) => {
1281 local_req_builder = local_req_builder.body(buf);
1282 }
1283 Err(e) => return Err(datadog::Error::Io(e)),
1284 }
1285 }
1286 _ => {
1287 local_req_builder = local_req_builder.body(ser.into_inner());
1288 }
1289 }
1290 } else {
1291 local_req_builder = local_req_builder.body(ser.into_inner());
1292 }
1293 }
1294
1295 local_req_builder = local_req_builder.headers(headers);
1296 let local_req = local_req_builder.build()?;
1297 log::debug!("request content: {:?}", local_req.body());
1298 let local_resp = local_client.execute(local_req).await?;
1299
1300 let local_status = local_resp.status();
1301 let local_content = local_resp.text().await?;
1302 log::debug!("response content: {}", local_content);
1303
1304 if !local_status.is_client_error() && !local_status.is_server_error() {
1305 match serde_json::from_str::<std::collections::BTreeMap<String, serde_json::Value>>(
1306 &local_content,
1307 ) {
1308 Ok(e) => {
1309 return Ok(datadog::ResponseContent {
1310 status: local_status,
1311 content: local_content,
1312 entity: Some(e),
1313 })
1314 }
1315 Err(e) => return Err(datadog::Error::Serde(e)),
1316 };
1317 } else {
1318 let local_entity: Option<DeleteAWSTagFilterError> =
1319 serde_json::from_str(&local_content).ok();
1320 let local_error = datadog::ResponseContent {
1321 status: local_status,
1322 content: local_content,
1323 entity: local_entity,
1324 };
1325 Err(datadog::Error::ResponseError(local_error))
1326 }
1327 }
1328
1329 pub async fn list_aws_accounts(
1331 &self,
1332 params: ListAWSAccountsOptionalParams,
1333 ) -> Result<crate::datadogV1::model::AWSAccountListResponse, datadog::Error<ListAWSAccountsError>>
1334 {
1335 match self.list_aws_accounts_with_http_info(params).await {
1336 Ok(response_content) => {
1337 if let Some(e) = response_content.entity {
1338 Ok(e)
1339 } else {
1340 Err(datadog::Error::Serde(serde::de::Error::custom(
1341 "response content was None",
1342 )))
1343 }
1344 }
1345 Err(err) => Err(err),
1346 }
1347 }
1348
1349 pub async fn list_aws_accounts_with_http_info(
1351 &self,
1352 params: ListAWSAccountsOptionalParams,
1353 ) -> Result<
1354 datadog::ResponseContent<crate::datadogV1::model::AWSAccountListResponse>,
1355 datadog::Error<ListAWSAccountsError>,
1356 > {
1357 let local_configuration = &self.config;
1358 let operation_id = "v1.list_aws_accounts";
1359
1360 let account_id = params.account_id;
1362 let role_name = params.role_name;
1363 let access_key_id = params.access_key_id;
1364
1365 let local_client = &self.client;
1366
1367 let local_uri_str = format!(
1368 "{}/api/v1/integration/aws",
1369 local_configuration.get_operation_host(operation_id)
1370 );
1371 let mut local_req_builder =
1372 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1373
1374 if let Some(ref local_query_param) = account_id {
1375 local_req_builder =
1376 local_req_builder.query(&[("account_id", &local_query_param.to_string())]);
1377 };
1378 if let Some(ref local_query_param) = role_name {
1379 local_req_builder =
1380 local_req_builder.query(&[("role_name", &local_query_param.to_string())]);
1381 };
1382 if let Some(ref local_query_param) = access_key_id {
1383 local_req_builder =
1384 local_req_builder.query(&[("access_key_id", &local_query_param.to_string())]);
1385 };
1386
1387 let mut headers = HeaderMap::new();
1389 headers.insert("Accept", HeaderValue::from_static("application/json"));
1390
1391 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1393 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1394 Err(e) => {
1395 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1396 headers.insert(
1397 reqwest::header::USER_AGENT,
1398 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1399 )
1400 }
1401 };
1402
1403 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1405 headers.insert(
1406 "DD-API-KEY",
1407 HeaderValue::from_str(local_key.key.as_str())
1408 .expect("failed to parse DD-API-KEY header"),
1409 );
1410 };
1411 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1412 headers.insert(
1413 "DD-APPLICATION-KEY",
1414 HeaderValue::from_str(local_key.key.as_str())
1415 .expect("failed to parse DD-APPLICATION-KEY header"),
1416 );
1417 };
1418
1419 local_req_builder = local_req_builder.headers(headers);
1420 let local_req = local_req_builder.build()?;
1421 log::debug!("request content: {:?}", local_req.body());
1422 let local_resp = local_client.execute(local_req).await?;
1423
1424 let local_status = local_resp.status();
1425 let local_content = local_resp.text().await?;
1426 log::debug!("response content: {}", local_content);
1427
1428 if !local_status.is_client_error() && !local_status.is_server_error() {
1429 match serde_json::from_str::<crate::datadogV1::model::AWSAccountListResponse>(
1430 &local_content,
1431 ) {
1432 Ok(e) => {
1433 return Ok(datadog::ResponseContent {
1434 status: local_status,
1435 content: local_content,
1436 entity: Some(e),
1437 })
1438 }
1439 Err(e) => return Err(datadog::Error::Serde(e)),
1440 };
1441 } else {
1442 let local_entity: Option<ListAWSAccountsError> =
1443 serde_json::from_str(&local_content).ok();
1444 let local_error = datadog::ResponseContent {
1445 status: local_status,
1446 content: local_content,
1447 entity: local_entity,
1448 };
1449 Err(datadog::Error::ResponseError(local_error))
1450 }
1451 }
1452
1453 pub async fn list_aws_event_bridge_sources(
1455 &self,
1456 ) -> Result<
1457 crate::datadogV1::model::AWSEventBridgeListResponse,
1458 datadog::Error<ListAWSEventBridgeSourcesError>,
1459 > {
1460 match self.list_aws_event_bridge_sources_with_http_info().await {
1461 Ok(response_content) => {
1462 if let Some(e) = response_content.entity {
1463 Ok(e)
1464 } else {
1465 Err(datadog::Error::Serde(serde::de::Error::custom(
1466 "response content was None",
1467 )))
1468 }
1469 }
1470 Err(err) => Err(err),
1471 }
1472 }
1473
1474 pub async fn list_aws_event_bridge_sources_with_http_info(
1476 &self,
1477 ) -> Result<
1478 datadog::ResponseContent<crate::datadogV1::model::AWSEventBridgeListResponse>,
1479 datadog::Error<ListAWSEventBridgeSourcesError>,
1480 > {
1481 let local_configuration = &self.config;
1482 let operation_id = "v1.list_aws_event_bridge_sources";
1483
1484 let local_client = &self.client;
1485
1486 let local_uri_str = format!(
1487 "{}/api/v1/integration/aws/event_bridge",
1488 local_configuration.get_operation_host(operation_id)
1489 );
1490 let mut local_req_builder =
1491 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1492
1493 let mut headers = HeaderMap::new();
1495 headers.insert("Accept", HeaderValue::from_static("application/json"));
1496
1497 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1499 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1500 Err(e) => {
1501 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1502 headers.insert(
1503 reqwest::header::USER_AGENT,
1504 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1505 )
1506 }
1507 };
1508
1509 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1511 headers.insert(
1512 "DD-API-KEY",
1513 HeaderValue::from_str(local_key.key.as_str())
1514 .expect("failed to parse DD-API-KEY header"),
1515 );
1516 };
1517 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1518 headers.insert(
1519 "DD-APPLICATION-KEY",
1520 HeaderValue::from_str(local_key.key.as_str())
1521 .expect("failed to parse DD-APPLICATION-KEY header"),
1522 );
1523 };
1524
1525 local_req_builder = local_req_builder.headers(headers);
1526 let local_req = local_req_builder.build()?;
1527 log::debug!("request content: {:?}", local_req.body());
1528 let local_resp = local_client.execute(local_req).await?;
1529
1530 let local_status = local_resp.status();
1531 let local_content = local_resp.text().await?;
1532 log::debug!("response content: {}", local_content);
1533
1534 if !local_status.is_client_error() && !local_status.is_server_error() {
1535 match serde_json::from_str::<crate::datadogV1::model::AWSEventBridgeListResponse>(
1536 &local_content,
1537 ) {
1538 Ok(e) => {
1539 return Ok(datadog::ResponseContent {
1540 status: local_status,
1541 content: local_content,
1542 entity: Some(e),
1543 })
1544 }
1545 Err(e) => return Err(datadog::Error::Serde(e)),
1546 };
1547 } else {
1548 let local_entity: Option<ListAWSEventBridgeSourcesError> =
1549 serde_json::from_str(&local_content).ok();
1550 let local_error = datadog::ResponseContent {
1551 status: local_status,
1552 content: local_content,
1553 entity: local_entity,
1554 };
1555 Err(datadog::Error::ResponseError(local_error))
1556 }
1557 }
1558
1559 pub async fn list_aws_tag_filters(
1561 &self,
1562 account_id: String,
1563 ) -> Result<
1564 crate::datadogV1::model::AWSTagFilterListResponse,
1565 datadog::Error<ListAWSTagFiltersError>,
1566 > {
1567 match self.list_aws_tag_filters_with_http_info(account_id).await {
1568 Ok(response_content) => {
1569 if let Some(e) = response_content.entity {
1570 Ok(e)
1571 } else {
1572 Err(datadog::Error::Serde(serde::de::Error::custom(
1573 "response content was None",
1574 )))
1575 }
1576 }
1577 Err(err) => Err(err),
1578 }
1579 }
1580
1581 pub async fn list_aws_tag_filters_with_http_info(
1583 &self,
1584 account_id: String,
1585 ) -> Result<
1586 datadog::ResponseContent<crate::datadogV1::model::AWSTagFilterListResponse>,
1587 datadog::Error<ListAWSTagFiltersError>,
1588 > {
1589 let local_configuration = &self.config;
1590 let operation_id = "v1.list_aws_tag_filters";
1591
1592 let local_client = &self.client;
1593
1594 let local_uri_str = format!(
1595 "{}/api/v1/integration/aws/filtering",
1596 local_configuration.get_operation_host(operation_id)
1597 );
1598 let mut local_req_builder =
1599 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1600
1601 local_req_builder = local_req_builder.query(&[("account_id", &account_id.to_string())]);
1602
1603 let mut headers = HeaderMap::new();
1605 headers.insert("Accept", HeaderValue::from_static("application/json"));
1606
1607 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1609 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1610 Err(e) => {
1611 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1612 headers.insert(
1613 reqwest::header::USER_AGENT,
1614 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1615 )
1616 }
1617 };
1618
1619 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1621 headers.insert(
1622 "DD-API-KEY",
1623 HeaderValue::from_str(local_key.key.as_str())
1624 .expect("failed to parse DD-API-KEY header"),
1625 );
1626 };
1627 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1628 headers.insert(
1629 "DD-APPLICATION-KEY",
1630 HeaderValue::from_str(local_key.key.as_str())
1631 .expect("failed to parse DD-APPLICATION-KEY header"),
1632 );
1633 };
1634
1635 local_req_builder = local_req_builder.headers(headers);
1636 let local_req = local_req_builder.build()?;
1637 log::debug!("request content: {:?}", local_req.body());
1638 let local_resp = local_client.execute(local_req).await?;
1639
1640 let local_status = local_resp.status();
1641 let local_content = local_resp.text().await?;
1642 log::debug!("response content: {}", local_content);
1643
1644 if !local_status.is_client_error() && !local_status.is_server_error() {
1645 match serde_json::from_str::<crate::datadogV1::model::AWSTagFilterListResponse>(
1646 &local_content,
1647 ) {
1648 Ok(e) => {
1649 return Ok(datadog::ResponseContent {
1650 status: local_status,
1651 content: local_content,
1652 entity: Some(e),
1653 })
1654 }
1655 Err(e) => return Err(datadog::Error::Serde(e)),
1656 };
1657 } else {
1658 let local_entity: Option<ListAWSTagFiltersError> =
1659 serde_json::from_str(&local_content).ok();
1660 let local_error = datadog::ResponseContent {
1661 status: local_status,
1662 content: local_content,
1663 entity: local_entity,
1664 };
1665 Err(datadog::Error::ResponseError(local_error))
1666 }
1667 }
1668
1669 pub async fn list_available_aws_namespaces(
1671 &self,
1672 ) -> Result<Vec<String>, datadog::Error<ListAvailableAWSNamespacesError>> {
1673 match self.list_available_aws_namespaces_with_http_info().await {
1674 Ok(response_content) => {
1675 if let Some(e) = response_content.entity {
1676 Ok(e)
1677 } else {
1678 Err(datadog::Error::Serde(serde::de::Error::custom(
1679 "response content was None",
1680 )))
1681 }
1682 }
1683 Err(err) => Err(err),
1684 }
1685 }
1686
1687 pub async fn list_available_aws_namespaces_with_http_info(
1689 &self,
1690 ) -> Result<
1691 datadog::ResponseContent<Vec<String>>,
1692 datadog::Error<ListAvailableAWSNamespacesError>,
1693 > {
1694 let local_configuration = &self.config;
1695 let operation_id = "v1.list_available_aws_namespaces";
1696
1697 let local_client = &self.client;
1698
1699 let local_uri_str = format!(
1700 "{}/api/v1/integration/aws/available_namespace_rules",
1701 local_configuration.get_operation_host(operation_id)
1702 );
1703 let mut local_req_builder =
1704 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1705
1706 let mut headers = HeaderMap::new();
1708 headers.insert("Accept", HeaderValue::from_static("application/json"));
1709
1710 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1712 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1713 Err(e) => {
1714 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1715 headers.insert(
1716 reqwest::header::USER_AGENT,
1717 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1718 )
1719 }
1720 };
1721
1722 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1724 headers.insert(
1725 "DD-API-KEY",
1726 HeaderValue::from_str(local_key.key.as_str())
1727 .expect("failed to parse DD-API-KEY header"),
1728 );
1729 };
1730 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1731 headers.insert(
1732 "DD-APPLICATION-KEY",
1733 HeaderValue::from_str(local_key.key.as_str())
1734 .expect("failed to parse DD-APPLICATION-KEY header"),
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::<Vec<String>>(&local_content) {
1749 Ok(e) => {
1750 return Ok(datadog::ResponseContent {
1751 status: local_status,
1752 content: local_content,
1753 entity: Some(e),
1754 })
1755 }
1756 Err(e) => return Err(datadog::Error::Serde(e)),
1757 };
1758 } else {
1759 let local_entity: Option<ListAvailableAWSNamespacesError> =
1760 serde_json::from_str(&local_content).ok();
1761 let local_error = datadog::ResponseContent {
1762 status: local_status,
1763 content: local_content,
1764 entity: local_entity,
1765 };
1766 Err(datadog::Error::ResponseError(local_error))
1767 }
1768 }
1769
1770 pub async fn update_aws_account(
1772 &self,
1773 body: crate::datadogV1::model::AWSAccount,
1774 params: UpdateAWSAccountOptionalParams,
1775 ) -> Result<
1776 std::collections::BTreeMap<String, serde_json::Value>,
1777 datadog::Error<UpdateAWSAccountError>,
1778 > {
1779 match self.update_aws_account_with_http_info(body, params).await {
1780 Ok(response_content) => {
1781 if let Some(e) = response_content.entity {
1782 Ok(e)
1783 } else {
1784 Err(datadog::Error::Serde(serde::de::Error::custom(
1785 "response content was None",
1786 )))
1787 }
1788 }
1789 Err(err) => Err(err),
1790 }
1791 }
1792
1793 pub async fn update_aws_account_with_http_info(
1795 &self,
1796 body: crate::datadogV1::model::AWSAccount,
1797 params: UpdateAWSAccountOptionalParams,
1798 ) -> Result<
1799 datadog::ResponseContent<std::collections::BTreeMap<String, serde_json::Value>>,
1800 datadog::Error<UpdateAWSAccountError>,
1801 > {
1802 let local_configuration = &self.config;
1803 let operation_id = "v1.update_aws_account";
1804
1805 let account_id = params.account_id;
1807 let role_name = params.role_name;
1808 let access_key_id = params.access_key_id;
1809
1810 let local_client = &self.client;
1811
1812 let local_uri_str = format!(
1813 "{}/api/v1/integration/aws",
1814 local_configuration.get_operation_host(operation_id)
1815 );
1816 let mut local_req_builder =
1817 local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
1818
1819 if let Some(ref local_query_param) = account_id {
1820 local_req_builder =
1821 local_req_builder.query(&[("account_id", &local_query_param.to_string())]);
1822 };
1823 if let Some(ref local_query_param) = role_name {
1824 local_req_builder =
1825 local_req_builder.query(&[("role_name", &local_query_param.to_string())]);
1826 };
1827 if let Some(ref local_query_param) = access_key_id {
1828 local_req_builder =
1829 local_req_builder.query(&[("access_key_id", &local_query_param.to_string())]);
1830 };
1831
1832 let mut headers = HeaderMap::new();
1834 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1835 headers.insert("Accept", HeaderValue::from_static("application/json"));
1836
1837 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1839 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1840 Err(e) => {
1841 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1842 headers.insert(
1843 reqwest::header::USER_AGENT,
1844 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1845 )
1846 }
1847 };
1848
1849 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1851 headers.insert(
1852 "DD-API-KEY",
1853 HeaderValue::from_str(local_key.key.as_str())
1854 .expect("failed to parse DD-API-KEY header"),
1855 );
1856 };
1857 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1858 headers.insert(
1859 "DD-APPLICATION-KEY",
1860 HeaderValue::from_str(local_key.key.as_str())
1861 .expect("failed to parse DD-APPLICATION-KEY header"),
1862 );
1863 };
1864
1865 let output = Vec::new();
1867 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1868 if body.serialize(&mut ser).is_ok() {
1869 if let Some(content_encoding) = headers.get("Content-Encoding") {
1870 match content_encoding.to_str().unwrap_or_default() {
1871 "gzip" => {
1872 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
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 "deflate" => {
1882 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1883 let _ = enc.write_all(ser.into_inner().as_slice());
1884 match enc.finish() {
1885 Ok(buf) => {
1886 local_req_builder = local_req_builder.body(buf);
1887 }
1888 Err(e) => return Err(datadog::Error::Io(e)),
1889 }
1890 }
1891 "zstd1" => {
1892 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1893 let _ = enc.write_all(ser.into_inner().as_slice());
1894 match enc.finish() {
1895 Ok(buf) => {
1896 local_req_builder = local_req_builder.body(buf);
1897 }
1898 Err(e) => return Err(datadog::Error::Io(e)),
1899 }
1900 }
1901 _ => {
1902 local_req_builder = local_req_builder.body(ser.into_inner());
1903 }
1904 }
1905 } else {
1906 local_req_builder = local_req_builder.body(ser.into_inner());
1907 }
1908 }
1909
1910 local_req_builder = local_req_builder.headers(headers);
1911 let local_req = local_req_builder.build()?;
1912 log::debug!("request content: {:?}", local_req.body());
1913 let local_resp = local_client.execute(local_req).await?;
1914
1915 let local_status = local_resp.status();
1916 let local_content = local_resp.text().await?;
1917 log::debug!("response content: {}", local_content);
1918
1919 if !local_status.is_client_error() && !local_status.is_server_error() {
1920 match serde_json::from_str::<std::collections::BTreeMap<String, serde_json::Value>>(
1921 &local_content,
1922 ) {
1923 Ok(e) => {
1924 return Ok(datadog::ResponseContent {
1925 status: local_status,
1926 content: local_content,
1927 entity: Some(e),
1928 })
1929 }
1930 Err(e) => return Err(datadog::Error::Serde(e)),
1931 };
1932 } else {
1933 let local_entity: Option<UpdateAWSAccountError> =
1934 serde_json::from_str(&local_content).ok();
1935 let local_error = datadog::ResponseContent {
1936 status: local_status,
1937 content: local_content,
1938 entity: local_entity,
1939 };
1940 Err(datadog::Error::ResponseError(local_error))
1941 }
1942 }
1943}