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