datadog_api_client/datadogV2/api/
api_aws_integration.rs

1// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2// This product includes software developed at Datadog (https://www.datadoghq.com/).
3// Copyright 2019-Present Datadog, Inc.
4use crate::datadog;
5use flate2::{
6    write::{GzEncoder, ZlibEncoder},
7    Compression,
8};
9use reqwest::header::{HeaderMap, HeaderValue};
10use serde::{Deserialize, Serialize};
11use std::io::Write;
12
13/// ListAWSAccountsOptionalParams is a struct for passing parameters to the method [`AWSIntegrationAPI::list_aws_accounts`]
14#[non_exhaustive]
15#[derive(Clone, Default, Debug)]
16pub struct ListAWSAccountsOptionalParams {
17    /// Optional query parameter to filter accounts by AWS Account ID. If not provided, all accounts are returned.
18    pub aws_account_id: Option<String>,
19}
20
21impl ListAWSAccountsOptionalParams {
22    /// Optional query parameter to filter accounts by AWS Account ID. If not provided, all accounts are returned.
23    pub fn aws_account_id(mut self, value: String) -> Self {
24        self.aws_account_id = Some(value);
25        self
26    }
27}
28
29/// CreateAWSAccountError is a struct for typed errors of method [`AWSIntegrationAPI::create_aws_account`]
30#[derive(Debug, Clone, Serialize, Deserialize)]
31#[serde(untagged)]
32pub enum CreateAWSAccountError {
33    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
34    UnknownValue(serde_json::Value),
35}
36
37/// CreateNewAWSExternalIDError is a struct for typed errors of method [`AWSIntegrationAPI::create_new_aws_external_id`]
38#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum CreateNewAWSExternalIDError {
41    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
42    UnknownValue(serde_json::Value),
43}
44
45/// DeleteAWSAccountError is a struct for typed errors of method [`AWSIntegrationAPI::delete_aws_account`]
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum DeleteAWSAccountError {
49    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
50    UnknownValue(serde_json::Value),
51}
52
53/// GetAWSAccountError is a struct for typed errors of method [`AWSIntegrationAPI::get_aws_account`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetAWSAccountError {
57    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
58    UnknownValue(serde_json::Value),
59}
60
61/// GetAWSIntegrationIAMPermissionsError is a struct for typed errors of method [`AWSIntegrationAPI::get_aws_integration_iam_permissions`]
62#[derive(Debug, Clone, Serialize, Deserialize)]
63#[serde(untagged)]
64pub enum GetAWSIntegrationIAMPermissionsError {
65    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
66    UnknownValue(serde_json::Value),
67}
68
69/// GetAWSIntegrationIAMPermissionsResourceCollectionError is a struct for typed errors of method [`AWSIntegrationAPI::get_aws_integration_iam_permissions_resource_collection`]
70#[derive(Debug, Clone, Serialize, Deserialize)]
71#[serde(untagged)]
72pub enum GetAWSIntegrationIAMPermissionsResourceCollectionError {
73    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
74    UnknownValue(serde_json::Value),
75}
76
77/// GetAWSIntegrationIAMPermissionsStandardError is a struct for typed errors of method [`AWSIntegrationAPI::get_aws_integration_iam_permissions_standard`]
78#[derive(Debug, Clone, Serialize, Deserialize)]
79#[serde(untagged)]
80pub enum GetAWSIntegrationIAMPermissionsStandardError {
81    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
82    UnknownValue(serde_json::Value),
83}
84
85/// ListAWSAccountsError is a struct for typed errors of method [`AWSIntegrationAPI::list_aws_accounts`]
86#[derive(Debug, Clone, Serialize, Deserialize)]
87#[serde(untagged)]
88pub enum ListAWSAccountsError {
89    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
90    UnknownValue(serde_json::Value),
91}
92
93/// ListAWSNamespacesError is a struct for typed errors of method [`AWSIntegrationAPI::list_aws_namespaces`]
94#[derive(Debug, Clone, Serialize, Deserialize)]
95#[serde(untagged)]
96pub enum ListAWSNamespacesError {
97    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
98    UnknownValue(serde_json::Value),
99}
100
101/// UpdateAWSAccountError is a struct for typed errors of method [`AWSIntegrationAPI::update_aws_account`]
102#[derive(Debug, Clone, Serialize, Deserialize)]
103#[serde(untagged)]
104pub enum UpdateAWSAccountError {
105    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
106    UnknownValue(serde_json::Value),
107}
108
109/// Configure your Datadog-AWS integration directly through the Datadog API.
110/// For more information, see the [AWS integration page](<https://docs.datadoghq.com/integrations/amazon_web_services>).
111#[derive(Debug, Clone)]
112pub struct AWSIntegrationAPI {
113    config: datadog::Configuration,
114    client: reqwest_middleware::ClientWithMiddleware,
115}
116
117impl Default for AWSIntegrationAPI {
118    fn default() -> Self {
119        Self::with_config(datadog::Configuration::default())
120    }
121}
122
123impl AWSIntegrationAPI {
124    pub fn new() -> Self {
125        Self::default()
126    }
127    pub fn with_config(config: datadog::Configuration) -> Self {
128        let mut reqwest_client_builder = reqwest::Client::builder();
129
130        if let Some(proxy_url) = &config.proxy_url {
131            let proxy = reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL");
132            reqwest_client_builder = reqwest_client_builder.proxy(proxy);
133        }
134
135        let mut middleware_client_builder =
136            reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap());
137
138        if config.enable_retry {
139            struct RetryableStatus;
140            impl reqwest_retry::RetryableStrategy for RetryableStatus {
141                fn handle(
142                    &self,
143                    res: &Result<reqwest::Response, reqwest_middleware::Error>,
144                ) -> Option<reqwest_retry::Retryable> {
145                    match res {
146                        Ok(success) => reqwest_retry::default_on_request_success(success),
147                        Err(_) => None,
148                    }
149                }
150            }
151            let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder()
152                .build_with_max_retries(config.max_retries);
153
154            let retry_middleware =
155                reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy(
156                    backoff_policy,
157                    RetryableStatus,
158                );
159
160            middleware_client_builder = middleware_client_builder.with(retry_middleware);
161        }
162
163        let client = middleware_client_builder.build();
164
165        Self { config, client }
166    }
167
168    pub fn with_client_and_config(
169        config: datadog::Configuration,
170        client: reqwest_middleware::ClientWithMiddleware,
171    ) -> Self {
172        Self { config, client }
173    }
174
175    /// Create a new AWS Account Integration Config.
176    pub async fn create_aws_account(
177        &self,
178        body: crate::datadogV2::model::AWSAccountCreateRequest,
179    ) -> Result<crate::datadogV2::model::AWSAccountResponse, datadog::Error<CreateAWSAccountError>>
180    {
181        match self.create_aws_account_with_http_info(body).await {
182            Ok(response_content) => {
183                if let Some(e) = response_content.entity {
184                    Ok(e)
185                } else {
186                    Err(datadog::Error::Serde(serde::de::Error::custom(
187                        "response content was None",
188                    )))
189                }
190            }
191            Err(err) => Err(err),
192        }
193    }
194
195    /// Create a new AWS Account Integration Config.
196    pub async fn create_aws_account_with_http_info(
197        &self,
198        body: crate::datadogV2::model::AWSAccountCreateRequest,
199    ) -> Result<
200        datadog::ResponseContent<crate::datadogV2::model::AWSAccountResponse>,
201        datadog::Error<CreateAWSAccountError>,
202    > {
203        let local_configuration = &self.config;
204        let operation_id = "v2.create_aws_account";
205
206        let local_client = &self.client;
207
208        let local_uri_str = format!(
209            "{}/api/v2/integration/aws/accounts",
210            local_configuration.get_operation_host(operation_id)
211        );
212        let mut local_req_builder =
213            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
214
215        // build headers
216        let mut headers = HeaderMap::new();
217        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
218        headers.insert("Accept", HeaderValue::from_static("application/json"));
219
220        // build user agent
221        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
222            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
223            Err(e) => {
224                log::warn!("Failed to parse user agent header: {e}, falling back to default");
225                headers.insert(
226                    reqwest::header::USER_AGENT,
227                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
228                )
229            }
230        };
231
232        // build auth
233        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
234            headers.insert(
235                "DD-API-KEY",
236                HeaderValue::from_str(local_key.key.as_str())
237                    .expect("failed to parse DD-API-KEY header"),
238            );
239        };
240        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
241            headers.insert(
242                "DD-APPLICATION-KEY",
243                HeaderValue::from_str(local_key.key.as_str())
244                    .expect("failed to parse DD-APPLICATION-KEY header"),
245            );
246        };
247
248        // build body parameters
249        let output = Vec::new();
250        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
251        if body.serialize(&mut ser).is_ok() {
252            if let Some(content_encoding) = headers.get("Content-Encoding") {
253                match content_encoding.to_str().unwrap_or_default() {
254                    "gzip" => {
255                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
256                        let _ = enc.write_all(ser.into_inner().as_slice());
257                        match enc.finish() {
258                            Ok(buf) => {
259                                local_req_builder = local_req_builder.body(buf);
260                            }
261                            Err(e) => return Err(datadog::Error::Io(e)),
262                        }
263                    }
264                    "deflate" => {
265                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
266                        let _ = enc.write_all(ser.into_inner().as_slice());
267                        match enc.finish() {
268                            Ok(buf) => {
269                                local_req_builder = local_req_builder.body(buf);
270                            }
271                            Err(e) => return Err(datadog::Error::Io(e)),
272                        }
273                    }
274                    "zstd1" => {
275                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
276                        let _ = enc.write_all(ser.into_inner().as_slice());
277                        match enc.finish() {
278                            Ok(buf) => {
279                                local_req_builder = local_req_builder.body(buf);
280                            }
281                            Err(e) => return Err(datadog::Error::Io(e)),
282                        }
283                    }
284                    _ => {
285                        local_req_builder = local_req_builder.body(ser.into_inner());
286                    }
287                }
288            } else {
289                local_req_builder = local_req_builder.body(ser.into_inner());
290            }
291        }
292
293        local_req_builder = local_req_builder.headers(headers);
294        let local_req = local_req_builder.build()?;
295        log::debug!("request content: {:?}", local_req.body());
296        let local_resp = local_client.execute(local_req).await?;
297
298        let local_status = local_resp.status();
299        let local_content = local_resp.text().await?;
300        log::debug!("response content: {}", local_content);
301
302        if !local_status.is_client_error() && !local_status.is_server_error() {
303            match serde_json::from_str::<crate::datadogV2::model::AWSAccountResponse>(
304                &local_content,
305            ) {
306                Ok(e) => {
307                    return Ok(datadog::ResponseContent {
308                        status: local_status,
309                        content: local_content,
310                        entity: Some(e),
311                    })
312                }
313                Err(e) => return Err(datadog::Error::Serde(e)),
314            };
315        } else {
316            let local_entity: Option<CreateAWSAccountError> =
317                serde_json::from_str(&local_content).ok();
318            let local_error = datadog::ResponseContent {
319                status: local_status,
320                content: local_content,
321                entity: local_entity,
322            };
323            Err(datadog::Error::ResponseError(local_error))
324        }
325    }
326
327    /// Generate a new external ID for AWS role-based authentication.
328    pub async fn create_new_aws_external_id(
329        &self,
330    ) -> Result<
331        crate::datadogV2::model::AWSNewExternalIDResponse,
332        datadog::Error<CreateNewAWSExternalIDError>,
333    > {
334        match self.create_new_aws_external_id_with_http_info().await {
335            Ok(response_content) => {
336                if let Some(e) = response_content.entity {
337                    Ok(e)
338                } else {
339                    Err(datadog::Error::Serde(serde::de::Error::custom(
340                        "response content was None",
341                    )))
342                }
343            }
344            Err(err) => Err(err),
345        }
346    }
347
348    /// Generate a new external ID for AWS role-based authentication.
349    pub async fn create_new_aws_external_id_with_http_info(
350        &self,
351    ) -> Result<
352        datadog::ResponseContent<crate::datadogV2::model::AWSNewExternalIDResponse>,
353        datadog::Error<CreateNewAWSExternalIDError>,
354    > {
355        let local_configuration = &self.config;
356        let operation_id = "v2.create_new_aws_external_id";
357
358        let local_client = &self.client;
359
360        let local_uri_str = format!(
361            "{}/api/v2/integration/aws/generate_new_external_id",
362            local_configuration.get_operation_host(operation_id)
363        );
364        let mut local_req_builder =
365            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
366
367        // build headers
368        let mut headers = HeaderMap::new();
369        headers.insert("Accept", HeaderValue::from_static("application/json"));
370
371        // build user agent
372        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
373            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
374            Err(e) => {
375                log::warn!("Failed to parse user agent header: {e}, falling back to default");
376                headers.insert(
377                    reqwest::header::USER_AGENT,
378                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
379                )
380            }
381        };
382
383        // build auth
384        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
385            headers.insert(
386                "DD-API-KEY",
387                HeaderValue::from_str(local_key.key.as_str())
388                    .expect("failed to parse DD-API-KEY header"),
389            );
390        };
391        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
392            headers.insert(
393                "DD-APPLICATION-KEY",
394                HeaderValue::from_str(local_key.key.as_str())
395                    .expect("failed to parse DD-APPLICATION-KEY header"),
396            );
397        };
398
399        local_req_builder = local_req_builder.headers(headers);
400        let local_req = local_req_builder.build()?;
401        log::debug!("request content: {:?}", local_req.body());
402        let local_resp = local_client.execute(local_req).await?;
403
404        let local_status = local_resp.status();
405        let local_content = local_resp.text().await?;
406        log::debug!("response content: {}", local_content);
407
408        if !local_status.is_client_error() && !local_status.is_server_error() {
409            match serde_json::from_str::<crate::datadogV2::model::AWSNewExternalIDResponse>(
410                &local_content,
411            ) {
412                Ok(e) => {
413                    return Ok(datadog::ResponseContent {
414                        status: local_status,
415                        content: local_content,
416                        entity: Some(e),
417                    })
418                }
419                Err(e) => return Err(datadog::Error::Serde(e)),
420            };
421        } else {
422            let local_entity: Option<CreateNewAWSExternalIDError> =
423                serde_json::from_str(&local_content).ok();
424            let local_error = datadog::ResponseContent {
425                status: local_status,
426                content: local_content,
427                entity: local_entity,
428            };
429            Err(datadog::Error::ResponseError(local_error))
430        }
431    }
432
433    /// Delete an AWS Account Integration Config by config ID.
434    pub async fn delete_aws_account(
435        &self,
436        aws_account_config_id: String,
437    ) -> Result<(), datadog::Error<DeleteAWSAccountError>> {
438        match self
439            .delete_aws_account_with_http_info(aws_account_config_id)
440            .await
441        {
442            Ok(_) => Ok(()),
443            Err(err) => Err(err),
444        }
445    }
446
447    /// Delete an AWS Account Integration Config by config ID.
448    pub async fn delete_aws_account_with_http_info(
449        &self,
450        aws_account_config_id: String,
451    ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteAWSAccountError>> {
452        let local_configuration = &self.config;
453        let operation_id = "v2.delete_aws_account";
454
455        let local_client = &self.client;
456
457        let local_uri_str = format!(
458            "{}/api/v2/integration/aws/accounts/{aws_account_config_id}",
459            local_configuration.get_operation_host(operation_id),
460            aws_account_config_id = datadog::urlencode(aws_account_config_id)
461        );
462        let mut local_req_builder =
463            local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
464
465        // build headers
466        let mut headers = HeaderMap::new();
467        headers.insert("Accept", HeaderValue::from_static("*/*"));
468
469        // build user agent
470        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
471            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
472            Err(e) => {
473                log::warn!("Failed to parse user agent header: {e}, falling back to default");
474                headers.insert(
475                    reqwest::header::USER_AGENT,
476                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
477                )
478            }
479        };
480
481        // build auth
482        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
483            headers.insert(
484                "DD-API-KEY",
485                HeaderValue::from_str(local_key.key.as_str())
486                    .expect("failed to parse DD-API-KEY header"),
487            );
488        };
489        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
490            headers.insert(
491                "DD-APPLICATION-KEY",
492                HeaderValue::from_str(local_key.key.as_str())
493                    .expect("failed to parse DD-APPLICATION-KEY header"),
494            );
495        };
496
497        local_req_builder = local_req_builder.headers(headers);
498        let local_req = local_req_builder.build()?;
499        log::debug!("request content: {:?}", local_req.body());
500        let local_resp = local_client.execute(local_req).await?;
501
502        let local_status = local_resp.status();
503        let local_content = local_resp.text().await?;
504        log::debug!("response content: {}", local_content);
505
506        if !local_status.is_client_error() && !local_status.is_server_error() {
507            Ok(datadog::ResponseContent {
508                status: local_status,
509                content: local_content,
510                entity: None,
511            })
512        } else {
513            let local_entity: Option<DeleteAWSAccountError> =
514                serde_json::from_str(&local_content).ok();
515            let local_error = datadog::ResponseContent {
516                status: local_status,
517                content: local_content,
518                entity: local_entity,
519            };
520            Err(datadog::Error::ResponseError(local_error))
521        }
522    }
523
524    /// Get an AWS Account Integration Config by config ID.
525    pub async fn get_aws_account(
526        &self,
527        aws_account_config_id: String,
528    ) -> Result<crate::datadogV2::model::AWSAccountResponse, datadog::Error<GetAWSAccountError>>
529    {
530        match self
531            .get_aws_account_with_http_info(aws_account_config_id)
532            .await
533        {
534            Ok(response_content) => {
535                if let Some(e) = response_content.entity {
536                    Ok(e)
537                } else {
538                    Err(datadog::Error::Serde(serde::de::Error::custom(
539                        "response content was None",
540                    )))
541                }
542            }
543            Err(err) => Err(err),
544        }
545    }
546
547    /// Get an AWS Account Integration Config by config ID.
548    pub async fn get_aws_account_with_http_info(
549        &self,
550        aws_account_config_id: String,
551    ) -> Result<
552        datadog::ResponseContent<crate::datadogV2::model::AWSAccountResponse>,
553        datadog::Error<GetAWSAccountError>,
554    > {
555        let local_configuration = &self.config;
556        let operation_id = "v2.get_aws_account";
557
558        let local_client = &self.client;
559
560        let local_uri_str = format!(
561            "{}/api/v2/integration/aws/accounts/{aws_account_config_id}",
562            local_configuration.get_operation_host(operation_id),
563            aws_account_config_id = datadog::urlencode(aws_account_config_id)
564        );
565        let mut local_req_builder =
566            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
567
568        // build headers
569        let mut headers = HeaderMap::new();
570        headers.insert("Accept", HeaderValue::from_static("application/json"));
571
572        // build user agent
573        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
574            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
575            Err(e) => {
576                log::warn!("Failed to parse user agent header: {e}, falling back to default");
577                headers.insert(
578                    reqwest::header::USER_AGENT,
579                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
580                )
581            }
582        };
583
584        // build auth
585        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
586            headers.insert(
587                "DD-API-KEY",
588                HeaderValue::from_str(local_key.key.as_str())
589                    .expect("failed to parse DD-API-KEY header"),
590            );
591        };
592        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
593            headers.insert(
594                "DD-APPLICATION-KEY",
595                HeaderValue::from_str(local_key.key.as_str())
596                    .expect("failed to parse DD-APPLICATION-KEY header"),
597            );
598        };
599
600        local_req_builder = local_req_builder.headers(headers);
601        let local_req = local_req_builder.build()?;
602        log::debug!("request content: {:?}", local_req.body());
603        let local_resp = local_client.execute(local_req).await?;
604
605        let local_status = local_resp.status();
606        let local_content = local_resp.text().await?;
607        log::debug!("response content: {}", local_content);
608
609        if !local_status.is_client_error() && !local_status.is_server_error() {
610            match serde_json::from_str::<crate::datadogV2::model::AWSAccountResponse>(
611                &local_content,
612            ) {
613                Ok(e) => {
614                    return Ok(datadog::ResponseContent {
615                        status: local_status,
616                        content: local_content,
617                        entity: Some(e),
618                    })
619                }
620                Err(e) => return Err(datadog::Error::Serde(e)),
621            };
622        } else {
623            let local_entity: Option<GetAWSAccountError> =
624                serde_json::from_str(&local_content).ok();
625            let local_error = datadog::ResponseContent {
626                status: local_status,
627                content: local_content,
628                entity: local_entity,
629            };
630            Err(datadog::Error::ResponseError(local_error))
631        }
632    }
633
634    /// Get all AWS IAM permissions required for the AWS integration.
635    pub async fn get_aws_integration_iam_permissions(
636        &self,
637    ) -> Result<
638        crate::datadogV2::model::AWSIntegrationIamPermissionsResponse,
639        datadog::Error<GetAWSIntegrationIAMPermissionsError>,
640    > {
641        match self
642            .get_aws_integration_iam_permissions_with_http_info()
643            .await
644        {
645            Ok(response_content) => {
646                if let Some(e) = response_content.entity {
647                    Ok(e)
648                } else {
649                    Err(datadog::Error::Serde(serde::de::Error::custom(
650                        "response content was None",
651                    )))
652                }
653            }
654            Err(err) => Err(err),
655        }
656    }
657
658    /// Get all AWS IAM permissions required for the AWS integration.
659    pub async fn get_aws_integration_iam_permissions_with_http_info(
660        &self,
661    ) -> Result<
662        datadog::ResponseContent<crate::datadogV2::model::AWSIntegrationIamPermissionsResponse>,
663        datadog::Error<GetAWSIntegrationIAMPermissionsError>,
664    > {
665        let local_configuration = &self.config;
666        let operation_id = "v2.get_aws_integration_iam_permissions";
667
668        let local_client = &self.client;
669
670        let local_uri_str = format!(
671            "{}/api/v2/integration/aws/iam_permissions",
672            local_configuration.get_operation_host(operation_id)
673        );
674        let mut local_req_builder =
675            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
676
677        // build headers
678        let mut headers = HeaderMap::new();
679        headers.insert("Accept", HeaderValue::from_static("application/json"));
680
681        // build user agent
682        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
683            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
684            Err(e) => {
685                log::warn!("Failed to parse user agent header: {e}, falling back to default");
686                headers.insert(
687                    reqwest::header::USER_AGENT,
688                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
689                )
690            }
691        };
692
693        // build auth
694        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
695            headers.insert(
696                "DD-API-KEY",
697                HeaderValue::from_str(local_key.key.as_str())
698                    .expect("failed to parse DD-API-KEY header"),
699            );
700        };
701        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
702            headers.insert(
703                "DD-APPLICATION-KEY",
704                HeaderValue::from_str(local_key.key.as_str())
705                    .expect("failed to parse DD-APPLICATION-KEY header"),
706            );
707        };
708
709        local_req_builder = local_req_builder.headers(headers);
710        let local_req = local_req_builder.build()?;
711        log::debug!("request content: {:?}", local_req.body());
712        let local_resp = local_client.execute(local_req).await?;
713
714        let local_status = local_resp.status();
715        let local_content = local_resp.text().await?;
716        log::debug!("response content: {}", local_content);
717
718        if !local_status.is_client_error() && !local_status.is_server_error() {
719            match serde_json::from_str::<
720                crate::datadogV2::model::AWSIntegrationIamPermissionsResponse,
721            >(&local_content)
722            {
723                Ok(e) => {
724                    return Ok(datadog::ResponseContent {
725                        status: local_status,
726                        content: local_content,
727                        entity: Some(e),
728                    })
729                }
730                Err(e) => return Err(datadog::Error::Serde(e)),
731            };
732        } else {
733            let local_entity: Option<GetAWSIntegrationIAMPermissionsError> =
734                serde_json::from_str(&local_content).ok();
735            let local_error = datadog::ResponseContent {
736                status: local_status,
737                content: local_content,
738                entity: local_entity,
739            };
740            Err(datadog::Error::ResponseError(local_error))
741        }
742    }
743
744    /// Get all resource collection AWS IAM permissions required for the AWS integration.
745    pub async fn get_aws_integration_iam_permissions_resource_collection(
746        &self,
747    ) -> Result<
748        crate::datadogV2::model::AWSIntegrationIamPermissionsResponse,
749        datadog::Error<GetAWSIntegrationIAMPermissionsResourceCollectionError>,
750    > {
751        match self
752            .get_aws_integration_iam_permissions_resource_collection_with_http_info()
753            .await
754        {
755            Ok(response_content) => {
756                if let Some(e) = response_content.entity {
757                    Ok(e)
758                } else {
759                    Err(datadog::Error::Serde(serde::de::Error::custom(
760                        "response content was None",
761                    )))
762                }
763            }
764            Err(err) => Err(err),
765        }
766    }
767
768    /// Get all resource collection AWS IAM permissions required for the AWS integration.
769    pub async fn get_aws_integration_iam_permissions_resource_collection_with_http_info(
770        &self,
771    ) -> Result<
772        datadog::ResponseContent<crate::datadogV2::model::AWSIntegrationIamPermissionsResponse>,
773        datadog::Error<GetAWSIntegrationIAMPermissionsResourceCollectionError>,
774    > {
775        let local_configuration = &self.config;
776        let operation_id = "v2.get_aws_integration_iam_permissions_resource_collection";
777
778        let local_client = &self.client;
779
780        let local_uri_str = format!(
781            "{}/api/v2/integration/aws/iam_permissions/resource_collection",
782            local_configuration.get_operation_host(operation_id)
783        );
784        let mut local_req_builder =
785            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
786
787        // build headers
788        let mut headers = HeaderMap::new();
789        headers.insert("Accept", HeaderValue::from_static("application/json"));
790
791        // build user agent
792        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
793            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
794            Err(e) => {
795                log::warn!("Failed to parse user agent header: {e}, falling back to default");
796                headers.insert(
797                    reqwest::header::USER_AGENT,
798                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
799                )
800            }
801        };
802
803        // build auth
804        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
805            headers.insert(
806                "DD-API-KEY",
807                HeaderValue::from_str(local_key.key.as_str())
808                    .expect("failed to parse DD-API-KEY header"),
809            );
810        };
811        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
812            headers.insert(
813                "DD-APPLICATION-KEY",
814                HeaderValue::from_str(local_key.key.as_str())
815                    .expect("failed to parse DD-APPLICATION-KEY header"),
816            );
817        };
818
819        local_req_builder = local_req_builder.headers(headers);
820        let local_req = local_req_builder.build()?;
821        log::debug!("request content: {:?}", local_req.body());
822        let local_resp = local_client.execute(local_req).await?;
823
824        let local_status = local_resp.status();
825        let local_content = local_resp.text().await?;
826        log::debug!("response content: {}", local_content);
827
828        if !local_status.is_client_error() && !local_status.is_server_error() {
829            match serde_json::from_str::<
830                crate::datadogV2::model::AWSIntegrationIamPermissionsResponse,
831            >(&local_content)
832            {
833                Ok(e) => {
834                    return Ok(datadog::ResponseContent {
835                        status: local_status,
836                        content: local_content,
837                        entity: Some(e),
838                    })
839                }
840                Err(e) => return Err(datadog::Error::Serde(e)),
841            };
842        } else {
843            let local_entity: Option<GetAWSIntegrationIAMPermissionsResourceCollectionError> =
844                serde_json::from_str(&local_content).ok();
845            let local_error = datadog::ResponseContent {
846                status: local_status,
847                content: local_content,
848                entity: local_entity,
849            };
850            Err(datadog::Error::ResponseError(local_error))
851        }
852    }
853
854    /// Get all standard AWS IAM permissions required for the AWS integration.
855    pub async fn get_aws_integration_iam_permissions_standard(
856        &self,
857    ) -> Result<
858        crate::datadogV2::model::AWSIntegrationIamPermissionsResponse,
859        datadog::Error<GetAWSIntegrationIAMPermissionsStandardError>,
860    > {
861        match self
862            .get_aws_integration_iam_permissions_standard_with_http_info()
863            .await
864        {
865            Ok(response_content) => {
866                if let Some(e) = response_content.entity {
867                    Ok(e)
868                } else {
869                    Err(datadog::Error::Serde(serde::de::Error::custom(
870                        "response content was None",
871                    )))
872                }
873            }
874            Err(err) => Err(err),
875        }
876    }
877
878    /// Get all standard AWS IAM permissions required for the AWS integration.
879    pub async fn get_aws_integration_iam_permissions_standard_with_http_info(
880        &self,
881    ) -> Result<
882        datadog::ResponseContent<crate::datadogV2::model::AWSIntegrationIamPermissionsResponse>,
883        datadog::Error<GetAWSIntegrationIAMPermissionsStandardError>,
884    > {
885        let local_configuration = &self.config;
886        let operation_id = "v2.get_aws_integration_iam_permissions_standard";
887
888        let local_client = &self.client;
889
890        let local_uri_str = format!(
891            "{}/api/v2/integration/aws/iam_permissions/standard",
892            local_configuration.get_operation_host(operation_id)
893        );
894        let mut local_req_builder =
895            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
896
897        // build headers
898        let mut headers = HeaderMap::new();
899        headers.insert("Accept", HeaderValue::from_static("application/json"));
900
901        // build user agent
902        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
903            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
904            Err(e) => {
905                log::warn!("Failed to parse user agent header: {e}, falling back to default");
906                headers.insert(
907                    reqwest::header::USER_AGENT,
908                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
909                )
910            }
911        };
912
913        // build auth
914        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
915            headers.insert(
916                "DD-API-KEY",
917                HeaderValue::from_str(local_key.key.as_str())
918                    .expect("failed to parse DD-API-KEY header"),
919            );
920        };
921        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
922            headers.insert(
923                "DD-APPLICATION-KEY",
924                HeaderValue::from_str(local_key.key.as_str())
925                    .expect("failed to parse DD-APPLICATION-KEY header"),
926            );
927        };
928
929        local_req_builder = local_req_builder.headers(headers);
930        let local_req = local_req_builder.build()?;
931        log::debug!("request content: {:?}", local_req.body());
932        let local_resp = local_client.execute(local_req).await?;
933
934        let local_status = local_resp.status();
935        let local_content = local_resp.text().await?;
936        log::debug!("response content: {}", local_content);
937
938        if !local_status.is_client_error() && !local_status.is_server_error() {
939            match serde_json::from_str::<
940                crate::datadogV2::model::AWSIntegrationIamPermissionsResponse,
941            >(&local_content)
942            {
943                Ok(e) => {
944                    return Ok(datadog::ResponseContent {
945                        status: local_status,
946                        content: local_content,
947                        entity: Some(e),
948                    })
949                }
950                Err(e) => return Err(datadog::Error::Serde(e)),
951            };
952        } else {
953            let local_entity: Option<GetAWSIntegrationIAMPermissionsStandardError> =
954                serde_json::from_str(&local_content).ok();
955            let local_error = datadog::ResponseContent {
956                status: local_status,
957                content: local_content,
958                entity: local_entity,
959            };
960            Err(datadog::Error::ResponseError(local_error))
961        }
962    }
963
964    /// Get a list of AWS Account Integration Configs.
965    pub async fn list_aws_accounts(
966        &self,
967        params: ListAWSAccountsOptionalParams,
968    ) -> Result<crate::datadogV2::model::AWSAccountsResponse, datadog::Error<ListAWSAccountsError>>
969    {
970        match self.list_aws_accounts_with_http_info(params).await {
971            Ok(response_content) => {
972                if let Some(e) = response_content.entity {
973                    Ok(e)
974                } else {
975                    Err(datadog::Error::Serde(serde::de::Error::custom(
976                        "response content was None",
977                    )))
978                }
979            }
980            Err(err) => Err(err),
981        }
982    }
983
984    /// Get a list of AWS Account Integration Configs.
985    pub async fn list_aws_accounts_with_http_info(
986        &self,
987        params: ListAWSAccountsOptionalParams,
988    ) -> Result<
989        datadog::ResponseContent<crate::datadogV2::model::AWSAccountsResponse>,
990        datadog::Error<ListAWSAccountsError>,
991    > {
992        let local_configuration = &self.config;
993        let operation_id = "v2.list_aws_accounts";
994
995        // unbox and build optional parameters
996        let aws_account_id = params.aws_account_id;
997
998        let local_client = &self.client;
999
1000        let local_uri_str = format!(
1001            "{}/api/v2/integration/aws/accounts",
1002            local_configuration.get_operation_host(operation_id)
1003        );
1004        let mut local_req_builder =
1005            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1006
1007        if let Some(ref local_query_param) = aws_account_id {
1008            local_req_builder =
1009                local_req_builder.query(&[("aws_account_id", &local_query_param.to_string())]);
1010        };
1011
1012        // build headers
1013        let mut headers = HeaderMap::new();
1014        headers.insert("Accept", HeaderValue::from_static("application/json"));
1015
1016        // build user agent
1017        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1018            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1019            Err(e) => {
1020                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1021                headers.insert(
1022                    reqwest::header::USER_AGENT,
1023                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1024                )
1025            }
1026        };
1027
1028        // build auth
1029        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1030            headers.insert(
1031                "DD-API-KEY",
1032                HeaderValue::from_str(local_key.key.as_str())
1033                    .expect("failed to parse DD-API-KEY header"),
1034            );
1035        };
1036        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1037            headers.insert(
1038                "DD-APPLICATION-KEY",
1039                HeaderValue::from_str(local_key.key.as_str())
1040                    .expect("failed to parse DD-APPLICATION-KEY header"),
1041            );
1042        };
1043
1044        local_req_builder = local_req_builder.headers(headers);
1045        let local_req = local_req_builder.build()?;
1046        log::debug!("request content: {:?}", local_req.body());
1047        let local_resp = local_client.execute(local_req).await?;
1048
1049        let local_status = local_resp.status();
1050        let local_content = local_resp.text().await?;
1051        log::debug!("response content: {}", local_content);
1052
1053        if !local_status.is_client_error() && !local_status.is_server_error() {
1054            match serde_json::from_str::<crate::datadogV2::model::AWSAccountsResponse>(
1055                &local_content,
1056            ) {
1057                Ok(e) => {
1058                    return Ok(datadog::ResponseContent {
1059                        status: local_status,
1060                        content: local_content,
1061                        entity: Some(e),
1062                    })
1063                }
1064                Err(e) => return Err(datadog::Error::Serde(e)),
1065            };
1066        } else {
1067            let local_entity: Option<ListAWSAccountsError> =
1068                serde_json::from_str(&local_content).ok();
1069            let local_error = datadog::ResponseContent {
1070                status: local_status,
1071                content: local_content,
1072                entity: local_entity,
1073            };
1074            Err(datadog::Error::ResponseError(local_error))
1075        }
1076    }
1077
1078    /// Get a list of available AWS CloudWatch namespaces that can send metrics to Datadog.
1079    pub async fn list_aws_namespaces(
1080        &self,
1081    ) -> Result<
1082        crate::datadogV2::model::AWSNamespacesResponse,
1083        datadog::Error<ListAWSNamespacesError>,
1084    > {
1085        match self.list_aws_namespaces_with_http_info().await {
1086            Ok(response_content) => {
1087                if let Some(e) = response_content.entity {
1088                    Ok(e)
1089                } else {
1090                    Err(datadog::Error::Serde(serde::de::Error::custom(
1091                        "response content was None",
1092                    )))
1093                }
1094            }
1095            Err(err) => Err(err),
1096        }
1097    }
1098
1099    /// Get a list of available AWS CloudWatch namespaces that can send metrics to Datadog.
1100    pub async fn list_aws_namespaces_with_http_info(
1101        &self,
1102    ) -> Result<
1103        datadog::ResponseContent<crate::datadogV2::model::AWSNamespacesResponse>,
1104        datadog::Error<ListAWSNamespacesError>,
1105    > {
1106        let local_configuration = &self.config;
1107        let operation_id = "v2.list_aws_namespaces";
1108
1109        let local_client = &self.client;
1110
1111        let local_uri_str = format!(
1112            "{}/api/v2/integration/aws/available_namespaces",
1113            local_configuration.get_operation_host(operation_id)
1114        );
1115        let mut local_req_builder =
1116            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1117
1118        // build headers
1119        let mut headers = HeaderMap::new();
1120        headers.insert("Accept", HeaderValue::from_static("application/json"));
1121
1122        // build user agent
1123        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1124            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1125            Err(e) => {
1126                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1127                headers.insert(
1128                    reqwest::header::USER_AGENT,
1129                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1130                )
1131            }
1132        };
1133
1134        // build auth
1135        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1136            headers.insert(
1137                "DD-API-KEY",
1138                HeaderValue::from_str(local_key.key.as_str())
1139                    .expect("failed to parse DD-API-KEY header"),
1140            );
1141        };
1142        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1143            headers.insert(
1144                "DD-APPLICATION-KEY",
1145                HeaderValue::from_str(local_key.key.as_str())
1146                    .expect("failed to parse DD-APPLICATION-KEY header"),
1147            );
1148        };
1149
1150        local_req_builder = local_req_builder.headers(headers);
1151        let local_req = local_req_builder.build()?;
1152        log::debug!("request content: {:?}", local_req.body());
1153        let local_resp = local_client.execute(local_req).await?;
1154
1155        let local_status = local_resp.status();
1156        let local_content = local_resp.text().await?;
1157        log::debug!("response content: {}", local_content);
1158
1159        if !local_status.is_client_error() && !local_status.is_server_error() {
1160            match serde_json::from_str::<crate::datadogV2::model::AWSNamespacesResponse>(
1161                &local_content,
1162            ) {
1163                Ok(e) => {
1164                    return Ok(datadog::ResponseContent {
1165                        status: local_status,
1166                        content: local_content,
1167                        entity: Some(e),
1168                    })
1169                }
1170                Err(e) => return Err(datadog::Error::Serde(e)),
1171            };
1172        } else {
1173            let local_entity: Option<ListAWSNamespacesError> =
1174                serde_json::from_str(&local_content).ok();
1175            let local_error = datadog::ResponseContent {
1176                status: local_status,
1177                content: local_content,
1178                entity: local_entity,
1179            };
1180            Err(datadog::Error::ResponseError(local_error))
1181        }
1182    }
1183
1184    /// Update an AWS Account Integration Config by config ID.
1185    pub async fn update_aws_account(
1186        &self,
1187        aws_account_config_id: String,
1188        body: crate::datadogV2::model::AWSAccountUpdateRequest,
1189    ) -> Result<crate::datadogV2::model::AWSAccountResponse, datadog::Error<UpdateAWSAccountError>>
1190    {
1191        match self
1192            .update_aws_account_with_http_info(aws_account_config_id, body)
1193            .await
1194        {
1195            Ok(response_content) => {
1196                if let Some(e) = response_content.entity {
1197                    Ok(e)
1198                } else {
1199                    Err(datadog::Error::Serde(serde::de::Error::custom(
1200                        "response content was None",
1201                    )))
1202                }
1203            }
1204            Err(err) => Err(err),
1205        }
1206    }
1207
1208    /// Update an AWS Account Integration Config by config ID.
1209    pub async fn update_aws_account_with_http_info(
1210        &self,
1211        aws_account_config_id: String,
1212        body: crate::datadogV2::model::AWSAccountUpdateRequest,
1213    ) -> Result<
1214        datadog::ResponseContent<crate::datadogV2::model::AWSAccountResponse>,
1215        datadog::Error<UpdateAWSAccountError>,
1216    > {
1217        let local_configuration = &self.config;
1218        let operation_id = "v2.update_aws_account";
1219
1220        let local_client = &self.client;
1221
1222        let local_uri_str = format!(
1223            "{}/api/v2/integration/aws/accounts/{aws_account_config_id}",
1224            local_configuration.get_operation_host(operation_id),
1225            aws_account_config_id = datadog::urlencode(aws_account_config_id)
1226        );
1227        let mut local_req_builder =
1228            local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
1229
1230        // build headers
1231        let mut headers = HeaderMap::new();
1232        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1233        headers.insert("Accept", HeaderValue::from_static("application/json"));
1234
1235        // build user agent
1236        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1237            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1238            Err(e) => {
1239                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1240                headers.insert(
1241                    reqwest::header::USER_AGENT,
1242                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1243                )
1244            }
1245        };
1246
1247        // build auth
1248        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1249            headers.insert(
1250                "DD-API-KEY",
1251                HeaderValue::from_str(local_key.key.as_str())
1252                    .expect("failed to parse DD-API-KEY header"),
1253            );
1254        };
1255        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1256            headers.insert(
1257                "DD-APPLICATION-KEY",
1258                HeaderValue::from_str(local_key.key.as_str())
1259                    .expect("failed to parse DD-APPLICATION-KEY header"),
1260            );
1261        };
1262
1263        // build body parameters
1264        let output = Vec::new();
1265        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1266        if body.serialize(&mut ser).is_ok() {
1267            if let Some(content_encoding) = headers.get("Content-Encoding") {
1268                match content_encoding.to_str().unwrap_or_default() {
1269                    "gzip" => {
1270                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1271                        let _ = enc.write_all(ser.into_inner().as_slice());
1272                        match enc.finish() {
1273                            Ok(buf) => {
1274                                local_req_builder = local_req_builder.body(buf);
1275                            }
1276                            Err(e) => return Err(datadog::Error::Io(e)),
1277                        }
1278                    }
1279                    "deflate" => {
1280                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1281                        let _ = enc.write_all(ser.into_inner().as_slice());
1282                        match enc.finish() {
1283                            Ok(buf) => {
1284                                local_req_builder = local_req_builder.body(buf);
1285                            }
1286                            Err(e) => return Err(datadog::Error::Io(e)),
1287                        }
1288                    }
1289                    "zstd1" => {
1290                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1291                        let _ = enc.write_all(ser.into_inner().as_slice());
1292                        match enc.finish() {
1293                            Ok(buf) => {
1294                                local_req_builder = local_req_builder.body(buf);
1295                            }
1296                            Err(e) => return Err(datadog::Error::Io(e)),
1297                        }
1298                    }
1299                    _ => {
1300                        local_req_builder = local_req_builder.body(ser.into_inner());
1301                    }
1302                }
1303            } else {
1304                local_req_builder = local_req_builder.body(ser.into_inner());
1305            }
1306        }
1307
1308        local_req_builder = local_req_builder.headers(headers);
1309        let local_req = local_req_builder.build()?;
1310        log::debug!("request content: {:?}", local_req.body());
1311        let local_resp = local_client.execute(local_req).await?;
1312
1313        let local_status = local_resp.status();
1314        let local_content = local_resp.text().await?;
1315        log::debug!("response content: {}", local_content);
1316
1317        if !local_status.is_client_error() && !local_status.is_server_error() {
1318            match serde_json::from_str::<crate::datadogV2::model::AWSAccountResponse>(
1319                &local_content,
1320            ) {
1321                Ok(e) => {
1322                    return Ok(datadog::ResponseContent {
1323                        status: local_status,
1324                        content: local_content,
1325                        entity: Some(e),
1326                    })
1327                }
1328                Err(e) => return Err(datadog::Error::Serde(e)),
1329            };
1330        } else {
1331            let local_entity: Option<UpdateAWSAccountError> =
1332                serde_json::from_str(&local_content).ok();
1333            let local_error = datadog::ResponseContent {
1334                status: local_status,
1335                content: local_content,
1336                entity: local_entity,
1337            };
1338            Err(datadog::Error::ResponseError(local_error))
1339        }
1340    }
1341}