datadog_api_client/datadogV2/api/
api_cloud_cost_management.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/// ListCustomCostsFilesOptionalParams is a struct for passing parameters to the method [`CloudCostManagementAPI::list_custom_costs_files`]
14#[non_exhaustive]
15#[derive(Clone, Default, Debug)]
16pub struct ListCustomCostsFilesOptionalParams {
17    /// Page number for pagination
18    pub page_number: Option<i64>,
19    /// Page size for pagination
20    pub page_size: Option<i64>,
21    /// Filter by file status
22    pub filter_status: Option<String>,
23    /// Sort key with optional descending prefix
24    pub sort: Option<String>,
25}
26
27impl ListCustomCostsFilesOptionalParams {
28    /// Page number for pagination
29    pub fn page_number(mut self, value: i64) -> Self {
30        self.page_number = Some(value);
31        self
32    }
33    /// Page size for pagination
34    pub fn page_size(mut self, value: i64) -> Self {
35        self.page_size = Some(value);
36        self
37    }
38    /// Filter by file status
39    pub fn filter_status(mut self, value: String) -> Self {
40        self.filter_status = Some(value);
41        self
42    }
43    /// Sort key with optional descending prefix
44    pub fn sort(mut self, value: String) -> Self {
45        self.sort = Some(value);
46        self
47    }
48}
49
50/// CreateCostAWSCURConfigError is a struct for typed errors of method [`CloudCostManagementAPI::create_cost_awscur_config`]
51#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(untagged)]
53pub enum CreateCostAWSCURConfigError {
54    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
55    UnknownValue(serde_json::Value),
56}
57
58/// CreateCostAzureUCConfigsError is a struct for typed errors of method [`CloudCostManagementAPI::create_cost_azure_uc_configs`]
59#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum CreateCostAzureUCConfigsError {
62    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
63    UnknownValue(serde_json::Value),
64}
65
66/// CreateCostGCPUsageCostConfigError is a struct for typed errors of method [`CloudCostManagementAPI::create_cost_gcp_usage_cost_config`]
67#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum CreateCostGCPUsageCostConfigError {
70    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
71    UnknownValue(serde_json::Value),
72}
73
74/// CreateCustomAllocationRuleError is a struct for typed errors of method [`CloudCostManagementAPI::create_custom_allocation_rule`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum CreateCustomAllocationRuleError {
78    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
79    UnknownValue(serde_json::Value),
80}
81
82/// CreateTagPipelinesRulesetError is a struct for typed errors of method [`CloudCostManagementAPI::create_tag_pipelines_ruleset`]
83#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum CreateTagPipelinesRulesetError {
86    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
87    UnknownValue(serde_json::Value),
88}
89
90/// DeleteBudgetError is a struct for typed errors of method [`CloudCostManagementAPI::delete_budget`]
91#[derive(Debug, Clone, Serialize, Deserialize)]
92#[serde(untagged)]
93pub enum DeleteBudgetError {
94    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
95    UnknownValue(serde_json::Value),
96}
97
98/// DeleteCostAWSCURConfigError is a struct for typed errors of method [`CloudCostManagementAPI::delete_cost_awscur_config`]
99#[derive(Debug, Clone, Serialize, Deserialize)]
100#[serde(untagged)]
101pub enum DeleteCostAWSCURConfigError {
102    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
103    UnknownValue(serde_json::Value),
104}
105
106/// DeleteCostAzureUCConfigError is a struct for typed errors of method [`CloudCostManagementAPI::delete_cost_azure_uc_config`]
107#[derive(Debug, Clone, Serialize, Deserialize)]
108#[serde(untagged)]
109pub enum DeleteCostAzureUCConfigError {
110    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
111    UnknownValue(serde_json::Value),
112}
113
114/// DeleteCostGCPUsageCostConfigError is a struct for typed errors of method [`CloudCostManagementAPI::delete_cost_gcp_usage_cost_config`]
115#[derive(Debug, Clone, Serialize, Deserialize)]
116#[serde(untagged)]
117pub enum DeleteCostGCPUsageCostConfigError {
118    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
119    UnknownValue(serde_json::Value),
120}
121
122/// DeleteCustomAllocationRuleError is a struct for typed errors of method [`CloudCostManagementAPI::delete_custom_allocation_rule`]
123#[derive(Debug, Clone, Serialize, Deserialize)]
124#[serde(untagged)]
125pub enum DeleteCustomAllocationRuleError {
126    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
127    UnknownValue(serde_json::Value),
128}
129
130/// DeleteCustomCostsFileError is a struct for typed errors of method [`CloudCostManagementAPI::delete_custom_costs_file`]
131#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(untagged)]
133pub enum DeleteCustomCostsFileError {
134    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
135    UnknownValue(serde_json::Value),
136}
137
138/// DeleteTagPipelinesRulesetError is a struct for typed errors of method [`CloudCostManagementAPI::delete_tag_pipelines_ruleset`]
139#[derive(Debug, Clone, Serialize, Deserialize)]
140#[serde(untagged)]
141pub enum DeleteTagPipelinesRulesetError {
142    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
143    UnknownValue(serde_json::Value),
144}
145
146/// GetBudgetError is a struct for typed errors of method [`CloudCostManagementAPI::get_budget`]
147#[derive(Debug, Clone, Serialize, Deserialize)]
148#[serde(untagged)]
149pub enum GetBudgetError {
150    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
151    UnknownValue(serde_json::Value),
152}
153
154/// GetCostAWSCURConfigError is a struct for typed errors of method [`CloudCostManagementAPI::get_cost_awscur_config`]
155#[derive(Debug, Clone, Serialize, Deserialize)]
156#[serde(untagged)]
157pub enum GetCostAWSCURConfigError {
158    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
159    UnknownValue(serde_json::Value),
160}
161
162/// GetCostAzureUCConfigError is a struct for typed errors of method [`CloudCostManagementAPI::get_cost_azure_uc_config`]
163#[derive(Debug, Clone, Serialize, Deserialize)]
164#[serde(untagged)]
165pub enum GetCostAzureUCConfigError {
166    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
167    UnknownValue(serde_json::Value),
168}
169
170/// GetCostGCPUsageCostConfigError is a struct for typed errors of method [`CloudCostManagementAPI::get_cost_gcp_usage_cost_config`]
171#[derive(Debug, Clone, Serialize, Deserialize)]
172#[serde(untagged)]
173pub enum GetCostGCPUsageCostConfigError {
174    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
175    UnknownValue(serde_json::Value),
176}
177
178/// GetCustomAllocationRuleError is a struct for typed errors of method [`CloudCostManagementAPI::get_custom_allocation_rule`]
179#[derive(Debug, Clone, Serialize, Deserialize)]
180#[serde(untagged)]
181pub enum GetCustomAllocationRuleError {
182    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
183    UnknownValue(serde_json::Value),
184}
185
186/// GetCustomCostsFileError is a struct for typed errors of method [`CloudCostManagementAPI::get_custom_costs_file`]
187#[derive(Debug, Clone, Serialize, Deserialize)]
188#[serde(untagged)]
189pub enum GetCustomCostsFileError {
190    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
191    UnknownValue(serde_json::Value),
192}
193
194/// GetTagPipelinesRulesetError is a struct for typed errors of method [`CloudCostManagementAPI::get_tag_pipelines_ruleset`]
195#[derive(Debug, Clone, Serialize, Deserialize)]
196#[serde(untagged)]
197pub enum GetTagPipelinesRulesetError {
198    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
199    UnknownValue(serde_json::Value),
200}
201
202/// ListBudgetsError is a struct for typed errors of method [`CloudCostManagementAPI::list_budgets`]
203#[derive(Debug, Clone, Serialize, Deserialize)]
204#[serde(untagged)]
205pub enum ListBudgetsError {
206    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
207    UnknownValue(serde_json::Value),
208}
209
210/// ListCostAWSCURConfigsError is a struct for typed errors of method [`CloudCostManagementAPI::list_cost_awscur_configs`]
211#[derive(Debug, Clone, Serialize, Deserialize)]
212#[serde(untagged)]
213pub enum ListCostAWSCURConfigsError {
214    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
215    UnknownValue(serde_json::Value),
216}
217
218/// ListCostAzureUCConfigsError is a struct for typed errors of method [`CloudCostManagementAPI::list_cost_azure_uc_configs`]
219#[derive(Debug, Clone, Serialize, Deserialize)]
220#[serde(untagged)]
221pub enum ListCostAzureUCConfigsError {
222    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
223    UnknownValue(serde_json::Value),
224}
225
226/// ListCostGCPUsageCostConfigsError is a struct for typed errors of method [`CloudCostManagementAPI::list_cost_gcp_usage_cost_configs`]
227#[derive(Debug, Clone, Serialize, Deserialize)]
228#[serde(untagged)]
229pub enum ListCostGCPUsageCostConfigsError {
230    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
231    UnknownValue(serde_json::Value),
232}
233
234/// ListCustomAllocationRulesError is a struct for typed errors of method [`CloudCostManagementAPI::list_custom_allocation_rules`]
235#[derive(Debug, Clone, Serialize, Deserialize)]
236#[serde(untagged)]
237pub enum ListCustomAllocationRulesError {
238    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
239    UnknownValue(serde_json::Value),
240}
241
242/// ListCustomCostsFilesError is a struct for typed errors of method [`CloudCostManagementAPI::list_custom_costs_files`]
243#[derive(Debug, Clone, Serialize, Deserialize)]
244#[serde(untagged)]
245pub enum ListCustomCostsFilesError {
246    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
247    UnknownValue(serde_json::Value),
248}
249
250/// ListTagPipelinesRulesetsError is a struct for typed errors of method [`CloudCostManagementAPI::list_tag_pipelines_rulesets`]
251#[derive(Debug, Clone, Serialize, Deserialize)]
252#[serde(untagged)]
253pub enum ListTagPipelinesRulesetsError {
254    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
255    UnknownValue(serde_json::Value),
256}
257
258/// ReorderCustomAllocationRulesError is a struct for typed errors of method [`CloudCostManagementAPI::reorder_custom_allocation_rules`]
259#[derive(Debug, Clone, Serialize, Deserialize)]
260#[serde(untagged)]
261pub enum ReorderCustomAllocationRulesError {
262    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
263    UnknownValue(serde_json::Value),
264}
265
266/// ReorderTagPipelinesRulesetsError is a struct for typed errors of method [`CloudCostManagementAPI::reorder_tag_pipelines_rulesets`]
267#[derive(Debug, Clone, Serialize, Deserialize)]
268#[serde(untagged)]
269pub enum ReorderTagPipelinesRulesetsError {
270    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
271    UnknownValue(serde_json::Value),
272}
273
274/// UpdateCostAWSCURConfigError is a struct for typed errors of method [`CloudCostManagementAPI::update_cost_awscur_config`]
275#[derive(Debug, Clone, Serialize, Deserialize)]
276#[serde(untagged)]
277pub enum UpdateCostAWSCURConfigError {
278    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
279    UnknownValue(serde_json::Value),
280}
281
282/// UpdateCostAzureUCConfigsError is a struct for typed errors of method [`CloudCostManagementAPI::update_cost_azure_uc_configs`]
283#[derive(Debug, Clone, Serialize, Deserialize)]
284#[serde(untagged)]
285pub enum UpdateCostAzureUCConfigsError {
286    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
287    UnknownValue(serde_json::Value),
288}
289
290/// UpdateCostGCPUsageCostConfigError is a struct for typed errors of method [`CloudCostManagementAPI::update_cost_gcp_usage_cost_config`]
291#[derive(Debug, Clone, Serialize, Deserialize)]
292#[serde(untagged)]
293pub enum UpdateCostGCPUsageCostConfigError {
294    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
295    UnknownValue(serde_json::Value),
296}
297
298/// UpdateCustomAllocationRuleError is a struct for typed errors of method [`CloudCostManagementAPI::update_custom_allocation_rule`]
299#[derive(Debug, Clone, Serialize, Deserialize)]
300#[serde(untagged)]
301pub enum UpdateCustomAllocationRuleError {
302    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
303    UnknownValue(serde_json::Value),
304}
305
306/// UpdateTagPipelinesRulesetError is a struct for typed errors of method [`CloudCostManagementAPI::update_tag_pipelines_ruleset`]
307#[derive(Debug, Clone, Serialize, Deserialize)]
308#[serde(untagged)]
309pub enum UpdateTagPipelinesRulesetError {
310    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
311    UnknownValue(serde_json::Value),
312}
313
314/// UploadCustomCostsFileError is a struct for typed errors of method [`CloudCostManagementAPI::upload_custom_costs_file`]
315#[derive(Debug, Clone, Serialize, Deserialize)]
316#[serde(untagged)]
317pub enum UploadCustomCostsFileError {
318    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
319    UnknownValue(serde_json::Value),
320}
321
322/// UpsertBudgetError is a struct for typed errors of method [`CloudCostManagementAPI::upsert_budget`]
323#[derive(Debug, Clone, Serialize, Deserialize)]
324#[serde(untagged)]
325pub enum UpsertBudgetError {
326    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
327    UnknownValue(serde_json::Value),
328}
329
330/// ValidateQueryError is a struct for typed errors of method [`CloudCostManagementAPI::validate_query`]
331#[derive(Debug, Clone, Serialize, Deserialize)]
332#[serde(untagged)]
333pub enum ValidateQueryError {
334    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
335    UnknownValue(serde_json::Value),
336}
337
338/// The Cloud Cost Management API allows you to set up, edit, and delete Cloud Cost Management accounts for AWS, Azure, and Google Cloud. You can query your cost data by using the [Metrics endpoint](<https://docs.datadoghq.com/api/latest/metrics/#query-timeseries-data-across-multiple-products>) and the `cloud_cost` data source. For more information, see the [Cloud Cost Management documentation](<https://docs.datadoghq.com/cloud_cost_management/>).
339#[derive(Debug, Clone)]
340pub struct CloudCostManagementAPI {
341    config: datadog::Configuration,
342    client: reqwest_middleware::ClientWithMiddleware,
343}
344
345impl Default for CloudCostManagementAPI {
346    fn default() -> Self {
347        Self::with_config(datadog::Configuration::default())
348    }
349}
350
351impl CloudCostManagementAPI {
352    pub fn new() -> Self {
353        Self::default()
354    }
355    pub fn with_config(config: datadog::Configuration) -> Self {
356        let mut reqwest_client_builder = reqwest::Client::builder();
357
358        if let Some(proxy_url) = &config.proxy_url {
359            let proxy = reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL");
360            reqwest_client_builder = reqwest_client_builder.proxy(proxy);
361        }
362
363        let mut middleware_client_builder =
364            reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap());
365
366        if config.enable_retry {
367            struct RetryableStatus;
368            impl reqwest_retry::RetryableStrategy for RetryableStatus {
369                fn handle(
370                    &self,
371                    res: &Result<reqwest::Response, reqwest_middleware::Error>,
372                ) -> Option<reqwest_retry::Retryable> {
373                    match res {
374                        Ok(success) => reqwest_retry::default_on_request_success(success),
375                        Err(_) => None,
376                    }
377                }
378            }
379            let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder()
380                .build_with_max_retries(config.max_retries);
381
382            let retry_middleware =
383                reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy(
384                    backoff_policy,
385                    RetryableStatus,
386                );
387
388            middleware_client_builder = middleware_client_builder.with(retry_middleware);
389        }
390
391        let client = middleware_client_builder.build();
392
393        Self { config, client }
394    }
395
396    pub fn with_client_and_config(
397        config: datadog::Configuration,
398        client: reqwest_middleware::ClientWithMiddleware,
399    ) -> Self {
400        Self { config, client }
401    }
402
403    /// Create a Cloud Cost Management account for an AWS CUR config.
404    pub async fn create_cost_awscur_config(
405        &self,
406        body: crate::datadogV2::model::AwsCURConfigPostRequest,
407    ) -> Result<
408        crate::datadogV2::model::AwsCurConfigResponse,
409        datadog::Error<CreateCostAWSCURConfigError>,
410    > {
411        match self.create_cost_awscur_config_with_http_info(body).await {
412            Ok(response_content) => {
413                if let Some(e) = response_content.entity {
414                    Ok(e)
415                } else {
416                    Err(datadog::Error::Serde(serde::de::Error::custom(
417                        "response content was None",
418                    )))
419                }
420            }
421            Err(err) => Err(err),
422        }
423    }
424
425    /// Create a Cloud Cost Management account for an AWS CUR config.
426    pub async fn create_cost_awscur_config_with_http_info(
427        &self,
428        body: crate::datadogV2::model::AwsCURConfigPostRequest,
429    ) -> Result<
430        datadog::ResponseContent<crate::datadogV2::model::AwsCurConfigResponse>,
431        datadog::Error<CreateCostAWSCURConfigError>,
432    > {
433        let local_configuration = &self.config;
434        let operation_id = "v2.create_cost_awscur_config";
435
436        let local_client = &self.client;
437
438        let local_uri_str = format!(
439            "{}/api/v2/cost/aws_cur_config",
440            local_configuration.get_operation_host(operation_id)
441        );
442        let mut local_req_builder =
443            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
444
445        // build headers
446        let mut headers = HeaderMap::new();
447        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
448        headers.insert("Accept", HeaderValue::from_static("application/json"));
449
450        // build user agent
451        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
452            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
453            Err(e) => {
454                log::warn!("Failed to parse user agent header: {e}, falling back to default");
455                headers.insert(
456                    reqwest::header::USER_AGENT,
457                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
458                )
459            }
460        };
461
462        // build auth
463        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
464            headers.insert(
465                "DD-API-KEY",
466                HeaderValue::from_str(local_key.key.as_str())
467                    .expect("failed to parse DD-API-KEY header"),
468            );
469        };
470        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
471            headers.insert(
472                "DD-APPLICATION-KEY",
473                HeaderValue::from_str(local_key.key.as_str())
474                    .expect("failed to parse DD-APPLICATION-KEY header"),
475            );
476        };
477
478        // build body parameters
479        let output = Vec::new();
480        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
481        if body.serialize(&mut ser).is_ok() {
482            if let Some(content_encoding) = headers.get("Content-Encoding") {
483                match content_encoding.to_str().unwrap_or_default() {
484                    "gzip" => {
485                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
486                        let _ = enc.write_all(ser.into_inner().as_slice());
487                        match enc.finish() {
488                            Ok(buf) => {
489                                local_req_builder = local_req_builder.body(buf);
490                            }
491                            Err(e) => return Err(datadog::Error::Io(e)),
492                        }
493                    }
494                    "deflate" => {
495                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
496                        let _ = enc.write_all(ser.into_inner().as_slice());
497                        match enc.finish() {
498                            Ok(buf) => {
499                                local_req_builder = local_req_builder.body(buf);
500                            }
501                            Err(e) => return Err(datadog::Error::Io(e)),
502                        }
503                    }
504                    "zstd1" => {
505                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
506                        let _ = enc.write_all(ser.into_inner().as_slice());
507                        match enc.finish() {
508                            Ok(buf) => {
509                                local_req_builder = local_req_builder.body(buf);
510                            }
511                            Err(e) => return Err(datadog::Error::Io(e)),
512                        }
513                    }
514                    _ => {
515                        local_req_builder = local_req_builder.body(ser.into_inner());
516                    }
517                }
518            } else {
519                local_req_builder = local_req_builder.body(ser.into_inner());
520            }
521        }
522
523        local_req_builder = local_req_builder.headers(headers);
524        let local_req = local_req_builder.build()?;
525        log::debug!("request content: {:?}", local_req.body());
526        let local_resp = local_client.execute(local_req).await?;
527
528        let local_status = local_resp.status();
529        let local_content = local_resp.text().await?;
530        log::debug!("response content: {}", local_content);
531
532        if !local_status.is_client_error() && !local_status.is_server_error() {
533            match serde_json::from_str::<crate::datadogV2::model::AwsCurConfigResponse>(
534                &local_content,
535            ) {
536                Ok(e) => {
537                    return Ok(datadog::ResponseContent {
538                        status: local_status,
539                        content: local_content,
540                        entity: Some(e),
541                    })
542                }
543                Err(e) => return Err(datadog::Error::Serde(e)),
544            };
545        } else {
546            let local_entity: Option<CreateCostAWSCURConfigError> =
547                serde_json::from_str(&local_content).ok();
548            let local_error = datadog::ResponseContent {
549                status: local_status,
550                content: local_content,
551                entity: local_entity,
552            };
553            Err(datadog::Error::ResponseError(local_error))
554        }
555    }
556
557    /// Create a Cloud Cost Management account for an Azure config.
558    pub async fn create_cost_azure_uc_configs(
559        &self,
560        body: crate::datadogV2::model::AzureUCConfigPostRequest,
561    ) -> Result<
562        crate::datadogV2::model::AzureUCConfigPairsResponse,
563        datadog::Error<CreateCostAzureUCConfigsError>,
564    > {
565        match self.create_cost_azure_uc_configs_with_http_info(body).await {
566            Ok(response_content) => {
567                if let Some(e) = response_content.entity {
568                    Ok(e)
569                } else {
570                    Err(datadog::Error::Serde(serde::de::Error::custom(
571                        "response content was None",
572                    )))
573                }
574            }
575            Err(err) => Err(err),
576        }
577    }
578
579    /// Create a Cloud Cost Management account for an Azure config.
580    pub async fn create_cost_azure_uc_configs_with_http_info(
581        &self,
582        body: crate::datadogV2::model::AzureUCConfigPostRequest,
583    ) -> Result<
584        datadog::ResponseContent<crate::datadogV2::model::AzureUCConfigPairsResponse>,
585        datadog::Error<CreateCostAzureUCConfigsError>,
586    > {
587        let local_configuration = &self.config;
588        let operation_id = "v2.create_cost_azure_uc_configs";
589
590        let local_client = &self.client;
591
592        let local_uri_str = format!(
593            "{}/api/v2/cost/azure_uc_config",
594            local_configuration.get_operation_host(operation_id)
595        );
596        let mut local_req_builder =
597            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
598
599        // build headers
600        let mut headers = HeaderMap::new();
601        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
602        headers.insert("Accept", HeaderValue::from_static("application/json"));
603
604        // build user agent
605        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
606            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
607            Err(e) => {
608                log::warn!("Failed to parse user agent header: {e}, falling back to default");
609                headers.insert(
610                    reqwest::header::USER_AGENT,
611                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
612                )
613            }
614        };
615
616        // build auth
617        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
618            headers.insert(
619                "DD-API-KEY",
620                HeaderValue::from_str(local_key.key.as_str())
621                    .expect("failed to parse DD-API-KEY header"),
622            );
623        };
624        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
625            headers.insert(
626                "DD-APPLICATION-KEY",
627                HeaderValue::from_str(local_key.key.as_str())
628                    .expect("failed to parse DD-APPLICATION-KEY header"),
629            );
630        };
631
632        // build body parameters
633        let output = Vec::new();
634        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
635        if body.serialize(&mut ser).is_ok() {
636            if let Some(content_encoding) = headers.get("Content-Encoding") {
637                match content_encoding.to_str().unwrap_or_default() {
638                    "gzip" => {
639                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
640                        let _ = enc.write_all(ser.into_inner().as_slice());
641                        match enc.finish() {
642                            Ok(buf) => {
643                                local_req_builder = local_req_builder.body(buf);
644                            }
645                            Err(e) => return Err(datadog::Error::Io(e)),
646                        }
647                    }
648                    "deflate" => {
649                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
650                        let _ = enc.write_all(ser.into_inner().as_slice());
651                        match enc.finish() {
652                            Ok(buf) => {
653                                local_req_builder = local_req_builder.body(buf);
654                            }
655                            Err(e) => return Err(datadog::Error::Io(e)),
656                        }
657                    }
658                    "zstd1" => {
659                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
660                        let _ = enc.write_all(ser.into_inner().as_slice());
661                        match enc.finish() {
662                            Ok(buf) => {
663                                local_req_builder = local_req_builder.body(buf);
664                            }
665                            Err(e) => return Err(datadog::Error::Io(e)),
666                        }
667                    }
668                    _ => {
669                        local_req_builder = local_req_builder.body(ser.into_inner());
670                    }
671                }
672            } else {
673                local_req_builder = local_req_builder.body(ser.into_inner());
674            }
675        }
676
677        local_req_builder = local_req_builder.headers(headers);
678        let local_req = local_req_builder.build()?;
679        log::debug!("request content: {:?}", local_req.body());
680        let local_resp = local_client.execute(local_req).await?;
681
682        let local_status = local_resp.status();
683        let local_content = local_resp.text().await?;
684        log::debug!("response content: {}", local_content);
685
686        if !local_status.is_client_error() && !local_status.is_server_error() {
687            match serde_json::from_str::<crate::datadogV2::model::AzureUCConfigPairsResponse>(
688                &local_content,
689            ) {
690                Ok(e) => {
691                    return Ok(datadog::ResponseContent {
692                        status: local_status,
693                        content: local_content,
694                        entity: Some(e),
695                    })
696                }
697                Err(e) => return Err(datadog::Error::Serde(e)),
698            };
699        } else {
700            let local_entity: Option<CreateCostAzureUCConfigsError> =
701                serde_json::from_str(&local_content).ok();
702            let local_error = datadog::ResponseContent {
703                status: local_status,
704                content: local_content,
705                entity: local_entity,
706            };
707            Err(datadog::Error::ResponseError(local_error))
708        }
709    }
710
711    /// Create a Cloud Cost Management account for an Google Cloud Usage Cost config.
712    pub async fn create_cost_gcp_usage_cost_config(
713        &self,
714        body: crate::datadogV2::model::GCPUsageCostConfigPostRequest,
715    ) -> Result<
716        crate::datadogV2::model::GCPUsageCostConfigResponse,
717        datadog::Error<CreateCostGCPUsageCostConfigError>,
718    > {
719        match self
720            .create_cost_gcp_usage_cost_config_with_http_info(body)
721            .await
722        {
723            Ok(response_content) => {
724                if let Some(e) = response_content.entity {
725                    Ok(e)
726                } else {
727                    Err(datadog::Error::Serde(serde::de::Error::custom(
728                        "response content was None",
729                    )))
730                }
731            }
732            Err(err) => Err(err),
733        }
734    }
735
736    /// Create a Cloud Cost Management account for an Google Cloud Usage Cost config.
737    pub async fn create_cost_gcp_usage_cost_config_with_http_info(
738        &self,
739        body: crate::datadogV2::model::GCPUsageCostConfigPostRequest,
740    ) -> Result<
741        datadog::ResponseContent<crate::datadogV2::model::GCPUsageCostConfigResponse>,
742        datadog::Error<CreateCostGCPUsageCostConfigError>,
743    > {
744        let local_configuration = &self.config;
745        let operation_id = "v2.create_cost_gcp_usage_cost_config";
746
747        let local_client = &self.client;
748
749        let local_uri_str = format!(
750            "{}/api/v2/cost/gcp_uc_config",
751            local_configuration.get_operation_host(operation_id)
752        );
753        let mut local_req_builder =
754            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
755
756        // build headers
757        let mut headers = HeaderMap::new();
758        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
759        headers.insert("Accept", HeaderValue::from_static("application/json"));
760
761        // build user agent
762        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
763            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
764            Err(e) => {
765                log::warn!("Failed to parse user agent header: {e}, falling back to default");
766                headers.insert(
767                    reqwest::header::USER_AGENT,
768                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
769                )
770            }
771        };
772
773        // build auth
774        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
775            headers.insert(
776                "DD-API-KEY",
777                HeaderValue::from_str(local_key.key.as_str())
778                    .expect("failed to parse DD-API-KEY header"),
779            );
780        };
781        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
782            headers.insert(
783                "DD-APPLICATION-KEY",
784                HeaderValue::from_str(local_key.key.as_str())
785                    .expect("failed to parse DD-APPLICATION-KEY header"),
786            );
787        };
788
789        // build body parameters
790        let output = Vec::new();
791        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
792        if body.serialize(&mut ser).is_ok() {
793            if let Some(content_encoding) = headers.get("Content-Encoding") {
794                match content_encoding.to_str().unwrap_or_default() {
795                    "gzip" => {
796                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
797                        let _ = enc.write_all(ser.into_inner().as_slice());
798                        match enc.finish() {
799                            Ok(buf) => {
800                                local_req_builder = local_req_builder.body(buf);
801                            }
802                            Err(e) => return Err(datadog::Error::Io(e)),
803                        }
804                    }
805                    "deflate" => {
806                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
807                        let _ = enc.write_all(ser.into_inner().as_slice());
808                        match enc.finish() {
809                            Ok(buf) => {
810                                local_req_builder = local_req_builder.body(buf);
811                            }
812                            Err(e) => return Err(datadog::Error::Io(e)),
813                        }
814                    }
815                    "zstd1" => {
816                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
817                        let _ = enc.write_all(ser.into_inner().as_slice());
818                        match enc.finish() {
819                            Ok(buf) => {
820                                local_req_builder = local_req_builder.body(buf);
821                            }
822                            Err(e) => return Err(datadog::Error::Io(e)),
823                        }
824                    }
825                    _ => {
826                        local_req_builder = local_req_builder.body(ser.into_inner());
827                    }
828                }
829            } else {
830                local_req_builder = local_req_builder.body(ser.into_inner());
831            }
832        }
833
834        local_req_builder = local_req_builder.headers(headers);
835        let local_req = local_req_builder.build()?;
836        log::debug!("request content: {:?}", local_req.body());
837        let local_resp = local_client.execute(local_req).await?;
838
839        let local_status = local_resp.status();
840        let local_content = local_resp.text().await?;
841        log::debug!("response content: {}", local_content);
842
843        if !local_status.is_client_error() && !local_status.is_server_error() {
844            match serde_json::from_str::<crate::datadogV2::model::GCPUsageCostConfigResponse>(
845                &local_content,
846            ) {
847                Ok(e) => {
848                    return Ok(datadog::ResponseContent {
849                        status: local_status,
850                        content: local_content,
851                        entity: Some(e),
852                    })
853                }
854                Err(e) => return Err(datadog::Error::Serde(e)),
855            };
856        } else {
857            let local_entity: Option<CreateCostGCPUsageCostConfigError> =
858                serde_json::from_str(&local_content).ok();
859            let local_error = datadog::ResponseContent {
860                status: local_status,
861                content: local_content,
862                entity: local_entity,
863            };
864            Err(datadog::Error::ResponseError(local_error))
865        }
866    }
867
868    /// Create a new custom allocation rule with the specified filters and allocation strategy.
869    ///
870    /// **Strategy Methods:**
871    /// - **PROPORTIONAL/EVEN**: Allocates costs proportionally/evenly based on existing costs. Requires: granularity, allocated_by_tag_keys. Optional: based_on_costs, allocated_by_filters, evaluate_grouped_by_tag_keys, evaluate_grouped_by_filters.
872    /// - **PROPORTIONAL_TIMESERIES/EVEN_TIMESERIES**: Allocates based on timeseries data. Requires: granularity, based_on_timeseries. Optional: evaluate_grouped_by_tag_keys.
873    /// - **PERCENT**: Allocates fixed percentages to specific tags. Requires: allocated_by (array of percentage allocations).
874    ///
875    /// **Filter Conditions:**
876    /// - Use **value** for single-value conditions: "is", "is not", "contains", "does not contain", "=", "!=", "like", "not like", "is all values", "is untagged"
877    /// - Use **values** for multi-value conditions: "in", "not in"
878    /// - Cannot use both value and values simultaneously.
879    ///
880    /// **Supported operators**: is, is not, is all values, is untagged, contains, does not contain, in, not in, =, !=, like, not like
881    pub async fn create_custom_allocation_rule(
882        &self,
883        body: crate::datadogV2::model::ArbitraryCostUpsertRequest,
884    ) -> Result<
885        crate::datadogV2::model::ArbitraryRuleResponse,
886        datadog::Error<CreateCustomAllocationRuleError>,
887    > {
888        match self
889            .create_custom_allocation_rule_with_http_info(body)
890            .await
891        {
892            Ok(response_content) => {
893                if let Some(e) = response_content.entity {
894                    Ok(e)
895                } else {
896                    Err(datadog::Error::Serde(serde::de::Error::custom(
897                        "response content was None",
898                    )))
899                }
900            }
901            Err(err) => Err(err),
902        }
903    }
904
905    /// Create a new custom allocation rule with the specified filters and allocation strategy.
906    ///
907    /// **Strategy Methods:**
908    /// - **PROPORTIONAL/EVEN**: Allocates costs proportionally/evenly based on existing costs. Requires: granularity, allocated_by_tag_keys. Optional: based_on_costs, allocated_by_filters, evaluate_grouped_by_tag_keys, evaluate_grouped_by_filters.
909    /// - **PROPORTIONAL_TIMESERIES/EVEN_TIMESERIES**: Allocates based on timeseries data. Requires: granularity, based_on_timeseries. Optional: evaluate_grouped_by_tag_keys.
910    /// - **PERCENT**: Allocates fixed percentages to specific tags. Requires: allocated_by (array of percentage allocations).
911    ///
912    /// **Filter Conditions:**
913    /// - Use **value** for single-value conditions: "is", "is not", "contains", "does not contain", "=", "!=", "like", "not like", "is all values", "is untagged"
914    /// - Use **values** for multi-value conditions: "in", "not in"
915    /// - Cannot use both value and values simultaneously.
916    ///
917    /// **Supported operators**: is, is not, is all values, is untagged, contains, does not contain, in, not in, =, !=, like, not like
918    pub async fn create_custom_allocation_rule_with_http_info(
919        &self,
920        body: crate::datadogV2::model::ArbitraryCostUpsertRequest,
921    ) -> Result<
922        datadog::ResponseContent<crate::datadogV2::model::ArbitraryRuleResponse>,
923        datadog::Error<CreateCustomAllocationRuleError>,
924    > {
925        let local_configuration = &self.config;
926        let operation_id = "v2.create_custom_allocation_rule";
927
928        let local_client = &self.client;
929
930        let local_uri_str = format!(
931            "{}/api/v2/cost/arbitrary_rule",
932            local_configuration.get_operation_host(operation_id)
933        );
934        let mut local_req_builder =
935            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
936
937        // build headers
938        let mut headers = HeaderMap::new();
939        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
940        headers.insert("Accept", HeaderValue::from_static("application/json"));
941
942        // build user agent
943        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
944            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
945            Err(e) => {
946                log::warn!("Failed to parse user agent header: {e}, falling back to default");
947                headers.insert(
948                    reqwest::header::USER_AGENT,
949                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
950                )
951            }
952        };
953
954        // build auth
955        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
956            headers.insert(
957                "DD-API-KEY",
958                HeaderValue::from_str(local_key.key.as_str())
959                    .expect("failed to parse DD-API-KEY header"),
960            );
961        };
962        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
963            headers.insert(
964                "DD-APPLICATION-KEY",
965                HeaderValue::from_str(local_key.key.as_str())
966                    .expect("failed to parse DD-APPLICATION-KEY header"),
967            );
968        };
969
970        // build body parameters
971        let output = Vec::new();
972        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
973        if body.serialize(&mut ser).is_ok() {
974            if let Some(content_encoding) = headers.get("Content-Encoding") {
975                match content_encoding.to_str().unwrap_or_default() {
976                    "gzip" => {
977                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
978                        let _ = enc.write_all(ser.into_inner().as_slice());
979                        match enc.finish() {
980                            Ok(buf) => {
981                                local_req_builder = local_req_builder.body(buf);
982                            }
983                            Err(e) => return Err(datadog::Error::Io(e)),
984                        }
985                    }
986                    "deflate" => {
987                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
988                        let _ = enc.write_all(ser.into_inner().as_slice());
989                        match enc.finish() {
990                            Ok(buf) => {
991                                local_req_builder = local_req_builder.body(buf);
992                            }
993                            Err(e) => return Err(datadog::Error::Io(e)),
994                        }
995                    }
996                    "zstd1" => {
997                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
998                        let _ = enc.write_all(ser.into_inner().as_slice());
999                        match enc.finish() {
1000                            Ok(buf) => {
1001                                local_req_builder = local_req_builder.body(buf);
1002                            }
1003                            Err(e) => return Err(datadog::Error::Io(e)),
1004                        }
1005                    }
1006                    _ => {
1007                        local_req_builder = local_req_builder.body(ser.into_inner());
1008                    }
1009                }
1010            } else {
1011                local_req_builder = local_req_builder.body(ser.into_inner());
1012            }
1013        }
1014
1015        local_req_builder = local_req_builder.headers(headers);
1016        let local_req = local_req_builder.build()?;
1017        log::debug!("request content: {:?}", local_req.body());
1018        let local_resp = local_client.execute(local_req).await?;
1019
1020        let local_status = local_resp.status();
1021        let local_content = local_resp.text().await?;
1022        log::debug!("response content: {}", local_content);
1023
1024        if !local_status.is_client_error() && !local_status.is_server_error() {
1025            match serde_json::from_str::<crate::datadogV2::model::ArbitraryRuleResponse>(
1026                &local_content,
1027            ) {
1028                Ok(e) => {
1029                    return Ok(datadog::ResponseContent {
1030                        status: local_status,
1031                        content: local_content,
1032                        entity: Some(e),
1033                    })
1034                }
1035                Err(e) => return Err(datadog::Error::Serde(e)),
1036            };
1037        } else {
1038            let local_entity: Option<CreateCustomAllocationRuleError> =
1039                serde_json::from_str(&local_content).ok();
1040            let local_error = datadog::ResponseContent {
1041                status: local_status,
1042                content: local_content,
1043                entity: local_entity,
1044            };
1045            Err(datadog::Error::ResponseError(local_error))
1046        }
1047    }
1048
1049    /// Create a new tag pipeline ruleset with the specified rules and configuration
1050    pub async fn create_tag_pipelines_ruleset(
1051        &self,
1052        body: crate::datadogV2::model::CreateRulesetRequest,
1053    ) -> Result<crate::datadogV2::model::RulesetResp, datadog::Error<CreateTagPipelinesRulesetError>>
1054    {
1055        match self.create_tag_pipelines_ruleset_with_http_info(body).await {
1056            Ok(response_content) => {
1057                if let Some(e) = response_content.entity {
1058                    Ok(e)
1059                } else {
1060                    Err(datadog::Error::Serde(serde::de::Error::custom(
1061                        "response content was None",
1062                    )))
1063                }
1064            }
1065            Err(err) => Err(err),
1066        }
1067    }
1068
1069    /// Create a new tag pipeline ruleset with the specified rules and configuration
1070    pub async fn create_tag_pipelines_ruleset_with_http_info(
1071        &self,
1072        body: crate::datadogV2::model::CreateRulesetRequest,
1073    ) -> Result<
1074        datadog::ResponseContent<crate::datadogV2::model::RulesetResp>,
1075        datadog::Error<CreateTagPipelinesRulesetError>,
1076    > {
1077        let local_configuration = &self.config;
1078        let operation_id = "v2.create_tag_pipelines_ruleset";
1079
1080        let local_client = &self.client;
1081
1082        let local_uri_str = format!(
1083            "{}/api/v2/tags/enrichment",
1084            local_configuration.get_operation_host(operation_id)
1085        );
1086        let mut local_req_builder =
1087            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
1088
1089        // build headers
1090        let mut headers = HeaderMap::new();
1091        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1092        headers.insert("Accept", HeaderValue::from_static("application/json"));
1093
1094        // build user agent
1095        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1096            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1097            Err(e) => {
1098                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1099                headers.insert(
1100                    reqwest::header::USER_AGENT,
1101                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1102                )
1103            }
1104        };
1105
1106        // build auth
1107        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1108            headers.insert(
1109                "DD-API-KEY",
1110                HeaderValue::from_str(local_key.key.as_str())
1111                    .expect("failed to parse DD-API-KEY header"),
1112            );
1113        };
1114        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1115            headers.insert(
1116                "DD-APPLICATION-KEY",
1117                HeaderValue::from_str(local_key.key.as_str())
1118                    .expect("failed to parse DD-APPLICATION-KEY header"),
1119            );
1120        };
1121
1122        // build body parameters
1123        let output = Vec::new();
1124        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1125        if body.serialize(&mut ser).is_ok() {
1126            if let Some(content_encoding) = headers.get("Content-Encoding") {
1127                match content_encoding.to_str().unwrap_or_default() {
1128                    "gzip" => {
1129                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1130                        let _ = enc.write_all(ser.into_inner().as_slice());
1131                        match enc.finish() {
1132                            Ok(buf) => {
1133                                local_req_builder = local_req_builder.body(buf);
1134                            }
1135                            Err(e) => return Err(datadog::Error::Io(e)),
1136                        }
1137                    }
1138                    "deflate" => {
1139                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1140                        let _ = enc.write_all(ser.into_inner().as_slice());
1141                        match enc.finish() {
1142                            Ok(buf) => {
1143                                local_req_builder = local_req_builder.body(buf);
1144                            }
1145                            Err(e) => return Err(datadog::Error::Io(e)),
1146                        }
1147                    }
1148                    "zstd1" => {
1149                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1150                        let _ = enc.write_all(ser.into_inner().as_slice());
1151                        match enc.finish() {
1152                            Ok(buf) => {
1153                                local_req_builder = local_req_builder.body(buf);
1154                            }
1155                            Err(e) => return Err(datadog::Error::Io(e)),
1156                        }
1157                    }
1158                    _ => {
1159                        local_req_builder = local_req_builder.body(ser.into_inner());
1160                    }
1161                }
1162            } else {
1163                local_req_builder = local_req_builder.body(ser.into_inner());
1164            }
1165        }
1166
1167        local_req_builder = local_req_builder.headers(headers);
1168        let local_req = local_req_builder.build()?;
1169        log::debug!("request content: {:?}", local_req.body());
1170        let local_resp = local_client.execute(local_req).await?;
1171
1172        let local_status = local_resp.status();
1173        let local_content = local_resp.text().await?;
1174        log::debug!("response content: {}", local_content);
1175
1176        if !local_status.is_client_error() && !local_status.is_server_error() {
1177            match serde_json::from_str::<crate::datadogV2::model::RulesetResp>(&local_content) {
1178                Ok(e) => {
1179                    return Ok(datadog::ResponseContent {
1180                        status: local_status,
1181                        content: local_content,
1182                        entity: Some(e),
1183                    })
1184                }
1185                Err(e) => return Err(datadog::Error::Serde(e)),
1186            };
1187        } else {
1188            let local_entity: Option<CreateTagPipelinesRulesetError> =
1189                serde_json::from_str(&local_content).ok();
1190            let local_error = datadog::ResponseContent {
1191                status: local_status,
1192                content: local_content,
1193                entity: local_entity,
1194            };
1195            Err(datadog::Error::ResponseError(local_error))
1196        }
1197    }
1198
1199    /// Delete a budget.
1200    pub async fn delete_budget(
1201        &self,
1202        budget_id: String,
1203    ) -> Result<(), datadog::Error<DeleteBudgetError>> {
1204        match self.delete_budget_with_http_info(budget_id).await {
1205            Ok(_) => Ok(()),
1206            Err(err) => Err(err),
1207        }
1208    }
1209
1210    /// Delete a budget.
1211    pub async fn delete_budget_with_http_info(
1212        &self,
1213        budget_id: String,
1214    ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteBudgetError>> {
1215        let local_configuration = &self.config;
1216        let operation_id = "v2.delete_budget";
1217
1218        let local_client = &self.client;
1219
1220        let local_uri_str = format!(
1221            "{}/api/v2/cost/budget/{budget_id}",
1222            local_configuration.get_operation_host(operation_id),
1223            budget_id = datadog::urlencode(budget_id)
1224        );
1225        let mut local_req_builder =
1226            local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
1227
1228        // build headers
1229        let mut headers = HeaderMap::new();
1230        headers.insert("Accept", HeaderValue::from_static("*/*"));
1231
1232        // build user agent
1233        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1234            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1235            Err(e) => {
1236                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1237                headers.insert(
1238                    reqwest::header::USER_AGENT,
1239                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1240                )
1241            }
1242        };
1243
1244        // build auth
1245        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1246            headers.insert(
1247                "DD-API-KEY",
1248                HeaderValue::from_str(local_key.key.as_str())
1249                    .expect("failed to parse DD-API-KEY header"),
1250            );
1251        };
1252        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1253            headers.insert(
1254                "DD-APPLICATION-KEY",
1255                HeaderValue::from_str(local_key.key.as_str())
1256                    .expect("failed to parse DD-APPLICATION-KEY header"),
1257            );
1258        };
1259
1260        local_req_builder = local_req_builder.headers(headers);
1261        let local_req = local_req_builder.build()?;
1262        log::debug!("request content: {:?}", local_req.body());
1263        let local_resp = local_client.execute(local_req).await?;
1264
1265        let local_status = local_resp.status();
1266        let local_content = local_resp.text().await?;
1267        log::debug!("response content: {}", local_content);
1268
1269        if !local_status.is_client_error() && !local_status.is_server_error() {
1270            Ok(datadog::ResponseContent {
1271                status: local_status,
1272                content: local_content,
1273                entity: None,
1274            })
1275        } else {
1276            let local_entity: Option<DeleteBudgetError> = serde_json::from_str(&local_content).ok();
1277            let local_error = datadog::ResponseContent {
1278                status: local_status,
1279                content: local_content,
1280                entity: local_entity,
1281            };
1282            Err(datadog::Error::ResponseError(local_error))
1283        }
1284    }
1285
1286    /// Archive a Cloud Cost Management Account.
1287    pub async fn delete_cost_awscur_config(
1288        &self,
1289        cloud_account_id: i64,
1290    ) -> Result<(), datadog::Error<DeleteCostAWSCURConfigError>> {
1291        match self
1292            .delete_cost_awscur_config_with_http_info(cloud_account_id)
1293            .await
1294        {
1295            Ok(_) => Ok(()),
1296            Err(err) => Err(err),
1297        }
1298    }
1299
1300    /// Archive a Cloud Cost Management Account.
1301    pub async fn delete_cost_awscur_config_with_http_info(
1302        &self,
1303        cloud_account_id: i64,
1304    ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteCostAWSCURConfigError>> {
1305        let local_configuration = &self.config;
1306        let operation_id = "v2.delete_cost_awscur_config";
1307
1308        let local_client = &self.client;
1309
1310        let local_uri_str = format!(
1311            "{}/api/v2/cost/aws_cur_config/{cloud_account_id}",
1312            local_configuration.get_operation_host(operation_id),
1313            cloud_account_id = cloud_account_id
1314        );
1315        let mut local_req_builder =
1316            local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
1317
1318        // build headers
1319        let mut headers = HeaderMap::new();
1320        headers.insert("Accept", HeaderValue::from_static("*/*"));
1321
1322        // build user agent
1323        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1324            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1325            Err(e) => {
1326                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1327                headers.insert(
1328                    reqwest::header::USER_AGENT,
1329                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1330                )
1331            }
1332        };
1333
1334        // build auth
1335        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1336            headers.insert(
1337                "DD-API-KEY",
1338                HeaderValue::from_str(local_key.key.as_str())
1339                    .expect("failed to parse DD-API-KEY header"),
1340            );
1341        };
1342        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1343            headers.insert(
1344                "DD-APPLICATION-KEY",
1345                HeaderValue::from_str(local_key.key.as_str())
1346                    .expect("failed to parse DD-APPLICATION-KEY header"),
1347            );
1348        };
1349
1350        local_req_builder = local_req_builder.headers(headers);
1351        let local_req = local_req_builder.build()?;
1352        log::debug!("request content: {:?}", local_req.body());
1353        let local_resp = local_client.execute(local_req).await?;
1354
1355        let local_status = local_resp.status();
1356        let local_content = local_resp.text().await?;
1357        log::debug!("response content: {}", local_content);
1358
1359        if !local_status.is_client_error() && !local_status.is_server_error() {
1360            Ok(datadog::ResponseContent {
1361                status: local_status,
1362                content: local_content,
1363                entity: None,
1364            })
1365        } else {
1366            let local_entity: Option<DeleteCostAWSCURConfigError> =
1367                serde_json::from_str(&local_content).ok();
1368            let local_error = datadog::ResponseContent {
1369                status: local_status,
1370                content: local_content,
1371                entity: local_entity,
1372            };
1373            Err(datadog::Error::ResponseError(local_error))
1374        }
1375    }
1376
1377    /// Archive a Cloud Cost Management Account.
1378    pub async fn delete_cost_azure_uc_config(
1379        &self,
1380        cloud_account_id: i64,
1381    ) -> Result<(), datadog::Error<DeleteCostAzureUCConfigError>> {
1382        match self
1383            .delete_cost_azure_uc_config_with_http_info(cloud_account_id)
1384            .await
1385        {
1386            Ok(_) => Ok(()),
1387            Err(err) => Err(err),
1388        }
1389    }
1390
1391    /// Archive a Cloud Cost Management Account.
1392    pub async fn delete_cost_azure_uc_config_with_http_info(
1393        &self,
1394        cloud_account_id: i64,
1395    ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteCostAzureUCConfigError>> {
1396        let local_configuration = &self.config;
1397        let operation_id = "v2.delete_cost_azure_uc_config";
1398
1399        let local_client = &self.client;
1400
1401        let local_uri_str = format!(
1402            "{}/api/v2/cost/azure_uc_config/{cloud_account_id}",
1403            local_configuration.get_operation_host(operation_id),
1404            cloud_account_id = cloud_account_id
1405        );
1406        let mut local_req_builder =
1407            local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
1408
1409        // build headers
1410        let mut headers = HeaderMap::new();
1411        headers.insert("Accept", HeaderValue::from_static("*/*"));
1412
1413        // build user agent
1414        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1415            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1416            Err(e) => {
1417                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1418                headers.insert(
1419                    reqwest::header::USER_AGENT,
1420                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1421                )
1422            }
1423        };
1424
1425        // build auth
1426        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1427            headers.insert(
1428                "DD-API-KEY",
1429                HeaderValue::from_str(local_key.key.as_str())
1430                    .expect("failed to parse DD-API-KEY header"),
1431            );
1432        };
1433        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1434            headers.insert(
1435                "DD-APPLICATION-KEY",
1436                HeaderValue::from_str(local_key.key.as_str())
1437                    .expect("failed to parse DD-APPLICATION-KEY header"),
1438            );
1439        };
1440
1441        local_req_builder = local_req_builder.headers(headers);
1442        let local_req = local_req_builder.build()?;
1443        log::debug!("request content: {:?}", local_req.body());
1444        let local_resp = local_client.execute(local_req).await?;
1445
1446        let local_status = local_resp.status();
1447        let local_content = local_resp.text().await?;
1448        log::debug!("response content: {}", local_content);
1449
1450        if !local_status.is_client_error() && !local_status.is_server_error() {
1451            Ok(datadog::ResponseContent {
1452                status: local_status,
1453                content: local_content,
1454                entity: None,
1455            })
1456        } else {
1457            let local_entity: Option<DeleteCostAzureUCConfigError> =
1458                serde_json::from_str(&local_content).ok();
1459            let local_error = datadog::ResponseContent {
1460                status: local_status,
1461                content: local_content,
1462                entity: local_entity,
1463            };
1464            Err(datadog::Error::ResponseError(local_error))
1465        }
1466    }
1467
1468    /// Archive a Cloud Cost Management account.
1469    pub async fn delete_cost_gcp_usage_cost_config(
1470        &self,
1471        cloud_account_id: i64,
1472    ) -> Result<(), datadog::Error<DeleteCostGCPUsageCostConfigError>> {
1473        match self
1474            .delete_cost_gcp_usage_cost_config_with_http_info(cloud_account_id)
1475            .await
1476        {
1477            Ok(_) => Ok(()),
1478            Err(err) => Err(err),
1479        }
1480    }
1481
1482    /// Archive a Cloud Cost Management account.
1483    pub async fn delete_cost_gcp_usage_cost_config_with_http_info(
1484        &self,
1485        cloud_account_id: i64,
1486    ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteCostGCPUsageCostConfigError>>
1487    {
1488        let local_configuration = &self.config;
1489        let operation_id = "v2.delete_cost_gcp_usage_cost_config";
1490
1491        let local_client = &self.client;
1492
1493        let local_uri_str = format!(
1494            "{}/api/v2/cost/gcp_uc_config/{cloud_account_id}",
1495            local_configuration.get_operation_host(operation_id),
1496            cloud_account_id = cloud_account_id
1497        );
1498        let mut local_req_builder =
1499            local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
1500
1501        // build headers
1502        let mut headers = HeaderMap::new();
1503        headers.insert("Accept", HeaderValue::from_static("*/*"));
1504
1505        // build user agent
1506        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1507            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1508            Err(e) => {
1509                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1510                headers.insert(
1511                    reqwest::header::USER_AGENT,
1512                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1513                )
1514            }
1515        };
1516
1517        // build auth
1518        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1519            headers.insert(
1520                "DD-API-KEY",
1521                HeaderValue::from_str(local_key.key.as_str())
1522                    .expect("failed to parse DD-API-KEY header"),
1523            );
1524        };
1525        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1526            headers.insert(
1527                "DD-APPLICATION-KEY",
1528                HeaderValue::from_str(local_key.key.as_str())
1529                    .expect("failed to parse DD-APPLICATION-KEY header"),
1530            );
1531        };
1532
1533        local_req_builder = local_req_builder.headers(headers);
1534        let local_req = local_req_builder.build()?;
1535        log::debug!("request content: {:?}", local_req.body());
1536        let local_resp = local_client.execute(local_req).await?;
1537
1538        let local_status = local_resp.status();
1539        let local_content = local_resp.text().await?;
1540        log::debug!("response content: {}", local_content);
1541
1542        if !local_status.is_client_error() && !local_status.is_server_error() {
1543            Ok(datadog::ResponseContent {
1544                status: local_status,
1545                content: local_content,
1546                entity: None,
1547            })
1548        } else {
1549            let local_entity: Option<DeleteCostGCPUsageCostConfigError> =
1550                serde_json::from_str(&local_content).ok();
1551            let local_error = datadog::ResponseContent {
1552                status: local_status,
1553                content: local_content,
1554                entity: local_entity,
1555            };
1556            Err(datadog::Error::ResponseError(local_error))
1557        }
1558    }
1559
1560    /// Delete a custom allocation rule - Delete an existing custom allocation rule by its ID
1561    pub async fn delete_custom_allocation_rule(
1562        &self,
1563        rule_id: i64,
1564    ) -> Result<(), datadog::Error<DeleteCustomAllocationRuleError>> {
1565        match self
1566            .delete_custom_allocation_rule_with_http_info(rule_id)
1567            .await
1568        {
1569            Ok(_) => Ok(()),
1570            Err(err) => Err(err),
1571        }
1572    }
1573
1574    /// Delete a custom allocation rule - Delete an existing custom allocation rule by its ID
1575    pub async fn delete_custom_allocation_rule_with_http_info(
1576        &self,
1577        rule_id: i64,
1578    ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteCustomAllocationRuleError>> {
1579        let local_configuration = &self.config;
1580        let operation_id = "v2.delete_custom_allocation_rule";
1581
1582        let local_client = &self.client;
1583
1584        let local_uri_str = format!(
1585            "{}/api/v2/cost/arbitrary_rule/{rule_id}",
1586            local_configuration.get_operation_host(operation_id),
1587            rule_id = rule_id
1588        );
1589        let mut local_req_builder =
1590            local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
1591
1592        // build headers
1593        let mut headers = HeaderMap::new();
1594        headers.insert("Accept", HeaderValue::from_static("*/*"));
1595
1596        // build user agent
1597        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1598            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1599            Err(e) => {
1600                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1601                headers.insert(
1602                    reqwest::header::USER_AGENT,
1603                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1604                )
1605            }
1606        };
1607
1608        // build auth
1609        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1610            headers.insert(
1611                "DD-API-KEY",
1612                HeaderValue::from_str(local_key.key.as_str())
1613                    .expect("failed to parse DD-API-KEY header"),
1614            );
1615        };
1616        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1617            headers.insert(
1618                "DD-APPLICATION-KEY",
1619                HeaderValue::from_str(local_key.key.as_str())
1620                    .expect("failed to parse DD-APPLICATION-KEY header"),
1621            );
1622        };
1623
1624        local_req_builder = local_req_builder.headers(headers);
1625        let local_req = local_req_builder.build()?;
1626        log::debug!("request content: {:?}", local_req.body());
1627        let local_resp = local_client.execute(local_req).await?;
1628
1629        let local_status = local_resp.status();
1630        let local_content = local_resp.text().await?;
1631        log::debug!("response content: {}", local_content);
1632
1633        if !local_status.is_client_error() && !local_status.is_server_error() {
1634            Ok(datadog::ResponseContent {
1635                status: local_status,
1636                content: local_content,
1637                entity: None,
1638            })
1639        } else {
1640            let local_entity: Option<DeleteCustomAllocationRuleError> =
1641                serde_json::from_str(&local_content).ok();
1642            let local_error = datadog::ResponseContent {
1643                status: local_status,
1644                content: local_content,
1645                entity: local_entity,
1646            };
1647            Err(datadog::Error::ResponseError(local_error))
1648        }
1649    }
1650
1651    /// Delete the specified Custom Costs file.
1652    pub async fn delete_custom_costs_file(
1653        &self,
1654        file_id: String,
1655    ) -> Result<(), datadog::Error<DeleteCustomCostsFileError>> {
1656        match self.delete_custom_costs_file_with_http_info(file_id).await {
1657            Ok(_) => Ok(()),
1658            Err(err) => Err(err),
1659        }
1660    }
1661
1662    /// Delete the specified Custom Costs file.
1663    pub async fn delete_custom_costs_file_with_http_info(
1664        &self,
1665        file_id: String,
1666    ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteCustomCostsFileError>> {
1667        let local_configuration = &self.config;
1668        let operation_id = "v2.delete_custom_costs_file";
1669
1670        let local_client = &self.client;
1671
1672        let local_uri_str = format!(
1673            "{}/api/v2/cost/custom_costs/{file_id}",
1674            local_configuration.get_operation_host(operation_id),
1675            file_id = datadog::urlencode(file_id)
1676        );
1677        let mut local_req_builder =
1678            local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
1679
1680        // build headers
1681        let mut headers = HeaderMap::new();
1682        headers.insert("Accept", HeaderValue::from_static("*/*"));
1683
1684        // build user agent
1685        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1686            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1687            Err(e) => {
1688                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1689                headers.insert(
1690                    reqwest::header::USER_AGENT,
1691                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1692                )
1693            }
1694        };
1695
1696        // build auth
1697        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1698            headers.insert(
1699                "DD-API-KEY",
1700                HeaderValue::from_str(local_key.key.as_str())
1701                    .expect("failed to parse DD-API-KEY header"),
1702            );
1703        };
1704        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1705            headers.insert(
1706                "DD-APPLICATION-KEY",
1707                HeaderValue::from_str(local_key.key.as_str())
1708                    .expect("failed to parse DD-APPLICATION-KEY header"),
1709            );
1710        };
1711
1712        local_req_builder = local_req_builder.headers(headers);
1713        let local_req = local_req_builder.build()?;
1714        log::debug!("request content: {:?}", local_req.body());
1715        let local_resp = local_client.execute(local_req).await?;
1716
1717        let local_status = local_resp.status();
1718        let local_content = local_resp.text().await?;
1719        log::debug!("response content: {}", local_content);
1720
1721        if !local_status.is_client_error() && !local_status.is_server_error() {
1722            Ok(datadog::ResponseContent {
1723                status: local_status,
1724                content: local_content,
1725                entity: None,
1726            })
1727        } else {
1728            let local_entity: Option<DeleteCustomCostsFileError> =
1729                serde_json::from_str(&local_content).ok();
1730            let local_error = datadog::ResponseContent {
1731                status: local_status,
1732                content: local_content,
1733                entity: local_entity,
1734            };
1735            Err(datadog::Error::ResponseError(local_error))
1736        }
1737    }
1738
1739    /// Delete a tag pipeline ruleset - Delete an existing tag pipeline ruleset by its ID
1740    pub async fn delete_tag_pipelines_ruleset(
1741        &self,
1742        ruleset_id: String,
1743    ) -> Result<(), datadog::Error<DeleteTagPipelinesRulesetError>> {
1744        match self
1745            .delete_tag_pipelines_ruleset_with_http_info(ruleset_id)
1746            .await
1747        {
1748            Ok(_) => Ok(()),
1749            Err(err) => Err(err),
1750        }
1751    }
1752
1753    /// Delete a tag pipeline ruleset - Delete an existing tag pipeline ruleset by its ID
1754    pub async fn delete_tag_pipelines_ruleset_with_http_info(
1755        &self,
1756        ruleset_id: String,
1757    ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteTagPipelinesRulesetError>> {
1758        let local_configuration = &self.config;
1759        let operation_id = "v2.delete_tag_pipelines_ruleset";
1760
1761        let local_client = &self.client;
1762
1763        let local_uri_str = format!(
1764            "{}/api/v2/tags/enrichment/{ruleset_id}",
1765            local_configuration.get_operation_host(operation_id),
1766            ruleset_id = datadog::urlencode(ruleset_id)
1767        );
1768        let mut local_req_builder =
1769            local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
1770
1771        // build headers
1772        let mut headers = HeaderMap::new();
1773        headers.insert("Accept", HeaderValue::from_static("*/*"));
1774
1775        // build user agent
1776        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1777            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1778            Err(e) => {
1779                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1780                headers.insert(
1781                    reqwest::header::USER_AGENT,
1782                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1783                )
1784            }
1785        };
1786
1787        // build auth
1788        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1789            headers.insert(
1790                "DD-API-KEY",
1791                HeaderValue::from_str(local_key.key.as_str())
1792                    .expect("failed to parse DD-API-KEY header"),
1793            );
1794        };
1795        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1796            headers.insert(
1797                "DD-APPLICATION-KEY",
1798                HeaderValue::from_str(local_key.key.as_str())
1799                    .expect("failed to parse DD-APPLICATION-KEY header"),
1800            );
1801        };
1802
1803        local_req_builder = local_req_builder.headers(headers);
1804        let local_req = local_req_builder.build()?;
1805        log::debug!("request content: {:?}", local_req.body());
1806        let local_resp = local_client.execute(local_req).await?;
1807
1808        let local_status = local_resp.status();
1809        let local_content = local_resp.text().await?;
1810        log::debug!("response content: {}", local_content);
1811
1812        if !local_status.is_client_error() && !local_status.is_server_error() {
1813            Ok(datadog::ResponseContent {
1814                status: local_status,
1815                content: local_content,
1816                entity: None,
1817            })
1818        } else {
1819            let local_entity: Option<DeleteTagPipelinesRulesetError> =
1820                serde_json::from_str(&local_content).ok();
1821            let local_error = datadog::ResponseContent {
1822                status: local_status,
1823                content: local_content,
1824                entity: local_entity,
1825            };
1826            Err(datadog::Error::ResponseError(local_error))
1827        }
1828    }
1829
1830    /// Get a budget.
1831    pub async fn get_budget(
1832        &self,
1833        budget_id: String,
1834    ) -> Result<crate::datadogV2::model::BudgetWithEntries, datadog::Error<GetBudgetError>> {
1835        match self.get_budget_with_http_info(budget_id).await {
1836            Ok(response_content) => {
1837                if let Some(e) = response_content.entity {
1838                    Ok(e)
1839                } else {
1840                    Err(datadog::Error::Serde(serde::de::Error::custom(
1841                        "response content was None",
1842                    )))
1843                }
1844            }
1845            Err(err) => Err(err),
1846        }
1847    }
1848
1849    /// Get a budget.
1850    pub async fn get_budget_with_http_info(
1851        &self,
1852        budget_id: String,
1853    ) -> Result<
1854        datadog::ResponseContent<crate::datadogV2::model::BudgetWithEntries>,
1855        datadog::Error<GetBudgetError>,
1856    > {
1857        let local_configuration = &self.config;
1858        let operation_id = "v2.get_budget";
1859
1860        let local_client = &self.client;
1861
1862        let local_uri_str = format!(
1863            "{}/api/v2/cost/budget/{budget_id}",
1864            local_configuration.get_operation_host(operation_id),
1865            budget_id = datadog::urlencode(budget_id)
1866        );
1867        let mut local_req_builder =
1868            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1869
1870        // build headers
1871        let mut headers = HeaderMap::new();
1872        headers.insert("Accept", HeaderValue::from_static("application/json"));
1873
1874        // build user agent
1875        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1876            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1877            Err(e) => {
1878                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1879                headers.insert(
1880                    reqwest::header::USER_AGENT,
1881                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1882                )
1883            }
1884        };
1885
1886        // build auth
1887        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1888            headers.insert(
1889                "DD-API-KEY",
1890                HeaderValue::from_str(local_key.key.as_str())
1891                    .expect("failed to parse DD-API-KEY header"),
1892            );
1893        };
1894        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1895            headers.insert(
1896                "DD-APPLICATION-KEY",
1897                HeaderValue::from_str(local_key.key.as_str())
1898                    .expect("failed to parse DD-APPLICATION-KEY header"),
1899            );
1900        };
1901
1902        local_req_builder = local_req_builder.headers(headers);
1903        let local_req = local_req_builder.build()?;
1904        log::debug!("request content: {:?}", local_req.body());
1905        let local_resp = local_client.execute(local_req).await?;
1906
1907        let local_status = local_resp.status();
1908        let local_content = local_resp.text().await?;
1909        log::debug!("response content: {}", local_content);
1910
1911        if !local_status.is_client_error() && !local_status.is_server_error() {
1912            match serde_json::from_str::<crate::datadogV2::model::BudgetWithEntries>(&local_content)
1913            {
1914                Ok(e) => {
1915                    return Ok(datadog::ResponseContent {
1916                        status: local_status,
1917                        content: local_content,
1918                        entity: Some(e),
1919                    })
1920                }
1921                Err(e) => return Err(datadog::Error::Serde(e)),
1922            };
1923        } else {
1924            let local_entity: Option<GetBudgetError> = serde_json::from_str(&local_content).ok();
1925            let local_error = datadog::ResponseContent {
1926                status: local_status,
1927                content: local_content,
1928                entity: local_entity,
1929            };
1930            Err(datadog::Error::ResponseError(local_error))
1931        }
1932    }
1933
1934    /// Get a specific AWS CUR config.
1935    pub async fn get_cost_awscur_config(
1936        &self,
1937        cloud_account_id: i64,
1938    ) -> Result<
1939        crate::datadogV2::model::AwsCurConfigResponse,
1940        datadog::Error<GetCostAWSCURConfigError>,
1941    > {
1942        match self
1943            .get_cost_awscur_config_with_http_info(cloud_account_id)
1944            .await
1945        {
1946            Ok(response_content) => {
1947                if let Some(e) = response_content.entity {
1948                    Ok(e)
1949                } else {
1950                    Err(datadog::Error::Serde(serde::de::Error::custom(
1951                        "response content was None",
1952                    )))
1953                }
1954            }
1955            Err(err) => Err(err),
1956        }
1957    }
1958
1959    /// Get a specific AWS CUR config.
1960    pub async fn get_cost_awscur_config_with_http_info(
1961        &self,
1962        cloud_account_id: i64,
1963    ) -> Result<
1964        datadog::ResponseContent<crate::datadogV2::model::AwsCurConfigResponse>,
1965        datadog::Error<GetCostAWSCURConfigError>,
1966    > {
1967        let local_configuration = &self.config;
1968        let operation_id = "v2.get_cost_awscur_config";
1969
1970        let local_client = &self.client;
1971
1972        let local_uri_str = format!(
1973            "{}/api/v2/cost/aws_cur_config/{cloud_account_id}",
1974            local_configuration.get_operation_host(operation_id),
1975            cloud_account_id = cloud_account_id
1976        );
1977        let mut local_req_builder =
1978            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1979
1980        // build headers
1981        let mut headers = HeaderMap::new();
1982        headers.insert("Accept", HeaderValue::from_static("application/json"));
1983
1984        // build user agent
1985        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1986            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1987            Err(e) => {
1988                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1989                headers.insert(
1990                    reqwest::header::USER_AGENT,
1991                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1992                )
1993            }
1994        };
1995
1996        // build auth
1997        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1998            headers.insert(
1999                "DD-API-KEY",
2000                HeaderValue::from_str(local_key.key.as_str())
2001                    .expect("failed to parse DD-API-KEY header"),
2002            );
2003        };
2004        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2005            headers.insert(
2006                "DD-APPLICATION-KEY",
2007                HeaderValue::from_str(local_key.key.as_str())
2008                    .expect("failed to parse DD-APPLICATION-KEY header"),
2009            );
2010        };
2011
2012        local_req_builder = local_req_builder.headers(headers);
2013        let local_req = local_req_builder.build()?;
2014        log::debug!("request content: {:?}", local_req.body());
2015        let local_resp = local_client.execute(local_req).await?;
2016
2017        let local_status = local_resp.status();
2018        let local_content = local_resp.text().await?;
2019        log::debug!("response content: {}", local_content);
2020
2021        if !local_status.is_client_error() && !local_status.is_server_error() {
2022            match serde_json::from_str::<crate::datadogV2::model::AwsCurConfigResponse>(
2023                &local_content,
2024            ) {
2025                Ok(e) => {
2026                    return Ok(datadog::ResponseContent {
2027                        status: local_status,
2028                        content: local_content,
2029                        entity: Some(e),
2030                    })
2031                }
2032                Err(e) => return Err(datadog::Error::Serde(e)),
2033            };
2034        } else {
2035            let local_entity: Option<GetCostAWSCURConfigError> =
2036                serde_json::from_str(&local_content).ok();
2037            let local_error = datadog::ResponseContent {
2038                status: local_status,
2039                content: local_content,
2040                entity: local_entity,
2041            };
2042            Err(datadog::Error::ResponseError(local_error))
2043        }
2044    }
2045
2046    /// Get a specific Azure config.
2047    pub async fn get_cost_azure_uc_config(
2048        &self,
2049        cloud_account_id: i64,
2050    ) -> Result<crate::datadogV2::model::UCConfigPair, datadog::Error<GetCostAzureUCConfigError>>
2051    {
2052        match self
2053            .get_cost_azure_uc_config_with_http_info(cloud_account_id)
2054            .await
2055        {
2056            Ok(response_content) => {
2057                if let Some(e) = response_content.entity {
2058                    Ok(e)
2059                } else {
2060                    Err(datadog::Error::Serde(serde::de::Error::custom(
2061                        "response content was None",
2062                    )))
2063                }
2064            }
2065            Err(err) => Err(err),
2066        }
2067    }
2068
2069    /// Get a specific Azure config.
2070    pub async fn get_cost_azure_uc_config_with_http_info(
2071        &self,
2072        cloud_account_id: i64,
2073    ) -> Result<
2074        datadog::ResponseContent<crate::datadogV2::model::UCConfigPair>,
2075        datadog::Error<GetCostAzureUCConfigError>,
2076    > {
2077        let local_configuration = &self.config;
2078        let operation_id = "v2.get_cost_azure_uc_config";
2079
2080        let local_client = &self.client;
2081
2082        let local_uri_str = format!(
2083            "{}/api/v2/cost/azure_uc_config/{cloud_account_id}",
2084            local_configuration.get_operation_host(operation_id),
2085            cloud_account_id = cloud_account_id
2086        );
2087        let mut local_req_builder =
2088            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2089
2090        // build headers
2091        let mut headers = HeaderMap::new();
2092        headers.insert("Accept", HeaderValue::from_static("application/json"));
2093
2094        // build user agent
2095        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2096            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2097            Err(e) => {
2098                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2099                headers.insert(
2100                    reqwest::header::USER_AGENT,
2101                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2102                )
2103            }
2104        };
2105
2106        // build auth
2107        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2108            headers.insert(
2109                "DD-API-KEY",
2110                HeaderValue::from_str(local_key.key.as_str())
2111                    .expect("failed to parse DD-API-KEY header"),
2112            );
2113        };
2114        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2115            headers.insert(
2116                "DD-APPLICATION-KEY",
2117                HeaderValue::from_str(local_key.key.as_str())
2118                    .expect("failed to parse DD-APPLICATION-KEY header"),
2119            );
2120        };
2121
2122        local_req_builder = local_req_builder.headers(headers);
2123        let local_req = local_req_builder.build()?;
2124        log::debug!("request content: {:?}", local_req.body());
2125        let local_resp = local_client.execute(local_req).await?;
2126
2127        let local_status = local_resp.status();
2128        let local_content = local_resp.text().await?;
2129        log::debug!("response content: {}", local_content);
2130
2131        if !local_status.is_client_error() && !local_status.is_server_error() {
2132            match serde_json::from_str::<crate::datadogV2::model::UCConfigPair>(&local_content) {
2133                Ok(e) => {
2134                    return Ok(datadog::ResponseContent {
2135                        status: local_status,
2136                        content: local_content,
2137                        entity: Some(e),
2138                    })
2139                }
2140                Err(e) => return Err(datadog::Error::Serde(e)),
2141            };
2142        } else {
2143            let local_entity: Option<GetCostAzureUCConfigError> =
2144                serde_json::from_str(&local_content).ok();
2145            let local_error = datadog::ResponseContent {
2146                status: local_status,
2147                content: local_content,
2148                entity: local_entity,
2149            };
2150            Err(datadog::Error::ResponseError(local_error))
2151        }
2152    }
2153
2154    /// Get a specific Google Cloud Usage Cost config.
2155    pub async fn get_cost_gcp_usage_cost_config(
2156        &self,
2157        cloud_account_id: i64,
2158    ) -> Result<
2159        crate::datadogV2::model::GcpUcConfigResponse,
2160        datadog::Error<GetCostGCPUsageCostConfigError>,
2161    > {
2162        match self
2163            .get_cost_gcp_usage_cost_config_with_http_info(cloud_account_id)
2164            .await
2165        {
2166            Ok(response_content) => {
2167                if let Some(e) = response_content.entity {
2168                    Ok(e)
2169                } else {
2170                    Err(datadog::Error::Serde(serde::de::Error::custom(
2171                        "response content was None",
2172                    )))
2173                }
2174            }
2175            Err(err) => Err(err),
2176        }
2177    }
2178
2179    /// Get a specific Google Cloud Usage Cost config.
2180    pub async fn get_cost_gcp_usage_cost_config_with_http_info(
2181        &self,
2182        cloud_account_id: i64,
2183    ) -> Result<
2184        datadog::ResponseContent<crate::datadogV2::model::GcpUcConfigResponse>,
2185        datadog::Error<GetCostGCPUsageCostConfigError>,
2186    > {
2187        let local_configuration = &self.config;
2188        let operation_id = "v2.get_cost_gcp_usage_cost_config";
2189
2190        let local_client = &self.client;
2191
2192        let local_uri_str = format!(
2193            "{}/api/v2/cost/gcp_uc_config/{cloud_account_id}",
2194            local_configuration.get_operation_host(operation_id),
2195            cloud_account_id = cloud_account_id
2196        );
2197        let mut local_req_builder =
2198            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2199
2200        // build headers
2201        let mut headers = HeaderMap::new();
2202        headers.insert("Accept", HeaderValue::from_static("application/json"));
2203
2204        // build user agent
2205        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2206            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2207            Err(e) => {
2208                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2209                headers.insert(
2210                    reqwest::header::USER_AGENT,
2211                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2212                )
2213            }
2214        };
2215
2216        // build auth
2217        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2218            headers.insert(
2219                "DD-API-KEY",
2220                HeaderValue::from_str(local_key.key.as_str())
2221                    .expect("failed to parse DD-API-KEY header"),
2222            );
2223        };
2224        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2225            headers.insert(
2226                "DD-APPLICATION-KEY",
2227                HeaderValue::from_str(local_key.key.as_str())
2228                    .expect("failed to parse DD-APPLICATION-KEY header"),
2229            );
2230        };
2231
2232        local_req_builder = local_req_builder.headers(headers);
2233        let local_req = local_req_builder.build()?;
2234        log::debug!("request content: {:?}", local_req.body());
2235        let local_resp = local_client.execute(local_req).await?;
2236
2237        let local_status = local_resp.status();
2238        let local_content = local_resp.text().await?;
2239        log::debug!("response content: {}", local_content);
2240
2241        if !local_status.is_client_error() && !local_status.is_server_error() {
2242            match serde_json::from_str::<crate::datadogV2::model::GcpUcConfigResponse>(
2243                &local_content,
2244            ) {
2245                Ok(e) => {
2246                    return Ok(datadog::ResponseContent {
2247                        status: local_status,
2248                        content: local_content,
2249                        entity: Some(e),
2250                    })
2251                }
2252                Err(e) => return Err(datadog::Error::Serde(e)),
2253            };
2254        } else {
2255            let local_entity: Option<GetCostGCPUsageCostConfigError> =
2256                serde_json::from_str(&local_content).ok();
2257            let local_error = datadog::ResponseContent {
2258                status: local_status,
2259                content: local_content,
2260                entity: local_entity,
2261            };
2262            Err(datadog::Error::ResponseError(local_error))
2263        }
2264    }
2265
2266    /// Get a specific custom allocation rule - Retrieve a specific custom allocation rule by its ID
2267    pub async fn get_custom_allocation_rule(
2268        &self,
2269        rule_id: i64,
2270    ) -> Result<
2271        crate::datadogV2::model::ArbitraryRuleResponse,
2272        datadog::Error<GetCustomAllocationRuleError>,
2273    > {
2274        match self
2275            .get_custom_allocation_rule_with_http_info(rule_id)
2276            .await
2277        {
2278            Ok(response_content) => {
2279                if let Some(e) = response_content.entity {
2280                    Ok(e)
2281                } else {
2282                    Err(datadog::Error::Serde(serde::de::Error::custom(
2283                        "response content was None",
2284                    )))
2285                }
2286            }
2287            Err(err) => Err(err),
2288        }
2289    }
2290
2291    /// Get a specific custom allocation rule - Retrieve a specific custom allocation rule by its ID
2292    pub async fn get_custom_allocation_rule_with_http_info(
2293        &self,
2294        rule_id: i64,
2295    ) -> Result<
2296        datadog::ResponseContent<crate::datadogV2::model::ArbitraryRuleResponse>,
2297        datadog::Error<GetCustomAllocationRuleError>,
2298    > {
2299        let local_configuration = &self.config;
2300        let operation_id = "v2.get_custom_allocation_rule";
2301
2302        let local_client = &self.client;
2303
2304        let local_uri_str = format!(
2305            "{}/api/v2/cost/arbitrary_rule/{rule_id}",
2306            local_configuration.get_operation_host(operation_id),
2307            rule_id = rule_id
2308        );
2309        let mut local_req_builder =
2310            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2311
2312        // build headers
2313        let mut headers = HeaderMap::new();
2314        headers.insert("Accept", HeaderValue::from_static("application/json"));
2315
2316        // build user agent
2317        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2318            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2319            Err(e) => {
2320                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2321                headers.insert(
2322                    reqwest::header::USER_AGENT,
2323                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2324                )
2325            }
2326        };
2327
2328        // build auth
2329        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2330            headers.insert(
2331                "DD-API-KEY",
2332                HeaderValue::from_str(local_key.key.as_str())
2333                    .expect("failed to parse DD-API-KEY header"),
2334            );
2335        };
2336        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2337            headers.insert(
2338                "DD-APPLICATION-KEY",
2339                HeaderValue::from_str(local_key.key.as_str())
2340                    .expect("failed to parse DD-APPLICATION-KEY header"),
2341            );
2342        };
2343
2344        local_req_builder = local_req_builder.headers(headers);
2345        let local_req = local_req_builder.build()?;
2346        log::debug!("request content: {:?}", local_req.body());
2347        let local_resp = local_client.execute(local_req).await?;
2348
2349        let local_status = local_resp.status();
2350        let local_content = local_resp.text().await?;
2351        log::debug!("response content: {}", local_content);
2352
2353        if !local_status.is_client_error() && !local_status.is_server_error() {
2354            match serde_json::from_str::<crate::datadogV2::model::ArbitraryRuleResponse>(
2355                &local_content,
2356            ) {
2357                Ok(e) => {
2358                    return Ok(datadog::ResponseContent {
2359                        status: local_status,
2360                        content: local_content,
2361                        entity: Some(e),
2362                    })
2363                }
2364                Err(e) => return Err(datadog::Error::Serde(e)),
2365            };
2366        } else {
2367            let local_entity: Option<GetCustomAllocationRuleError> =
2368                serde_json::from_str(&local_content).ok();
2369            let local_error = datadog::ResponseContent {
2370                status: local_status,
2371                content: local_content,
2372                entity: local_entity,
2373            };
2374            Err(datadog::Error::ResponseError(local_error))
2375        }
2376    }
2377
2378    /// Fetch the specified Custom Costs file.
2379    pub async fn get_custom_costs_file(
2380        &self,
2381        file_id: String,
2382    ) -> Result<
2383        crate::datadogV2::model::CustomCostsFileGetResponse,
2384        datadog::Error<GetCustomCostsFileError>,
2385    > {
2386        match self.get_custom_costs_file_with_http_info(file_id).await {
2387            Ok(response_content) => {
2388                if let Some(e) = response_content.entity {
2389                    Ok(e)
2390                } else {
2391                    Err(datadog::Error::Serde(serde::de::Error::custom(
2392                        "response content was None",
2393                    )))
2394                }
2395            }
2396            Err(err) => Err(err),
2397        }
2398    }
2399
2400    /// Fetch the specified Custom Costs file.
2401    pub async fn get_custom_costs_file_with_http_info(
2402        &self,
2403        file_id: String,
2404    ) -> Result<
2405        datadog::ResponseContent<crate::datadogV2::model::CustomCostsFileGetResponse>,
2406        datadog::Error<GetCustomCostsFileError>,
2407    > {
2408        let local_configuration = &self.config;
2409        let operation_id = "v2.get_custom_costs_file";
2410
2411        let local_client = &self.client;
2412
2413        let local_uri_str = format!(
2414            "{}/api/v2/cost/custom_costs/{file_id}",
2415            local_configuration.get_operation_host(operation_id),
2416            file_id = datadog::urlencode(file_id)
2417        );
2418        let mut local_req_builder =
2419            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2420
2421        // build headers
2422        let mut headers = HeaderMap::new();
2423        headers.insert("Accept", HeaderValue::from_static("application/json"));
2424
2425        // build user agent
2426        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2427            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2428            Err(e) => {
2429                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2430                headers.insert(
2431                    reqwest::header::USER_AGENT,
2432                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2433                )
2434            }
2435        };
2436
2437        // build auth
2438        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2439            headers.insert(
2440                "DD-API-KEY",
2441                HeaderValue::from_str(local_key.key.as_str())
2442                    .expect("failed to parse DD-API-KEY header"),
2443            );
2444        };
2445        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2446            headers.insert(
2447                "DD-APPLICATION-KEY",
2448                HeaderValue::from_str(local_key.key.as_str())
2449                    .expect("failed to parse DD-APPLICATION-KEY header"),
2450            );
2451        };
2452
2453        local_req_builder = local_req_builder.headers(headers);
2454        let local_req = local_req_builder.build()?;
2455        log::debug!("request content: {:?}", local_req.body());
2456        let local_resp = local_client.execute(local_req).await?;
2457
2458        let local_status = local_resp.status();
2459        let local_content = local_resp.text().await?;
2460        log::debug!("response content: {}", local_content);
2461
2462        if !local_status.is_client_error() && !local_status.is_server_error() {
2463            match serde_json::from_str::<crate::datadogV2::model::CustomCostsFileGetResponse>(
2464                &local_content,
2465            ) {
2466                Ok(e) => {
2467                    return Ok(datadog::ResponseContent {
2468                        status: local_status,
2469                        content: local_content,
2470                        entity: Some(e),
2471                    })
2472                }
2473                Err(e) => return Err(datadog::Error::Serde(e)),
2474            };
2475        } else {
2476            let local_entity: Option<GetCustomCostsFileError> =
2477                serde_json::from_str(&local_content).ok();
2478            let local_error = datadog::ResponseContent {
2479                status: local_status,
2480                content: local_content,
2481                entity: local_entity,
2482            };
2483            Err(datadog::Error::ResponseError(local_error))
2484        }
2485    }
2486
2487    /// Get a specific tag pipeline ruleset - Retrieve a specific tag pipeline ruleset by its ID
2488    pub async fn get_tag_pipelines_ruleset(
2489        &self,
2490        ruleset_id: String,
2491    ) -> Result<crate::datadogV2::model::RulesetResp, datadog::Error<GetTagPipelinesRulesetError>>
2492    {
2493        match self
2494            .get_tag_pipelines_ruleset_with_http_info(ruleset_id)
2495            .await
2496        {
2497            Ok(response_content) => {
2498                if let Some(e) = response_content.entity {
2499                    Ok(e)
2500                } else {
2501                    Err(datadog::Error::Serde(serde::de::Error::custom(
2502                        "response content was None",
2503                    )))
2504                }
2505            }
2506            Err(err) => Err(err),
2507        }
2508    }
2509
2510    /// Get a specific tag pipeline ruleset - Retrieve a specific tag pipeline ruleset by its ID
2511    pub async fn get_tag_pipelines_ruleset_with_http_info(
2512        &self,
2513        ruleset_id: String,
2514    ) -> Result<
2515        datadog::ResponseContent<crate::datadogV2::model::RulesetResp>,
2516        datadog::Error<GetTagPipelinesRulesetError>,
2517    > {
2518        let local_configuration = &self.config;
2519        let operation_id = "v2.get_tag_pipelines_ruleset";
2520
2521        let local_client = &self.client;
2522
2523        let local_uri_str = format!(
2524            "{}/api/v2/tags/enrichment/{ruleset_id}",
2525            local_configuration.get_operation_host(operation_id),
2526            ruleset_id = datadog::urlencode(ruleset_id)
2527        );
2528        let mut local_req_builder =
2529            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2530
2531        // build headers
2532        let mut headers = HeaderMap::new();
2533        headers.insert("Accept", HeaderValue::from_static("application/json"));
2534
2535        // build user agent
2536        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2537            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2538            Err(e) => {
2539                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2540                headers.insert(
2541                    reqwest::header::USER_AGENT,
2542                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2543                )
2544            }
2545        };
2546
2547        // build auth
2548        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2549            headers.insert(
2550                "DD-API-KEY",
2551                HeaderValue::from_str(local_key.key.as_str())
2552                    .expect("failed to parse DD-API-KEY header"),
2553            );
2554        };
2555        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2556            headers.insert(
2557                "DD-APPLICATION-KEY",
2558                HeaderValue::from_str(local_key.key.as_str())
2559                    .expect("failed to parse DD-APPLICATION-KEY header"),
2560            );
2561        };
2562
2563        local_req_builder = local_req_builder.headers(headers);
2564        let local_req = local_req_builder.build()?;
2565        log::debug!("request content: {:?}", local_req.body());
2566        let local_resp = local_client.execute(local_req).await?;
2567
2568        let local_status = local_resp.status();
2569        let local_content = local_resp.text().await?;
2570        log::debug!("response content: {}", local_content);
2571
2572        if !local_status.is_client_error() && !local_status.is_server_error() {
2573            match serde_json::from_str::<crate::datadogV2::model::RulesetResp>(&local_content) {
2574                Ok(e) => {
2575                    return Ok(datadog::ResponseContent {
2576                        status: local_status,
2577                        content: local_content,
2578                        entity: Some(e),
2579                    })
2580                }
2581                Err(e) => return Err(datadog::Error::Serde(e)),
2582            };
2583        } else {
2584            let local_entity: Option<GetTagPipelinesRulesetError> =
2585                serde_json::from_str(&local_content).ok();
2586            let local_error = datadog::ResponseContent {
2587                status: local_status,
2588                content: local_content,
2589                entity: local_entity,
2590            };
2591            Err(datadog::Error::ResponseError(local_error))
2592        }
2593    }
2594
2595    /// List budgets.
2596    pub async fn list_budgets(
2597        &self,
2598    ) -> Result<crate::datadogV2::model::BudgetArray, datadog::Error<ListBudgetsError>> {
2599        match self.list_budgets_with_http_info().await {
2600            Ok(response_content) => {
2601                if let Some(e) = response_content.entity {
2602                    Ok(e)
2603                } else {
2604                    Err(datadog::Error::Serde(serde::de::Error::custom(
2605                        "response content was None",
2606                    )))
2607                }
2608            }
2609            Err(err) => Err(err),
2610        }
2611    }
2612
2613    /// List budgets.
2614    pub async fn list_budgets_with_http_info(
2615        &self,
2616    ) -> Result<
2617        datadog::ResponseContent<crate::datadogV2::model::BudgetArray>,
2618        datadog::Error<ListBudgetsError>,
2619    > {
2620        let local_configuration = &self.config;
2621        let operation_id = "v2.list_budgets";
2622
2623        let local_client = &self.client;
2624
2625        let local_uri_str = format!(
2626            "{}/api/v2/cost/budgets",
2627            local_configuration.get_operation_host(operation_id)
2628        );
2629        let mut local_req_builder =
2630            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2631
2632        // build headers
2633        let mut headers = HeaderMap::new();
2634        headers.insert("Accept", HeaderValue::from_static("application/json"));
2635
2636        // build user agent
2637        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2638            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2639            Err(e) => {
2640                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2641                headers.insert(
2642                    reqwest::header::USER_AGENT,
2643                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2644                )
2645            }
2646        };
2647
2648        // build auth
2649        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2650            headers.insert(
2651                "DD-API-KEY",
2652                HeaderValue::from_str(local_key.key.as_str())
2653                    .expect("failed to parse DD-API-KEY header"),
2654            );
2655        };
2656        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2657            headers.insert(
2658                "DD-APPLICATION-KEY",
2659                HeaderValue::from_str(local_key.key.as_str())
2660                    .expect("failed to parse DD-APPLICATION-KEY header"),
2661            );
2662        };
2663
2664        local_req_builder = local_req_builder.headers(headers);
2665        let local_req = local_req_builder.build()?;
2666        log::debug!("request content: {:?}", local_req.body());
2667        let local_resp = local_client.execute(local_req).await?;
2668
2669        let local_status = local_resp.status();
2670        let local_content = local_resp.text().await?;
2671        log::debug!("response content: {}", local_content);
2672
2673        if !local_status.is_client_error() && !local_status.is_server_error() {
2674            match serde_json::from_str::<crate::datadogV2::model::BudgetArray>(&local_content) {
2675                Ok(e) => {
2676                    return Ok(datadog::ResponseContent {
2677                        status: local_status,
2678                        content: local_content,
2679                        entity: Some(e),
2680                    })
2681                }
2682                Err(e) => return Err(datadog::Error::Serde(e)),
2683            };
2684        } else {
2685            let local_entity: Option<ListBudgetsError> = serde_json::from_str(&local_content).ok();
2686            let local_error = datadog::ResponseContent {
2687                status: local_status,
2688                content: local_content,
2689                entity: local_entity,
2690            };
2691            Err(datadog::Error::ResponseError(local_error))
2692        }
2693    }
2694
2695    /// List the AWS CUR configs.
2696    pub async fn list_cost_awscur_configs(
2697        &self,
2698    ) -> Result<
2699        crate::datadogV2::model::AwsCURConfigsResponse,
2700        datadog::Error<ListCostAWSCURConfigsError>,
2701    > {
2702        match self.list_cost_awscur_configs_with_http_info().await {
2703            Ok(response_content) => {
2704                if let Some(e) = response_content.entity {
2705                    Ok(e)
2706                } else {
2707                    Err(datadog::Error::Serde(serde::de::Error::custom(
2708                        "response content was None",
2709                    )))
2710                }
2711            }
2712            Err(err) => Err(err),
2713        }
2714    }
2715
2716    /// List the AWS CUR configs.
2717    pub async fn list_cost_awscur_configs_with_http_info(
2718        &self,
2719    ) -> Result<
2720        datadog::ResponseContent<crate::datadogV2::model::AwsCURConfigsResponse>,
2721        datadog::Error<ListCostAWSCURConfigsError>,
2722    > {
2723        let local_configuration = &self.config;
2724        let operation_id = "v2.list_cost_awscur_configs";
2725
2726        let local_client = &self.client;
2727
2728        let local_uri_str = format!(
2729            "{}/api/v2/cost/aws_cur_config",
2730            local_configuration.get_operation_host(operation_id)
2731        );
2732        let mut local_req_builder =
2733            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2734
2735        // build headers
2736        let mut headers = HeaderMap::new();
2737        headers.insert("Accept", HeaderValue::from_static("application/json"));
2738
2739        // build user agent
2740        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2741            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2742            Err(e) => {
2743                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2744                headers.insert(
2745                    reqwest::header::USER_AGENT,
2746                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2747                )
2748            }
2749        };
2750
2751        // build auth
2752        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2753            headers.insert(
2754                "DD-API-KEY",
2755                HeaderValue::from_str(local_key.key.as_str())
2756                    .expect("failed to parse DD-API-KEY header"),
2757            );
2758        };
2759        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2760            headers.insert(
2761                "DD-APPLICATION-KEY",
2762                HeaderValue::from_str(local_key.key.as_str())
2763                    .expect("failed to parse DD-APPLICATION-KEY header"),
2764            );
2765        };
2766
2767        local_req_builder = local_req_builder.headers(headers);
2768        let local_req = local_req_builder.build()?;
2769        log::debug!("request content: {:?}", local_req.body());
2770        let local_resp = local_client.execute(local_req).await?;
2771
2772        let local_status = local_resp.status();
2773        let local_content = local_resp.text().await?;
2774        log::debug!("response content: {}", local_content);
2775
2776        if !local_status.is_client_error() && !local_status.is_server_error() {
2777            match serde_json::from_str::<crate::datadogV2::model::AwsCURConfigsResponse>(
2778                &local_content,
2779            ) {
2780                Ok(e) => {
2781                    return Ok(datadog::ResponseContent {
2782                        status: local_status,
2783                        content: local_content,
2784                        entity: Some(e),
2785                    })
2786                }
2787                Err(e) => return Err(datadog::Error::Serde(e)),
2788            };
2789        } else {
2790            let local_entity: Option<ListCostAWSCURConfigsError> =
2791                serde_json::from_str(&local_content).ok();
2792            let local_error = datadog::ResponseContent {
2793                status: local_status,
2794                content: local_content,
2795                entity: local_entity,
2796            };
2797            Err(datadog::Error::ResponseError(local_error))
2798        }
2799    }
2800
2801    /// List the Azure configs.
2802    pub async fn list_cost_azure_uc_configs(
2803        &self,
2804    ) -> Result<
2805        crate::datadogV2::model::AzureUCConfigsResponse,
2806        datadog::Error<ListCostAzureUCConfigsError>,
2807    > {
2808        match self.list_cost_azure_uc_configs_with_http_info().await {
2809            Ok(response_content) => {
2810                if let Some(e) = response_content.entity {
2811                    Ok(e)
2812                } else {
2813                    Err(datadog::Error::Serde(serde::de::Error::custom(
2814                        "response content was None",
2815                    )))
2816                }
2817            }
2818            Err(err) => Err(err),
2819        }
2820    }
2821
2822    /// List the Azure configs.
2823    pub async fn list_cost_azure_uc_configs_with_http_info(
2824        &self,
2825    ) -> Result<
2826        datadog::ResponseContent<crate::datadogV2::model::AzureUCConfigsResponse>,
2827        datadog::Error<ListCostAzureUCConfigsError>,
2828    > {
2829        let local_configuration = &self.config;
2830        let operation_id = "v2.list_cost_azure_uc_configs";
2831
2832        let local_client = &self.client;
2833
2834        let local_uri_str = format!(
2835            "{}/api/v2/cost/azure_uc_config",
2836            local_configuration.get_operation_host(operation_id)
2837        );
2838        let mut local_req_builder =
2839            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2840
2841        // build headers
2842        let mut headers = HeaderMap::new();
2843        headers.insert("Accept", HeaderValue::from_static("application/json"));
2844
2845        // build user agent
2846        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2847            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2848            Err(e) => {
2849                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2850                headers.insert(
2851                    reqwest::header::USER_AGENT,
2852                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2853                )
2854            }
2855        };
2856
2857        // build auth
2858        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2859            headers.insert(
2860                "DD-API-KEY",
2861                HeaderValue::from_str(local_key.key.as_str())
2862                    .expect("failed to parse DD-API-KEY header"),
2863            );
2864        };
2865        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2866            headers.insert(
2867                "DD-APPLICATION-KEY",
2868                HeaderValue::from_str(local_key.key.as_str())
2869                    .expect("failed to parse DD-APPLICATION-KEY header"),
2870            );
2871        };
2872
2873        local_req_builder = local_req_builder.headers(headers);
2874        let local_req = local_req_builder.build()?;
2875        log::debug!("request content: {:?}", local_req.body());
2876        let local_resp = local_client.execute(local_req).await?;
2877
2878        let local_status = local_resp.status();
2879        let local_content = local_resp.text().await?;
2880        log::debug!("response content: {}", local_content);
2881
2882        if !local_status.is_client_error() && !local_status.is_server_error() {
2883            match serde_json::from_str::<crate::datadogV2::model::AzureUCConfigsResponse>(
2884                &local_content,
2885            ) {
2886                Ok(e) => {
2887                    return Ok(datadog::ResponseContent {
2888                        status: local_status,
2889                        content: local_content,
2890                        entity: Some(e),
2891                    })
2892                }
2893                Err(e) => return Err(datadog::Error::Serde(e)),
2894            };
2895        } else {
2896            let local_entity: Option<ListCostAzureUCConfigsError> =
2897                serde_json::from_str(&local_content).ok();
2898            let local_error = datadog::ResponseContent {
2899                status: local_status,
2900                content: local_content,
2901                entity: local_entity,
2902            };
2903            Err(datadog::Error::ResponseError(local_error))
2904        }
2905    }
2906
2907    /// List the Google Cloud Usage Cost configs.
2908    pub async fn list_cost_gcp_usage_cost_configs(
2909        &self,
2910    ) -> Result<
2911        crate::datadogV2::model::GCPUsageCostConfigsResponse,
2912        datadog::Error<ListCostGCPUsageCostConfigsError>,
2913    > {
2914        match self.list_cost_gcp_usage_cost_configs_with_http_info().await {
2915            Ok(response_content) => {
2916                if let Some(e) = response_content.entity {
2917                    Ok(e)
2918                } else {
2919                    Err(datadog::Error::Serde(serde::de::Error::custom(
2920                        "response content was None",
2921                    )))
2922                }
2923            }
2924            Err(err) => Err(err),
2925        }
2926    }
2927
2928    /// List the Google Cloud Usage Cost configs.
2929    pub async fn list_cost_gcp_usage_cost_configs_with_http_info(
2930        &self,
2931    ) -> Result<
2932        datadog::ResponseContent<crate::datadogV2::model::GCPUsageCostConfigsResponse>,
2933        datadog::Error<ListCostGCPUsageCostConfigsError>,
2934    > {
2935        let local_configuration = &self.config;
2936        let operation_id = "v2.list_cost_gcp_usage_cost_configs";
2937
2938        let local_client = &self.client;
2939
2940        let local_uri_str = format!(
2941            "{}/api/v2/cost/gcp_uc_config",
2942            local_configuration.get_operation_host(operation_id)
2943        );
2944        let mut local_req_builder =
2945            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2946
2947        // build headers
2948        let mut headers = HeaderMap::new();
2949        headers.insert("Accept", HeaderValue::from_static("application/json"));
2950
2951        // build user agent
2952        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2953            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2954            Err(e) => {
2955                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2956                headers.insert(
2957                    reqwest::header::USER_AGENT,
2958                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2959                )
2960            }
2961        };
2962
2963        // build auth
2964        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2965            headers.insert(
2966                "DD-API-KEY",
2967                HeaderValue::from_str(local_key.key.as_str())
2968                    .expect("failed to parse DD-API-KEY header"),
2969            );
2970        };
2971        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2972            headers.insert(
2973                "DD-APPLICATION-KEY",
2974                HeaderValue::from_str(local_key.key.as_str())
2975                    .expect("failed to parse DD-APPLICATION-KEY header"),
2976            );
2977        };
2978
2979        local_req_builder = local_req_builder.headers(headers);
2980        let local_req = local_req_builder.build()?;
2981        log::debug!("request content: {:?}", local_req.body());
2982        let local_resp = local_client.execute(local_req).await?;
2983
2984        let local_status = local_resp.status();
2985        let local_content = local_resp.text().await?;
2986        log::debug!("response content: {}", local_content);
2987
2988        if !local_status.is_client_error() && !local_status.is_server_error() {
2989            match serde_json::from_str::<crate::datadogV2::model::GCPUsageCostConfigsResponse>(
2990                &local_content,
2991            ) {
2992                Ok(e) => {
2993                    return Ok(datadog::ResponseContent {
2994                        status: local_status,
2995                        content: local_content,
2996                        entity: Some(e),
2997                    })
2998                }
2999                Err(e) => return Err(datadog::Error::Serde(e)),
3000            };
3001        } else {
3002            let local_entity: Option<ListCostGCPUsageCostConfigsError> =
3003                serde_json::from_str(&local_content).ok();
3004            let local_error = datadog::ResponseContent {
3005                status: local_status,
3006                content: local_content,
3007                entity: local_entity,
3008            };
3009            Err(datadog::Error::ResponseError(local_error))
3010        }
3011    }
3012
3013    /// List all custom allocation rules - Retrieve a list of all custom allocation rules for the organization
3014    pub async fn list_custom_allocation_rules(
3015        &self,
3016    ) -> Result<
3017        crate::datadogV2::model::ArbitraryRuleResponseArray,
3018        datadog::Error<ListCustomAllocationRulesError>,
3019    > {
3020        match self.list_custom_allocation_rules_with_http_info().await {
3021            Ok(response_content) => {
3022                if let Some(e) = response_content.entity {
3023                    Ok(e)
3024                } else {
3025                    Err(datadog::Error::Serde(serde::de::Error::custom(
3026                        "response content was None",
3027                    )))
3028                }
3029            }
3030            Err(err) => Err(err),
3031        }
3032    }
3033
3034    /// List all custom allocation rules - Retrieve a list of all custom allocation rules for the organization
3035    pub async fn list_custom_allocation_rules_with_http_info(
3036        &self,
3037    ) -> Result<
3038        datadog::ResponseContent<crate::datadogV2::model::ArbitraryRuleResponseArray>,
3039        datadog::Error<ListCustomAllocationRulesError>,
3040    > {
3041        let local_configuration = &self.config;
3042        let operation_id = "v2.list_custom_allocation_rules";
3043
3044        let local_client = &self.client;
3045
3046        let local_uri_str = format!(
3047            "{}/api/v2/cost/arbitrary_rule",
3048            local_configuration.get_operation_host(operation_id)
3049        );
3050        let mut local_req_builder =
3051            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3052
3053        // build headers
3054        let mut headers = HeaderMap::new();
3055        headers.insert("Accept", HeaderValue::from_static("application/json"));
3056
3057        // build user agent
3058        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3059            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3060            Err(e) => {
3061                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3062                headers.insert(
3063                    reqwest::header::USER_AGENT,
3064                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3065                )
3066            }
3067        };
3068
3069        // build auth
3070        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3071            headers.insert(
3072                "DD-API-KEY",
3073                HeaderValue::from_str(local_key.key.as_str())
3074                    .expect("failed to parse DD-API-KEY header"),
3075            );
3076        };
3077        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3078            headers.insert(
3079                "DD-APPLICATION-KEY",
3080                HeaderValue::from_str(local_key.key.as_str())
3081                    .expect("failed to parse DD-APPLICATION-KEY header"),
3082            );
3083        };
3084
3085        local_req_builder = local_req_builder.headers(headers);
3086        let local_req = local_req_builder.build()?;
3087        log::debug!("request content: {:?}", local_req.body());
3088        let local_resp = local_client.execute(local_req).await?;
3089
3090        let local_status = local_resp.status();
3091        let local_content = local_resp.text().await?;
3092        log::debug!("response content: {}", local_content);
3093
3094        if !local_status.is_client_error() && !local_status.is_server_error() {
3095            match serde_json::from_str::<crate::datadogV2::model::ArbitraryRuleResponseArray>(
3096                &local_content,
3097            ) {
3098                Ok(e) => {
3099                    return Ok(datadog::ResponseContent {
3100                        status: local_status,
3101                        content: local_content,
3102                        entity: Some(e),
3103                    })
3104                }
3105                Err(e) => return Err(datadog::Error::Serde(e)),
3106            };
3107        } else {
3108            let local_entity: Option<ListCustomAllocationRulesError> =
3109                serde_json::from_str(&local_content).ok();
3110            let local_error = datadog::ResponseContent {
3111                status: local_status,
3112                content: local_content,
3113                entity: local_entity,
3114            };
3115            Err(datadog::Error::ResponseError(local_error))
3116        }
3117    }
3118
3119    /// List the Custom Costs files.
3120    pub async fn list_custom_costs_files(
3121        &self,
3122        params: ListCustomCostsFilesOptionalParams,
3123    ) -> Result<
3124        crate::datadogV2::model::CustomCostsFileListResponse,
3125        datadog::Error<ListCustomCostsFilesError>,
3126    > {
3127        match self.list_custom_costs_files_with_http_info(params).await {
3128            Ok(response_content) => {
3129                if let Some(e) = response_content.entity {
3130                    Ok(e)
3131                } else {
3132                    Err(datadog::Error::Serde(serde::de::Error::custom(
3133                        "response content was None",
3134                    )))
3135                }
3136            }
3137            Err(err) => Err(err),
3138        }
3139    }
3140
3141    /// List the Custom Costs files.
3142    pub async fn list_custom_costs_files_with_http_info(
3143        &self,
3144        params: ListCustomCostsFilesOptionalParams,
3145    ) -> Result<
3146        datadog::ResponseContent<crate::datadogV2::model::CustomCostsFileListResponse>,
3147        datadog::Error<ListCustomCostsFilesError>,
3148    > {
3149        let local_configuration = &self.config;
3150        let operation_id = "v2.list_custom_costs_files";
3151
3152        // unbox and build optional parameters
3153        let page_number = params.page_number;
3154        let page_size = params.page_size;
3155        let filter_status = params.filter_status;
3156        let sort = params.sort;
3157
3158        let local_client = &self.client;
3159
3160        let local_uri_str = format!(
3161            "{}/api/v2/cost/custom_costs",
3162            local_configuration.get_operation_host(operation_id)
3163        );
3164        let mut local_req_builder =
3165            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3166
3167        if let Some(ref local_query_param) = page_number {
3168            local_req_builder =
3169                local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
3170        };
3171        if let Some(ref local_query_param) = page_size {
3172            local_req_builder =
3173                local_req_builder.query(&[("page[size]", &local_query_param.to_string())]);
3174        };
3175        if let Some(ref local_query_param) = filter_status {
3176            local_req_builder =
3177                local_req_builder.query(&[("filter[status]", &local_query_param.to_string())]);
3178        };
3179        if let Some(ref local_query_param) = sort {
3180            local_req_builder =
3181                local_req_builder.query(&[("sort", &local_query_param.to_string())]);
3182        };
3183
3184        // build headers
3185        let mut headers = HeaderMap::new();
3186        headers.insert("Accept", HeaderValue::from_static("application/json"));
3187
3188        // build user agent
3189        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3190            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3191            Err(e) => {
3192                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3193                headers.insert(
3194                    reqwest::header::USER_AGENT,
3195                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3196                )
3197            }
3198        };
3199
3200        // build auth
3201        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3202            headers.insert(
3203                "DD-API-KEY",
3204                HeaderValue::from_str(local_key.key.as_str())
3205                    .expect("failed to parse DD-API-KEY header"),
3206            );
3207        };
3208        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3209            headers.insert(
3210                "DD-APPLICATION-KEY",
3211                HeaderValue::from_str(local_key.key.as_str())
3212                    .expect("failed to parse DD-APPLICATION-KEY header"),
3213            );
3214        };
3215
3216        local_req_builder = local_req_builder.headers(headers);
3217        let local_req = local_req_builder.build()?;
3218        log::debug!("request content: {:?}", local_req.body());
3219        let local_resp = local_client.execute(local_req).await?;
3220
3221        let local_status = local_resp.status();
3222        let local_content = local_resp.text().await?;
3223        log::debug!("response content: {}", local_content);
3224
3225        if !local_status.is_client_error() && !local_status.is_server_error() {
3226            match serde_json::from_str::<crate::datadogV2::model::CustomCostsFileListResponse>(
3227                &local_content,
3228            ) {
3229                Ok(e) => {
3230                    return Ok(datadog::ResponseContent {
3231                        status: local_status,
3232                        content: local_content,
3233                        entity: Some(e),
3234                    })
3235                }
3236                Err(e) => return Err(datadog::Error::Serde(e)),
3237            };
3238        } else {
3239            let local_entity: Option<ListCustomCostsFilesError> =
3240                serde_json::from_str(&local_content).ok();
3241            let local_error = datadog::ResponseContent {
3242                status: local_status,
3243                content: local_content,
3244                entity: local_entity,
3245            };
3246            Err(datadog::Error::ResponseError(local_error))
3247        }
3248    }
3249
3250    /// List all tag pipeline rulesets - Retrieve a list of all tag pipeline rulesets for the organization
3251    pub async fn list_tag_pipelines_rulesets(
3252        &self,
3253    ) -> Result<
3254        crate::datadogV2::model::RulesetRespArray,
3255        datadog::Error<ListTagPipelinesRulesetsError>,
3256    > {
3257        match self.list_tag_pipelines_rulesets_with_http_info().await {
3258            Ok(response_content) => {
3259                if let Some(e) = response_content.entity {
3260                    Ok(e)
3261                } else {
3262                    Err(datadog::Error::Serde(serde::de::Error::custom(
3263                        "response content was None",
3264                    )))
3265                }
3266            }
3267            Err(err) => Err(err),
3268        }
3269    }
3270
3271    /// List all tag pipeline rulesets - Retrieve a list of all tag pipeline rulesets for the organization
3272    pub async fn list_tag_pipelines_rulesets_with_http_info(
3273        &self,
3274    ) -> Result<
3275        datadog::ResponseContent<crate::datadogV2::model::RulesetRespArray>,
3276        datadog::Error<ListTagPipelinesRulesetsError>,
3277    > {
3278        let local_configuration = &self.config;
3279        let operation_id = "v2.list_tag_pipelines_rulesets";
3280
3281        let local_client = &self.client;
3282
3283        let local_uri_str = format!(
3284            "{}/api/v2/tags/enrichment",
3285            local_configuration.get_operation_host(operation_id)
3286        );
3287        let mut local_req_builder =
3288            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3289
3290        // build headers
3291        let mut headers = HeaderMap::new();
3292        headers.insert("Accept", HeaderValue::from_static("application/json"));
3293
3294        // build user agent
3295        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3296            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3297            Err(e) => {
3298                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3299                headers.insert(
3300                    reqwest::header::USER_AGENT,
3301                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3302                )
3303            }
3304        };
3305
3306        // build auth
3307        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3308            headers.insert(
3309                "DD-API-KEY",
3310                HeaderValue::from_str(local_key.key.as_str())
3311                    .expect("failed to parse DD-API-KEY header"),
3312            );
3313        };
3314        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3315            headers.insert(
3316                "DD-APPLICATION-KEY",
3317                HeaderValue::from_str(local_key.key.as_str())
3318                    .expect("failed to parse DD-APPLICATION-KEY header"),
3319            );
3320        };
3321
3322        local_req_builder = local_req_builder.headers(headers);
3323        let local_req = local_req_builder.build()?;
3324        log::debug!("request content: {:?}", local_req.body());
3325        let local_resp = local_client.execute(local_req).await?;
3326
3327        let local_status = local_resp.status();
3328        let local_content = local_resp.text().await?;
3329        log::debug!("response content: {}", local_content);
3330
3331        if !local_status.is_client_error() && !local_status.is_server_error() {
3332            match serde_json::from_str::<crate::datadogV2::model::RulesetRespArray>(&local_content)
3333            {
3334                Ok(e) => {
3335                    return Ok(datadog::ResponseContent {
3336                        status: local_status,
3337                        content: local_content,
3338                        entity: Some(e),
3339                    })
3340                }
3341                Err(e) => return Err(datadog::Error::Serde(e)),
3342            };
3343        } else {
3344            let local_entity: Option<ListTagPipelinesRulesetsError> =
3345                serde_json::from_str(&local_content).ok();
3346            let local_error = datadog::ResponseContent {
3347                status: local_status,
3348                content: local_content,
3349                entity: local_entity,
3350            };
3351            Err(datadog::Error::ResponseError(local_error))
3352        }
3353    }
3354
3355    /// Reorder custom allocation rules - Change the execution order of custom allocation rules.
3356    ///
3357    /// **Important**: You must provide the **complete list** of all rule IDs in the desired execution order. The API will reorder ALL rules according to the provided sequence.
3358    ///
3359    /// Rules are executed in the order specified, with lower indices (earlier in the array) having higher priority.
3360    ///
3361    /// **Example**: If you have rules with IDs [123, 456, 789] and want to change order from 123→456→789 to 456→123→789, send: [{"id": "456"}, {"id": "123"}, {"id": "789"}]
3362    pub async fn reorder_custom_allocation_rules(
3363        &self,
3364        body: crate::datadogV2::model::ReorderRuleResourceArray,
3365    ) -> Result<(), datadog::Error<ReorderCustomAllocationRulesError>> {
3366        match self
3367            .reorder_custom_allocation_rules_with_http_info(body)
3368            .await
3369        {
3370            Ok(_) => Ok(()),
3371            Err(err) => Err(err),
3372        }
3373    }
3374
3375    /// Reorder custom allocation rules - Change the execution order of custom allocation rules.
3376    ///
3377    /// **Important**: You must provide the **complete list** of all rule IDs in the desired execution order. The API will reorder ALL rules according to the provided sequence.
3378    ///
3379    /// Rules are executed in the order specified, with lower indices (earlier in the array) having higher priority.
3380    ///
3381    /// **Example**: If you have rules with IDs [123, 456, 789] and want to change order from 123→456→789 to 456→123→789, send: [{"id": "456"}, {"id": "123"}, {"id": "789"}]
3382    pub async fn reorder_custom_allocation_rules_with_http_info(
3383        &self,
3384        body: crate::datadogV2::model::ReorderRuleResourceArray,
3385    ) -> Result<datadog::ResponseContent<()>, datadog::Error<ReorderCustomAllocationRulesError>>
3386    {
3387        let local_configuration = &self.config;
3388        let operation_id = "v2.reorder_custom_allocation_rules";
3389
3390        let local_client = &self.client;
3391
3392        let local_uri_str = format!(
3393            "{}/api/v2/cost/arbitrary_rule/reorder",
3394            local_configuration.get_operation_host(operation_id)
3395        );
3396        let mut local_req_builder =
3397            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
3398
3399        // build headers
3400        let mut headers = HeaderMap::new();
3401        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
3402        headers.insert("Accept", HeaderValue::from_static("*/*"));
3403
3404        // build user agent
3405        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3406            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3407            Err(e) => {
3408                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3409                headers.insert(
3410                    reqwest::header::USER_AGENT,
3411                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3412                )
3413            }
3414        };
3415
3416        // build auth
3417        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3418            headers.insert(
3419                "DD-API-KEY",
3420                HeaderValue::from_str(local_key.key.as_str())
3421                    .expect("failed to parse DD-API-KEY header"),
3422            );
3423        };
3424        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3425            headers.insert(
3426                "DD-APPLICATION-KEY",
3427                HeaderValue::from_str(local_key.key.as_str())
3428                    .expect("failed to parse DD-APPLICATION-KEY header"),
3429            );
3430        };
3431
3432        // build body parameters
3433        let output = Vec::new();
3434        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
3435        if body.serialize(&mut ser).is_ok() {
3436            if let Some(content_encoding) = headers.get("Content-Encoding") {
3437                match content_encoding.to_str().unwrap_or_default() {
3438                    "gzip" => {
3439                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
3440                        let _ = enc.write_all(ser.into_inner().as_slice());
3441                        match enc.finish() {
3442                            Ok(buf) => {
3443                                local_req_builder = local_req_builder.body(buf);
3444                            }
3445                            Err(e) => return Err(datadog::Error::Io(e)),
3446                        }
3447                    }
3448                    "deflate" => {
3449                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
3450                        let _ = enc.write_all(ser.into_inner().as_slice());
3451                        match enc.finish() {
3452                            Ok(buf) => {
3453                                local_req_builder = local_req_builder.body(buf);
3454                            }
3455                            Err(e) => return Err(datadog::Error::Io(e)),
3456                        }
3457                    }
3458                    "zstd1" => {
3459                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
3460                        let _ = enc.write_all(ser.into_inner().as_slice());
3461                        match enc.finish() {
3462                            Ok(buf) => {
3463                                local_req_builder = local_req_builder.body(buf);
3464                            }
3465                            Err(e) => return Err(datadog::Error::Io(e)),
3466                        }
3467                    }
3468                    _ => {
3469                        local_req_builder = local_req_builder.body(ser.into_inner());
3470                    }
3471                }
3472            } else {
3473                local_req_builder = local_req_builder.body(ser.into_inner());
3474            }
3475        }
3476
3477        local_req_builder = local_req_builder.headers(headers);
3478        let local_req = local_req_builder.build()?;
3479        log::debug!("request content: {:?}", local_req.body());
3480        let local_resp = local_client.execute(local_req).await?;
3481
3482        let local_status = local_resp.status();
3483        let local_content = local_resp.text().await?;
3484        log::debug!("response content: {}", local_content);
3485
3486        if !local_status.is_client_error() && !local_status.is_server_error() {
3487            Ok(datadog::ResponseContent {
3488                status: local_status,
3489                content: local_content,
3490                entity: None,
3491            })
3492        } else {
3493            let local_entity: Option<ReorderCustomAllocationRulesError> =
3494                serde_json::from_str(&local_content).ok();
3495            let local_error = datadog::ResponseContent {
3496                status: local_status,
3497                content: local_content,
3498                entity: local_entity,
3499            };
3500            Err(datadog::Error::ResponseError(local_error))
3501        }
3502    }
3503
3504    /// Reorder tag pipeline rulesets - Change the execution order of tag pipeline rulesets
3505    pub async fn reorder_tag_pipelines_rulesets(
3506        &self,
3507        body: crate::datadogV2::model::ReorderRulesetResourceArray,
3508    ) -> Result<(), datadog::Error<ReorderTagPipelinesRulesetsError>> {
3509        match self
3510            .reorder_tag_pipelines_rulesets_with_http_info(body)
3511            .await
3512        {
3513            Ok(_) => Ok(()),
3514            Err(err) => Err(err),
3515        }
3516    }
3517
3518    /// Reorder tag pipeline rulesets - Change the execution order of tag pipeline rulesets
3519    pub async fn reorder_tag_pipelines_rulesets_with_http_info(
3520        &self,
3521        body: crate::datadogV2::model::ReorderRulesetResourceArray,
3522    ) -> Result<datadog::ResponseContent<()>, datadog::Error<ReorderTagPipelinesRulesetsError>>
3523    {
3524        let local_configuration = &self.config;
3525        let operation_id = "v2.reorder_tag_pipelines_rulesets";
3526
3527        let local_client = &self.client;
3528
3529        let local_uri_str = format!(
3530            "{}/api/v2/tags/enrichment/reorder",
3531            local_configuration.get_operation_host(operation_id)
3532        );
3533        let mut local_req_builder =
3534            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
3535
3536        // build headers
3537        let mut headers = HeaderMap::new();
3538        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
3539        headers.insert("Accept", HeaderValue::from_static("*/*"));
3540
3541        // build user agent
3542        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3543            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3544            Err(e) => {
3545                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3546                headers.insert(
3547                    reqwest::header::USER_AGENT,
3548                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3549                )
3550            }
3551        };
3552
3553        // build auth
3554        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3555            headers.insert(
3556                "DD-API-KEY",
3557                HeaderValue::from_str(local_key.key.as_str())
3558                    .expect("failed to parse DD-API-KEY header"),
3559            );
3560        };
3561        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3562            headers.insert(
3563                "DD-APPLICATION-KEY",
3564                HeaderValue::from_str(local_key.key.as_str())
3565                    .expect("failed to parse DD-APPLICATION-KEY header"),
3566            );
3567        };
3568
3569        // build body parameters
3570        let output = Vec::new();
3571        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
3572        if body.serialize(&mut ser).is_ok() {
3573            if let Some(content_encoding) = headers.get("Content-Encoding") {
3574                match content_encoding.to_str().unwrap_or_default() {
3575                    "gzip" => {
3576                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
3577                        let _ = enc.write_all(ser.into_inner().as_slice());
3578                        match enc.finish() {
3579                            Ok(buf) => {
3580                                local_req_builder = local_req_builder.body(buf);
3581                            }
3582                            Err(e) => return Err(datadog::Error::Io(e)),
3583                        }
3584                    }
3585                    "deflate" => {
3586                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
3587                        let _ = enc.write_all(ser.into_inner().as_slice());
3588                        match enc.finish() {
3589                            Ok(buf) => {
3590                                local_req_builder = local_req_builder.body(buf);
3591                            }
3592                            Err(e) => return Err(datadog::Error::Io(e)),
3593                        }
3594                    }
3595                    "zstd1" => {
3596                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
3597                        let _ = enc.write_all(ser.into_inner().as_slice());
3598                        match enc.finish() {
3599                            Ok(buf) => {
3600                                local_req_builder = local_req_builder.body(buf);
3601                            }
3602                            Err(e) => return Err(datadog::Error::Io(e)),
3603                        }
3604                    }
3605                    _ => {
3606                        local_req_builder = local_req_builder.body(ser.into_inner());
3607                    }
3608                }
3609            } else {
3610                local_req_builder = local_req_builder.body(ser.into_inner());
3611            }
3612        }
3613
3614        local_req_builder = local_req_builder.headers(headers);
3615        let local_req = local_req_builder.build()?;
3616        log::debug!("request content: {:?}", local_req.body());
3617        let local_resp = local_client.execute(local_req).await?;
3618
3619        let local_status = local_resp.status();
3620        let local_content = local_resp.text().await?;
3621        log::debug!("response content: {}", local_content);
3622
3623        if !local_status.is_client_error() && !local_status.is_server_error() {
3624            Ok(datadog::ResponseContent {
3625                status: local_status,
3626                content: local_content,
3627                entity: None,
3628            })
3629        } else {
3630            let local_entity: Option<ReorderTagPipelinesRulesetsError> =
3631                serde_json::from_str(&local_content).ok();
3632            let local_error = datadog::ResponseContent {
3633                status: local_status,
3634                content: local_content,
3635                entity: local_entity,
3636            };
3637            Err(datadog::Error::ResponseError(local_error))
3638        }
3639    }
3640
3641    /// Update the status (active/archived) and/or account filtering configuration of an AWS CUR config.
3642    pub async fn update_cost_awscur_config(
3643        &self,
3644        cloud_account_id: i64,
3645        body: crate::datadogV2::model::AwsCURConfigPatchRequest,
3646    ) -> Result<
3647        crate::datadogV2::model::AwsCURConfigsResponse,
3648        datadog::Error<UpdateCostAWSCURConfigError>,
3649    > {
3650        match self
3651            .update_cost_awscur_config_with_http_info(cloud_account_id, body)
3652            .await
3653        {
3654            Ok(response_content) => {
3655                if let Some(e) = response_content.entity {
3656                    Ok(e)
3657                } else {
3658                    Err(datadog::Error::Serde(serde::de::Error::custom(
3659                        "response content was None",
3660                    )))
3661                }
3662            }
3663            Err(err) => Err(err),
3664        }
3665    }
3666
3667    /// Update the status (active/archived) and/or account filtering configuration of an AWS CUR config.
3668    pub async fn update_cost_awscur_config_with_http_info(
3669        &self,
3670        cloud_account_id: i64,
3671        body: crate::datadogV2::model::AwsCURConfigPatchRequest,
3672    ) -> Result<
3673        datadog::ResponseContent<crate::datadogV2::model::AwsCURConfigsResponse>,
3674        datadog::Error<UpdateCostAWSCURConfigError>,
3675    > {
3676        let local_configuration = &self.config;
3677        let operation_id = "v2.update_cost_awscur_config";
3678
3679        let local_client = &self.client;
3680
3681        let local_uri_str = format!(
3682            "{}/api/v2/cost/aws_cur_config/{cloud_account_id}",
3683            local_configuration.get_operation_host(operation_id),
3684            cloud_account_id = cloud_account_id
3685        );
3686        let mut local_req_builder =
3687            local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
3688
3689        // build headers
3690        let mut headers = HeaderMap::new();
3691        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
3692        headers.insert("Accept", HeaderValue::from_static("application/json"));
3693
3694        // build user agent
3695        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3696            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3697            Err(e) => {
3698                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3699                headers.insert(
3700                    reqwest::header::USER_AGENT,
3701                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3702                )
3703            }
3704        };
3705
3706        // build auth
3707        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3708            headers.insert(
3709                "DD-API-KEY",
3710                HeaderValue::from_str(local_key.key.as_str())
3711                    .expect("failed to parse DD-API-KEY header"),
3712            );
3713        };
3714        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3715            headers.insert(
3716                "DD-APPLICATION-KEY",
3717                HeaderValue::from_str(local_key.key.as_str())
3718                    .expect("failed to parse DD-APPLICATION-KEY header"),
3719            );
3720        };
3721
3722        // build body parameters
3723        let output = Vec::new();
3724        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
3725        if body.serialize(&mut ser).is_ok() {
3726            if let Some(content_encoding) = headers.get("Content-Encoding") {
3727                match content_encoding.to_str().unwrap_or_default() {
3728                    "gzip" => {
3729                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
3730                        let _ = enc.write_all(ser.into_inner().as_slice());
3731                        match enc.finish() {
3732                            Ok(buf) => {
3733                                local_req_builder = local_req_builder.body(buf);
3734                            }
3735                            Err(e) => return Err(datadog::Error::Io(e)),
3736                        }
3737                    }
3738                    "deflate" => {
3739                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
3740                        let _ = enc.write_all(ser.into_inner().as_slice());
3741                        match enc.finish() {
3742                            Ok(buf) => {
3743                                local_req_builder = local_req_builder.body(buf);
3744                            }
3745                            Err(e) => return Err(datadog::Error::Io(e)),
3746                        }
3747                    }
3748                    "zstd1" => {
3749                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
3750                        let _ = enc.write_all(ser.into_inner().as_slice());
3751                        match enc.finish() {
3752                            Ok(buf) => {
3753                                local_req_builder = local_req_builder.body(buf);
3754                            }
3755                            Err(e) => return Err(datadog::Error::Io(e)),
3756                        }
3757                    }
3758                    _ => {
3759                        local_req_builder = local_req_builder.body(ser.into_inner());
3760                    }
3761                }
3762            } else {
3763                local_req_builder = local_req_builder.body(ser.into_inner());
3764            }
3765        }
3766
3767        local_req_builder = local_req_builder.headers(headers);
3768        let local_req = local_req_builder.build()?;
3769        log::debug!("request content: {:?}", local_req.body());
3770        let local_resp = local_client.execute(local_req).await?;
3771
3772        let local_status = local_resp.status();
3773        let local_content = local_resp.text().await?;
3774        log::debug!("response content: {}", local_content);
3775
3776        if !local_status.is_client_error() && !local_status.is_server_error() {
3777            match serde_json::from_str::<crate::datadogV2::model::AwsCURConfigsResponse>(
3778                &local_content,
3779            ) {
3780                Ok(e) => {
3781                    return Ok(datadog::ResponseContent {
3782                        status: local_status,
3783                        content: local_content,
3784                        entity: Some(e),
3785                    })
3786                }
3787                Err(e) => return Err(datadog::Error::Serde(e)),
3788            };
3789        } else {
3790            let local_entity: Option<UpdateCostAWSCURConfigError> =
3791                serde_json::from_str(&local_content).ok();
3792            let local_error = datadog::ResponseContent {
3793                status: local_status,
3794                content: local_content,
3795                entity: local_entity,
3796            };
3797            Err(datadog::Error::ResponseError(local_error))
3798        }
3799    }
3800
3801    /// Update the status of an  Azure config (active/archived).
3802    pub async fn update_cost_azure_uc_configs(
3803        &self,
3804        cloud_account_id: i64,
3805        body: crate::datadogV2::model::AzureUCConfigPatchRequest,
3806    ) -> Result<
3807        crate::datadogV2::model::AzureUCConfigPairsResponse,
3808        datadog::Error<UpdateCostAzureUCConfigsError>,
3809    > {
3810        match self
3811            .update_cost_azure_uc_configs_with_http_info(cloud_account_id, body)
3812            .await
3813        {
3814            Ok(response_content) => {
3815                if let Some(e) = response_content.entity {
3816                    Ok(e)
3817                } else {
3818                    Err(datadog::Error::Serde(serde::de::Error::custom(
3819                        "response content was None",
3820                    )))
3821                }
3822            }
3823            Err(err) => Err(err),
3824        }
3825    }
3826
3827    /// Update the status of an  Azure config (active/archived).
3828    pub async fn update_cost_azure_uc_configs_with_http_info(
3829        &self,
3830        cloud_account_id: i64,
3831        body: crate::datadogV2::model::AzureUCConfigPatchRequest,
3832    ) -> Result<
3833        datadog::ResponseContent<crate::datadogV2::model::AzureUCConfigPairsResponse>,
3834        datadog::Error<UpdateCostAzureUCConfigsError>,
3835    > {
3836        let local_configuration = &self.config;
3837        let operation_id = "v2.update_cost_azure_uc_configs";
3838
3839        let local_client = &self.client;
3840
3841        let local_uri_str = format!(
3842            "{}/api/v2/cost/azure_uc_config/{cloud_account_id}",
3843            local_configuration.get_operation_host(operation_id),
3844            cloud_account_id = cloud_account_id
3845        );
3846        let mut local_req_builder =
3847            local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
3848
3849        // build headers
3850        let mut headers = HeaderMap::new();
3851        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
3852        headers.insert("Accept", HeaderValue::from_static("application/json"));
3853
3854        // build user agent
3855        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3856            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3857            Err(e) => {
3858                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3859                headers.insert(
3860                    reqwest::header::USER_AGENT,
3861                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3862                )
3863            }
3864        };
3865
3866        // build auth
3867        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3868            headers.insert(
3869                "DD-API-KEY",
3870                HeaderValue::from_str(local_key.key.as_str())
3871                    .expect("failed to parse DD-API-KEY header"),
3872            );
3873        };
3874        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3875            headers.insert(
3876                "DD-APPLICATION-KEY",
3877                HeaderValue::from_str(local_key.key.as_str())
3878                    .expect("failed to parse DD-APPLICATION-KEY header"),
3879            );
3880        };
3881
3882        // build body parameters
3883        let output = Vec::new();
3884        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
3885        if body.serialize(&mut ser).is_ok() {
3886            if let Some(content_encoding) = headers.get("Content-Encoding") {
3887                match content_encoding.to_str().unwrap_or_default() {
3888                    "gzip" => {
3889                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
3890                        let _ = enc.write_all(ser.into_inner().as_slice());
3891                        match enc.finish() {
3892                            Ok(buf) => {
3893                                local_req_builder = local_req_builder.body(buf);
3894                            }
3895                            Err(e) => return Err(datadog::Error::Io(e)),
3896                        }
3897                    }
3898                    "deflate" => {
3899                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
3900                        let _ = enc.write_all(ser.into_inner().as_slice());
3901                        match enc.finish() {
3902                            Ok(buf) => {
3903                                local_req_builder = local_req_builder.body(buf);
3904                            }
3905                            Err(e) => return Err(datadog::Error::Io(e)),
3906                        }
3907                    }
3908                    "zstd1" => {
3909                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
3910                        let _ = enc.write_all(ser.into_inner().as_slice());
3911                        match enc.finish() {
3912                            Ok(buf) => {
3913                                local_req_builder = local_req_builder.body(buf);
3914                            }
3915                            Err(e) => return Err(datadog::Error::Io(e)),
3916                        }
3917                    }
3918                    _ => {
3919                        local_req_builder = local_req_builder.body(ser.into_inner());
3920                    }
3921                }
3922            } else {
3923                local_req_builder = local_req_builder.body(ser.into_inner());
3924            }
3925        }
3926
3927        local_req_builder = local_req_builder.headers(headers);
3928        let local_req = local_req_builder.build()?;
3929        log::debug!("request content: {:?}", local_req.body());
3930        let local_resp = local_client.execute(local_req).await?;
3931
3932        let local_status = local_resp.status();
3933        let local_content = local_resp.text().await?;
3934        log::debug!("response content: {}", local_content);
3935
3936        if !local_status.is_client_error() && !local_status.is_server_error() {
3937            match serde_json::from_str::<crate::datadogV2::model::AzureUCConfigPairsResponse>(
3938                &local_content,
3939            ) {
3940                Ok(e) => {
3941                    return Ok(datadog::ResponseContent {
3942                        status: local_status,
3943                        content: local_content,
3944                        entity: Some(e),
3945                    })
3946                }
3947                Err(e) => return Err(datadog::Error::Serde(e)),
3948            };
3949        } else {
3950            let local_entity: Option<UpdateCostAzureUCConfigsError> =
3951                serde_json::from_str(&local_content).ok();
3952            let local_error = datadog::ResponseContent {
3953                status: local_status,
3954                content: local_content,
3955                entity: local_entity,
3956            };
3957            Err(datadog::Error::ResponseError(local_error))
3958        }
3959    }
3960
3961    /// Update the status of an Google Cloud Usage Cost config (active/archived).
3962    pub async fn update_cost_gcp_usage_cost_config(
3963        &self,
3964        cloud_account_id: i64,
3965        body: crate::datadogV2::model::GCPUsageCostConfigPatchRequest,
3966    ) -> Result<
3967        crate::datadogV2::model::GCPUsageCostConfigResponse,
3968        datadog::Error<UpdateCostGCPUsageCostConfigError>,
3969    > {
3970        match self
3971            .update_cost_gcp_usage_cost_config_with_http_info(cloud_account_id, body)
3972            .await
3973        {
3974            Ok(response_content) => {
3975                if let Some(e) = response_content.entity {
3976                    Ok(e)
3977                } else {
3978                    Err(datadog::Error::Serde(serde::de::Error::custom(
3979                        "response content was None",
3980                    )))
3981                }
3982            }
3983            Err(err) => Err(err),
3984        }
3985    }
3986
3987    /// Update the status of an Google Cloud Usage Cost config (active/archived).
3988    pub async fn update_cost_gcp_usage_cost_config_with_http_info(
3989        &self,
3990        cloud_account_id: i64,
3991        body: crate::datadogV2::model::GCPUsageCostConfigPatchRequest,
3992    ) -> Result<
3993        datadog::ResponseContent<crate::datadogV2::model::GCPUsageCostConfigResponse>,
3994        datadog::Error<UpdateCostGCPUsageCostConfigError>,
3995    > {
3996        let local_configuration = &self.config;
3997        let operation_id = "v2.update_cost_gcp_usage_cost_config";
3998
3999        let local_client = &self.client;
4000
4001        let local_uri_str = format!(
4002            "{}/api/v2/cost/gcp_uc_config/{cloud_account_id}",
4003            local_configuration.get_operation_host(operation_id),
4004            cloud_account_id = cloud_account_id
4005        );
4006        let mut local_req_builder =
4007            local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
4008
4009        // build headers
4010        let mut headers = HeaderMap::new();
4011        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
4012        headers.insert("Accept", HeaderValue::from_static("application/json"));
4013
4014        // build user agent
4015        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4016            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4017            Err(e) => {
4018                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4019                headers.insert(
4020                    reqwest::header::USER_AGENT,
4021                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4022                )
4023            }
4024        };
4025
4026        // build auth
4027        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4028            headers.insert(
4029                "DD-API-KEY",
4030                HeaderValue::from_str(local_key.key.as_str())
4031                    .expect("failed to parse DD-API-KEY header"),
4032            );
4033        };
4034        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4035            headers.insert(
4036                "DD-APPLICATION-KEY",
4037                HeaderValue::from_str(local_key.key.as_str())
4038                    .expect("failed to parse DD-APPLICATION-KEY header"),
4039            );
4040        };
4041
4042        // build body parameters
4043        let output = Vec::new();
4044        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
4045        if body.serialize(&mut ser).is_ok() {
4046            if let Some(content_encoding) = headers.get("Content-Encoding") {
4047                match content_encoding.to_str().unwrap_or_default() {
4048                    "gzip" => {
4049                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
4050                        let _ = enc.write_all(ser.into_inner().as_slice());
4051                        match enc.finish() {
4052                            Ok(buf) => {
4053                                local_req_builder = local_req_builder.body(buf);
4054                            }
4055                            Err(e) => return Err(datadog::Error::Io(e)),
4056                        }
4057                    }
4058                    "deflate" => {
4059                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
4060                        let _ = enc.write_all(ser.into_inner().as_slice());
4061                        match enc.finish() {
4062                            Ok(buf) => {
4063                                local_req_builder = local_req_builder.body(buf);
4064                            }
4065                            Err(e) => return Err(datadog::Error::Io(e)),
4066                        }
4067                    }
4068                    "zstd1" => {
4069                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
4070                        let _ = enc.write_all(ser.into_inner().as_slice());
4071                        match enc.finish() {
4072                            Ok(buf) => {
4073                                local_req_builder = local_req_builder.body(buf);
4074                            }
4075                            Err(e) => return Err(datadog::Error::Io(e)),
4076                        }
4077                    }
4078                    _ => {
4079                        local_req_builder = local_req_builder.body(ser.into_inner());
4080                    }
4081                }
4082            } else {
4083                local_req_builder = local_req_builder.body(ser.into_inner());
4084            }
4085        }
4086
4087        local_req_builder = local_req_builder.headers(headers);
4088        let local_req = local_req_builder.build()?;
4089        log::debug!("request content: {:?}", local_req.body());
4090        let local_resp = local_client.execute(local_req).await?;
4091
4092        let local_status = local_resp.status();
4093        let local_content = local_resp.text().await?;
4094        log::debug!("response content: {}", local_content);
4095
4096        if !local_status.is_client_error() && !local_status.is_server_error() {
4097            match serde_json::from_str::<crate::datadogV2::model::GCPUsageCostConfigResponse>(
4098                &local_content,
4099            ) {
4100                Ok(e) => {
4101                    return Ok(datadog::ResponseContent {
4102                        status: local_status,
4103                        content: local_content,
4104                        entity: Some(e),
4105                    })
4106                }
4107                Err(e) => return Err(datadog::Error::Serde(e)),
4108            };
4109        } else {
4110            let local_entity: Option<UpdateCostGCPUsageCostConfigError> =
4111                serde_json::from_str(&local_content).ok();
4112            let local_error = datadog::ResponseContent {
4113                status: local_status,
4114                content: local_content,
4115                entity: local_entity,
4116            };
4117            Err(datadog::Error::ResponseError(local_error))
4118        }
4119    }
4120
4121    /// Update an existing custom allocation rule with new filters and allocation strategy.
4122    ///
4123    /// **Strategy Methods:**
4124    /// - **PROPORTIONAL/EVEN**: Allocates costs proportionally/evenly based on existing costs. Requires: granularity, allocated_by_tag_keys. Optional: based_on_costs, allocated_by_filters, evaluate_grouped_by_tag_keys, evaluate_grouped_by_filters.
4125    /// - **PROPORTIONAL_TIMESERIES/EVEN_TIMESERIES**: Allocates based on timeseries data. Requires: granularity, based_on_timeseries. Optional: evaluate_grouped_by_tag_keys.
4126    /// - **PERCENT**: Allocates fixed percentages to specific tags. Requires: allocated_by (array of percentage allocations).
4127    /// - **USAGE_METRIC**: Allocates based on usage metrics (implementation varies).
4128    ///
4129    /// **Filter Conditions:**
4130    /// - Use **value** for single-value conditions: "is", "is not", "contains", "does not contain", "=", "!=", "like", "not like", "is all values", "is untagged"
4131    /// - Use **values** for multi-value conditions: "in", "not in"
4132    /// - Cannot use both value and values simultaneously.
4133    ///
4134    /// **Supported operators**: is, is not, is all values, is untagged, contains, does not contain, in, not in, =, !=, like, not like
4135    pub async fn update_custom_allocation_rule(
4136        &self,
4137        rule_id: i64,
4138        body: crate::datadogV2::model::ArbitraryCostUpsertRequest,
4139    ) -> Result<
4140        crate::datadogV2::model::ArbitraryRuleResponse,
4141        datadog::Error<UpdateCustomAllocationRuleError>,
4142    > {
4143        match self
4144            .update_custom_allocation_rule_with_http_info(rule_id, body)
4145            .await
4146        {
4147            Ok(response_content) => {
4148                if let Some(e) = response_content.entity {
4149                    Ok(e)
4150                } else {
4151                    Err(datadog::Error::Serde(serde::de::Error::custom(
4152                        "response content was None",
4153                    )))
4154                }
4155            }
4156            Err(err) => Err(err),
4157        }
4158    }
4159
4160    /// Update an existing custom allocation rule with new filters and allocation strategy.
4161    ///
4162    /// **Strategy Methods:**
4163    /// - **PROPORTIONAL/EVEN**: Allocates costs proportionally/evenly based on existing costs. Requires: granularity, allocated_by_tag_keys. Optional: based_on_costs, allocated_by_filters, evaluate_grouped_by_tag_keys, evaluate_grouped_by_filters.
4164    /// - **PROPORTIONAL_TIMESERIES/EVEN_TIMESERIES**: Allocates based on timeseries data. Requires: granularity, based_on_timeseries. Optional: evaluate_grouped_by_tag_keys.
4165    /// - **PERCENT**: Allocates fixed percentages to specific tags. Requires: allocated_by (array of percentage allocations).
4166    /// - **USAGE_METRIC**: Allocates based on usage metrics (implementation varies).
4167    ///
4168    /// **Filter Conditions:**
4169    /// - Use **value** for single-value conditions: "is", "is not", "contains", "does not contain", "=", "!=", "like", "not like", "is all values", "is untagged"
4170    /// - Use **values** for multi-value conditions: "in", "not in"
4171    /// - Cannot use both value and values simultaneously.
4172    ///
4173    /// **Supported operators**: is, is not, is all values, is untagged, contains, does not contain, in, not in, =, !=, like, not like
4174    pub async fn update_custom_allocation_rule_with_http_info(
4175        &self,
4176        rule_id: i64,
4177        body: crate::datadogV2::model::ArbitraryCostUpsertRequest,
4178    ) -> Result<
4179        datadog::ResponseContent<crate::datadogV2::model::ArbitraryRuleResponse>,
4180        datadog::Error<UpdateCustomAllocationRuleError>,
4181    > {
4182        let local_configuration = &self.config;
4183        let operation_id = "v2.update_custom_allocation_rule";
4184
4185        let local_client = &self.client;
4186
4187        let local_uri_str = format!(
4188            "{}/api/v2/cost/arbitrary_rule/{rule_id}",
4189            local_configuration.get_operation_host(operation_id),
4190            rule_id = rule_id
4191        );
4192        let mut local_req_builder =
4193            local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
4194
4195        // build headers
4196        let mut headers = HeaderMap::new();
4197        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
4198        headers.insert("Accept", HeaderValue::from_static("application/json"));
4199
4200        // build user agent
4201        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4202            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4203            Err(e) => {
4204                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4205                headers.insert(
4206                    reqwest::header::USER_AGENT,
4207                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4208                )
4209            }
4210        };
4211
4212        // build auth
4213        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4214            headers.insert(
4215                "DD-API-KEY",
4216                HeaderValue::from_str(local_key.key.as_str())
4217                    .expect("failed to parse DD-API-KEY header"),
4218            );
4219        };
4220        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4221            headers.insert(
4222                "DD-APPLICATION-KEY",
4223                HeaderValue::from_str(local_key.key.as_str())
4224                    .expect("failed to parse DD-APPLICATION-KEY header"),
4225            );
4226        };
4227
4228        // build body parameters
4229        let output = Vec::new();
4230        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
4231        if body.serialize(&mut ser).is_ok() {
4232            if let Some(content_encoding) = headers.get("Content-Encoding") {
4233                match content_encoding.to_str().unwrap_or_default() {
4234                    "gzip" => {
4235                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
4236                        let _ = enc.write_all(ser.into_inner().as_slice());
4237                        match enc.finish() {
4238                            Ok(buf) => {
4239                                local_req_builder = local_req_builder.body(buf);
4240                            }
4241                            Err(e) => return Err(datadog::Error::Io(e)),
4242                        }
4243                    }
4244                    "deflate" => {
4245                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
4246                        let _ = enc.write_all(ser.into_inner().as_slice());
4247                        match enc.finish() {
4248                            Ok(buf) => {
4249                                local_req_builder = local_req_builder.body(buf);
4250                            }
4251                            Err(e) => return Err(datadog::Error::Io(e)),
4252                        }
4253                    }
4254                    "zstd1" => {
4255                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
4256                        let _ = enc.write_all(ser.into_inner().as_slice());
4257                        match enc.finish() {
4258                            Ok(buf) => {
4259                                local_req_builder = local_req_builder.body(buf);
4260                            }
4261                            Err(e) => return Err(datadog::Error::Io(e)),
4262                        }
4263                    }
4264                    _ => {
4265                        local_req_builder = local_req_builder.body(ser.into_inner());
4266                    }
4267                }
4268            } else {
4269                local_req_builder = local_req_builder.body(ser.into_inner());
4270            }
4271        }
4272
4273        local_req_builder = local_req_builder.headers(headers);
4274        let local_req = local_req_builder.build()?;
4275        log::debug!("request content: {:?}", local_req.body());
4276        let local_resp = local_client.execute(local_req).await?;
4277
4278        let local_status = local_resp.status();
4279        let local_content = local_resp.text().await?;
4280        log::debug!("response content: {}", local_content);
4281
4282        if !local_status.is_client_error() && !local_status.is_server_error() {
4283            match serde_json::from_str::<crate::datadogV2::model::ArbitraryRuleResponse>(
4284                &local_content,
4285            ) {
4286                Ok(e) => {
4287                    return Ok(datadog::ResponseContent {
4288                        status: local_status,
4289                        content: local_content,
4290                        entity: Some(e),
4291                    })
4292                }
4293                Err(e) => return Err(datadog::Error::Serde(e)),
4294            };
4295        } else {
4296            let local_entity: Option<UpdateCustomAllocationRuleError> =
4297                serde_json::from_str(&local_content).ok();
4298            let local_error = datadog::ResponseContent {
4299                status: local_status,
4300                content: local_content,
4301                entity: local_entity,
4302            };
4303            Err(datadog::Error::ResponseError(local_error))
4304        }
4305    }
4306
4307    /// Update a tag pipeline ruleset - Update an existing tag pipeline ruleset with new rules and configuration
4308    pub async fn update_tag_pipelines_ruleset(
4309        &self,
4310        ruleset_id: String,
4311        body: crate::datadogV2::model::UpdateRulesetRequest,
4312    ) -> Result<crate::datadogV2::model::RulesetResp, datadog::Error<UpdateTagPipelinesRulesetError>>
4313    {
4314        match self
4315            .update_tag_pipelines_ruleset_with_http_info(ruleset_id, body)
4316            .await
4317        {
4318            Ok(response_content) => {
4319                if let Some(e) = response_content.entity {
4320                    Ok(e)
4321                } else {
4322                    Err(datadog::Error::Serde(serde::de::Error::custom(
4323                        "response content was None",
4324                    )))
4325                }
4326            }
4327            Err(err) => Err(err),
4328        }
4329    }
4330
4331    /// Update a tag pipeline ruleset - Update an existing tag pipeline ruleset with new rules and configuration
4332    pub async fn update_tag_pipelines_ruleset_with_http_info(
4333        &self,
4334        ruleset_id: String,
4335        body: crate::datadogV2::model::UpdateRulesetRequest,
4336    ) -> Result<
4337        datadog::ResponseContent<crate::datadogV2::model::RulesetResp>,
4338        datadog::Error<UpdateTagPipelinesRulesetError>,
4339    > {
4340        let local_configuration = &self.config;
4341        let operation_id = "v2.update_tag_pipelines_ruleset";
4342
4343        let local_client = &self.client;
4344
4345        let local_uri_str = format!(
4346            "{}/api/v2/tags/enrichment/{ruleset_id}",
4347            local_configuration.get_operation_host(operation_id),
4348            ruleset_id = datadog::urlencode(ruleset_id)
4349        );
4350        let mut local_req_builder =
4351            local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
4352
4353        // build headers
4354        let mut headers = HeaderMap::new();
4355        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
4356        headers.insert("Accept", HeaderValue::from_static("application/json"));
4357
4358        // build user agent
4359        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4360            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4361            Err(e) => {
4362                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4363                headers.insert(
4364                    reqwest::header::USER_AGENT,
4365                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4366                )
4367            }
4368        };
4369
4370        // build auth
4371        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4372            headers.insert(
4373                "DD-API-KEY",
4374                HeaderValue::from_str(local_key.key.as_str())
4375                    .expect("failed to parse DD-API-KEY header"),
4376            );
4377        };
4378        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4379            headers.insert(
4380                "DD-APPLICATION-KEY",
4381                HeaderValue::from_str(local_key.key.as_str())
4382                    .expect("failed to parse DD-APPLICATION-KEY header"),
4383            );
4384        };
4385
4386        // build body parameters
4387        let output = Vec::new();
4388        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
4389        if body.serialize(&mut ser).is_ok() {
4390            if let Some(content_encoding) = headers.get("Content-Encoding") {
4391                match content_encoding.to_str().unwrap_or_default() {
4392                    "gzip" => {
4393                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
4394                        let _ = enc.write_all(ser.into_inner().as_slice());
4395                        match enc.finish() {
4396                            Ok(buf) => {
4397                                local_req_builder = local_req_builder.body(buf);
4398                            }
4399                            Err(e) => return Err(datadog::Error::Io(e)),
4400                        }
4401                    }
4402                    "deflate" => {
4403                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
4404                        let _ = enc.write_all(ser.into_inner().as_slice());
4405                        match enc.finish() {
4406                            Ok(buf) => {
4407                                local_req_builder = local_req_builder.body(buf);
4408                            }
4409                            Err(e) => return Err(datadog::Error::Io(e)),
4410                        }
4411                    }
4412                    "zstd1" => {
4413                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
4414                        let _ = enc.write_all(ser.into_inner().as_slice());
4415                        match enc.finish() {
4416                            Ok(buf) => {
4417                                local_req_builder = local_req_builder.body(buf);
4418                            }
4419                            Err(e) => return Err(datadog::Error::Io(e)),
4420                        }
4421                    }
4422                    _ => {
4423                        local_req_builder = local_req_builder.body(ser.into_inner());
4424                    }
4425                }
4426            } else {
4427                local_req_builder = local_req_builder.body(ser.into_inner());
4428            }
4429        }
4430
4431        local_req_builder = local_req_builder.headers(headers);
4432        let local_req = local_req_builder.build()?;
4433        log::debug!("request content: {:?}", local_req.body());
4434        let local_resp = local_client.execute(local_req).await?;
4435
4436        let local_status = local_resp.status();
4437        let local_content = local_resp.text().await?;
4438        log::debug!("response content: {}", local_content);
4439
4440        if !local_status.is_client_error() && !local_status.is_server_error() {
4441            match serde_json::from_str::<crate::datadogV2::model::RulesetResp>(&local_content) {
4442                Ok(e) => {
4443                    return Ok(datadog::ResponseContent {
4444                        status: local_status,
4445                        content: local_content,
4446                        entity: Some(e),
4447                    })
4448                }
4449                Err(e) => return Err(datadog::Error::Serde(e)),
4450            };
4451        } else {
4452            let local_entity: Option<UpdateTagPipelinesRulesetError> =
4453                serde_json::from_str(&local_content).ok();
4454            let local_error = datadog::ResponseContent {
4455                status: local_status,
4456                content: local_content,
4457                entity: local_entity,
4458            };
4459            Err(datadog::Error::ResponseError(local_error))
4460        }
4461    }
4462
4463    /// Upload a Custom Costs file.
4464    pub async fn upload_custom_costs_file(
4465        &self,
4466        body: Vec<crate::datadogV2::model::CustomCostsFileLineItem>,
4467    ) -> Result<
4468        crate::datadogV2::model::CustomCostsFileUploadResponse,
4469        datadog::Error<UploadCustomCostsFileError>,
4470    > {
4471        match self.upload_custom_costs_file_with_http_info(body).await {
4472            Ok(response_content) => {
4473                if let Some(e) = response_content.entity {
4474                    Ok(e)
4475                } else {
4476                    Err(datadog::Error::Serde(serde::de::Error::custom(
4477                        "response content was None",
4478                    )))
4479                }
4480            }
4481            Err(err) => Err(err),
4482        }
4483    }
4484
4485    /// Upload a Custom Costs file.
4486    pub async fn upload_custom_costs_file_with_http_info(
4487        &self,
4488        body: Vec<crate::datadogV2::model::CustomCostsFileLineItem>,
4489    ) -> Result<
4490        datadog::ResponseContent<crate::datadogV2::model::CustomCostsFileUploadResponse>,
4491        datadog::Error<UploadCustomCostsFileError>,
4492    > {
4493        let local_configuration = &self.config;
4494        let operation_id = "v2.upload_custom_costs_file";
4495
4496        let local_client = &self.client;
4497
4498        let local_uri_str = format!(
4499            "{}/api/v2/cost/custom_costs",
4500            local_configuration.get_operation_host(operation_id)
4501        );
4502        let mut local_req_builder =
4503            local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
4504
4505        // build headers
4506        let mut headers = HeaderMap::new();
4507        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
4508        headers.insert("Accept", HeaderValue::from_static("application/json"));
4509
4510        // build user agent
4511        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4512            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4513            Err(e) => {
4514                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4515                headers.insert(
4516                    reqwest::header::USER_AGENT,
4517                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4518                )
4519            }
4520        };
4521
4522        // build auth
4523        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4524            headers.insert(
4525                "DD-API-KEY",
4526                HeaderValue::from_str(local_key.key.as_str())
4527                    .expect("failed to parse DD-API-KEY header"),
4528            );
4529        };
4530        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4531            headers.insert(
4532                "DD-APPLICATION-KEY",
4533                HeaderValue::from_str(local_key.key.as_str())
4534                    .expect("failed to parse DD-APPLICATION-KEY header"),
4535            );
4536        };
4537
4538        // build body parameters
4539        let output = Vec::new();
4540        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
4541        if body.serialize(&mut ser).is_ok() {
4542            if let Some(content_encoding) = headers.get("Content-Encoding") {
4543                match content_encoding.to_str().unwrap_or_default() {
4544                    "gzip" => {
4545                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
4546                        let _ = enc.write_all(ser.into_inner().as_slice());
4547                        match enc.finish() {
4548                            Ok(buf) => {
4549                                local_req_builder = local_req_builder.body(buf);
4550                            }
4551                            Err(e) => return Err(datadog::Error::Io(e)),
4552                        }
4553                    }
4554                    "deflate" => {
4555                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
4556                        let _ = enc.write_all(ser.into_inner().as_slice());
4557                        match enc.finish() {
4558                            Ok(buf) => {
4559                                local_req_builder = local_req_builder.body(buf);
4560                            }
4561                            Err(e) => return Err(datadog::Error::Io(e)),
4562                        }
4563                    }
4564                    "zstd1" => {
4565                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
4566                        let _ = enc.write_all(ser.into_inner().as_slice());
4567                        match enc.finish() {
4568                            Ok(buf) => {
4569                                local_req_builder = local_req_builder.body(buf);
4570                            }
4571                            Err(e) => return Err(datadog::Error::Io(e)),
4572                        }
4573                    }
4574                    _ => {
4575                        local_req_builder = local_req_builder.body(ser.into_inner());
4576                    }
4577                }
4578            } else {
4579                local_req_builder = local_req_builder.body(ser.into_inner());
4580            }
4581        }
4582
4583        local_req_builder = local_req_builder.headers(headers);
4584        let local_req = local_req_builder.build()?;
4585        log::debug!("request content: {:?}", local_req.body());
4586        let local_resp = local_client.execute(local_req).await?;
4587
4588        let local_status = local_resp.status();
4589        let local_content = local_resp.text().await?;
4590        log::debug!("response content: {}", local_content);
4591
4592        if !local_status.is_client_error() && !local_status.is_server_error() {
4593            match serde_json::from_str::<crate::datadogV2::model::CustomCostsFileUploadResponse>(
4594                &local_content,
4595            ) {
4596                Ok(e) => {
4597                    return Ok(datadog::ResponseContent {
4598                        status: local_status,
4599                        content: local_content,
4600                        entity: Some(e),
4601                    })
4602                }
4603                Err(e) => return Err(datadog::Error::Serde(e)),
4604            };
4605        } else {
4606            let local_entity: Option<UploadCustomCostsFileError> =
4607                serde_json::from_str(&local_content).ok();
4608            let local_error = datadog::ResponseContent {
4609                status: local_status,
4610                content: local_content,
4611                entity: local_entity,
4612            };
4613            Err(datadog::Error::ResponseError(local_error))
4614        }
4615    }
4616
4617    /// Create a new budget or update an existing one.
4618    pub async fn upsert_budget(
4619        &self,
4620        body: crate::datadogV2::model::BudgetWithEntries,
4621    ) -> Result<crate::datadogV2::model::BudgetWithEntries, datadog::Error<UpsertBudgetError>> {
4622        match self.upsert_budget_with_http_info(body).await {
4623            Ok(response_content) => {
4624                if let Some(e) = response_content.entity {
4625                    Ok(e)
4626                } else {
4627                    Err(datadog::Error::Serde(serde::de::Error::custom(
4628                        "response content was None",
4629                    )))
4630                }
4631            }
4632            Err(err) => Err(err),
4633        }
4634    }
4635
4636    /// Create a new budget or update an existing one.
4637    pub async fn upsert_budget_with_http_info(
4638        &self,
4639        body: crate::datadogV2::model::BudgetWithEntries,
4640    ) -> Result<
4641        datadog::ResponseContent<crate::datadogV2::model::BudgetWithEntries>,
4642        datadog::Error<UpsertBudgetError>,
4643    > {
4644        let local_configuration = &self.config;
4645        let operation_id = "v2.upsert_budget";
4646
4647        let local_client = &self.client;
4648
4649        let local_uri_str = format!(
4650            "{}/api/v2/cost/budget",
4651            local_configuration.get_operation_host(operation_id)
4652        );
4653        let mut local_req_builder =
4654            local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
4655
4656        // build headers
4657        let mut headers = HeaderMap::new();
4658        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
4659        headers.insert("Accept", HeaderValue::from_static("application/json"));
4660
4661        // build user agent
4662        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4663            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4664            Err(e) => {
4665                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4666                headers.insert(
4667                    reqwest::header::USER_AGENT,
4668                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4669                )
4670            }
4671        };
4672
4673        // build auth
4674        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4675            headers.insert(
4676                "DD-API-KEY",
4677                HeaderValue::from_str(local_key.key.as_str())
4678                    .expect("failed to parse DD-API-KEY header"),
4679            );
4680        };
4681        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4682            headers.insert(
4683                "DD-APPLICATION-KEY",
4684                HeaderValue::from_str(local_key.key.as_str())
4685                    .expect("failed to parse DD-APPLICATION-KEY header"),
4686            );
4687        };
4688
4689        // build body parameters
4690        let output = Vec::new();
4691        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
4692        if body.serialize(&mut ser).is_ok() {
4693            if let Some(content_encoding) = headers.get("Content-Encoding") {
4694                match content_encoding.to_str().unwrap_or_default() {
4695                    "gzip" => {
4696                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
4697                        let _ = enc.write_all(ser.into_inner().as_slice());
4698                        match enc.finish() {
4699                            Ok(buf) => {
4700                                local_req_builder = local_req_builder.body(buf);
4701                            }
4702                            Err(e) => return Err(datadog::Error::Io(e)),
4703                        }
4704                    }
4705                    "deflate" => {
4706                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
4707                        let _ = enc.write_all(ser.into_inner().as_slice());
4708                        match enc.finish() {
4709                            Ok(buf) => {
4710                                local_req_builder = local_req_builder.body(buf);
4711                            }
4712                            Err(e) => return Err(datadog::Error::Io(e)),
4713                        }
4714                    }
4715                    "zstd1" => {
4716                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
4717                        let _ = enc.write_all(ser.into_inner().as_slice());
4718                        match enc.finish() {
4719                            Ok(buf) => {
4720                                local_req_builder = local_req_builder.body(buf);
4721                            }
4722                            Err(e) => return Err(datadog::Error::Io(e)),
4723                        }
4724                    }
4725                    _ => {
4726                        local_req_builder = local_req_builder.body(ser.into_inner());
4727                    }
4728                }
4729            } else {
4730                local_req_builder = local_req_builder.body(ser.into_inner());
4731            }
4732        }
4733
4734        local_req_builder = local_req_builder.headers(headers);
4735        let local_req = local_req_builder.build()?;
4736        log::debug!("request content: {:?}", local_req.body());
4737        let local_resp = local_client.execute(local_req).await?;
4738
4739        let local_status = local_resp.status();
4740        let local_content = local_resp.text().await?;
4741        log::debug!("response content: {}", local_content);
4742
4743        if !local_status.is_client_error() && !local_status.is_server_error() {
4744            match serde_json::from_str::<crate::datadogV2::model::BudgetWithEntries>(&local_content)
4745            {
4746                Ok(e) => {
4747                    return Ok(datadog::ResponseContent {
4748                        status: local_status,
4749                        content: local_content,
4750                        entity: Some(e),
4751                    })
4752                }
4753                Err(e) => return Err(datadog::Error::Serde(e)),
4754            };
4755        } else {
4756            let local_entity: Option<UpsertBudgetError> = serde_json::from_str(&local_content).ok();
4757            let local_error = datadog::ResponseContent {
4758                status: local_status,
4759                content: local_content,
4760                entity: local_entity,
4761            };
4762            Err(datadog::Error::ResponseError(local_error))
4763        }
4764    }
4765
4766    /// Validate a tag pipeline query - Validate the syntax and structure of a tag pipeline query
4767    pub async fn validate_query(
4768        &self,
4769        body: crate::datadogV2::model::RulesValidateQueryRequest,
4770    ) -> Result<
4771        crate::datadogV2::model::RulesValidateQueryResponse,
4772        datadog::Error<ValidateQueryError>,
4773    > {
4774        match self.validate_query_with_http_info(body).await {
4775            Ok(response_content) => {
4776                if let Some(e) = response_content.entity {
4777                    Ok(e)
4778                } else {
4779                    Err(datadog::Error::Serde(serde::de::Error::custom(
4780                        "response content was None",
4781                    )))
4782                }
4783            }
4784            Err(err) => Err(err),
4785        }
4786    }
4787
4788    /// Validate a tag pipeline query - Validate the syntax and structure of a tag pipeline query
4789    pub async fn validate_query_with_http_info(
4790        &self,
4791        body: crate::datadogV2::model::RulesValidateQueryRequest,
4792    ) -> Result<
4793        datadog::ResponseContent<crate::datadogV2::model::RulesValidateQueryResponse>,
4794        datadog::Error<ValidateQueryError>,
4795    > {
4796        let local_configuration = &self.config;
4797        let operation_id = "v2.validate_query";
4798
4799        let local_client = &self.client;
4800
4801        let local_uri_str = format!(
4802            "{}/api/v2/tags/enrichment/validate-query",
4803            local_configuration.get_operation_host(operation_id)
4804        );
4805        let mut local_req_builder =
4806            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
4807
4808        // build headers
4809        let mut headers = HeaderMap::new();
4810        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
4811        headers.insert("Accept", HeaderValue::from_static("application/json"));
4812
4813        // build user agent
4814        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4815            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4816            Err(e) => {
4817                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4818                headers.insert(
4819                    reqwest::header::USER_AGENT,
4820                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4821                )
4822            }
4823        };
4824
4825        // build auth
4826        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4827            headers.insert(
4828                "DD-API-KEY",
4829                HeaderValue::from_str(local_key.key.as_str())
4830                    .expect("failed to parse DD-API-KEY header"),
4831            );
4832        };
4833        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4834            headers.insert(
4835                "DD-APPLICATION-KEY",
4836                HeaderValue::from_str(local_key.key.as_str())
4837                    .expect("failed to parse DD-APPLICATION-KEY header"),
4838            );
4839        };
4840
4841        // build body parameters
4842        let output = Vec::new();
4843        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
4844        if body.serialize(&mut ser).is_ok() {
4845            if let Some(content_encoding) = headers.get("Content-Encoding") {
4846                match content_encoding.to_str().unwrap_or_default() {
4847                    "gzip" => {
4848                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
4849                        let _ = enc.write_all(ser.into_inner().as_slice());
4850                        match enc.finish() {
4851                            Ok(buf) => {
4852                                local_req_builder = local_req_builder.body(buf);
4853                            }
4854                            Err(e) => return Err(datadog::Error::Io(e)),
4855                        }
4856                    }
4857                    "deflate" => {
4858                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
4859                        let _ = enc.write_all(ser.into_inner().as_slice());
4860                        match enc.finish() {
4861                            Ok(buf) => {
4862                                local_req_builder = local_req_builder.body(buf);
4863                            }
4864                            Err(e) => return Err(datadog::Error::Io(e)),
4865                        }
4866                    }
4867                    "zstd1" => {
4868                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
4869                        let _ = enc.write_all(ser.into_inner().as_slice());
4870                        match enc.finish() {
4871                            Ok(buf) => {
4872                                local_req_builder = local_req_builder.body(buf);
4873                            }
4874                            Err(e) => return Err(datadog::Error::Io(e)),
4875                        }
4876                    }
4877                    _ => {
4878                        local_req_builder = local_req_builder.body(ser.into_inner());
4879                    }
4880                }
4881            } else {
4882                local_req_builder = local_req_builder.body(ser.into_inner());
4883            }
4884        }
4885
4886        local_req_builder = local_req_builder.headers(headers);
4887        let local_req = local_req_builder.build()?;
4888        log::debug!("request content: {:?}", local_req.body());
4889        let local_resp = local_client.execute(local_req).await?;
4890
4891        let local_status = local_resp.status();
4892        let local_content = local_resp.text().await?;
4893        log::debug!("response content: {}", local_content);
4894
4895        if !local_status.is_client_error() && !local_status.is_server_error() {
4896            match serde_json::from_str::<crate::datadogV2::model::RulesValidateQueryResponse>(
4897                &local_content,
4898            ) {
4899                Ok(e) => {
4900                    return Ok(datadog::ResponseContent {
4901                        status: local_status,
4902                        content: local_content,
4903                        entity: Some(e),
4904                    })
4905                }
4906                Err(e) => return Err(datadog::Error::Serde(e)),
4907            };
4908        } else {
4909            let local_entity: Option<ValidateQueryError> =
4910                serde_json::from_str(&local_content).ok();
4911            let local_error = datadog::ResponseContent {
4912                status: local_status,
4913                content: local_content,
4914                entity: local_entity,
4915            };
4916            Err(datadog::Error::ResponseError(local_error))
4917        }
4918    }
4919}