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