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