datadog_api_client/datadogV2/api/
api_okta_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/// CreateOktaAccountError is a struct for typed errors of method [`OktaIntegrationAPI::create_okta_account`]
14#[derive(Debug, Clone, Serialize, Deserialize)]
15#[serde(untagged)]
16pub enum CreateOktaAccountError {
17    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
18    UnknownValue(serde_json::Value),
19}
20
21/// DeleteOktaAccountError is a struct for typed errors of method [`OktaIntegrationAPI::delete_okta_account`]
22#[derive(Debug, Clone, Serialize, Deserialize)]
23#[serde(untagged)]
24pub enum DeleteOktaAccountError {
25    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
26    UnknownValue(serde_json::Value),
27}
28
29/// GetOktaAccountError is a struct for typed errors of method [`OktaIntegrationAPI::get_okta_account`]
30#[derive(Debug, Clone, Serialize, Deserialize)]
31#[serde(untagged)]
32pub enum GetOktaAccountError {
33    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
34    UnknownValue(serde_json::Value),
35}
36
37/// ListOktaAccountsError is a struct for typed errors of method [`OktaIntegrationAPI::list_okta_accounts`]
38#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum ListOktaAccountsError {
41    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
42    UnknownValue(serde_json::Value),
43}
44
45/// UpdateOktaAccountError is a struct for typed errors of method [`OktaIntegrationAPI::update_okta_account`]
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum UpdateOktaAccountError {
49    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
50    UnknownValue(serde_json::Value),
51}
52
53/// Configure your [Datadog Okta integration](<https://docs.datadoghq.com/integrations/okta/>) directly through the Datadog API.
54#[derive(Debug, Clone)]
55pub struct OktaIntegrationAPI {
56    config: datadog::Configuration,
57    client: reqwest_middleware::ClientWithMiddleware,
58}
59
60impl Default for OktaIntegrationAPI {
61    fn default() -> Self {
62        Self::with_config(datadog::Configuration::default())
63    }
64}
65
66impl OktaIntegrationAPI {
67    pub fn new() -> Self {
68        Self::default()
69    }
70    pub fn with_config(config: datadog::Configuration) -> Self {
71        let mut reqwest_client_builder = reqwest::Client::builder();
72
73        if let Some(proxy_url) = &config.proxy_url {
74            let proxy = reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL");
75            reqwest_client_builder = reqwest_client_builder.proxy(proxy);
76        }
77
78        let mut middleware_client_builder =
79            reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap());
80
81        if config.enable_retry {
82            struct RetryableStatus;
83            impl reqwest_retry::RetryableStrategy for RetryableStatus {
84                fn handle(
85                    &self,
86                    res: &Result<reqwest::Response, reqwest_middleware::Error>,
87                ) -> Option<reqwest_retry::Retryable> {
88                    match res {
89                        Ok(success) => reqwest_retry::default_on_request_success(success),
90                        Err(_) => None,
91                    }
92                }
93            }
94            let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder()
95                .build_with_max_retries(config.max_retries);
96
97            let retry_middleware =
98                reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy(
99                    backoff_policy,
100                    RetryableStatus,
101                );
102
103            middleware_client_builder = middleware_client_builder.with(retry_middleware);
104        }
105
106        let client = middleware_client_builder.build();
107
108        Self { config, client }
109    }
110
111    pub fn with_client_and_config(
112        config: datadog::Configuration,
113        client: reqwest_middleware::ClientWithMiddleware,
114    ) -> Self {
115        Self { config, client }
116    }
117
118    /// Create an Okta account.
119    pub async fn create_okta_account(
120        &self,
121        body: crate::datadogV2::model::OktaAccountRequest,
122    ) -> Result<crate::datadogV2::model::OktaAccountResponse, datadog::Error<CreateOktaAccountError>>
123    {
124        match self.create_okta_account_with_http_info(body).await {
125            Ok(response_content) => {
126                if let Some(e) = response_content.entity {
127                    Ok(e)
128                } else {
129                    Err(datadog::Error::Serde(serde::de::Error::custom(
130                        "response content was None",
131                    )))
132                }
133            }
134            Err(err) => Err(err),
135        }
136    }
137
138    /// Create an Okta account.
139    pub async fn create_okta_account_with_http_info(
140        &self,
141        body: crate::datadogV2::model::OktaAccountRequest,
142    ) -> Result<
143        datadog::ResponseContent<crate::datadogV2::model::OktaAccountResponse>,
144        datadog::Error<CreateOktaAccountError>,
145    > {
146        let local_configuration = &self.config;
147        let operation_id = "v2.create_okta_account";
148
149        let local_client = &self.client;
150
151        let local_uri_str = format!(
152            "{}/api/v2/integrations/okta/accounts",
153            local_configuration.get_operation_host(operation_id)
154        );
155        let mut local_req_builder =
156            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
157
158        // build headers
159        let mut headers = HeaderMap::new();
160        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
161        headers.insert("Accept", HeaderValue::from_static("application/json"));
162
163        // build user agent
164        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
165            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
166            Err(e) => {
167                log::warn!("Failed to parse user agent header: {e}, falling back to default");
168                headers.insert(
169                    reqwest::header::USER_AGENT,
170                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
171                )
172            }
173        };
174
175        // build auth
176        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
177            headers.insert(
178                "DD-API-KEY",
179                HeaderValue::from_str(local_key.key.as_str())
180                    .expect("failed to parse DD-API-KEY header"),
181            );
182        };
183        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
184            headers.insert(
185                "DD-APPLICATION-KEY",
186                HeaderValue::from_str(local_key.key.as_str())
187                    .expect("failed to parse DD-APPLICATION-KEY header"),
188            );
189        };
190
191        // build body parameters
192        let output = Vec::new();
193        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
194        if body.serialize(&mut ser).is_ok() {
195            if let Some(content_encoding) = headers.get("Content-Encoding") {
196                match content_encoding.to_str().unwrap_or_default() {
197                    "gzip" => {
198                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
199                        let _ = enc.write_all(ser.into_inner().as_slice());
200                        match enc.finish() {
201                            Ok(buf) => {
202                                local_req_builder = local_req_builder.body(buf);
203                            }
204                            Err(e) => return Err(datadog::Error::Io(e)),
205                        }
206                    }
207                    "deflate" => {
208                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
209                        let _ = enc.write_all(ser.into_inner().as_slice());
210                        match enc.finish() {
211                            Ok(buf) => {
212                                local_req_builder = local_req_builder.body(buf);
213                            }
214                            Err(e) => return Err(datadog::Error::Io(e)),
215                        }
216                    }
217                    "zstd1" => {
218                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
219                        let _ = enc.write_all(ser.into_inner().as_slice());
220                        match enc.finish() {
221                            Ok(buf) => {
222                                local_req_builder = local_req_builder.body(buf);
223                            }
224                            Err(e) => return Err(datadog::Error::Io(e)),
225                        }
226                    }
227                    _ => {
228                        local_req_builder = local_req_builder.body(ser.into_inner());
229                    }
230                }
231            } else {
232                local_req_builder = local_req_builder.body(ser.into_inner());
233            }
234        }
235
236        local_req_builder = local_req_builder.headers(headers);
237        let local_req = local_req_builder.build()?;
238        log::debug!("request content: {:?}", local_req.body());
239        let local_resp = local_client.execute(local_req).await?;
240
241        let local_status = local_resp.status();
242        let local_content = local_resp.text().await?;
243        log::debug!("response content: {}", local_content);
244
245        if !local_status.is_client_error() && !local_status.is_server_error() {
246            match serde_json::from_str::<crate::datadogV2::model::OktaAccountResponse>(
247                &local_content,
248            ) {
249                Ok(e) => {
250                    return Ok(datadog::ResponseContent {
251                        status: local_status,
252                        content: local_content,
253                        entity: Some(e),
254                    })
255                }
256                Err(e) => return Err(datadog::Error::Serde(e)),
257            };
258        } else {
259            let local_entity: Option<CreateOktaAccountError> =
260                serde_json::from_str(&local_content).ok();
261            let local_error = datadog::ResponseContent {
262                status: local_status,
263                content: local_content,
264                entity: local_entity,
265            };
266            Err(datadog::Error::ResponseError(local_error))
267        }
268    }
269
270    /// Delete an Okta account.
271    pub async fn delete_okta_account(
272        &self,
273        account_id: String,
274    ) -> Result<(), datadog::Error<DeleteOktaAccountError>> {
275        match self.delete_okta_account_with_http_info(account_id).await {
276            Ok(_) => Ok(()),
277            Err(err) => Err(err),
278        }
279    }
280
281    /// Delete an Okta account.
282    pub async fn delete_okta_account_with_http_info(
283        &self,
284        account_id: String,
285    ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteOktaAccountError>> {
286        let local_configuration = &self.config;
287        let operation_id = "v2.delete_okta_account";
288
289        let local_client = &self.client;
290
291        let local_uri_str = format!(
292            "{}/api/v2/integrations/okta/accounts/{account_id}",
293            local_configuration.get_operation_host(operation_id),
294            account_id = datadog::urlencode(account_id)
295        );
296        let mut local_req_builder =
297            local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
298
299        // build headers
300        let mut headers = HeaderMap::new();
301        headers.insert("Accept", HeaderValue::from_static("*/*"));
302
303        // build user agent
304        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
305            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
306            Err(e) => {
307                log::warn!("Failed to parse user agent header: {e}, falling back to default");
308                headers.insert(
309                    reqwest::header::USER_AGENT,
310                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
311                )
312            }
313        };
314
315        // build auth
316        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
317            headers.insert(
318                "DD-API-KEY",
319                HeaderValue::from_str(local_key.key.as_str())
320                    .expect("failed to parse DD-API-KEY header"),
321            );
322        };
323        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
324            headers.insert(
325                "DD-APPLICATION-KEY",
326                HeaderValue::from_str(local_key.key.as_str())
327                    .expect("failed to parse DD-APPLICATION-KEY header"),
328            );
329        };
330
331        local_req_builder = local_req_builder.headers(headers);
332        let local_req = local_req_builder.build()?;
333        log::debug!("request content: {:?}", local_req.body());
334        let local_resp = local_client.execute(local_req).await?;
335
336        let local_status = local_resp.status();
337        let local_content = local_resp.text().await?;
338        log::debug!("response content: {}", local_content);
339
340        if !local_status.is_client_error() && !local_status.is_server_error() {
341            Ok(datadog::ResponseContent {
342                status: local_status,
343                content: local_content,
344                entity: None,
345            })
346        } else {
347            let local_entity: Option<DeleteOktaAccountError> =
348                serde_json::from_str(&local_content).ok();
349            let local_error = datadog::ResponseContent {
350                status: local_status,
351                content: local_content,
352                entity: local_entity,
353            };
354            Err(datadog::Error::ResponseError(local_error))
355        }
356    }
357
358    /// Get an Okta account.
359    pub async fn get_okta_account(
360        &self,
361        account_id: String,
362    ) -> Result<crate::datadogV2::model::OktaAccountResponse, datadog::Error<GetOktaAccountError>>
363    {
364        match self.get_okta_account_with_http_info(account_id).await {
365            Ok(response_content) => {
366                if let Some(e) = response_content.entity {
367                    Ok(e)
368                } else {
369                    Err(datadog::Error::Serde(serde::de::Error::custom(
370                        "response content was None",
371                    )))
372                }
373            }
374            Err(err) => Err(err),
375        }
376    }
377
378    /// Get an Okta account.
379    pub async fn get_okta_account_with_http_info(
380        &self,
381        account_id: String,
382    ) -> Result<
383        datadog::ResponseContent<crate::datadogV2::model::OktaAccountResponse>,
384        datadog::Error<GetOktaAccountError>,
385    > {
386        let local_configuration = &self.config;
387        let operation_id = "v2.get_okta_account";
388
389        let local_client = &self.client;
390
391        let local_uri_str = format!(
392            "{}/api/v2/integrations/okta/accounts/{account_id}",
393            local_configuration.get_operation_host(operation_id),
394            account_id = datadog::urlencode(account_id)
395        );
396        let mut local_req_builder =
397            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
398
399        // build headers
400        let mut headers = HeaderMap::new();
401        headers.insert("Accept", HeaderValue::from_static("application/json"));
402
403        // build user agent
404        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
405            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
406            Err(e) => {
407                log::warn!("Failed to parse user agent header: {e}, falling back to default");
408                headers.insert(
409                    reqwest::header::USER_AGENT,
410                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
411                )
412            }
413        };
414
415        // build auth
416        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
417            headers.insert(
418                "DD-API-KEY",
419                HeaderValue::from_str(local_key.key.as_str())
420                    .expect("failed to parse DD-API-KEY header"),
421            );
422        };
423        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
424            headers.insert(
425                "DD-APPLICATION-KEY",
426                HeaderValue::from_str(local_key.key.as_str())
427                    .expect("failed to parse DD-APPLICATION-KEY header"),
428            );
429        };
430
431        local_req_builder = local_req_builder.headers(headers);
432        let local_req = local_req_builder.build()?;
433        log::debug!("request content: {:?}", local_req.body());
434        let local_resp = local_client.execute(local_req).await?;
435
436        let local_status = local_resp.status();
437        let local_content = local_resp.text().await?;
438        log::debug!("response content: {}", local_content);
439
440        if !local_status.is_client_error() && !local_status.is_server_error() {
441            match serde_json::from_str::<crate::datadogV2::model::OktaAccountResponse>(
442                &local_content,
443            ) {
444                Ok(e) => {
445                    return Ok(datadog::ResponseContent {
446                        status: local_status,
447                        content: local_content,
448                        entity: Some(e),
449                    })
450                }
451                Err(e) => return Err(datadog::Error::Serde(e)),
452            };
453        } else {
454            let local_entity: Option<GetOktaAccountError> =
455                serde_json::from_str(&local_content).ok();
456            let local_error = datadog::ResponseContent {
457                status: local_status,
458                content: local_content,
459                entity: local_entity,
460            };
461            Err(datadog::Error::ResponseError(local_error))
462        }
463    }
464
465    /// List Okta accounts.
466    pub async fn list_okta_accounts(
467        &self,
468    ) -> Result<crate::datadogV2::model::OktaAccountsResponse, datadog::Error<ListOktaAccountsError>>
469    {
470        match self.list_okta_accounts_with_http_info().await {
471            Ok(response_content) => {
472                if let Some(e) = response_content.entity {
473                    Ok(e)
474                } else {
475                    Err(datadog::Error::Serde(serde::de::Error::custom(
476                        "response content was None",
477                    )))
478                }
479            }
480            Err(err) => Err(err),
481        }
482    }
483
484    /// List Okta accounts.
485    pub async fn list_okta_accounts_with_http_info(
486        &self,
487    ) -> Result<
488        datadog::ResponseContent<crate::datadogV2::model::OktaAccountsResponse>,
489        datadog::Error<ListOktaAccountsError>,
490    > {
491        let local_configuration = &self.config;
492        let operation_id = "v2.list_okta_accounts";
493
494        let local_client = &self.client;
495
496        let local_uri_str = format!(
497            "{}/api/v2/integrations/okta/accounts",
498            local_configuration.get_operation_host(operation_id)
499        );
500        let mut local_req_builder =
501            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
502
503        // build headers
504        let mut headers = HeaderMap::new();
505        headers.insert("Accept", HeaderValue::from_static("application/json"));
506
507        // build user agent
508        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
509            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
510            Err(e) => {
511                log::warn!("Failed to parse user agent header: {e}, falling back to default");
512                headers.insert(
513                    reqwest::header::USER_AGENT,
514                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
515                )
516            }
517        };
518
519        // build auth
520        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
521            headers.insert(
522                "DD-API-KEY",
523                HeaderValue::from_str(local_key.key.as_str())
524                    .expect("failed to parse DD-API-KEY header"),
525            );
526        };
527        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
528            headers.insert(
529                "DD-APPLICATION-KEY",
530                HeaderValue::from_str(local_key.key.as_str())
531                    .expect("failed to parse DD-APPLICATION-KEY header"),
532            );
533        };
534
535        local_req_builder = local_req_builder.headers(headers);
536        let local_req = local_req_builder.build()?;
537        log::debug!("request content: {:?}", local_req.body());
538        let local_resp = local_client.execute(local_req).await?;
539
540        let local_status = local_resp.status();
541        let local_content = local_resp.text().await?;
542        log::debug!("response content: {}", local_content);
543
544        if !local_status.is_client_error() && !local_status.is_server_error() {
545            match serde_json::from_str::<crate::datadogV2::model::OktaAccountsResponse>(
546                &local_content,
547            ) {
548                Ok(e) => {
549                    return Ok(datadog::ResponseContent {
550                        status: local_status,
551                        content: local_content,
552                        entity: Some(e),
553                    })
554                }
555                Err(e) => return Err(datadog::Error::Serde(e)),
556            };
557        } else {
558            let local_entity: Option<ListOktaAccountsError> =
559                serde_json::from_str(&local_content).ok();
560            let local_error = datadog::ResponseContent {
561                status: local_status,
562                content: local_content,
563                entity: local_entity,
564            };
565            Err(datadog::Error::ResponseError(local_error))
566        }
567    }
568
569    /// Update an Okta account.
570    pub async fn update_okta_account(
571        &self,
572        account_id: String,
573        body: crate::datadogV2::model::OktaAccountUpdateRequest,
574    ) -> Result<crate::datadogV2::model::OktaAccountResponse, datadog::Error<UpdateOktaAccountError>>
575    {
576        match self
577            .update_okta_account_with_http_info(account_id, body)
578            .await
579        {
580            Ok(response_content) => {
581                if let Some(e) = response_content.entity {
582                    Ok(e)
583                } else {
584                    Err(datadog::Error::Serde(serde::de::Error::custom(
585                        "response content was None",
586                    )))
587                }
588            }
589            Err(err) => Err(err),
590        }
591    }
592
593    /// Update an Okta account.
594    pub async fn update_okta_account_with_http_info(
595        &self,
596        account_id: String,
597        body: crate::datadogV2::model::OktaAccountUpdateRequest,
598    ) -> Result<
599        datadog::ResponseContent<crate::datadogV2::model::OktaAccountResponse>,
600        datadog::Error<UpdateOktaAccountError>,
601    > {
602        let local_configuration = &self.config;
603        let operation_id = "v2.update_okta_account";
604
605        let local_client = &self.client;
606
607        let local_uri_str = format!(
608            "{}/api/v2/integrations/okta/accounts/{account_id}",
609            local_configuration.get_operation_host(operation_id),
610            account_id = datadog::urlencode(account_id)
611        );
612        let mut local_req_builder =
613            local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
614
615        // build headers
616        let mut headers = HeaderMap::new();
617        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
618        headers.insert("Accept", HeaderValue::from_static("application/json"));
619
620        // build user agent
621        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
622            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
623            Err(e) => {
624                log::warn!("Failed to parse user agent header: {e}, falling back to default");
625                headers.insert(
626                    reqwest::header::USER_AGENT,
627                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
628                )
629            }
630        };
631
632        // build auth
633        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
634            headers.insert(
635                "DD-API-KEY",
636                HeaderValue::from_str(local_key.key.as_str())
637                    .expect("failed to parse DD-API-KEY header"),
638            );
639        };
640        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
641            headers.insert(
642                "DD-APPLICATION-KEY",
643                HeaderValue::from_str(local_key.key.as_str())
644                    .expect("failed to parse DD-APPLICATION-KEY header"),
645            );
646        };
647
648        // build body parameters
649        let output = Vec::new();
650        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
651        if body.serialize(&mut ser).is_ok() {
652            if let Some(content_encoding) = headers.get("Content-Encoding") {
653                match content_encoding.to_str().unwrap_or_default() {
654                    "gzip" => {
655                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
656                        let _ = enc.write_all(ser.into_inner().as_slice());
657                        match enc.finish() {
658                            Ok(buf) => {
659                                local_req_builder = local_req_builder.body(buf);
660                            }
661                            Err(e) => return Err(datadog::Error::Io(e)),
662                        }
663                    }
664                    "deflate" => {
665                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
666                        let _ = enc.write_all(ser.into_inner().as_slice());
667                        match enc.finish() {
668                            Ok(buf) => {
669                                local_req_builder = local_req_builder.body(buf);
670                            }
671                            Err(e) => return Err(datadog::Error::Io(e)),
672                        }
673                    }
674                    "zstd1" => {
675                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
676                        let _ = enc.write_all(ser.into_inner().as_slice());
677                        match enc.finish() {
678                            Ok(buf) => {
679                                local_req_builder = local_req_builder.body(buf);
680                            }
681                            Err(e) => return Err(datadog::Error::Io(e)),
682                        }
683                    }
684                    _ => {
685                        local_req_builder = local_req_builder.body(ser.into_inner());
686                    }
687                }
688            } else {
689                local_req_builder = local_req_builder.body(ser.into_inner());
690            }
691        }
692
693        local_req_builder = local_req_builder.headers(headers);
694        let local_req = local_req_builder.build()?;
695        log::debug!("request content: {:?}", local_req.body());
696        let local_resp = local_client.execute(local_req).await?;
697
698        let local_status = local_resp.status();
699        let local_content = local_resp.text().await?;
700        log::debug!("response content: {}", local_content);
701
702        if !local_status.is_client_error() && !local_status.is_server_error() {
703            match serde_json::from_str::<crate::datadogV2::model::OktaAccountResponse>(
704                &local_content,
705            ) {
706                Ok(e) => {
707                    return Ok(datadog::ResponseContent {
708                        status: local_status,
709                        content: local_content,
710                        entity: Some(e),
711                    })
712                }
713                Err(e) => return Err(datadog::Error::Serde(e)),
714            };
715        } else {
716            let local_entity: Option<UpdateOktaAccountError> =
717                serde_json::from_str(&local_content).ok();
718            let local_error = datadog::ResponseContent {
719                status: local_status,
720                content: local_content,
721                entity: local_entity,
722            };
723            Err(datadog::Error::ResponseError(local_error))
724        }
725    }
726}