1use crate::datadog;
5use reqwest::header::{HeaderMap, HeaderValue};
6use serde::{Deserialize, Serialize};
7
8#[non_exhaustive]
10#[derive(Clone, Default, Debug)]
11pub struct GetDailyCustomReportsOptionalParams {
12 pub page_size: Option<i64>,
14 pub page_number: Option<i64>,
16 pub sort_dir: Option<crate::datadogV1::model::UsageSortDirection>,
18 pub sort: Option<crate::datadogV1::model::UsageSort>,
20}
21
22impl GetDailyCustomReportsOptionalParams {
23 pub fn page_size(mut self, value: i64) -> Self {
25 self.page_size = Some(value);
26 self
27 }
28 pub fn page_number(mut self, value: i64) -> Self {
30 self.page_number = Some(value);
31 self
32 }
33 pub fn sort_dir(mut self, value: crate::datadogV1::model::UsageSortDirection) -> Self {
35 self.sort_dir = Some(value);
36 self
37 }
38 pub fn sort(mut self, value: crate::datadogV1::model::UsageSort) -> Self {
40 self.sort = Some(value);
41 self
42 }
43}
44
45#[non_exhaustive]
47#[derive(Clone, Default, Debug)]
48pub struct GetHourlyUsageAttributionOptionalParams {
49 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
52 pub next_record_id: Option<String>,
54 pub tag_breakdown_keys: Option<String>,
58 pub include_descendants: Option<bool>,
60}
61
62impl GetHourlyUsageAttributionOptionalParams {
63 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
66 self.end_hr = Some(value);
67 self
68 }
69 pub fn next_record_id(mut self, value: String) -> Self {
71 self.next_record_id = Some(value);
72 self
73 }
74 pub fn tag_breakdown_keys(mut self, value: String) -> Self {
78 self.tag_breakdown_keys = Some(value);
79 self
80 }
81 pub fn include_descendants(mut self, value: bool) -> Self {
83 self.include_descendants = Some(value);
84 self
85 }
86}
87
88#[non_exhaustive]
90#[derive(Clone, Default, Debug)]
91pub struct GetIncidentManagementOptionalParams {
92 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
95}
96
97impl GetIncidentManagementOptionalParams {
98 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
101 self.end_hr = Some(value);
102 self
103 }
104}
105
106#[non_exhaustive]
108#[derive(Clone, Default, Debug)]
109pub struct GetIngestedSpansOptionalParams {
110 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
113}
114
115impl GetIngestedSpansOptionalParams {
116 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
119 self.end_hr = Some(value);
120 self
121 }
122}
123
124#[non_exhaustive]
126#[derive(Clone, Default, Debug)]
127pub struct GetMonthlyCustomReportsOptionalParams {
128 pub page_size: Option<i64>,
130 pub page_number: Option<i64>,
132 pub sort_dir: Option<crate::datadogV1::model::UsageSortDirection>,
134 pub sort: Option<crate::datadogV1::model::UsageSort>,
136}
137
138impl GetMonthlyCustomReportsOptionalParams {
139 pub fn page_size(mut self, value: i64) -> Self {
141 self.page_size = Some(value);
142 self
143 }
144 pub fn page_number(mut self, value: i64) -> Self {
146 self.page_number = Some(value);
147 self
148 }
149 pub fn sort_dir(mut self, value: crate::datadogV1::model::UsageSortDirection) -> Self {
151 self.sort_dir = Some(value);
152 self
153 }
154 pub fn sort(mut self, value: crate::datadogV1::model::UsageSort) -> Self {
156 self.sort = Some(value);
157 self
158 }
159}
160
161#[non_exhaustive]
163#[derive(Clone, Default, Debug)]
164pub struct GetMonthlyUsageAttributionOptionalParams {
165 pub end_month: Option<chrono::DateTime<chrono::Utc>>,
167 pub sort_direction: Option<crate::datadogV1::model::UsageSortDirection>,
169 pub sort_name: Option<crate::datadogV1::model::MonthlyUsageAttributionSupportedMetrics>,
173 pub tag_breakdown_keys: Option<String>,
177 pub next_record_id: Option<String>,
179 pub include_descendants: Option<bool>,
181}
182
183impl GetMonthlyUsageAttributionOptionalParams {
184 pub fn end_month(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
186 self.end_month = Some(value);
187 self
188 }
189 pub fn sort_direction(mut self, value: crate::datadogV1::model::UsageSortDirection) -> Self {
191 self.sort_direction = Some(value);
192 self
193 }
194 pub fn sort_name(
198 mut self,
199 value: crate::datadogV1::model::MonthlyUsageAttributionSupportedMetrics,
200 ) -> Self {
201 self.sort_name = Some(value);
202 self
203 }
204 pub fn tag_breakdown_keys(mut self, value: String) -> Self {
208 self.tag_breakdown_keys = Some(value);
209 self
210 }
211 pub fn next_record_id(mut self, value: String) -> Self {
213 self.next_record_id = Some(value);
214 self
215 }
216 pub fn include_descendants(mut self, value: bool) -> Self {
218 self.include_descendants = Some(value);
219 self
220 }
221}
222
223#[non_exhaustive]
225#[derive(Clone, Default, Debug)]
226pub struct GetUsageAnalyzedLogsOptionalParams {
227 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
230}
231
232impl GetUsageAnalyzedLogsOptionalParams {
233 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
236 self.end_hr = Some(value);
237 self
238 }
239}
240
241#[non_exhaustive]
243#[derive(Clone, Default, Debug)]
244pub struct GetUsageAuditLogsOptionalParams {
245 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
248}
249
250impl GetUsageAuditLogsOptionalParams {
251 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
254 self.end_hr = Some(value);
255 self
256 }
257}
258
259#[non_exhaustive]
261#[derive(Clone, Default, Debug)]
262pub struct GetUsageBillableSummaryOptionalParams {
263 pub month: Option<chrono::DateTime<chrono::Utc>>,
265 pub include_connected_accounts: Option<bool>,
267}
268
269impl GetUsageBillableSummaryOptionalParams {
270 pub fn month(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
272 self.month = Some(value);
273 self
274 }
275 pub fn include_connected_accounts(mut self, value: bool) -> Self {
277 self.include_connected_accounts = Some(value);
278 self
279 }
280}
281
282#[non_exhaustive]
284#[derive(Clone, Default, Debug)]
285pub struct GetUsageCIAppOptionalParams {
286 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
289}
290
291impl GetUsageCIAppOptionalParams {
292 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
295 self.end_hr = Some(value);
296 self
297 }
298}
299
300#[non_exhaustive]
302#[derive(Clone, Default, Debug)]
303pub struct GetUsageCWSOptionalParams {
304 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
307}
308
309impl GetUsageCWSOptionalParams {
310 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
313 self.end_hr = Some(value);
314 self
315 }
316}
317
318#[non_exhaustive]
320#[derive(Clone, Default, Debug)]
321pub struct GetUsageCloudSecurityPostureManagementOptionalParams {
322 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
325}
326
327impl GetUsageCloudSecurityPostureManagementOptionalParams {
328 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
331 self.end_hr = Some(value);
332 self
333 }
334}
335
336#[non_exhaustive]
338#[derive(Clone, Default, Debug)]
339pub struct GetUsageDBMOptionalParams {
340 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
343}
344
345impl GetUsageDBMOptionalParams {
346 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
349 self.end_hr = Some(value);
350 self
351 }
352}
353
354#[non_exhaustive]
356#[derive(Clone, Default, Debug)]
357pub struct GetUsageFargateOptionalParams {
358 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
360}
361
362impl GetUsageFargateOptionalParams {
363 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
365 self.end_hr = Some(value);
366 self
367 }
368}
369
370#[non_exhaustive]
372#[derive(Clone, Default, Debug)]
373pub struct GetUsageHostsOptionalParams {
374 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
376}
377
378impl GetUsageHostsOptionalParams {
379 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
381 self.end_hr = Some(value);
382 self
383 }
384}
385
386#[non_exhaustive]
388#[derive(Clone, Default, Debug)]
389pub struct GetUsageIndexedSpansOptionalParams {
390 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
392}
393
394impl GetUsageIndexedSpansOptionalParams {
395 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
397 self.end_hr = Some(value);
398 self
399 }
400}
401
402#[non_exhaustive]
404#[derive(Clone, Default, Debug)]
405pub struct GetUsageInternetOfThingsOptionalParams {
406 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
409}
410
411impl GetUsageInternetOfThingsOptionalParams {
412 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
415 self.end_hr = Some(value);
416 self
417 }
418}
419
420#[non_exhaustive]
422#[derive(Clone, Default, Debug)]
423pub struct GetUsageLambdaOptionalParams {
424 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
426}
427
428impl GetUsageLambdaOptionalParams {
429 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
431 self.end_hr = Some(value);
432 self
433 }
434}
435
436#[non_exhaustive]
438#[derive(Clone, Default, Debug)]
439pub struct GetUsageLogsOptionalParams {
440 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
442}
443
444impl GetUsageLogsOptionalParams {
445 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
447 self.end_hr = Some(value);
448 self
449 }
450}
451
452#[non_exhaustive]
454#[derive(Clone, Default, Debug)]
455pub struct GetUsageLogsByIndexOptionalParams {
456 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
458 pub index_name: Option<Vec<String>>,
460}
461
462impl GetUsageLogsByIndexOptionalParams {
463 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
465 self.end_hr = Some(value);
466 self
467 }
468 pub fn index_name(mut self, value: Vec<String>) -> Self {
470 self.index_name = Some(value);
471 self
472 }
473}
474
475#[non_exhaustive]
477#[derive(Clone, Default, Debug)]
478pub struct GetUsageLogsByRetentionOptionalParams {
479 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
482}
483
484impl GetUsageLogsByRetentionOptionalParams {
485 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
488 self.end_hr = Some(value);
489 self
490 }
491}
492
493#[non_exhaustive]
495#[derive(Clone, Default, Debug)]
496pub struct GetUsageNetworkFlowsOptionalParams {
497 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
500}
501
502impl GetUsageNetworkFlowsOptionalParams {
503 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
506 self.end_hr = Some(value);
507 self
508 }
509}
510
511#[non_exhaustive]
513#[derive(Clone, Default, Debug)]
514pub struct GetUsageNetworkHostsOptionalParams {
515 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
517}
518
519impl GetUsageNetworkHostsOptionalParams {
520 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
522 self.end_hr = Some(value);
523 self
524 }
525}
526
527#[non_exhaustive]
529#[derive(Clone, Default, Debug)]
530pub struct GetUsageOnlineArchiveOptionalParams {
531 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
534}
535
536impl GetUsageOnlineArchiveOptionalParams {
537 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
540 self.end_hr = Some(value);
541 self
542 }
543}
544
545#[non_exhaustive]
547#[derive(Clone, Default, Debug)]
548pub struct GetUsageProfilingOptionalParams {
549 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
552}
553
554impl GetUsageProfilingOptionalParams {
555 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
558 self.end_hr = Some(value);
559 self
560 }
561}
562
563#[non_exhaustive]
565#[derive(Clone, Default, Debug)]
566pub struct GetUsageRumSessionsOptionalParams {
567 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
569 pub type_: Option<String>,
571}
572
573impl GetUsageRumSessionsOptionalParams {
574 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
576 self.end_hr = Some(value);
577 self
578 }
579 pub fn type_(mut self, value: String) -> Self {
581 self.type_ = Some(value);
582 self
583 }
584}
585
586#[non_exhaustive]
588#[derive(Clone, Default, Debug)]
589pub struct GetUsageRumUnitsOptionalParams {
590 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
592}
593
594impl GetUsageRumUnitsOptionalParams {
595 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
597 self.end_hr = Some(value);
598 self
599 }
600}
601
602#[non_exhaustive]
604#[derive(Clone, Default, Debug)]
605pub struct GetUsageSDSOptionalParams {
606 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
609}
610
611impl GetUsageSDSOptionalParams {
612 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
615 self.end_hr = Some(value);
616 self
617 }
618}
619
620#[non_exhaustive]
622#[derive(Clone, Default, Debug)]
623pub struct GetUsageSNMPOptionalParams {
624 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
627}
628
629impl GetUsageSNMPOptionalParams {
630 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
633 self.end_hr = Some(value);
634 self
635 }
636}
637
638#[non_exhaustive]
640#[derive(Clone, Default, Debug)]
641pub struct GetUsageSummaryOptionalParams {
642 pub end_month: Option<chrono::DateTime<chrono::Utc>>,
644 pub include_org_details: Option<bool>,
646 pub include_connected_accounts: Option<bool>,
648}
649
650impl GetUsageSummaryOptionalParams {
651 pub fn end_month(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
653 self.end_month = Some(value);
654 self
655 }
656 pub fn include_org_details(mut self, value: bool) -> Self {
658 self.include_org_details = Some(value);
659 self
660 }
661 pub fn include_connected_accounts(mut self, value: bool) -> Self {
663 self.include_connected_accounts = Some(value);
664 self
665 }
666}
667
668#[non_exhaustive]
670#[derive(Clone, Default, Debug)]
671pub struct GetUsageSyntheticsOptionalParams {
672 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
674}
675
676impl GetUsageSyntheticsOptionalParams {
677 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
679 self.end_hr = Some(value);
680 self
681 }
682}
683
684#[non_exhaustive]
686#[derive(Clone, Default, Debug)]
687pub struct GetUsageSyntheticsAPIOptionalParams {
688 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
690}
691
692impl GetUsageSyntheticsAPIOptionalParams {
693 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
695 self.end_hr = Some(value);
696 self
697 }
698}
699
700#[non_exhaustive]
702#[derive(Clone, Default, Debug)]
703pub struct GetUsageSyntheticsBrowserOptionalParams {
704 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
706}
707
708impl GetUsageSyntheticsBrowserOptionalParams {
709 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
711 self.end_hr = Some(value);
712 self
713 }
714}
715
716#[non_exhaustive]
718#[derive(Clone, Default, Debug)]
719pub struct GetUsageTimeseriesOptionalParams {
720 pub end_hr: Option<chrono::DateTime<chrono::Utc>>,
722}
723
724impl GetUsageTimeseriesOptionalParams {
725 pub fn end_hr(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
727 self.end_hr = Some(value);
728 self
729 }
730}
731
732#[non_exhaustive]
734#[derive(Clone, Default, Debug)]
735pub struct GetUsageTopAvgMetricsOptionalParams {
736 pub month: Option<chrono::DateTime<chrono::Utc>>,
738 pub day: Option<chrono::DateTime<chrono::Utc>>,
740 pub names: Option<Vec<String>>,
742 pub limit: Option<i32>,
744 pub next_record_id: Option<String>,
746}
747
748impl GetUsageTopAvgMetricsOptionalParams {
749 pub fn month(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
751 self.month = Some(value);
752 self
753 }
754 pub fn day(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
756 self.day = Some(value);
757 self
758 }
759 pub fn names(mut self, value: Vec<String>) -> Self {
761 self.names = Some(value);
762 self
763 }
764 pub fn limit(mut self, value: i32) -> Self {
766 self.limit = Some(value);
767 self
768 }
769 pub fn next_record_id(mut self, value: String) -> Self {
771 self.next_record_id = Some(value);
772 self
773 }
774}
775
776#[derive(Debug, Clone, Serialize, Deserialize)]
778#[serde(untagged)]
779pub enum GetDailyCustomReportsError {
780 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
781 UnknownValue(serde_json::Value),
782}
783
784#[derive(Debug, Clone, Serialize, Deserialize)]
786#[serde(untagged)]
787pub enum GetHourlyUsageAttributionError {
788 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
789 UnknownValue(serde_json::Value),
790}
791
792#[derive(Debug, Clone, Serialize, Deserialize)]
794#[serde(untagged)]
795pub enum GetIncidentManagementError {
796 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
797 UnknownValue(serde_json::Value),
798}
799
800#[derive(Debug, Clone, Serialize, Deserialize)]
802#[serde(untagged)]
803pub enum GetIngestedSpansError {
804 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
805 UnknownValue(serde_json::Value),
806}
807
808#[derive(Debug, Clone, Serialize, Deserialize)]
810#[serde(untagged)]
811pub enum GetMonthlyCustomReportsError {
812 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
813 UnknownValue(serde_json::Value),
814}
815
816#[derive(Debug, Clone, Serialize, Deserialize)]
818#[serde(untagged)]
819pub enum GetMonthlyUsageAttributionError {
820 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
821 UnknownValue(serde_json::Value),
822}
823
824#[derive(Debug, Clone, Serialize, Deserialize)]
826#[serde(untagged)]
827pub enum GetSpecifiedDailyCustomReportsError {
828 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
829 UnknownValue(serde_json::Value),
830}
831
832#[derive(Debug, Clone, Serialize, Deserialize)]
834#[serde(untagged)]
835pub enum GetSpecifiedMonthlyCustomReportsError {
836 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
837 UnknownValue(serde_json::Value),
838}
839
840#[derive(Debug, Clone, Serialize, Deserialize)]
842#[serde(untagged)]
843pub enum GetUsageAnalyzedLogsError {
844 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
845 UnknownValue(serde_json::Value),
846}
847
848#[derive(Debug, Clone, Serialize, Deserialize)]
850#[serde(untagged)]
851pub enum GetUsageAuditLogsError {
852 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
853 UnknownValue(serde_json::Value),
854}
855
856#[derive(Debug, Clone, Serialize, Deserialize)]
858#[serde(untagged)]
859pub enum GetUsageBillableSummaryError {
860 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
861 UnknownValue(serde_json::Value),
862}
863
864#[derive(Debug, Clone, Serialize, Deserialize)]
866#[serde(untagged)]
867pub enum GetUsageCIAppError {
868 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
869 UnknownValue(serde_json::Value),
870}
871
872#[derive(Debug, Clone, Serialize, Deserialize)]
874#[serde(untagged)]
875pub enum GetUsageCWSError {
876 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
877 UnknownValue(serde_json::Value),
878}
879
880#[derive(Debug, Clone, Serialize, Deserialize)]
882#[serde(untagged)]
883pub enum GetUsageCloudSecurityPostureManagementError {
884 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
885 UnknownValue(serde_json::Value),
886}
887
888#[derive(Debug, Clone, Serialize, Deserialize)]
890#[serde(untagged)]
891pub enum GetUsageDBMError {
892 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
893 UnknownValue(serde_json::Value),
894}
895
896#[derive(Debug, Clone, Serialize, Deserialize)]
898#[serde(untagged)]
899pub enum GetUsageFargateError {
900 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
901 UnknownValue(serde_json::Value),
902}
903
904#[derive(Debug, Clone, Serialize, Deserialize)]
906#[serde(untagged)]
907pub enum GetUsageHostsError {
908 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
909 UnknownValue(serde_json::Value),
910}
911
912#[derive(Debug, Clone, Serialize, Deserialize)]
914#[serde(untagged)]
915pub enum GetUsageIndexedSpansError {
916 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
917 UnknownValue(serde_json::Value),
918}
919
920#[derive(Debug, Clone, Serialize, Deserialize)]
922#[serde(untagged)]
923pub enum GetUsageInternetOfThingsError {
924 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
925 UnknownValue(serde_json::Value),
926}
927
928#[derive(Debug, Clone, Serialize, Deserialize)]
930#[serde(untagged)]
931pub enum GetUsageLambdaError {
932 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
933 UnknownValue(serde_json::Value),
934}
935
936#[derive(Debug, Clone, Serialize, Deserialize)]
938#[serde(untagged)]
939pub enum GetUsageLogsError {
940 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
941 UnknownValue(serde_json::Value),
942}
943
944#[derive(Debug, Clone, Serialize, Deserialize)]
946#[serde(untagged)]
947pub enum GetUsageLogsByIndexError {
948 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
949 UnknownValue(serde_json::Value),
950}
951
952#[derive(Debug, Clone, Serialize, Deserialize)]
954#[serde(untagged)]
955pub enum GetUsageLogsByRetentionError {
956 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
957 UnknownValue(serde_json::Value),
958}
959
960#[derive(Debug, Clone, Serialize, Deserialize)]
962#[serde(untagged)]
963pub enum GetUsageNetworkFlowsError {
964 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
965 UnknownValue(serde_json::Value),
966}
967
968#[derive(Debug, Clone, Serialize, Deserialize)]
970#[serde(untagged)]
971pub enum GetUsageNetworkHostsError {
972 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
973 UnknownValue(serde_json::Value),
974}
975
976#[derive(Debug, Clone, Serialize, Deserialize)]
978#[serde(untagged)]
979pub enum GetUsageOnlineArchiveError {
980 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
981 UnknownValue(serde_json::Value),
982}
983
984#[derive(Debug, Clone, Serialize, Deserialize)]
986#[serde(untagged)]
987pub enum GetUsageProfilingError {
988 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
989 UnknownValue(serde_json::Value),
990}
991
992#[derive(Debug, Clone, Serialize, Deserialize)]
994#[serde(untagged)]
995pub enum GetUsageRumSessionsError {
996 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
997 UnknownValue(serde_json::Value),
998}
999
1000#[derive(Debug, Clone, Serialize, Deserialize)]
1002#[serde(untagged)]
1003pub enum GetUsageRumUnitsError {
1004 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
1005 UnknownValue(serde_json::Value),
1006}
1007
1008#[derive(Debug, Clone, Serialize, Deserialize)]
1010#[serde(untagged)]
1011pub enum GetUsageSDSError {
1012 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
1013 UnknownValue(serde_json::Value),
1014}
1015
1016#[derive(Debug, Clone, Serialize, Deserialize)]
1018#[serde(untagged)]
1019pub enum GetUsageSNMPError {
1020 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
1021 UnknownValue(serde_json::Value),
1022}
1023
1024#[derive(Debug, Clone, Serialize, Deserialize)]
1026#[serde(untagged)]
1027pub enum GetUsageSummaryError {
1028 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
1029 UnknownValue(serde_json::Value),
1030}
1031
1032#[derive(Debug, Clone, Serialize, Deserialize)]
1034#[serde(untagged)]
1035pub enum GetUsageSyntheticsError {
1036 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
1037 UnknownValue(serde_json::Value),
1038}
1039
1040#[derive(Debug, Clone, Serialize, Deserialize)]
1042#[serde(untagged)]
1043pub enum GetUsageSyntheticsAPIError {
1044 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
1045 UnknownValue(serde_json::Value),
1046}
1047
1048#[derive(Debug, Clone, Serialize, Deserialize)]
1050#[serde(untagged)]
1051pub enum GetUsageSyntheticsBrowserError {
1052 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
1053 UnknownValue(serde_json::Value),
1054}
1055
1056#[derive(Debug, Clone, Serialize, Deserialize)]
1058#[serde(untagged)]
1059pub enum GetUsageTimeseriesError {
1060 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
1061 UnknownValue(serde_json::Value),
1062}
1063
1064#[derive(Debug, Clone, Serialize, Deserialize)]
1066#[serde(untagged)]
1067pub enum GetUsageTopAvgMetricsError {
1068 APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
1069 UnknownValue(serde_json::Value),
1070}
1071
1072#[derive(Debug, Clone)]
1083pub struct UsageMeteringAPI {
1084 config: datadog::Configuration,
1085 client: reqwest_middleware::ClientWithMiddleware,
1086}
1087
1088impl Default for UsageMeteringAPI {
1089 fn default() -> Self {
1090 Self::with_config(datadog::Configuration::default())
1091 }
1092}
1093
1094impl UsageMeteringAPI {
1095 pub fn new() -> Self {
1096 Self::default()
1097 }
1098 pub fn with_config(config: datadog::Configuration) -> Self {
1099 let mut reqwest_client_builder = reqwest::Client::builder();
1100
1101 if let Some(proxy_url) = &config.proxy_url {
1102 let proxy = reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL");
1103 reqwest_client_builder = reqwest_client_builder.proxy(proxy);
1104 }
1105
1106 let mut middleware_client_builder =
1107 reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap());
1108
1109 if config.enable_retry {
1110 struct RetryableStatus;
1111 impl reqwest_retry::RetryableStrategy for RetryableStatus {
1112 fn handle(
1113 &self,
1114 res: &Result<reqwest::Response, reqwest_middleware::Error>,
1115 ) -> Option<reqwest_retry::Retryable> {
1116 match res {
1117 Ok(success) => reqwest_retry::default_on_request_success(success),
1118 Err(_) => None,
1119 }
1120 }
1121 }
1122 let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder()
1123 .build_with_max_retries(config.max_retries);
1124
1125 let retry_middleware =
1126 reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy(
1127 backoff_policy,
1128 RetryableStatus,
1129 );
1130
1131 middleware_client_builder = middleware_client_builder.with(retry_middleware);
1132 }
1133
1134 let client = middleware_client_builder.build();
1135
1136 Self { config, client }
1137 }
1138
1139 pub fn with_client_and_config(
1140 config: datadog::Configuration,
1141 client: reqwest_middleware::ClientWithMiddleware,
1142 ) -> Self {
1143 Self { config, client }
1144 }
1145
1146 pub async fn get_daily_custom_reports(
1150 &self,
1151 params: GetDailyCustomReportsOptionalParams,
1152 ) -> Result<
1153 crate::datadogV1::model::UsageCustomReportsResponse,
1154 datadog::Error<GetDailyCustomReportsError>,
1155 > {
1156 match self.get_daily_custom_reports_with_http_info(params).await {
1157 Ok(response_content) => {
1158 if let Some(e) = response_content.entity {
1159 Ok(e)
1160 } else {
1161 Err(datadog::Error::Serde(serde::de::Error::custom(
1162 "response content was None",
1163 )))
1164 }
1165 }
1166 Err(err) => Err(err),
1167 }
1168 }
1169
1170 pub async fn get_daily_custom_reports_with_http_info(
1174 &self,
1175 params: GetDailyCustomReportsOptionalParams,
1176 ) -> Result<
1177 datadog::ResponseContent<crate::datadogV1::model::UsageCustomReportsResponse>,
1178 datadog::Error<GetDailyCustomReportsError>,
1179 > {
1180 let local_configuration = &self.config;
1181 let operation_id = "v1.get_daily_custom_reports";
1182
1183 let page_size = params.page_size;
1185 let page_number = params.page_number;
1186 let sort_dir = params.sort_dir;
1187 let sort = params.sort;
1188
1189 let local_client = &self.client;
1190
1191 let local_uri_str = format!(
1192 "{}/api/v1/daily_custom_reports",
1193 local_configuration.get_operation_host(operation_id)
1194 );
1195 let mut local_req_builder =
1196 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1197
1198 if let Some(ref local_query_param) = page_size {
1199 local_req_builder =
1200 local_req_builder.query(&[("page[size]", &local_query_param.to_string())]);
1201 };
1202 if let Some(ref local_query_param) = page_number {
1203 local_req_builder =
1204 local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
1205 };
1206 if let Some(ref local_query_param) = sort_dir {
1207 local_req_builder =
1208 local_req_builder.query(&[("sort_dir", &local_query_param.to_string())]);
1209 };
1210 if let Some(ref local_query_param) = sort {
1211 local_req_builder =
1212 local_req_builder.query(&[("sort", &local_query_param.to_string())]);
1213 };
1214
1215 let mut headers = HeaderMap::new();
1217 headers.insert(
1218 "Accept",
1219 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
1220 );
1221
1222 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1224 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1225 Err(e) => {
1226 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1227 headers.insert(
1228 reqwest::header::USER_AGENT,
1229 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1230 )
1231 }
1232 };
1233
1234 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1236 headers.insert(
1237 "DD-API-KEY",
1238 HeaderValue::from_str(local_key.key.as_str())
1239 .expect("failed to parse DD-API-KEY header"),
1240 );
1241 };
1242 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1243 headers.insert(
1244 "DD-APPLICATION-KEY",
1245 HeaderValue::from_str(local_key.key.as_str())
1246 .expect("failed to parse DD-APPLICATION-KEY header"),
1247 );
1248 };
1249
1250 local_req_builder = local_req_builder.headers(headers);
1251 let local_req = local_req_builder.build()?;
1252 log::debug!("request content: {:?}", local_req.body());
1253 let local_resp = local_client.execute(local_req).await?;
1254
1255 let local_status = local_resp.status();
1256 let local_content = local_resp.text().await?;
1257 log::debug!("response content: {}", local_content);
1258
1259 if !local_status.is_client_error() && !local_status.is_server_error() {
1260 match serde_json::from_str::<crate::datadogV1::model::UsageCustomReportsResponse>(
1261 &local_content,
1262 ) {
1263 Ok(e) => {
1264 return Ok(datadog::ResponseContent {
1265 status: local_status,
1266 content: local_content,
1267 entity: Some(e),
1268 })
1269 }
1270 Err(e) => return Err(datadog::Error::Serde(e)),
1271 };
1272 } else {
1273 let local_entity: Option<GetDailyCustomReportsError> =
1274 serde_json::from_str(&local_content).ok();
1275 let local_error = datadog::ResponseContent {
1276 status: local_status,
1277 content: local_content,
1278 entity: local_entity,
1279 };
1280 Err(datadog::Error::ResponseError(local_error))
1281 }
1282 }
1283
1284 pub async fn get_hourly_usage_attribution(
1300 &self,
1301 start_hr: chrono::DateTime<chrono::Utc>,
1302 usage_type: crate::datadogV1::model::HourlyUsageAttributionUsageType,
1303 params: GetHourlyUsageAttributionOptionalParams,
1304 ) -> Result<
1305 crate::datadogV1::model::HourlyUsageAttributionResponse,
1306 datadog::Error<GetHourlyUsageAttributionError>,
1307 > {
1308 match self
1309 .get_hourly_usage_attribution_with_http_info(start_hr, usage_type, params)
1310 .await
1311 {
1312 Ok(response_content) => {
1313 if let Some(e) = response_content.entity {
1314 Ok(e)
1315 } else {
1316 Err(datadog::Error::Serde(serde::de::Error::custom(
1317 "response content was None",
1318 )))
1319 }
1320 }
1321 Err(err) => Err(err),
1322 }
1323 }
1324
1325 pub async fn get_hourly_usage_attribution_with_http_info(
1341 &self,
1342 start_hr: chrono::DateTime<chrono::Utc>,
1343 usage_type: crate::datadogV1::model::HourlyUsageAttributionUsageType,
1344 params: GetHourlyUsageAttributionOptionalParams,
1345 ) -> Result<
1346 datadog::ResponseContent<crate::datadogV1::model::HourlyUsageAttributionResponse>,
1347 datadog::Error<GetHourlyUsageAttributionError>,
1348 > {
1349 let local_configuration = &self.config;
1350 let operation_id = "v1.get_hourly_usage_attribution";
1351
1352 let end_hr = params.end_hr;
1354 let next_record_id = params.next_record_id;
1355 let tag_breakdown_keys = params.tag_breakdown_keys;
1356 let include_descendants = params.include_descendants;
1357
1358 let local_client = &self.client;
1359
1360 let local_uri_str = format!(
1361 "{}/api/v1/usage/hourly-attribution",
1362 local_configuration.get_operation_host(operation_id)
1363 );
1364 let mut local_req_builder =
1365 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1366
1367 local_req_builder = local_req_builder.query(&[(
1368 "start_hr",
1369 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
1370 )]);
1371 local_req_builder = local_req_builder.query(&[("usage_type", &usage_type.to_string())]);
1372 if let Some(ref local_query_param) = end_hr {
1373 local_req_builder = local_req_builder.query(&[(
1374 "end_hr",
1375 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
1376 )]);
1377 };
1378 if let Some(ref local_query_param) = next_record_id {
1379 local_req_builder =
1380 local_req_builder.query(&[("next_record_id", &local_query_param.to_string())]);
1381 };
1382 if let Some(ref local_query_param) = tag_breakdown_keys {
1383 local_req_builder =
1384 local_req_builder.query(&[("tag_breakdown_keys", &local_query_param.to_string())]);
1385 };
1386 if let Some(ref local_query_param) = include_descendants {
1387 local_req_builder =
1388 local_req_builder.query(&[("include_descendants", &local_query_param.to_string())]);
1389 };
1390
1391 let mut headers = HeaderMap::new();
1393 headers.insert(
1394 "Accept",
1395 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
1396 );
1397
1398 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1400 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1401 Err(e) => {
1402 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1403 headers.insert(
1404 reqwest::header::USER_AGENT,
1405 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1406 )
1407 }
1408 };
1409
1410 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1412 headers.insert(
1413 "DD-API-KEY",
1414 HeaderValue::from_str(local_key.key.as_str())
1415 .expect("failed to parse DD-API-KEY header"),
1416 );
1417 };
1418 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1419 headers.insert(
1420 "DD-APPLICATION-KEY",
1421 HeaderValue::from_str(local_key.key.as_str())
1422 .expect("failed to parse DD-APPLICATION-KEY header"),
1423 );
1424 };
1425
1426 local_req_builder = local_req_builder.headers(headers);
1427 let local_req = local_req_builder.build()?;
1428 log::debug!("request content: {:?}", local_req.body());
1429 let local_resp = local_client.execute(local_req).await?;
1430
1431 let local_status = local_resp.status();
1432 let local_content = local_resp.text().await?;
1433 log::debug!("response content: {}", local_content);
1434
1435 if !local_status.is_client_error() && !local_status.is_server_error() {
1436 match serde_json::from_str::<crate::datadogV1::model::HourlyUsageAttributionResponse>(
1437 &local_content,
1438 ) {
1439 Ok(e) => {
1440 return Ok(datadog::ResponseContent {
1441 status: local_status,
1442 content: local_content,
1443 entity: Some(e),
1444 })
1445 }
1446 Err(e) => return Err(datadog::Error::Serde(e)),
1447 };
1448 } else {
1449 let local_entity: Option<GetHourlyUsageAttributionError> =
1450 serde_json::from_str(&local_content).ok();
1451 let local_error = datadog::ResponseContent {
1452 status: local_status,
1453 content: local_content,
1454 entity: local_entity,
1455 };
1456 Err(datadog::Error::ResponseError(local_error))
1457 }
1458 }
1459
1460 pub async fn get_incident_management(
1463 &self,
1464 start_hr: chrono::DateTime<chrono::Utc>,
1465 params: GetIncidentManagementOptionalParams,
1466 ) -> Result<
1467 crate::datadogV1::model::UsageIncidentManagementResponse,
1468 datadog::Error<GetIncidentManagementError>,
1469 > {
1470 match self
1471 .get_incident_management_with_http_info(start_hr, params)
1472 .await
1473 {
1474 Ok(response_content) => {
1475 if let Some(e) = response_content.entity {
1476 Ok(e)
1477 } else {
1478 Err(datadog::Error::Serde(serde::de::Error::custom(
1479 "response content was None",
1480 )))
1481 }
1482 }
1483 Err(err) => Err(err),
1484 }
1485 }
1486
1487 pub async fn get_incident_management_with_http_info(
1490 &self,
1491 start_hr: chrono::DateTime<chrono::Utc>,
1492 params: GetIncidentManagementOptionalParams,
1493 ) -> Result<
1494 datadog::ResponseContent<crate::datadogV1::model::UsageIncidentManagementResponse>,
1495 datadog::Error<GetIncidentManagementError>,
1496 > {
1497 let local_configuration = &self.config;
1498 let operation_id = "v1.get_incident_management";
1499
1500 let end_hr = params.end_hr;
1502
1503 let local_client = &self.client;
1504
1505 let local_uri_str = format!(
1506 "{}/api/v1/usage/incident-management",
1507 local_configuration.get_operation_host(operation_id)
1508 );
1509 let mut local_req_builder =
1510 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1511
1512 local_req_builder = local_req_builder.query(&[(
1513 "start_hr",
1514 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
1515 )]);
1516 if let Some(ref local_query_param) = end_hr {
1517 local_req_builder = local_req_builder.query(&[(
1518 "end_hr",
1519 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
1520 )]);
1521 };
1522
1523 let mut headers = HeaderMap::new();
1525 headers.insert(
1526 "Accept",
1527 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
1528 );
1529
1530 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1532 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1533 Err(e) => {
1534 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1535 headers.insert(
1536 reqwest::header::USER_AGENT,
1537 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1538 )
1539 }
1540 };
1541
1542 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1544 headers.insert(
1545 "DD-API-KEY",
1546 HeaderValue::from_str(local_key.key.as_str())
1547 .expect("failed to parse DD-API-KEY header"),
1548 );
1549 };
1550 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1551 headers.insert(
1552 "DD-APPLICATION-KEY",
1553 HeaderValue::from_str(local_key.key.as_str())
1554 .expect("failed to parse DD-APPLICATION-KEY header"),
1555 );
1556 };
1557
1558 local_req_builder = local_req_builder.headers(headers);
1559 let local_req = local_req_builder.build()?;
1560 log::debug!("request content: {:?}", local_req.body());
1561 let local_resp = local_client.execute(local_req).await?;
1562
1563 let local_status = local_resp.status();
1564 let local_content = local_resp.text().await?;
1565 log::debug!("response content: {}", local_content);
1566
1567 if !local_status.is_client_error() && !local_status.is_server_error() {
1568 match serde_json::from_str::<crate::datadogV1::model::UsageIncidentManagementResponse>(
1569 &local_content,
1570 ) {
1571 Ok(e) => {
1572 return Ok(datadog::ResponseContent {
1573 status: local_status,
1574 content: local_content,
1575 entity: Some(e),
1576 })
1577 }
1578 Err(e) => return Err(datadog::Error::Serde(e)),
1579 };
1580 } else {
1581 let local_entity: Option<GetIncidentManagementError> =
1582 serde_json::from_str(&local_content).ok();
1583 let local_error = datadog::ResponseContent {
1584 status: local_status,
1585 content: local_content,
1586 entity: local_entity,
1587 };
1588 Err(datadog::Error::ResponseError(local_error))
1589 }
1590 }
1591
1592 pub async fn get_ingested_spans(
1595 &self,
1596 start_hr: chrono::DateTime<chrono::Utc>,
1597 params: GetIngestedSpansOptionalParams,
1598 ) -> Result<
1599 crate::datadogV1::model::UsageIngestedSpansResponse,
1600 datadog::Error<GetIngestedSpansError>,
1601 > {
1602 match self
1603 .get_ingested_spans_with_http_info(start_hr, params)
1604 .await
1605 {
1606 Ok(response_content) => {
1607 if let Some(e) = response_content.entity {
1608 Ok(e)
1609 } else {
1610 Err(datadog::Error::Serde(serde::de::Error::custom(
1611 "response content was None",
1612 )))
1613 }
1614 }
1615 Err(err) => Err(err),
1616 }
1617 }
1618
1619 pub async fn get_ingested_spans_with_http_info(
1622 &self,
1623 start_hr: chrono::DateTime<chrono::Utc>,
1624 params: GetIngestedSpansOptionalParams,
1625 ) -> Result<
1626 datadog::ResponseContent<crate::datadogV1::model::UsageIngestedSpansResponse>,
1627 datadog::Error<GetIngestedSpansError>,
1628 > {
1629 let local_configuration = &self.config;
1630 let operation_id = "v1.get_ingested_spans";
1631
1632 let end_hr = params.end_hr;
1634
1635 let local_client = &self.client;
1636
1637 let local_uri_str = format!(
1638 "{}/api/v1/usage/ingested-spans",
1639 local_configuration.get_operation_host(operation_id)
1640 );
1641 let mut local_req_builder =
1642 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1643
1644 local_req_builder = local_req_builder.query(&[(
1645 "start_hr",
1646 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
1647 )]);
1648 if let Some(ref local_query_param) = end_hr {
1649 local_req_builder = local_req_builder.query(&[(
1650 "end_hr",
1651 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
1652 )]);
1653 };
1654
1655 let mut headers = HeaderMap::new();
1657 headers.insert(
1658 "Accept",
1659 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
1660 );
1661
1662 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1664 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1665 Err(e) => {
1666 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1667 headers.insert(
1668 reqwest::header::USER_AGENT,
1669 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1670 )
1671 }
1672 };
1673
1674 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1676 headers.insert(
1677 "DD-API-KEY",
1678 HeaderValue::from_str(local_key.key.as_str())
1679 .expect("failed to parse DD-API-KEY header"),
1680 );
1681 };
1682 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1683 headers.insert(
1684 "DD-APPLICATION-KEY",
1685 HeaderValue::from_str(local_key.key.as_str())
1686 .expect("failed to parse DD-APPLICATION-KEY header"),
1687 );
1688 };
1689
1690 local_req_builder = local_req_builder.headers(headers);
1691 let local_req = local_req_builder.build()?;
1692 log::debug!("request content: {:?}", local_req.body());
1693 let local_resp = local_client.execute(local_req).await?;
1694
1695 let local_status = local_resp.status();
1696 let local_content = local_resp.text().await?;
1697 log::debug!("response content: {}", local_content);
1698
1699 if !local_status.is_client_error() && !local_status.is_server_error() {
1700 match serde_json::from_str::<crate::datadogV1::model::UsageIngestedSpansResponse>(
1701 &local_content,
1702 ) {
1703 Ok(e) => {
1704 return Ok(datadog::ResponseContent {
1705 status: local_status,
1706 content: local_content,
1707 entity: Some(e),
1708 })
1709 }
1710 Err(e) => return Err(datadog::Error::Serde(e)),
1711 };
1712 } else {
1713 let local_entity: Option<GetIngestedSpansError> =
1714 serde_json::from_str(&local_content).ok();
1715 let local_error = datadog::ResponseContent {
1716 status: local_status,
1717 content: local_content,
1718 entity: local_entity,
1719 };
1720 Err(datadog::Error::ResponseError(local_error))
1721 }
1722 }
1723
1724 pub async fn get_monthly_custom_reports(
1728 &self,
1729 params: GetMonthlyCustomReportsOptionalParams,
1730 ) -> Result<
1731 crate::datadogV1::model::UsageCustomReportsResponse,
1732 datadog::Error<GetMonthlyCustomReportsError>,
1733 > {
1734 match self.get_monthly_custom_reports_with_http_info(params).await {
1735 Ok(response_content) => {
1736 if let Some(e) = response_content.entity {
1737 Ok(e)
1738 } else {
1739 Err(datadog::Error::Serde(serde::de::Error::custom(
1740 "response content was None",
1741 )))
1742 }
1743 }
1744 Err(err) => Err(err),
1745 }
1746 }
1747
1748 pub async fn get_monthly_custom_reports_with_http_info(
1752 &self,
1753 params: GetMonthlyCustomReportsOptionalParams,
1754 ) -> Result<
1755 datadog::ResponseContent<crate::datadogV1::model::UsageCustomReportsResponse>,
1756 datadog::Error<GetMonthlyCustomReportsError>,
1757 > {
1758 let local_configuration = &self.config;
1759 let operation_id = "v1.get_monthly_custom_reports";
1760
1761 let page_size = params.page_size;
1763 let page_number = params.page_number;
1764 let sort_dir = params.sort_dir;
1765 let sort = params.sort;
1766
1767 let local_client = &self.client;
1768
1769 let local_uri_str = format!(
1770 "{}/api/v1/monthly_custom_reports",
1771 local_configuration.get_operation_host(operation_id)
1772 );
1773 let mut local_req_builder =
1774 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1775
1776 if let Some(ref local_query_param) = page_size {
1777 local_req_builder =
1778 local_req_builder.query(&[("page[size]", &local_query_param.to_string())]);
1779 };
1780 if let Some(ref local_query_param) = page_number {
1781 local_req_builder =
1782 local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
1783 };
1784 if let Some(ref local_query_param) = sort_dir {
1785 local_req_builder =
1786 local_req_builder.query(&[("sort_dir", &local_query_param.to_string())]);
1787 };
1788 if let Some(ref local_query_param) = sort {
1789 local_req_builder =
1790 local_req_builder.query(&[("sort", &local_query_param.to_string())]);
1791 };
1792
1793 let mut headers = HeaderMap::new();
1795 headers.insert(
1796 "Accept",
1797 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
1798 );
1799
1800 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1802 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1803 Err(e) => {
1804 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1805 headers.insert(
1806 reqwest::header::USER_AGENT,
1807 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1808 )
1809 }
1810 };
1811
1812 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1814 headers.insert(
1815 "DD-API-KEY",
1816 HeaderValue::from_str(local_key.key.as_str())
1817 .expect("failed to parse DD-API-KEY header"),
1818 );
1819 };
1820 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1821 headers.insert(
1822 "DD-APPLICATION-KEY",
1823 HeaderValue::from_str(local_key.key.as_str())
1824 .expect("failed to parse DD-APPLICATION-KEY header"),
1825 );
1826 };
1827
1828 local_req_builder = local_req_builder.headers(headers);
1829 let local_req = local_req_builder.build()?;
1830 log::debug!("request content: {:?}", local_req.body());
1831 let local_resp = local_client.execute(local_req).await?;
1832
1833 let local_status = local_resp.status();
1834 let local_content = local_resp.text().await?;
1835 log::debug!("response content: {}", local_content);
1836
1837 if !local_status.is_client_error() && !local_status.is_server_error() {
1838 match serde_json::from_str::<crate::datadogV1::model::UsageCustomReportsResponse>(
1839 &local_content,
1840 ) {
1841 Ok(e) => {
1842 return Ok(datadog::ResponseContent {
1843 status: local_status,
1844 content: local_content,
1845 entity: Some(e),
1846 })
1847 }
1848 Err(e) => return Err(datadog::Error::Serde(e)),
1849 };
1850 } else {
1851 let local_entity: Option<GetMonthlyCustomReportsError> =
1852 serde_json::from_str(&local_content).ok();
1853 let local_error = datadog::ResponseContent {
1854 status: local_status,
1855 content: local_content,
1856 entity: local_entity,
1857 };
1858 Err(datadog::Error::ResponseError(local_error))
1859 }
1860 }
1861
1862 pub async fn get_monthly_usage_attribution(
1878 &self,
1879 start_month: chrono::DateTime<chrono::Utc>,
1880 fields: crate::datadogV1::model::MonthlyUsageAttributionSupportedMetrics,
1881 params: GetMonthlyUsageAttributionOptionalParams,
1882 ) -> Result<
1883 crate::datadogV1::model::MonthlyUsageAttributionResponse,
1884 datadog::Error<GetMonthlyUsageAttributionError>,
1885 > {
1886 match self
1887 .get_monthly_usage_attribution_with_http_info(start_month, fields, params)
1888 .await
1889 {
1890 Ok(response_content) => {
1891 if let Some(e) = response_content.entity {
1892 Ok(e)
1893 } else {
1894 Err(datadog::Error::Serde(serde::de::Error::custom(
1895 "response content was None",
1896 )))
1897 }
1898 }
1899 Err(err) => Err(err),
1900 }
1901 }
1902
1903 pub async fn get_monthly_usage_attribution_with_http_info(
1919 &self,
1920 start_month: chrono::DateTime<chrono::Utc>,
1921 fields: crate::datadogV1::model::MonthlyUsageAttributionSupportedMetrics,
1922 params: GetMonthlyUsageAttributionOptionalParams,
1923 ) -> Result<
1924 datadog::ResponseContent<crate::datadogV1::model::MonthlyUsageAttributionResponse>,
1925 datadog::Error<GetMonthlyUsageAttributionError>,
1926 > {
1927 let local_configuration = &self.config;
1928 let operation_id = "v1.get_monthly_usage_attribution";
1929
1930 let end_month = params.end_month;
1932 let sort_direction = params.sort_direction;
1933 let sort_name = params.sort_name;
1934 let tag_breakdown_keys = params.tag_breakdown_keys;
1935 let next_record_id = params.next_record_id;
1936 let include_descendants = params.include_descendants;
1937
1938 let local_client = &self.client;
1939
1940 let local_uri_str = format!(
1941 "{}/api/v1/usage/monthly-attribution",
1942 local_configuration.get_operation_host(operation_id)
1943 );
1944 let mut local_req_builder =
1945 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1946
1947 local_req_builder = local_req_builder.query(&[(
1948 "start_month",
1949 &start_month.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
1950 )]);
1951 local_req_builder = local_req_builder.query(&[("fields", &fields.to_string())]);
1952 if let Some(ref local_query_param) = end_month {
1953 local_req_builder = local_req_builder.query(&[(
1954 "end_month",
1955 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
1956 )]);
1957 };
1958 if let Some(ref local_query_param) = sort_direction {
1959 local_req_builder =
1960 local_req_builder.query(&[("sort_direction", &local_query_param.to_string())]);
1961 };
1962 if let Some(ref local_query_param) = sort_name {
1963 local_req_builder =
1964 local_req_builder.query(&[("sort_name", &local_query_param.to_string())]);
1965 };
1966 if let Some(ref local_query_param) = tag_breakdown_keys {
1967 local_req_builder =
1968 local_req_builder.query(&[("tag_breakdown_keys", &local_query_param.to_string())]);
1969 };
1970 if let Some(ref local_query_param) = next_record_id {
1971 local_req_builder =
1972 local_req_builder.query(&[("next_record_id", &local_query_param.to_string())]);
1973 };
1974 if let Some(ref local_query_param) = include_descendants {
1975 local_req_builder =
1976 local_req_builder.query(&[("include_descendants", &local_query_param.to_string())]);
1977 };
1978
1979 let mut headers = HeaderMap::new();
1981 headers.insert(
1982 "Accept",
1983 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
1984 );
1985
1986 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1988 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1989 Err(e) => {
1990 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1991 headers.insert(
1992 reqwest::header::USER_AGENT,
1993 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1994 )
1995 }
1996 };
1997
1998 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2000 headers.insert(
2001 "DD-API-KEY",
2002 HeaderValue::from_str(local_key.key.as_str())
2003 .expect("failed to parse DD-API-KEY header"),
2004 );
2005 };
2006 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2007 headers.insert(
2008 "DD-APPLICATION-KEY",
2009 HeaderValue::from_str(local_key.key.as_str())
2010 .expect("failed to parse DD-APPLICATION-KEY header"),
2011 );
2012 };
2013
2014 local_req_builder = local_req_builder.headers(headers);
2015 let local_req = local_req_builder.build()?;
2016 log::debug!("request content: {:?}", local_req.body());
2017 let local_resp = local_client.execute(local_req).await?;
2018
2019 let local_status = local_resp.status();
2020 let local_content = local_resp.text().await?;
2021 log::debug!("response content: {}", local_content);
2022
2023 if !local_status.is_client_error() && !local_status.is_server_error() {
2024 match serde_json::from_str::<crate::datadogV1::model::MonthlyUsageAttributionResponse>(
2025 &local_content,
2026 ) {
2027 Ok(e) => {
2028 return Ok(datadog::ResponseContent {
2029 status: local_status,
2030 content: local_content,
2031 entity: Some(e),
2032 })
2033 }
2034 Err(e) => return Err(datadog::Error::Serde(e)),
2035 };
2036 } else {
2037 let local_entity: Option<GetMonthlyUsageAttributionError> =
2038 serde_json::from_str(&local_content).ok();
2039 let local_error = datadog::ResponseContent {
2040 status: local_status,
2041 content: local_content,
2042 entity: local_entity,
2043 };
2044 Err(datadog::Error::ResponseError(local_error))
2045 }
2046 }
2047
2048 pub async fn get_specified_daily_custom_reports(
2052 &self,
2053 report_id: String,
2054 ) -> Result<
2055 crate::datadogV1::model::UsageSpecifiedCustomReportsResponse,
2056 datadog::Error<GetSpecifiedDailyCustomReportsError>,
2057 > {
2058 match self
2059 .get_specified_daily_custom_reports_with_http_info(report_id)
2060 .await
2061 {
2062 Ok(response_content) => {
2063 if let Some(e) = response_content.entity {
2064 Ok(e)
2065 } else {
2066 Err(datadog::Error::Serde(serde::de::Error::custom(
2067 "response content was None",
2068 )))
2069 }
2070 }
2071 Err(err) => Err(err),
2072 }
2073 }
2074
2075 pub async fn get_specified_daily_custom_reports_with_http_info(
2079 &self,
2080 report_id: String,
2081 ) -> Result<
2082 datadog::ResponseContent<crate::datadogV1::model::UsageSpecifiedCustomReportsResponse>,
2083 datadog::Error<GetSpecifiedDailyCustomReportsError>,
2084 > {
2085 let local_configuration = &self.config;
2086 let operation_id = "v1.get_specified_daily_custom_reports";
2087
2088 let local_client = &self.client;
2089
2090 let local_uri_str = format!(
2091 "{}/api/v1/daily_custom_reports/{report_id}",
2092 local_configuration.get_operation_host(operation_id),
2093 report_id = datadog::urlencode(report_id)
2094 );
2095 let mut local_req_builder =
2096 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2097
2098 let mut headers = HeaderMap::new();
2100 headers.insert(
2101 "Accept",
2102 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
2103 );
2104
2105 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2107 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2108 Err(e) => {
2109 log::warn!("Failed to parse user agent header: {e}, falling back to default");
2110 headers.insert(
2111 reqwest::header::USER_AGENT,
2112 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2113 )
2114 }
2115 };
2116
2117 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2119 headers.insert(
2120 "DD-API-KEY",
2121 HeaderValue::from_str(local_key.key.as_str())
2122 .expect("failed to parse DD-API-KEY header"),
2123 );
2124 };
2125 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2126 headers.insert(
2127 "DD-APPLICATION-KEY",
2128 HeaderValue::from_str(local_key.key.as_str())
2129 .expect("failed to parse DD-APPLICATION-KEY header"),
2130 );
2131 };
2132
2133 local_req_builder = local_req_builder.headers(headers);
2134 let local_req = local_req_builder.build()?;
2135 log::debug!("request content: {:?}", local_req.body());
2136 let local_resp = local_client.execute(local_req).await?;
2137
2138 let local_status = local_resp.status();
2139 let local_content = local_resp.text().await?;
2140 log::debug!("response content: {}", local_content);
2141
2142 if !local_status.is_client_error() && !local_status.is_server_error() {
2143 match serde_json::from_str::<crate::datadogV1::model::UsageSpecifiedCustomReportsResponse>(
2144 &local_content,
2145 ) {
2146 Ok(e) => {
2147 return Ok(datadog::ResponseContent {
2148 status: local_status,
2149 content: local_content,
2150 entity: Some(e),
2151 })
2152 }
2153 Err(e) => return Err(datadog::Error::Serde(e)),
2154 };
2155 } else {
2156 let local_entity: Option<GetSpecifiedDailyCustomReportsError> =
2157 serde_json::from_str(&local_content).ok();
2158 let local_error = datadog::ResponseContent {
2159 status: local_status,
2160 content: local_content,
2161 entity: local_entity,
2162 };
2163 Err(datadog::Error::ResponseError(local_error))
2164 }
2165 }
2166
2167 pub async fn get_specified_monthly_custom_reports(
2171 &self,
2172 report_id: String,
2173 ) -> Result<
2174 crate::datadogV1::model::UsageSpecifiedCustomReportsResponse,
2175 datadog::Error<GetSpecifiedMonthlyCustomReportsError>,
2176 > {
2177 match self
2178 .get_specified_monthly_custom_reports_with_http_info(report_id)
2179 .await
2180 {
2181 Ok(response_content) => {
2182 if let Some(e) = response_content.entity {
2183 Ok(e)
2184 } else {
2185 Err(datadog::Error::Serde(serde::de::Error::custom(
2186 "response content was None",
2187 )))
2188 }
2189 }
2190 Err(err) => Err(err),
2191 }
2192 }
2193
2194 pub async fn get_specified_monthly_custom_reports_with_http_info(
2198 &self,
2199 report_id: String,
2200 ) -> Result<
2201 datadog::ResponseContent<crate::datadogV1::model::UsageSpecifiedCustomReportsResponse>,
2202 datadog::Error<GetSpecifiedMonthlyCustomReportsError>,
2203 > {
2204 let local_configuration = &self.config;
2205 let operation_id = "v1.get_specified_monthly_custom_reports";
2206
2207 let local_client = &self.client;
2208
2209 let local_uri_str = format!(
2210 "{}/api/v1/monthly_custom_reports/{report_id}",
2211 local_configuration.get_operation_host(operation_id),
2212 report_id = datadog::urlencode(report_id)
2213 );
2214 let mut local_req_builder =
2215 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2216
2217 let mut headers = HeaderMap::new();
2219 headers.insert(
2220 "Accept",
2221 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
2222 );
2223
2224 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2226 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2227 Err(e) => {
2228 log::warn!("Failed to parse user agent header: {e}, falling back to default");
2229 headers.insert(
2230 reqwest::header::USER_AGENT,
2231 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2232 )
2233 }
2234 };
2235
2236 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2238 headers.insert(
2239 "DD-API-KEY",
2240 HeaderValue::from_str(local_key.key.as_str())
2241 .expect("failed to parse DD-API-KEY header"),
2242 );
2243 };
2244 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2245 headers.insert(
2246 "DD-APPLICATION-KEY",
2247 HeaderValue::from_str(local_key.key.as_str())
2248 .expect("failed to parse DD-APPLICATION-KEY header"),
2249 );
2250 };
2251
2252 local_req_builder = local_req_builder.headers(headers);
2253 let local_req = local_req_builder.build()?;
2254 log::debug!("request content: {:?}", local_req.body());
2255 let local_resp = local_client.execute(local_req).await?;
2256
2257 let local_status = local_resp.status();
2258 let local_content = local_resp.text().await?;
2259 log::debug!("response content: {}", local_content);
2260
2261 if !local_status.is_client_error() && !local_status.is_server_error() {
2262 match serde_json::from_str::<crate::datadogV1::model::UsageSpecifiedCustomReportsResponse>(
2263 &local_content,
2264 ) {
2265 Ok(e) => {
2266 return Ok(datadog::ResponseContent {
2267 status: local_status,
2268 content: local_content,
2269 entity: Some(e),
2270 })
2271 }
2272 Err(e) => return Err(datadog::Error::Serde(e)),
2273 };
2274 } else {
2275 let local_entity: Option<GetSpecifiedMonthlyCustomReportsError> =
2276 serde_json::from_str(&local_content).ok();
2277 let local_error = datadog::ResponseContent {
2278 status: local_status,
2279 content: local_content,
2280 entity: local_entity,
2281 };
2282 Err(datadog::Error::ResponseError(local_error))
2283 }
2284 }
2285
2286 pub async fn get_usage_analyzed_logs(
2289 &self,
2290 start_hr: chrono::DateTime<chrono::Utc>,
2291 params: GetUsageAnalyzedLogsOptionalParams,
2292 ) -> Result<
2293 crate::datadogV1::model::UsageAnalyzedLogsResponse,
2294 datadog::Error<GetUsageAnalyzedLogsError>,
2295 > {
2296 match self
2297 .get_usage_analyzed_logs_with_http_info(start_hr, params)
2298 .await
2299 {
2300 Ok(response_content) => {
2301 if let Some(e) = response_content.entity {
2302 Ok(e)
2303 } else {
2304 Err(datadog::Error::Serde(serde::de::Error::custom(
2305 "response content was None",
2306 )))
2307 }
2308 }
2309 Err(err) => Err(err),
2310 }
2311 }
2312
2313 pub async fn get_usage_analyzed_logs_with_http_info(
2316 &self,
2317 start_hr: chrono::DateTime<chrono::Utc>,
2318 params: GetUsageAnalyzedLogsOptionalParams,
2319 ) -> Result<
2320 datadog::ResponseContent<crate::datadogV1::model::UsageAnalyzedLogsResponse>,
2321 datadog::Error<GetUsageAnalyzedLogsError>,
2322 > {
2323 let local_configuration = &self.config;
2324 let operation_id = "v1.get_usage_analyzed_logs";
2325
2326 let end_hr = params.end_hr;
2328
2329 let local_client = &self.client;
2330
2331 let local_uri_str = format!(
2332 "{}/api/v1/usage/analyzed_logs",
2333 local_configuration.get_operation_host(operation_id)
2334 );
2335 let mut local_req_builder =
2336 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2337
2338 local_req_builder = local_req_builder.query(&[(
2339 "start_hr",
2340 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
2341 )]);
2342 if let Some(ref local_query_param) = end_hr {
2343 local_req_builder = local_req_builder.query(&[(
2344 "end_hr",
2345 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
2346 )]);
2347 };
2348
2349 let mut headers = HeaderMap::new();
2351 headers.insert(
2352 "Accept",
2353 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
2354 );
2355
2356 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2358 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2359 Err(e) => {
2360 log::warn!("Failed to parse user agent header: {e}, falling back to default");
2361 headers.insert(
2362 reqwest::header::USER_AGENT,
2363 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2364 )
2365 }
2366 };
2367
2368 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2370 headers.insert(
2371 "DD-API-KEY",
2372 HeaderValue::from_str(local_key.key.as_str())
2373 .expect("failed to parse DD-API-KEY header"),
2374 );
2375 };
2376 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2377 headers.insert(
2378 "DD-APPLICATION-KEY",
2379 HeaderValue::from_str(local_key.key.as_str())
2380 .expect("failed to parse DD-APPLICATION-KEY header"),
2381 );
2382 };
2383
2384 local_req_builder = local_req_builder.headers(headers);
2385 let local_req = local_req_builder.build()?;
2386 log::debug!("request content: {:?}", local_req.body());
2387 let local_resp = local_client.execute(local_req).await?;
2388
2389 let local_status = local_resp.status();
2390 let local_content = local_resp.text().await?;
2391 log::debug!("response content: {}", local_content);
2392
2393 if !local_status.is_client_error() && !local_status.is_server_error() {
2394 match serde_json::from_str::<crate::datadogV1::model::UsageAnalyzedLogsResponse>(
2395 &local_content,
2396 ) {
2397 Ok(e) => {
2398 return Ok(datadog::ResponseContent {
2399 status: local_status,
2400 content: local_content,
2401 entity: Some(e),
2402 })
2403 }
2404 Err(e) => return Err(datadog::Error::Serde(e)),
2405 };
2406 } else {
2407 let local_entity: Option<GetUsageAnalyzedLogsError> =
2408 serde_json::from_str(&local_content).ok();
2409 let local_error = datadog::ResponseContent {
2410 status: local_status,
2411 content: local_content,
2412 entity: local_entity,
2413 };
2414 Err(datadog::Error::ResponseError(local_error))
2415 }
2416 }
2417
2418 pub async fn get_usage_audit_logs(
2421 &self,
2422 start_hr: chrono::DateTime<chrono::Utc>,
2423 params: GetUsageAuditLogsOptionalParams,
2424 ) -> Result<
2425 crate::datadogV1::model::UsageAuditLogsResponse,
2426 datadog::Error<GetUsageAuditLogsError>,
2427 > {
2428 match self
2429 .get_usage_audit_logs_with_http_info(start_hr, params)
2430 .await
2431 {
2432 Ok(response_content) => {
2433 if let Some(e) = response_content.entity {
2434 Ok(e)
2435 } else {
2436 Err(datadog::Error::Serde(serde::de::Error::custom(
2437 "response content was None",
2438 )))
2439 }
2440 }
2441 Err(err) => Err(err),
2442 }
2443 }
2444
2445 pub async fn get_usage_audit_logs_with_http_info(
2448 &self,
2449 start_hr: chrono::DateTime<chrono::Utc>,
2450 params: GetUsageAuditLogsOptionalParams,
2451 ) -> Result<
2452 datadog::ResponseContent<crate::datadogV1::model::UsageAuditLogsResponse>,
2453 datadog::Error<GetUsageAuditLogsError>,
2454 > {
2455 let local_configuration = &self.config;
2456 let operation_id = "v1.get_usage_audit_logs";
2457
2458 let end_hr = params.end_hr;
2460
2461 let local_client = &self.client;
2462
2463 let local_uri_str = format!(
2464 "{}/api/v1/usage/audit_logs",
2465 local_configuration.get_operation_host(operation_id)
2466 );
2467 let mut local_req_builder =
2468 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2469
2470 local_req_builder = local_req_builder.query(&[(
2471 "start_hr",
2472 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
2473 )]);
2474 if let Some(ref local_query_param) = end_hr {
2475 local_req_builder = local_req_builder.query(&[(
2476 "end_hr",
2477 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
2478 )]);
2479 };
2480
2481 let mut headers = HeaderMap::new();
2483 headers.insert(
2484 "Accept",
2485 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
2486 );
2487
2488 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2490 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2491 Err(e) => {
2492 log::warn!("Failed to parse user agent header: {e}, falling back to default");
2493 headers.insert(
2494 reqwest::header::USER_AGENT,
2495 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2496 )
2497 }
2498 };
2499
2500 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2502 headers.insert(
2503 "DD-API-KEY",
2504 HeaderValue::from_str(local_key.key.as_str())
2505 .expect("failed to parse DD-API-KEY header"),
2506 );
2507 };
2508 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2509 headers.insert(
2510 "DD-APPLICATION-KEY",
2511 HeaderValue::from_str(local_key.key.as_str())
2512 .expect("failed to parse DD-APPLICATION-KEY header"),
2513 );
2514 };
2515
2516 local_req_builder = local_req_builder.headers(headers);
2517 let local_req = local_req_builder.build()?;
2518 log::debug!("request content: {:?}", local_req.body());
2519 let local_resp = local_client.execute(local_req).await?;
2520
2521 let local_status = local_resp.status();
2522 let local_content = local_resp.text().await?;
2523 log::debug!("response content: {}", local_content);
2524
2525 if !local_status.is_client_error() && !local_status.is_server_error() {
2526 match serde_json::from_str::<crate::datadogV1::model::UsageAuditLogsResponse>(
2527 &local_content,
2528 ) {
2529 Ok(e) => {
2530 return Ok(datadog::ResponseContent {
2531 status: local_status,
2532 content: local_content,
2533 entity: Some(e),
2534 })
2535 }
2536 Err(e) => return Err(datadog::Error::Serde(e)),
2537 };
2538 } else {
2539 let local_entity: Option<GetUsageAuditLogsError> =
2540 serde_json::from_str(&local_content).ok();
2541 let local_error = datadog::ResponseContent {
2542 status: local_status,
2543 content: local_content,
2544 entity: local_entity,
2545 };
2546 Err(datadog::Error::ResponseError(local_error))
2547 }
2548 }
2549
2550 pub async fn get_usage_billable_summary(
2554 &self,
2555 params: GetUsageBillableSummaryOptionalParams,
2556 ) -> Result<
2557 crate::datadogV1::model::UsageBillableSummaryResponse,
2558 datadog::Error<GetUsageBillableSummaryError>,
2559 > {
2560 match self.get_usage_billable_summary_with_http_info(params).await {
2561 Ok(response_content) => {
2562 if let Some(e) = response_content.entity {
2563 Ok(e)
2564 } else {
2565 Err(datadog::Error::Serde(serde::de::Error::custom(
2566 "response content was None",
2567 )))
2568 }
2569 }
2570 Err(err) => Err(err),
2571 }
2572 }
2573
2574 pub async fn get_usage_billable_summary_with_http_info(
2578 &self,
2579 params: GetUsageBillableSummaryOptionalParams,
2580 ) -> Result<
2581 datadog::ResponseContent<crate::datadogV1::model::UsageBillableSummaryResponse>,
2582 datadog::Error<GetUsageBillableSummaryError>,
2583 > {
2584 let local_configuration = &self.config;
2585 let operation_id = "v1.get_usage_billable_summary";
2586
2587 let month = params.month;
2589 let include_connected_accounts = params.include_connected_accounts;
2590
2591 let local_client = &self.client;
2592
2593 let local_uri_str = format!(
2594 "{}/api/v1/usage/billable-summary",
2595 local_configuration.get_operation_host(operation_id)
2596 );
2597 let mut local_req_builder =
2598 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2599
2600 if let Some(ref local_query_param) = month {
2601 local_req_builder = local_req_builder.query(&[(
2602 "month",
2603 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
2604 )]);
2605 };
2606 if let Some(ref local_query_param) = include_connected_accounts {
2607 local_req_builder = local_req_builder
2608 .query(&[("include_connected_accounts", &local_query_param.to_string())]);
2609 };
2610
2611 let mut headers = HeaderMap::new();
2613 headers.insert(
2614 "Accept",
2615 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
2616 );
2617
2618 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2620 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2621 Err(e) => {
2622 log::warn!("Failed to parse user agent header: {e}, falling back to default");
2623 headers.insert(
2624 reqwest::header::USER_AGENT,
2625 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2626 )
2627 }
2628 };
2629
2630 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2632 headers.insert(
2633 "DD-API-KEY",
2634 HeaderValue::from_str(local_key.key.as_str())
2635 .expect("failed to parse DD-API-KEY header"),
2636 );
2637 };
2638 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2639 headers.insert(
2640 "DD-APPLICATION-KEY",
2641 HeaderValue::from_str(local_key.key.as_str())
2642 .expect("failed to parse DD-APPLICATION-KEY header"),
2643 );
2644 };
2645
2646 local_req_builder = local_req_builder.headers(headers);
2647 let local_req = local_req_builder.build()?;
2648 log::debug!("request content: {:?}", local_req.body());
2649 let local_resp = local_client.execute(local_req).await?;
2650
2651 let local_status = local_resp.status();
2652 let local_content = local_resp.text().await?;
2653 log::debug!("response content: {}", local_content);
2654
2655 if !local_status.is_client_error() && !local_status.is_server_error() {
2656 match serde_json::from_str::<crate::datadogV1::model::UsageBillableSummaryResponse>(
2657 &local_content,
2658 ) {
2659 Ok(e) => {
2660 return Ok(datadog::ResponseContent {
2661 status: local_status,
2662 content: local_content,
2663 entity: Some(e),
2664 })
2665 }
2666 Err(e) => return Err(datadog::Error::Serde(e)),
2667 };
2668 } else {
2669 let local_entity: Option<GetUsageBillableSummaryError> =
2670 serde_json::from_str(&local_content).ok();
2671 let local_error = datadog::ResponseContent {
2672 status: local_status,
2673 content: local_content,
2674 entity: local_entity,
2675 };
2676 Err(datadog::Error::ResponseError(local_error))
2677 }
2678 }
2679
2680 pub async fn get_usage_ci_app(
2683 &self,
2684 start_hr: chrono::DateTime<chrono::Utc>,
2685 params: GetUsageCIAppOptionalParams,
2686 ) -> Result<
2687 crate::datadogV1::model::UsageCIVisibilityResponse,
2688 datadog::Error<GetUsageCIAppError>,
2689 > {
2690 match self.get_usage_ci_app_with_http_info(start_hr, params).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 get_usage_ci_app_with_http_info(
2707 &self,
2708 start_hr: chrono::DateTime<chrono::Utc>,
2709 params: GetUsageCIAppOptionalParams,
2710 ) -> Result<
2711 datadog::ResponseContent<crate::datadogV1::model::UsageCIVisibilityResponse>,
2712 datadog::Error<GetUsageCIAppError>,
2713 > {
2714 let local_configuration = &self.config;
2715 let operation_id = "v1.get_usage_ci_app";
2716
2717 let end_hr = params.end_hr;
2719
2720 let local_client = &self.client;
2721
2722 let local_uri_str = format!(
2723 "{}/api/v1/usage/ci-app",
2724 local_configuration.get_operation_host(operation_id)
2725 );
2726 let mut local_req_builder =
2727 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2728
2729 local_req_builder = local_req_builder.query(&[(
2730 "start_hr",
2731 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
2732 )]);
2733 if let Some(ref local_query_param) = end_hr {
2734 local_req_builder = local_req_builder.query(&[(
2735 "end_hr",
2736 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
2737 )]);
2738 };
2739
2740 let mut headers = HeaderMap::new();
2742 headers.insert(
2743 "Accept",
2744 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
2745 );
2746
2747 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2749 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2750 Err(e) => {
2751 log::warn!("Failed to parse user agent header: {e}, falling back to default");
2752 headers.insert(
2753 reqwest::header::USER_AGENT,
2754 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2755 )
2756 }
2757 };
2758
2759 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2761 headers.insert(
2762 "DD-API-KEY",
2763 HeaderValue::from_str(local_key.key.as_str())
2764 .expect("failed to parse DD-API-KEY header"),
2765 );
2766 };
2767 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2768 headers.insert(
2769 "DD-APPLICATION-KEY",
2770 HeaderValue::from_str(local_key.key.as_str())
2771 .expect("failed to parse DD-APPLICATION-KEY header"),
2772 );
2773 };
2774
2775 local_req_builder = local_req_builder.headers(headers);
2776 let local_req = local_req_builder.build()?;
2777 log::debug!("request content: {:?}", local_req.body());
2778 let local_resp = local_client.execute(local_req).await?;
2779
2780 let local_status = local_resp.status();
2781 let local_content = local_resp.text().await?;
2782 log::debug!("response content: {}", local_content);
2783
2784 if !local_status.is_client_error() && !local_status.is_server_error() {
2785 match serde_json::from_str::<crate::datadogV1::model::UsageCIVisibilityResponse>(
2786 &local_content,
2787 ) {
2788 Ok(e) => {
2789 return Ok(datadog::ResponseContent {
2790 status: local_status,
2791 content: local_content,
2792 entity: Some(e),
2793 })
2794 }
2795 Err(e) => return Err(datadog::Error::Serde(e)),
2796 };
2797 } else {
2798 let local_entity: Option<GetUsageCIAppError> =
2799 serde_json::from_str(&local_content).ok();
2800 let local_error = datadog::ResponseContent {
2801 status: local_status,
2802 content: local_content,
2803 entity: local_entity,
2804 };
2805 Err(datadog::Error::ResponseError(local_error))
2806 }
2807 }
2808
2809 pub async fn get_usage_cws(
2812 &self,
2813 start_hr: chrono::DateTime<chrono::Utc>,
2814 params: GetUsageCWSOptionalParams,
2815 ) -> Result<crate::datadogV1::model::UsageCWSResponse, datadog::Error<GetUsageCWSError>> {
2816 match self.get_usage_cws_with_http_info(start_hr, params).await {
2817 Ok(response_content) => {
2818 if let Some(e) = response_content.entity {
2819 Ok(e)
2820 } else {
2821 Err(datadog::Error::Serde(serde::de::Error::custom(
2822 "response content was None",
2823 )))
2824 }
2825 }
2826 Err(err) => Err(err),
2827 }
2828 }
2829
2830 pub async fn get_usage_cws_with_http_info(
2833 &self,
2834 start_hr: chrono::DateTime<chrono::Utc>,
2835 params: GetUsageCWSOptionalParams,
2836 ) -> Result<
2837 datadog::ResponseContent<crate::datadogV1::model::UsageCWSResponse>,
2838 datadog::Error<GetUsageCWSError>,
2839 > {
2840 let local_configuration = &self.config;
2841 let operation_id = "v1.get_usage_cws";
2842
2843 let end_hr = params.end_hr;
2845
2846 let local_client = &self.client;
2847
2848 let local_uri_str = format!(
2849 "{}/api/v1/usage/cws",
2850 local_configuration.get_operation_host(operation_id)
2851 );
2852 let mut local_req_builder =
2853 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2854
2855 local_req_builder = local_req_builder.query(&[(
2856 "start_hr",
2857 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
2858 )]);
2859 if let Some(ref local_query_param) = end_hr {
2860 local_req_builder = local_req_builder.query(&[(
2861 "end_hr",
2862 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
2863 )]);
2864 };
2865
2866 let mut headers = HeaderMap::new();
2868 headers.insert(
2869 "Accept",
2870 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
2871 );
2872
2873 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2875 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2876 Err(e) => {
2877 log::warn!("Failed to parse user agent header: {e}, falling back to default");
2878 headers.insert(
2879 reqwest::header::USER_AGENT,
2880 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2881 )
2882 }
2883 };
2884
2885 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2887 headers.insert(
2888 "DD-API-KEY",
2889 HeaderValue::from_str(local_key.key.as_str())
2890 .expect("failed to parse DD-API-KEY header"),
2891 );
2892 };
2893 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2894 headers.insert(
2895 "DD-APPLICATION-KEY",
2896 HeaderValue::from_str(local_key.key.as_str())
2897 .expect("failed to parse DD-APPLICATION-KEY header"),
2898 );
2899 };
2900
2901 local_req_builder = local_req_builder.headers(headers);
2902 let local_req = local_req_builder.build()?;
2903 log::debug!("request content: {:?}", local_req.body());
2904 let local_resp = local_client.execute(local_req).await?;
2905
2906 let local_status = local_resp.status();
2907 let local_content = local_resp.text().await?;
2908 log::debug!("response content: {}", local_content);
2909
2910 if !local_status.is_client_error() && !local_status.is_server_error() {
2911 match serde_json::from_str::<crate::datadogV1::model::UsageCWSResponse>(&local_content)
2912 {
2913 Ok(e) => {
2914 return Ok(datadog::ResponseContent {
2915 status: local_status,
2916 content: local_content,
2917 entity: Some(e),
2918 })
2919 }
2920 Err(e) => return Err(datadog::Error::Serde(e)),
2921 };
2922 } else {
2923 let local_entity: Option<GetUsageCWSError> = serde_json::from_str(&local_content).ok();
2924 let local_error = datadog::ResponseContent {
2925 status: local_status,
2926 content: local_content,
2927 entity: local_entity,
2928 };
2929 Err(datadog::Error::ResponseError(local_error))
2930 }
2931 }
2932
2933 pub async fn get_usage_cloud_security_posture_management(
2936 &self,
2937 start_hr: chrono::DateTime<chrono::Utc>,
2938 params: GetUsageCloudSecurityPostureManagementOptionalParams,
2939 ) -> Result<
2940 crate::datadogV1::model::UsageCloudSecurityPostureManagementResponse,
2941 datadog::Error<GetUsageCloudSecurityPostureManagementError>,
2942 > {
2943 match self
2944 .get_usage_cloud_security_posture_management_with_http_info(start_hr, params)
2945 .await
2946 {
2947 Ok(response_content) => {
2948 if let Some(e) = response_content.entity {
2949 Ok(e)
2950 } else {
2951 Err(datadog::Error::Serde(serde::de::Error::custom(
2952 "response content was None",
2953 )))
2954 }
2955 }
2956 Err(err) => Err(err),
2957 }
2958 }
2959
2960 pub async fn get_usage_cloud_security_posture_management_with_http_info(
2963 &self,
2964 start_hr: chrono::DateTime<chrono::Utc>,
2965 params: GetUsageCloudSecurityPostureManagementOptionalParams,
2966 ) -> Result<
2967 datadog::ResponseContent<
2968 crate::datadogV1::model::UsageCloudSecurityPostureManagementResponse,
2969 >,
2970 datadog::Error<GetUsageCloudSecurityPostureManagementError>,
2971 > {
2972 let local_configuration = &self.config;
2973 let operation_id = "v1.get_usage_cloud_security_posture_management";
2974
2975 let end_hr = params.end_hr;
2977
2978 let local_client = &self.client;
2979
2980 let local_uri_str = format!(
2981 "{}/api/v1/usage/cspm",
2982 local_configuration.get_operation_host(operation_id)
2983 );
2984 let mut local_req_builder =
2985 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
2986
2987 local_req_builder = local_req_builder.query(&[(
2988 "start_hr",
2989 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
2990 )]);
2991 if let Some(ref local_query_param) = end_hr {
2992 local_req_builder = local_req_builder.query(&[(
2993 "end_hr",
2994 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
2995 )]);
2996 };
2997
2998 let mut headers = HeaderMap::new();
3000 headers.insert(
3001 "Accept",
3002 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
3003 );
3004
3005 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3007 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3008 Err(e) => {
3009 log::warn!("Failed to parse user agent header: {e}, falling back to default");
3010 headers.insert(
3011 reqwest::header::USER_AGENT,
3012 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3013 )
3014 }
3015 };
3016
3017 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3019 headers.insert(
3020 "DD-API-KEY",
3021 HeaderValue::from_str(local_key.key.as_str())
3022 .expect("failed to parse DD-API-KEY header"),
3023 );
3024 };
3025 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3026 headers.insert(
3027 "DD-APPLICATION-KEY",
3028 HeaderValue::from_str(local_key.key.as_str())
3029 .expect("failed to parse DD-APPLICATION-KEY header"),
3030 );
3031 };
3032
3033 local_req_builder = local_req_builder.headers(headers);
3034 let local_req = local_req_builder.build()?;
3035 log::debug!("request content: {:?}", local_req.body());
3036 let local_resp = local_client.execute(local_req).await?;
3037
3038 let local_status = local_resp.status();
3039 let local_content = local_resp.text().await?;
3040 log::debug!("response content: {}", local_content);
3041
3042 if !local_status.is_client_error() && !local_status.is_server_error() {
3043 match serde_json::from_str::<
3044 crate::datadogV1::model::UsageCloudSecurityPostureManagementResponse,
3045 >(&local_content)
3046 {
3047 Ok(e) => {
3048 return Ok(datadog::ResponseContent {
3049 status: local_status,
3050 content: local_content,
3051 entity: Some(e),
3052 })
3053 }
3054 Err(e) => return Err(datadog::Error::Serde(e)),
3055 };
3056 } else {
3057 let local_entity: Option<GetUsageCloudSecurityPostureManagementError> =
3058 serde_json::from_str(&local_content).ok();
3059 let local_error = datadog::ResponseContent {
3060 status: local_status,
3061 content: local_content,
3062 entity: local_entity,
3063 };
3064 Err(datadog::Error::ResponseError(local_error))
3065 }
3066 }
3067
3068 pub async fn get_usage_dbm(
3071 &self,
3072 start_hr: chrono::DateTime<chrono::Utc>,
3073 params: GetUsageDBMOptionalParams,
3074 ) -> Result<crate::datadogV1::model::UsageDBMResponse, datadog::Error<GetUsageDBMError>> {
3075 match self.get_usage_dbm_with_http_info(start_hr, params).await {
3076 Ok(response_content) => {
3077 if let Some(e) = response_content.entity {
3078 Ok(e)
3079 } else {
3080 Err(datadog::Error::Serde(serde::de::Error::custom(
3081 "response content was None",
3082 )))
3083 }
3084 }
3085 Err(err) => Err(err),
3086 }
3087 }
3088
3089 pub async fn get_usage_dbm_with_http_info(
3092 &self,
3093 start_hr: chrono::DateTime<chrono::Utc>,
3094 params: GetUsageDBMOptionalParams,
3095 ) -> Result<
3096 datadog::ResponseContent<crate::datadogV1::model::UsageDBMResponse>,
3097 datadog::Error<GetUsageDBMError>,
3098 > {
3099 let local_configuration = &self.config;
3100 let operation_id = "v1.get_usage_dbm";
3101
3102 let end_hr = params.end_hr;
3104
3105 let local_client = &self.client;
3106
3107 let local_uri_str = format!(
3108 "{}/api/v1/usage/dbm",
3109 local_configuration.get_operation_host(operation_id)
3110 );
3111 let mut local_req_builder =
3112 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3113
3114 local_req_builder = local_req_builder.query(&[(
3115 "start_hr",
3116 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
3117 )]);
3118 if let Some(ref local_query_param) = end_hr {
3119 local_req_builder = local_req_builder.query(&[(
3120 "end_hr",
3121 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
3122 )]);
3123 };
3124
3125 let mut headers = HeaderMap::new();
3127 headers.insert(
3128 "Accept",
3129 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
3130 );
3131
3132 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3134 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3135 Err(e) => {
3136 log::warn!("Failed to parse user agent header: {e}, falling back to default");
3137 headers.insert(
3138 reqwest::header::USER_AGENT,
3139 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3140 )
3141 }
3142 };
3143
3144 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3146 headers.insert(
3147 "DD-API-KEY",
3148 HeaderValue::from_str(local_key.key.as_str())
3149 .expect("failed to parse DD-API-KEY header"),
3150 );
3151 };
3152 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3153 headers.insert(
3154 "DD-APPLICATION-KEY",
3155 HeaderValue::from_str(local_key.key.as_str())
3156 .expect("failed to parse DD-APPLICATION-KEY header"),
3157 );
3158 };
3159
3160 local_req_builder = local_req_builder.headers(headers);
3161 let local_req = local_req_builder.build()?;
3162 log::debug!("request content: {:?}", local_req.body());
3163 let local_resp = local_client.execute(local_req).await?;
3164
3165 let local_status = local_resp.status();
3166 let local_content = local_resp.text().await?;
3167 log::debug!("response content: {}", local_content);
3168
3169 if !local_status.is_client_error() && !local_status.is_server_error() {
3170 match serde_json::from_str::<crate::datadogV1::model::UsageDBMResponse>(&local_content)
3171 {
3172 Ok(e) => {
3173 return Ok(datadog::ResponseContent {
3174 status: local_status,
3175 content: local_content,
3176 entity: Some(e),
3177 })
3178 }
3179 Err(e) => return Err(datadog::Error::Serde(e)),
3180 };
3181 } else {
3182 let local_entity: Option<GetUsageDBMError> = serde_json::from_str(&local_content).ok();
3183 let local_error = datadog::ResponseContent {
3184 status: local_status,
3185 content: local_content,
3186 entity: local_entity,
3187 };
3188 Err(datadog::Error::ResponseError(local_error))
3189 }
3190 }
3191
3192 pub async fn get_usage_fargate(
3195 &self,
3196 start_hr: chrono::DateTime<chrono::Utc>,
3197 params: GetUsageFargateOptionalParams,
3198 ) -> Result<crate::datadogV1::model::UsageFargateResponse, datadog::Error<GetUsageFargateError>>
3199 {
3200 match self
3201 .get_usage_fargate_with_http_info(start_hr, params)
3202 .await
3203 {
3204 Ok(response_content) => {
3205 if let Some(e) = response_content.entity {
3206 Ok(e)
3207 } else {
3208 Err(datadog::Error::Serde(serde::de::Error::custom(
3209 "response content was None",
3210 )))
3211 }
3212 }
3213 Err(err) => Err(err),
3214 }
3215 }
3216
3217 pub async fn get_usage_fargate_with_http_info(
3220 &self,
3221 start_hr: chrono::DateTime<chrono::Utc>,
3222 params: GetUsageFargateOptionalParams,
3223 ) -> Result<
3224 datadog::ResponseContent<crate::datadogV1::model::UsageFargateResponse>,
3225 datadog::Error<GetUsageFargateError>,
3226 > {
3227 let local_configuration = &self.config;
3228 let operation_id = "v1.get_usage_fargate";
3229
3230 let end_hr = params.end_hr;
3232
3233 let local_client = &self.client;
3234
3235 let local_uri_str = format!(
3236 "{}/api/v1/usage/fargate",
3237 local_configuration.get_operation_host(operation_id)
3238 );
3239 let mut local_req_builder =
3240 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3241
3242 local_req_builder = local_req_builder.query(&[(
3243 "start_hr",
3244 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
3245 )]);
3246 if let Some(ref local_query_param) = end_hr {
3247 local_req_builder = local_req_builder.query(&[(
3248 "end_hr",
3249 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
3250 )]);
3251 };
3252
3253 let mut headers = HeaderMap::new();
3255 headers.insert(
3256 "Accept",
3257 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
3258 );
3259
3260 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3262 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3263 Err(e) => {
3264 log::warn!("Failed to parse user agent header: {e}, falling back to default");
3265 headers.insert(
3266 reqwest::header::USER_AGENT,
3267 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3268 )
3269 }
3270 };
3271
3272 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3274 headers.insert(
3275 "DD-API-KEY",
3276 HeaderValue::from_str(local_key.key.as_str())
3277 .expect("failed to parse DD-API-KEY header"),
3278 );
3279 };
3280 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3281 headers.insert(
3282 "DD-APPLICATION-KEY",
3283 HeaderValue::from_str(local_key.key.as_str())
3284 .expect("failed to parse DD-APPLICATION-KEY header"),
3285 );
3286 };
3287
3288 local_req_builder = local_req_builder.headers(headers);
3289 let local_req = local_req_builder.build()?;
3290 log::debug!("request content: {:?}", local_req.body());
3291 let local_resp = local_client.execute(local_req).await?;
3292
3293 let local_status = local_resp.status();
3294 let local_content = local_resp.text().await?;
3295 log::debug!("response content: {}", local_content);
3296
3297 if !local_status.is_client_error() && !local_status.is_server_error() {
3298 match serde_json::from_str::<crate::datadogV1::model::UsageFargateResponse>(
3299 &local_content,
3300 ) {
3301 Ok(e) => {
3302 return Ok(datadog::ResponseContent {
3303 status: local_status,
3304 content: local_content,
3305 entity: Some(e),
3306 })
3307 }
3308 Err(e) => return Err(datadog::Error::Serde(e)),
3309 };
3310 } else {
3311 let local_entity: Option<GetUsageFargateError> =
3312 serde_json::from_str(&local_content).ok();
3313 let local_error = datadog::ResponseContent {
3314 status: local_status,
3315 content: local_content,
3316 entity: local_entity,
3317 };
3318 Err(datadog::Error::ResponseError(local_error))
3319 }
3320 }
3321
3322 pub async fn get_usage_hosts(
3325 &self,
3326 start_hr: chrono::DateTime<chrono::Utc>,
3327 params: GetUsageHostsOptionalParams,
3328 ) -> Result<crate::datadogV1::model::UsageHostsResponse, datadog::Error<GetUsageHostsError>>
3329 {
3330 match self.get_usage_hosts_with_http_info(start_hr, params).await {
3331 Ok(response_content) => {
3332 if let Some(e) = response_content.entity {
3333 Ok(e)
3334 } else {
3335 Err(datadog::Error::Serde(serde::de::Error::custom(
3336 "response content was None",
3337 )))
3338 }
3339 }
3340 Err(err) => Err(err),
3341 }
3342 }
3343
3344 pub async fn get_usage_hosts_with_http_info(
3347 &self,
3348 start_hr: chrono::DateTime<chrono::Utc>,
3349 params: GetUsageHostsOptionalParams,
3350 ) -> Result<
3351 datadog::ResponseContent<crate::datadogV1::model::UsageHostsResponse>,
3352 datadog::Error<GetUsageHostsError>,
3353 > {
3354 let local_configuration = &self.config;
3355 let operation_id = "v1.get_usage_hosts";
3356
3357 let end_hr = params.end_hr;
3359
3360 let local_client = &self.client;
3361
3362 let local_uri_str = format!(
3363 "{}/api/v1/usage/hosts",
3364 local_configuration.get_operation_host(operation_id)
3365 );
3366 let mut local_req_builder =
3367 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3368
3369 local_req_builder = local_req_builder.query(&[(
3370 "start_hr",
3371 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
3372 )]);
3373 if let Some(ref local_query_param) = end_hr {
3374 local_req_builder = local_req_builder.query(&[(
3375 "end_hr",
3376 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
3377 )]);
3378 };
3379
3380 let mut headers = HeaderMap::new();
3382 headers.insert(
3383 "Accept",
3384 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
3385 );
3386
3387 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3389 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3390 Err(e) => {
3391 log::warn!("Failed to parse user agent header: {e}, falling back to default");
3392 headers.insert(
3393 reqwest::header::USER_AGENT,
3394 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3395 )
3396 }
3397 };
3398
3399 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3401 headers.insert(
3402 "DD-API-KEY",
3403 HeaderValue::from_str(local_key.key.as_str())
3404 .expect("failed to parse DD-API-KEY header"),
3405 );
3406 };
3407 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3408 headers.insert(
3409 "DD-APPLICATION-KEY",
3410 HeaderValue::from_str(local_key.key.as_str())
3411 .expect("failed to parse DD-APPLICATION-KEY header"),
3412 );
3413 };
3414
3415 local_req_builder = local_req_builder.headers(headers);
3416 let local_req = local_req_builder.build()?;
3417 log::debug!("request content: {:?}", local_req.body());
3418 let local_resp = local_client.execute(local_req).await?;
3419
3420 let local_status = local_resp.status();
3421 let local_content = local_resp.text().await?;
3422 log::debug!("response content: {}", local_content);
3423
3424 if !local_status.is_client_error() && !local_status.is_server_error() {
3425 match serde_json::from_str::<crate::datadogV1::model::UsageHostsResponse>(
3426 &local_content,
3427 ) {
3428 Ok(e) => {
3429 return Ok(datadog::ResponseContent {
3430 status: local_status,
3431 content: local_content,
3432 entity: Some(e),
3433 })
3434 }
3435 Err(e) => return Err(datadog::Error::Serde(e)),
3436 };
3437 } else {
3438 let local_entity: Option<GetUsageHostsError> =
3439 serde_json::from_str(&local_content).ok();
3440 let local_error = datadog::ResponseContent {
3441 status: local_status,
3442 content: local_content,
3443 entity: local_entity,
3444 };
3445 Err(datadog::Error::ResponseError(local_error))
3446 }
3447 }
3448
3449 pub async fn get_usage_indexed_spans(
3452 &self,
3453 start_hr: chrono::DateTime<chrono::Utc>,
3454 params: GetUsageIndexedSpansOptionalParams,
3455 ) -> Result<
3456 crate::datadogV1::model::UsageIndexedSpansResponse,
3457 datadog::Error<GetUsageIndexedSpansError>,
3458 > {
3459 match self
3460 .get_usage_indexed_spans_with_http_info(start_hr, params)
3461 .await
3462 {
3463 Ok(response_content) => {
3464 if let Some(e) = response_content.entity {
3465 Ok(e)
3466 } else {
3467 Err(datadog::Error::Serde(serde::de::Error::custom(
3468 "response content was None",
3469 )))
3470 }
3471 }
3472 Err(err) => Err(err),
3473 }
3474 }
3475
3476 pub async fn get_usage_indexed_spans_with_http_info(
3479 &self,
3480 start_hr: chrono::DateTime<chrono::Utc>,
3481 params: GetUsageIndexedSpansOptionalParams,
3482 ) -> Result<
3483 datadog::ResponseContent<crate::datadogV1::model::UsageIndexedSpansResponse>,
3484 datadog::Error<GetUsageIndexedSpansError>,
3485 > {
3486 let local_configuration = &self.config;
3487 let operation_id = "v1.get_usage_indexed_spans";
3488
3489 let end_hr = params.end_hr;
3491
3492 let local_client = &self.client;
3493
3494 let local_uri_str = format!(
3495 "{}/api/v1/usage/indexed-spans",
3496 local_configuration.get_operation_host(operation_id)
3497 );
3498 let mut local_req_builder =
3499 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3500
3501 local_req_builder = local_req_builder.query(&[(
3502 "start_hr",
3503 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
3504 )]);
3505 if let Some(ref local_query_param) = end_hr {
3506 local_req_builder = local_req_builder.query(&[(
3507 "end_hr",
3508 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
3509 )]);
3510 };
3511
3512 let mut headers = HeaderMap::new();
3514 headers.insert(
3515 "Accept",
3516 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
3517 );
3518
3519 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3521 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3522 Err(e) => {
3523 log::warn!("Failed to parse user agent header: {e}, falling back to default");
3524 headers.insert(
3525 reqwest::header::USER_AGENT,
3526 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3527 )
3528 }
3529 };
3530
3531 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3533 headers.insert(
3534 "DD-API-KEY",
3535 HeaderValue::from_str(local_key.key.as_str())
3536 .expect("failed to parse DD-API-KEY header"),
3537 );
3538 };
3539 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3540 headers.insert(
3541 "DD-APPLICATION-KEY",
3542 HeaderValue::from_str(local_key.key.as_str())
3543 .expect("failed to parse DD-APPLICATION-KEY header"),
3544 );
3545 };
3546
3547 local_req_builder = local_req_builder.headers(headers);
3548 let local_req = local_req_builder.build()?;
3549 log::debug!("request content: {:?}", local_req.body());
3550 let local_resp = local_client.execute(local_req).await?;
3551
3552 let local_status = local_resp.status();
3553 let local_content = local_resp.text().await?;
3554 log::debug!("response content: {}", local_content);
3555
3556 if !local_status.is_client_error() && !local_status.is_server_error() {
3557 match serde_json::from_str::<crate::datadogV1::model::UsageIndexedSpansResponse>(
3558 &local_content,
3559 ) {
3560 Ok(e) => {
3561 return Ok(datadog::ResponseContent {
3562 status: local_status,
3563 content: local_content,
3564 entity: Some(e),
3565 })
3566 }
3567 Err(e) => return Err(datadog::Error::Serde(e)),
3568 };
3569 } else {
3570 let local_entity: Option<GetUsageIndexedSpansError> =
3571 serde_json::from_str(&local_content).ok();
3572 let local_error = datadog::ResponseContent {
3573 status: local_status,
3574 content: local_content,
3575 entity: local_entity,
3576 };
3577 Err(datadog::Error::ResponseError(local_error))
3578 }
3579 }
3580
3581 pub async fn get_usage_internet_of_things(
3584 &self,
3585 start_hr: chrono::DateTime<chrono::Utc>,
3586 params: GetUsageInternetOfThingsOptionalParams,
3587 ) -> Result<
3588 crate::datadogV1::model::UsageIoTResponse,
3589 datadog::Error<GetUsageInternetOfThingsError>,
3590 > {
3591 match self
3592 .get_usage_internet_of_things_with_http_info(start_hr, params)
3593 .await
3594 {
3595 Ok(response_content) => {
3596 if let Some(e) = response_content.entity {
3597 Ok(e)
3598 } else {
3599 Err(datadog::Error::Serde(serde::de::Error::custom(
3600 "response content was None",
3601 )))
3602 }
3603 }
3604 Err(err) => Err(err),
3605 }
3606 }
3607
3608 pub async fn get_usage_internet_of_things_with_http_info(
3611 &self,
3612 start_hr: chrono::DateTime<chrono::Utc>,
3613 params: GetUsageInternetOfThingsOptionalParams,
3614 ) -> Result<
3615 datadog::ResponseContent<crate::datadogV1::model::UsageIoTResponse>,
3616 datadog::Error<GetUsageInternetOfThingsError>,
3617 > {
3618 let local_configuration = &self.config;
3619 let operation_id = "v1.get_usage_internet_of_things";
3620
3621 let end_hr = params.end_hr;
3623
3624 let local_client = &self.client;
3625
3626 let local_uri_str = format!(
3627 "{}/api/v1/usage/iot",
3628 local_configuration.get_operation_host(operation_id)
3629 );
3630 let mut local_req_builder =
3631 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3632
3633 local_req_builder = local_req_builder.query(&[(
3634 "start_hr",
3635 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
3636 )]);
3637 if let Some(ref local_query_param) = end_hr {
3638 local_req_builder = local_req_builder.query(&[(
3639 "end_hr",
3640 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
3641 )]);
3642 };
3643
3644 let mut headers = HeaderMap::new();
3646 headers.insert(
3647 "Accept",
3648 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
3649 );
3650
3651 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3653 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3654 Err(e) => {
3655 log::warn!("Failed to parse user agent header: {e}, falling back to default");
3656 headers.insert(
3657 reqwest::header::USER_AGENT,
3658 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3659 )
3660 }
3661 };
3662
3663 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3665 headers.insert(
3666 "DD-API-KEY",
3667 HeaderValue::from_str(local_key.key.as_str())
3668 .expect("failed to parse DD-API-KEY header"),
3669 );
3670 };
3671 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3672 headers.insert(
3673 "DD-APPLICATION-KEY",
3674 HeaderValue::from_str(local_key.key.as_str())
3675 .expect("failed to parse DD-APPLICATION-KEY header"),
3676 );
3677 };
3678
3679 local_req_builder = local_req_builder.headers(headers);
3680 let local_req = local_req_builder.build()?;
3681 log::debug!("request content: {:?}", local_req.body());
3682 let local_resp = local_client.execute(local_req).await?;
3683
3684 let local_status = local_resp.status();
3685 let local_content = local_resp.text().await?;
3686 log::debug!("response content: {}", local_content);
3687
3688 if !local_status.is_client_error() && !local_status.is_server_error() {
3689 match serde_json::from_str::<crate::datadogV1::model::UsageIoTResponse>(&local_content)
3690 {
3691 Ok(e) => {
3692 return Ok(datadog::ResponseContent {
3693 status: local_status,
3694 content: local_content,
3695 entity: Some(e),
3696 })
3697 }
3698 Err(e) => return Err(datadog::Error::Serde(e)),
3699 };
3700 } else {
3701 let local_entity: Option<GetUsageInternetOfThingsError> =
3702 serde_json::from_str(&local_content).ok();
3703 let local_error = datadog::ResponseContent {
3704 status: local_status,
3705 content: local_content,
3706 entity: local_entity,
3707 };
3708 Err(datadog::Error::ResponseError(local_error))
3709 }
3710 }
3711
3712 pub async fn get_usage_lambda(
3715 &self,
3716 start_hr: chrono::DateTime<chrono::Utc>,
3717 params: GetUsageLambdaOptionalParams,
3718 ) -> Result<crate::datadogV1::model::UsageLambdaResponse, datadog::Error<GetUsageLambdaError>>
3719 {
3720 match self.get_usage_lambda_with_http_info(start_hr, params).await {
3721 Ok(response_content) => {
3722 if let Some(e) = response_content.entity {
3723 Ok(e)
3724 } else {
3725 Err(datadog::Error::Serde(serde::de::Error::custom(
3726 "response content was None",
3727 )))
3728 }
3729 }
3730 Err(err) => Err(err),
3731 }
3732 }
3733
3734 pub async fn get_usage_lambda_with_http_info(
3737 &self,
3738 start_hr: chrono::DateTime<chrono::Utc>,
3739 params: GetUsageLambdaOptionalParams,
3740 ) -> Result<
3741 datadog::ResponseContent<crate::datadogV1::model::UsageLambdaResponse>,
3742 datadog::Error<GetUsageLambdaError>,
3743 > {
3744 let local_configuration = &self.config;
3745 let operation_id = "v1.get_usage_lambda";
3746
3747 let end_hr = params.end_hr;
3749
3750 let local_client = &self.client;
3751
3752 let local_uri_str = format!(
3753 "{}/api/v1/usage/aws_lambda",
3754 local_configuration.get_operation_host(operation_id)
3755 );
3756 let mut local_req_builder =
3757 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3758
3759 local_req_builder = local_req_builder.query(&[(
3760 "start_hr",
3761 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
3762 )]);
3763 if let Some(ref local_query_param) = end_hr {
3764 local_req_builder = local_req_builder.query(&[(
3765 "end_hr",
3766 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
3767 )]);
3768 };
3769
3770 let mut headers = HeaderMap::new();
3772 headers.insert(
3773 "Accept",
3774 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
3775 );
3776
3777 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3779 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3780 Err(e) => {
3781 log::warn!("Failed to parse user agent header: {e}, falling back to default");
3782 headers.insert(
3783 reqwest::header::USER_AGENT,
3784 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3785 )
3786 }
3787 };
3788
3789 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3791 headers.insert(
3792 "DD-API-KEY",
3793 HeaderValue::from_str(local_key.key.as_str())
3794 .expect("failed to parse DD-API-KEY header"),
3795 );
3796 };
3797 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3798 headers.insert(
3799 "DD-APPLICATION-KEY",
3800 HeaderValue::from_str(local_key.key.as_str())
3801 .expect("failed to parse DD-APPLICATION-KEY header"),
3802 );
3803 };
3804
3805 local_req_builder = local_req_builder.headers(headers);
3806 let local_req = local_req_builder.build()?;
3807 log::debug!("request content: {:?}", local_req.body());
3808 let local_resp = local_client.execute(local_req).await?;
3809
3810 let local_status = local_resp.status();
3811 let local_content = local_resp.text().await?;
3812 log::debug!("response content: {}", local_content);
3813
3814 if !local_status.is_client_error() && !local_status.is_server_error() {
3815 match serde_json::from_str::<crate::datadogV1::model::UsageLambdaResponse>(
3816 &local_content,
3817 ) {
3818 Ok(e) => {
3819 return Ok(datadog::ResponseContent {
3820 status: local_status,
3821 content: local_content,
3822 entity: Some(e),
3823 })
3824 }
3825 Err(e) => return Err(datadog::Error::Serde(e)),
3826 };
3827 } else {
3828 let local_entity: Option<GetUsageLambdaError> =
3829 serde_json::from_str(&local_content).ok();
3830 let local_error = datadog::ResponseContent {
3831 status: local_status,
3832 content: local_content,
3833 entity: local_entity,
3834 };
3835 Err(datadog::Error::ResponseError(local_error))
3836 }
3837 }
3838
3839 pub async fn get_usage_logs(
3842 &self,
3843 start_hr: chrono::DateTime<chrono::Utc>,
3844 params: GetUsageLogsOptionalParams,
3845 ) -> Result<crate::datadogV1::model::UsageLogsResponse, datadog::Error<GetUsageLogsError>> {
3846 match self.get_usage_logs_with_http_info(start_hr, params).await {
3847 Ok(response_content) => {
3848 if let Some(e) = response_content.entity {
3849 Ok(e)
3850 } else {
3851 Err(datadog::Error::Serde(serde::de::Error::custom(
3852 "response content was None",
3853 )))
3854 }
3855 }
3856 Err(err) => Err(err),
3857 }
3858 }
3859
3860 pub async fn get_usage_logs_with_http_info(
3863 &self,
3864 start_hr: chrono::DateTime<chrono::Utc>,
3865 params: GetUsageLogsOptionalParams,
3866 ) -> Result<
3867 datadog::ResponseContent<crate::datadogV1::model::UsageLogsResponse>,
3868 datadog::Error<GetUsageLogsError>,
3869 > {
3870 let local_configuration = &self.config;
3871 let operation_id = "v1.get_usage_logs";
3872
3873 let end_hr = params.end_hr;
3875
3876 let local_client = &self.client;
3877
3878 let local_uri_str = format!(
3879 "{}/api/v1/usage/logs",
3880 local_configuration.get_operation_host(operation_id)
3881 );
3882 let mut local_req_builder =
3883 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3884
3885 local_req_builder = local_req_builder.query(&[(
3886 "start_hr",
3887 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
3888 )]);
3889 if let Some(ref local_query_param) = end_hr {
3890 local_req_builder = local_req_builder.query(&[(
3891 "end_hr",
3892 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
3893 )]);
3894 };
3895
3896 let mut headers = HeaderMap::new();
3898 headers.insert(
3899 "Accept",
3900 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
3901 );
3902
3903 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3905 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3906 Err(e) => {
3907 log::warn!("Failed to parse user agent header: {e}, falling back to default");
3908 headers.insert(
3909 reqwest::header::USER_AGENT,
3910 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3911 )
3912 }
3913 };
3914
3915 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3917 headers.insert(
3918 "DD-API-KEY",
3919 HeaderValue::from_str(local_key.key.as_str())
3920 .expect("failed to parse DD-API-KEY header"),
3921 );
3922 };
3923 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3924 headers.insert(
3925 "DD-APPLICATION-KEY",
3926 HeaderValue::from_str(local_key.key.as_str())
3927 .expect("failed to parse DD-APPLICATION-KEY header"),
3928 );
3929 };
3930
3931 local_req_builder = local_req_builder.headers(headers);
3932 let local_req = local_req_builder.build()?;
3933 log::debug!("request content: {:?}", local_req.body());
3934 let local_resp = local_client.execute(local_req).await?;
3935
3936 let local_status = local_resp.status();
3937 let local_content = local_resp.text().await?;
3938 log::debug!("response content: {}", local_content);
3939
3940 if !local_status.is_client_error() && !local_status.is_server_error() {
3941 match serde_json::from_str::<crate::datadogV1::model::UsageLogsResponse>(&local_content)
3942 {
3943 Ok(e) => {
3944 return Ok(datadog::ResponseContent {
3945 status: local_status,
3946 content: local_content,
3947 entity: Some(e),
3948 })
3949 }
3950 Err(e) => return Err(datadog::Error::Serde(e)),
3951 };
3952 } else {
3953 let local_entity: Option<GetUsageLogsError> = serde_json::from_str(&local_content).ok();
3954 let local_error = datadog::ResponseContent {
3955 status: local_status,
3956 content: local_content,
3957 entity: local_entity,
3958 };
3959 Err(datadog::Error::ResponseError(local_error))
3960 }
3961 }
3962
3963 pub async fn get_usage_logs_by_index(
3965 &self,
3966 start_hr: chrono::DateTime<chrono::Utc>,
3967 params: GetUsageLogsByIndexOptionalParams,
3968 ) -> Result<
3969 crate::datadogV1::model::UsageLogsByIndexResponse,
3970 datadog::Error<GetUsageLogsByIndexError>,
3971 > {
3972 match self
3973 .get_usage_logs_by_index_with_http_info(start_hr, params)
3974 .await
3975 {
3976 Ok(response_content) => {
3977 if let Some(e) = response_content.entity {
3978 Ok(e)
3979 } else {
3980 Err(datadog::Error::Serde(serde::de::Error::custom(
3981 "response content was None",
3982 )))
3983 }
3984 }
3985 Err(err) => Err(err),
3986 }
3987 }
3988
3989 pub async fn get_usage_logs_by_index_with_http_info(
3991 &self,
3992 start_hr: chrono::DateTime<chrono::Utc>,
3993 params: GetUsageLogsByIndexOptionalParams,
3994 ) -> Result<
3995 datadog::ResponseContent<crate::datadogV1::model::UsageLogsByIndexResponse>,
3996 datadog::Error<GetUsageLogsByIndexError>,
3997 > {
3998 let local_configuration = &self.config;
3999 let operation_id = "v1.get_usage_logs_by_index";
4000
4001 let end_hr = params.end_hr;
4003 let index_name = params.index_name;
4004
4005 let local_client = &self.client;
4006
4007 let local_uri_str = format!(
4008 "{}/api/v1/usage/logs_by_index",
4009 local_configuration.get_operation_host(operation_id)
4010 );
4011 let mut local_req_builder =
4012 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4013
4014 local_req_builder = local_req_builder.query(&[(
4015 "start_hr",
4016 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
4017 )]);
4018 if let Some(ref local_query_param) = end_hr {
4019 local_req_builder = local_req_builder.query(&[(
4020 "end_hr",
4021 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
4022 )]);
4023 };
4024 if let Some(ref local) = index_name {
4025 for param in local {
4026 local_req_builder = local_req_builder.query(&[("index_name", ¶m.to_string())]);
4027 }
4028 };
4029
4030 let mut headers = HeaderMap::new();
4032 headers.insert(
4033 "Accept",
4034 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
4035 );
4036
4037 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4039 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4040 Err(e) => {
4041 log::warn!("Failed to parse user agent header: {e}, falling back to default");
4042 headers.insert(
4043 reqwest::header::USER_AGENT,
4044 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4045 )
4046 }
4047 };
4048
4049 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4051 headers.insert(
4052 "DD-API-KEY",
4053 HeaderValue::from_str(local_key.key.as_str())
4054 .expect("failed to parse DD-API-KEY header"),
4055 );
4056 };
4057 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4058 headers.insert(
4059 "DD-APPLICATION-KEY",
4060 HeaderValue::from_str(local_key.key.as_str())
4061 .expect("failed to parse DD-APPLICATION-KEY header"),
4062 );
4063 };
4064
4065 local_req_builder = local_req_builder.headers(headers);
4066 let local_req = local_req_builder.build()?;
4067 log::debug!("request content: {:?}", local_req.body());
4068 let local_resp = local_client.execute(local_req).await?;
4069
4070 let local_status = local_resp.status();
4071 let local_content = local_resp.text().await?;
4072 log::debug!("response content: {}", local_content);
4073
4074 if !local_status.is_client_error() && !local_status.is_server_error() {
4075 match serde_json::from_str::<crate::datadogV1::model::UsageLogsByIndexResponse>(
4076 &local_content,
4077 ) {
4078 Ok(e) => {
4079 return Ok(datadog::ResponseContent {
4080 status: local_status,
4081 content: local_content,
4082 entity: Some(e),
4083 })
4084 }
4085 Err(e) => return Err(datadog::Error::Serde(e)),
4086 };
4087 } else {
4088 let local_entity: Option<GetUsageLogsByIndexError> =
4089 serde_json::from_str(&local_content).ok();
4090 let local_error = datadog::ResponseContent {
4091 status: local_status,
4092 content: local_content,
4093 entity: local_entity,
4094 };
4095 Err(datadog::Error::ResponseError(local_error))
4096 }
4097 }
4098
4099 pub async fn get_usage_logs_by_retention(
4102 &self,
4103 start_hr: chrono::DateTime<chrono::Utc>,
4104 params: GetUsageLogsByRetentionOptionalParams,
4105 ) -> Result<
4106 crate::datadogV1::model::UsageLogsByRetentionResponse,
4107 datadog::Error<GetUsageLogsByRetentionError>,
4108 > {
4109 match self
4110 .get_usage_logs_by_retention_with_http_info(start_hr, params)
4111 .await
4112 {
4113 Ok(response_content) => {
4114 if let Some(e) = response_content.entity {
4115 Ok(e)
4116 } else {
4117 Err(datadog::Error::Serde(serde::de::Error::custom(
4118 "response content was None",
4119 )))
4120 }
4121 }
4122 Err(err) => Err(err),
4123 }
4124 }
4125
4126 pub async fn get_usage_logs_by_retention_with_http_info(
4129 &self,
4130 start_hr: chrono::DateTime<chrono::Utc>,
4131 params: GetUsageLogsByRetentionOptionalParams,
4132 ) -> Result<
4133 datadog::ResponseContent<crate::datadogV1::model::UsageLogsByRetentionResponse>,
4134 datadog::Error<GetUsageLogsByRetentionError>,
4135 > {
4136 let local_configuration = &self.config;
4137 let operation_id = "v1.get_usage_logs_by_retention";
4138
4139 let end_hr = params.end_hr;
4141
4142 let local_client = &self.client;
4143
4144 let local_uri_str = format!(
4145 "{}/api/v1/usage/logs-by-retention",
4146 local_configuration.get_operation_host(operation_id)
4147 );
4148 let mut local_req_builder =
4149 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4150
4151 local_req_builder = local_req_builder.query(&[(
4152 "start_hr",
4153 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
4154 )]);
4155 if let Some(ref local_query_param) = end_hr {
4156 local_req_builder = local_req_builder.query(&[(
4157 "end_hr",
4158 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
4159 )]);
4160 };
4161
4162 let mut headers = HeaderMap::new();
4164 headers.insert(
4165 "Accept",
4166 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
4167 );
4168
4169 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4171 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4172 Err(e) => {
4173 log::warn!("Failed to parse user agent header: {e}, falling back to default");
4174 headers.insert(
4175 reqwest::header::USER_AGENT,
4176 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4177 )
4178 }
4179 };
4180
4181 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4183 headers.insert(
4184 "DD-API-KEY",
4185 HeaderValue::from_str(local_key.key.as_str())
4186 .expect("failed to parse DD-API-KEY header"),
4187 );
4188 };
4189 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4190 headers.insert(
4191 "DD-APPLICATION-KEY",
4192 HeaderValue::from_str(local_key.key.as_str())
4193 .expect("failed to parse DD-APPLICATION-KEY header"),
4194 );
4195 };
4196
4197 local_req_builder = local_req_builder.headers(headers);
4198 let local_req = local_req_builder.build()?;
4199 log::debug!("request content: {:?}", local_req.body());
4200 let local_resp = local_client.execute(local_req).await?;
4201
4202 let local_status = local_resp.status();
4203 let local_content = local_resp.text().await?;
4204 log::debug!("response content: {}", local_content);
4205
4206 if !local_status.is_client_error() && !local_status.is_server_error() {
4207 match serde_json::from_str::<crate::datadogV1::model::UsageLogsByRetentionResponse>(
4208 &local_content,
4209 ) {
4210 Ok(e) => {
4211 return Ok(datadog::ResponseContent {
4212 status: local_status,
4213 content: local_content,
4214 entity: Some(e),
4215 })
4216 }
4217 Err(e) => return Err(datadog::Error::Serde(e)),
4218 };
4219 } else {
4220 let local_entity: Option<GetUsageLogsByRetentionError> =
4221 serde_json::from_str(&local_content).ok();
4222 let local_error = datadog::ResponseContent {
4223 status: local_status,
4224 content: local_content,
4225 entity: local_entity,
4226 };
4227 Err(datadog::Error::ResponseError(local_error))
4228 }
4229 }
4230
4231 pub async fn get_usage_network_flows(
4234 &self,
4235 start_hr: chrono::DateTime<chrono::Utc>,
4236 params: GetUsageNetworkFlowsOptionalParams,
4237 ) -> Result<
4238 crate::datadogV1::model::UsageNetworkFlowsResponse,
4239 datadog::Error<GetUsageNetworkFlowsError>,
4240 > {
4241 match self
4242 .get_usage_network_flows_with_http_info(start_hr, params)
4243 .await
4244 {
4245 Ok(response_content) => {
4246 if let Some(e) = response_content.entity {
4247 Ok(e)
4248 } else {
4249 Err(datadog::Error::Serde(serde::de::Error::custom(
4250 "response content was None",
4251 )))
4252 }
4253 }
4254 Err(err) => Err(err),
4255 }
4256 }
4257
4258 pub async fn get_usage_network_flows_with_http_info(
4261 &self,
4262 start_hr: chrono::DateTime<chrono::Utc>,
4263 params: GetUsageNetworkFlowsOptionalParams,
4264 ) -> Result<
4265 datadog::ResponseContent<crate::datadogV1::model::UsageNetworkFlowsResponse>,
4266 datadog::Error<GetUsageNetworkFlowsError>,
4267 > {
4268 let local_configuration = &self.config;
4269 let operation_id = "v1.get_usage_network_flows";
4270
4271 let end_hr = params.end_hr;
4273
4274 let local_client = &self.client;
4275
4276 let local_uri_str = format!(
4277 "{}/api/v1/usage/network_flows",
4278 local_configuration.get_operation_host(operation_id)
4279 );
4280 let mut local_req_builder =
4281 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4282
4283 local_req_builder = local_req_builder.query(&[(
4284 "start_hr",
4285 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
4286 )]);
4287 if let Some(ref local_query_param) = end_hr {
4288 local_req_builder = local_req_builder.query(&[(
4289 "end_hr",
4290 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
4291 )]);
4292 };
4293
4294 let mut headers = HeaderMap::new();
4296 headers.insert(
4297 "Accept",
4298 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
4299 );
4300
4301 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4303 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4304 Err(e) => {
4305 log::warn!("Failed to parse user agent header: {e}, falling back to default");
4306 headers.insert(
4307 reqwest::header::USER_AGENT,
4308 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4309 )
4310 }
4311 };
4312
4313 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4315 headers.insert(
4316 "DD-API-KEY",
4317 HeaderValue::from_str(local_key.key.as_str())
4318 .expect("failed to parse DD-API-KEY header"),
4319 );
4320 };
4321 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4322 headers.insert(
4323 "DD-APPLICATION-KEY",
4324 HeaderValue::from_str(local_key.key.as_str())
4325 .expect("failed to parse DD-APPLICATION-KEY header"),
4326 );
4327 };
4328
4329 local_req_builder = local_req_builder.headers(headers);
4330 let local_req = local_req_builder.build()?;
4331 log::debug!("request content: {:?}", local_req.body());
4332 let local_resp = local_client.execute(local_req).await?;
4333
4334 let local_status = local_resp.status();
4335 let local_content = local_resp.text().await?;
4336 log::debug!("response content: {}", local_content);
4337
4338 if !local_status.is_client_error() && !local_status.is_server_error() {
4339 match serde_json::from_str::<crate::datadogV1::model::UsageNetworkFlowsResponse>(
4340 &local_content,
4341 ) {
4342 Ok(e) => {
4343 return Ok(datadog::ResponseContent {
4344 status: local_status,
4345 content: local_content,
4346 entity: Some(e),
4347 })
4348 }
4349 Err(e) => return Err(datadog::Error::Serde(e)),
4350 };
4351 } else {
4352 let local_entity: Option<GetUsageNetworkFlowsError> =
4353 serde_json::from_str(&local_content).ok();
4354 let local_error = datadog::ResponseContent {
4355 status: local_status,
4356 content: local_content,
4357 entity: local_entity,
4358 };
4359 Err(datadog::Error::ResponseError(local_error))
4360 }
4361 }
4362
4363 pub async fn get_usage_network_hosts(
4366 &self,
4367 start_hr: chrono::DateTime<chrono::Utc>,
4368 params: GetUsageNetworkHostsOptionalParams,
4369 ) -> Result<
4370 crate::datadogV1::model::UsageNetworkHostsResponse,
4371 datadog::Error<GetUsageNetworkHostsError>,
4372 > {
4373 match self
4374 .get_usage_network_hosts_with_http_info(start_hr, params)
4375 .await
4376 {
4377 Ok(response_content) => {
4378 if let Some(e) = response_content.entity {
4379 Ok(e)
4380 } else {
4381 Err(datadog::Error::Serde(serde::de::Error::custom(
4382 "response content was None",
4383 )))
4384 }
4385 }
4386 Err(err) => Err(err),
4387 }
4388 }
4389
4390 pub async fn get_usage_network_hosts_with_http_info(
4393 &self,
4394 start_hr: chrono::DateTime<chrono::Utc>,
4395 params: GetUsageNetworkHostsOptionalParams,
4396 ) -> Result<
4397 datadog::ResponseContent<crate::datadogV1::model::UsageNetworkHostsResponse>,
4398 datadog::Error<GetUsageNetworkHostsError>,
4399 > {
4400 let local_configuration = &self.config;
4401 let operation_id = "v1.get_usage_network_hosts";
4402
4403 let end_hr = params.end_hr;
4405
4406 let local_client = &self.client;
4407
4408 let local_uri_str = format!(
4409 "{}/api/v1/usage/network_hosts",
4410 local_configuration.get_operation_host(operation_id)
4411 );
4412 let mut local_req_builder =
4413 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4414
4415 local_req_builder = local_req_builder.query(&[(
4416 "start_hr",
4417 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
4418 )]);
4419 if let Some(ref local_query_param) = end_hr {
4420 local_req_builder = local_req_builder.query(&[(
4421 "end_hr",
4422 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
4423 )]);
4424 };
4425
4426 let mut headers = HeaderMap::new();
4428 headers.insert(
4429 "Accept",
4430 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
4431 );
4432
4433 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4435 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4436 Err(e) => {
4437 log::warn!("Failed to parse user agent header: {e}, falling back to default");
4438 headers.insert(
4439 reqwest::header::USER_AGENT,
4440 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4441 )
4442 }
4443 };
4444
4445 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4447 headers.insert(
4448 "DD-API-KEY",
4449 HeaderValue::from_str(local_key.key.as_str())
4450 .expect("failed to parse DD-API-KEY header"),
4451 );
4452 };
4453 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4454 headers.insert(
4455 "DD-APPLICATION-KEY",
4456 HeaderValue::from_str(local_key.key.as_str())
4457 .expect("failed to parse DD-APPLICATION-KEY header"),
4458 );
4459 };
4460
4461 local_req_builder = local_req_builder.headers(headers);
4462 let local_req = local_req_builder.build()?;
4463 log::debug!("request content: {:?}", local_req.body());
4464 let local_resp = local_client.execute(local_req).await?;
4465
4466 let local_status = local_resp.status();
4467 let local_content = local_resp.text().await?;
4468 log::debug!("response content: {}", local_content);
4469
4470 if !local_status.is_client_error() && !local_status.is_server_error() {
4471 match serde_json::from_str::<crate::datadogV1::model::UsageNetworkHostsResponse>(
4472 &local_content,
4473 ) {
4474 Ok(e) => {
4475 return Ok(datadog::ResponseContent {
4476 status: local_status,
4477 content: local_content,
4478 entity: Some(e),
4479 })
4480 }
4481 Err(e) => return Err(datadog::Error::Serde(e)),
4482 };
4483 } else {
4484 let local_entity: Option<GetUsageNetworkHostsError> =
4485 serde_json::from_str(&local_content).ok();
4486 let local_error = datadog::ResponseContent {
4487 status: local_status,
4488 content: local_content,
4489 entity: local_entity,
4490 };
4491 Err(datadog::Error::ResponseError(local_error))
4492 }
4493 }
4494
4495 pub async fn get_usage_online_archive(
4498 &self,
4499 start_hr: chrono::DateTime<chrono::Utc>,
4500 params: GetUsageOnlineArchiveOptionalParams,
4501 ) -> Result<
4502 crate::datadogV1::model::UsageOnlineArchiveResponse,
4503 datadog::Error<GetUsageOnlineArchiveError>,
4504 > {
4505 match self
4506 .get_usage_online_archive_with_http_info(start_hr, params)
4507 .await
4508 {
4509 Ok(response_content) => {
4510 if let Some(e) = response_content.entity {
4511 Ok(e)
4512 } else {
4513 Err(datadog::Error::Serde(serde::de::Error::custom(
4514 "response content was None",
4515 )))
4516 }
4517 }
4518 Err(err) => Err(err),
4519 }
4520 }
4521
4522 pub async fn get_usage_online_archive_with_http_info(
4525 &self,
4526 start_hr: chrono::DateTime<chrono::Utc>,
4527 params: GetUsageOnlineArchiveOptionalParams,
4528 ) -> Result<
4529 datadog::ResponseContent<crate::datadogV1::model::UsageOnlineArchiveResponse>,
4530 datadog::Error<GetUsageOnlineArchiveError>,
4531 > {
4532 let local_configuration = &self.config;
4533 let operation_id = "v1.get_usage_online_archive";
4534
4535 let end_hr = params.end_hr;
4537
4538 let local_client = &self.client;
4539
4540 let local_uri_str = format!(
4541 "{}/api/v1/usage/online-archive",
4542 local_configuration.get_operation_host(operation_id)
4543 );
4544 let mut local_req_builder =
4545 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4546
4547 local_req_builder = local_req_builder.query(&[(
4548 "start_hr",
4549 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
4550 )]);
4551 if let Some(ref local_query_param) = end_hr {
4552 local_req_builder = local_req_builder.query(&[(
4553 "end_hr",
4554 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
4555 )]);
4556 };
4557
4558 let mut headers = HeaderMap::new();
4560 headers.insert(
4561 "Accept",
4562 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
4563 );
4564
4565 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4567 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4568 Err(e) => {
4569 log::warn!("Failed to parse user agent header: {e}, falling back to default");
4570 headers.insert(
4571 reqwest::header::USER_AGENT,
4572 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4573 )
4574 }
4575 };
4576
4577 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4579 headers.insert(
4580 "DD-API-KEY",
4581 HeaderValue::from_str(local_key.key.as_str())
4582 .expect("failed to parse DD-API-KEY header"),
4583 );
4584 };
4585 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4586 headers.insert(
4587 "DD-APPLICATION-KEY",
4588 HeaderValue::from_str(local_key.key.as_str())
4589 .expect("failed to parse DD-APPLICATION-KEY header"),
4590 );
4591 };
4592
4593 local_req_builder = local_req_builder.headers(headers);
4594 let local_req = local_req_builder.build()?;
4595 log::debug!("request content: {:?}", local_req.body());
4596 let local_resp = local_client.execute(local_req).await?;
4597
4598 let local_status = local_resp.status();
4599 let local_content = local_resp.text().await?;
4600 log::debug!("response content: {}", local_content);
4601
4602 if !local_status.is_client_error() && !local_status.is_server_error() {
4603 match serde_json::from_str::<crate::datadogV1::model::UsageOnlineArchiveResponse>(
4604 &local_content,
4605 ) {
4606 Ok(e) => {
4607 return Ok(datadog::ResponseContent {
4608 status: local_status,
4609 content: local_content,
4610 entity: Some(e),
4611 })
4612 }
4613 Err(e) => return Err(datadog::Error::Serde(e)),
4614 };
4615 } else {
4616 let local_entity: Option<GetUsageOnlineArchiveError> =
4617 serde_json::from_str(&local_content).ok();
4618 let local_error = datadog::ResponseContent {
4619 status: local_status,
4620 content: local_content,
4621 entity: local_entity,
4622 };
4623 Err(datadog::Error::ResponseError(local_error))
4624 }
4625 }
4626
4627 pub async fn get_usage_profiling(
4630 &self,
4631 start_hr: chrono::DateTime<chrono::Utc>,
4632 params: GetUsageProfilingOptionalParams,
4633 ) -> Result<
4634 crate::datadogV1::model::UsageProfilingResponse,
4635 datadog::Error<GetUsageProfilingError>,
4636 > {
4637 match self
4638 .get_usage_profiling_with_http_info(start_hr, params)
4639 .await
4640 {
4641 Ok(response_content) => {
4642 if let Some(e) = response_content.entity {
4643 Ok(e)
4644 } else {
4645 Err(datadog::Error::Serde(serde::de::Error::custom(
4646 "response content was None",
4647 )))
4648 }
4649 }
4650 Err(err) => Err(err),
4651 }
4652 }
4653
4654 pub async fn get_usage_profiling_with_http_info(
4657 &self,
4658 start_hr: chrono::DateTime<chrono::Utc>,
4659 params: GetUsageProfilingOptionalParams,
4660 ) -> Result<
4661 datadog::ResponseContent<crate::datadogV1::model::UsageProfilingResponse>,
4662 datadog::Error<GetUsageProfilingError>,
4663 > {
4664 let local_configuration = &self.config;
4665 let operation_id = "v1.get_usage_profiling";
4666
4667 let end_hr = params.end_hr;
4669
4670 let local_client = &self.client;
4671
4672 let local_uri_str = format!(
4673 "{}/api/v1/usage/profiling",
4674 local_configuration.get_operation_host(operation_id)
4675 );
4676 let mut local_req_builder =
4677 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4678
4679 local_req_builder = local_req_builder.query(&[(
4680 "start_hr",
4681 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
4682 )]);
4683 if let Some(ref local_query_param) = end_hr {
4684 local_req_builder = local_req_builder.query(&[(
4685 "end_hr",
4686 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
4687 )]);
4688 };
4689
4690 let mut headers = HeaderMap::new();
4692 headers.insert(
4693 "Accept",
4694 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
4695 );
4696
4697 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4699 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4700 Err(e) => {
4701 log::warn!("Failed to parse user agent header: {e}, falling back to default");
4702 headers.insert(
4703 reqwest::header::USER_AGENT,
4704 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4705 )
4706 }
4707 };
4708
4709 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4711 headers.insert(
4712 "DD-API-KEY",
4713 HeaderValue::from_str(local_key.key.as_str())
4714 .expect("failed to parse DD-API-KEY header"),
4715 );
4716 };
4717 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4718 headers.insert(
4719 "DD-APPLICATION-KEY",
4720 HeaderValue::from_str(local_key.key.as_str())
4721 .expect("failed to parse DD-APPLICATION-KEY header"),
4722 );
4723 };
4724
4725 local_req_builder = local_req_builder.headers(headers);
4726 let local_req = local_req_builder.build()?;
4727 log::debug!("request content: {:?}", local_req.body());
4728 let local_resp = local_client.execute(local_req).await?;
4729
4730 let local_status = local_resp.status();
4731 let local_content = local_resp.text().await?;
4732 log::debug!("response content: {}", local_content);
4733
4734 if !local_status.is_client_error() && !local_status.is_server_error() {
4735 match serde_json::from_str::<crate::datadogV1::model::UsageProfilingResponse>(
4736 &local_content,
4737 ) {
4738 Ok(e) => {
4739 return Ok(datadog::ResponseContent {
4740 status: local_status,
4741 content: local_content,
4742 entity: Some(e),
4743 })
4744 }
4745 Err(e) => return Err(datadog::Error::Serde(e)),
4746 };
4747 } else {
4748 let local_entity: Option<GetUsageProfilingError> =
4749 serde_json::from_str(&local_content).ok();
4750 let local_error = datadog::ResponseContent {
4751 status: local_status,
4752 content: local_content,
4753 entity: local_entity,
4754 };
4755 Err(datadog::Error::ResponseError(local_error))
4756 }
4757 }
4758
4759 pub async fn get_usage_rum_sessions(
4762 &self,
4763 start_hr: chrono::DateTime<chrono::Utc>,
4764 params: GetUsageRumSessionsOptionalParams,
4765 ) -> Result<
4766 crate::datadogV1::model::UsageRumSessionsResponse,
4767 datadog::Error<GetUsageRumSessionsError>,
4768 > {
4769 match self
4770 .get_usage_rum_sessions_with_http_info(start_hr, params)
4771 .await
4772 {
4773 Ok(response_content) => {
4774 if let Some(e) = response_content.entity {
4775 Ok(e)
4776 } else {
4777 Err(datadog::Error::Serde(serde::de::Error::custom(
4778 "response content was None",
4779 )))
4780 }
4781 }
4782 Err(err) => Err(err),
4783 }
4784 }
4785
4786 pub async fn get_usage_rum_sessions_with_http_info(
4789 &self,
4790 start_hr: chrono::DateTime<chrono::Utc>,
4791 params: GetUsageRumSessionsOptionalParams,
4792 ) -> Result<
4793 datadog::ResponseContent<crate::datadogV1::model::UsageRumSessionsResponse>,
4794 datadog::Error<GetUsageRumSessionsError>,
4795 > {
4796 let local_configuration = &self.config;
4797 let operation_id = "v1.get_usage_rum_sessions";
4798
4799 let end_hr = params.end_hr;
4801 let type_ = params.type_;
4802
4803 let local_client = &self.client;
4804
4805 let local_uri_str = format!(
4806 "{}/api/v1/usage/rum_sessions",
4807 local_configuration.get_operation_host(operation_id)
4808 );
4809 let mut local_req_builder =
4810 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4811
4812 local_req_builder = local_req_builder.query(&[(
4813 "start_hr",
4814 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
4815 )]);
4816 if let Some(ref local_query_param) = end_hr {
4817 local_req_builder = local_req_builder.query(&[(
4818 "end_hr",
4819 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
4820 )]);
4821 };
4822 if let Some(ref local_query_param) = type_ {
4823 local_req_builder =
4824 local_req_builder.query(&[("type", &local_query_param.to_string())]);
4825 };
4826
4827 let mut headers = HeaderMap::new();
4829 headers.insert(
4830 "Accept",
4831 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
4832 );
4833
4834 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4836 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4837 Err(e) => {
4838 log::warn!("Failed to parse user agent header: {e}, falling back to default");
4839 headers.insert(
4840 reqwest::header::USER_AGENT,
4841 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4842 )
4843 }
4844 };
4845
4846 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4848 headers.insert(
4849 "DD-API-KEY",
4850 HeaderValue::from_str(local_key.key.as_str())
4851 .expect("failed to parse DD-API-KEY header"),
4852 );
4853 };
4854 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4855 headers.insert(
4856 "DD-APPLICATION-KEY",
4857 HeaderValue::from_str(local_key.key.as_str())
4858 .expect("failed to parse DD-APPLICATION-KEY header"),
4859 );
4860 };
4861
4862 local_req_builder = local_req_builder.headers(headers);
4863 let local_req = local_req_builder.build()?;
4864 log::debug!("request content: {:?}", local_req.body());
4865 let local_resp = local_client.execute(local_req).await?;
4866
4867 let local_status = local_resp.status();
4868 let local_content = local_resp.text().await?;
4869 log::debug!("response content: {}", local_content);
4870
4871 if !local_status.is_client_error() && !local_status.is_server_error() {
4872 match serde_json::from_str::<crate::datadogV1::model::UsageRumSessionsResponse>(
4873 &local_content,
4874 ) {
4875 Ok(e) => {
4876 return Ok(datadog::ResponseContent {
4877 status: local_status,
4878 content: local_content,
4879 entity: Some(e),
4880 })
4881 }
4882 Err(e) => return Err(datadog::Error::Serde(e)),
4883 };
4884 } else {
4885 let local_entity: Option<GetUsageRumSessionsError> =
4886 serde_json::from_str(&local_content).ok();
4887 let local_error = datadog::ResponseContent {
4888 status: local_status,
4889 content: local_content,
4890 entity: local_entity,
4891 };
4892 Err(datadog::Error::ResponseError(local_error))
4893 }
4894 }
4895
4896 pub async fn get_usage_rum_units(
4899 &self,
4900 start_hr: chrono::DateTime<chrono::Utc>,
4901 params: GetUsageRumUnitsOptionalParams,
4902 ) -> Result<crate::datadogV1::model::UsageRumUnitsResponse, datadog::Error<GetUsageRumUnitsError>>
4903 {
4904 match self
4905 .get_usage_rum_units_with_http_info(start_hr, params)
4906 .await
4907 {
4908 Ok(response_content) => {
4909 if let Some(e) = response_content.entity {
4910 Ok(e)
4911 } else {
4912 Err(datadog::Error::Serde(serde::de::Error::custom(
4913 "response content was None",
4914 )))
4915 }
4916 }
4917 Err(err) => Err(err),
4918 }
4919 }
4920
4921 pub async fn get_usage_rum_units_with_http_info(
4924 &self,
4925 start_hr: chrono::DateTime<chrono::Utc>,
4926 params: GetUsageRumUnitsOptionalParams,
4927 ) -> Result<
4928 datadog::ResponseContent<crate::datadogV1::model::UsageRumUnitsResponse>,
4929 datadog::Error<GetUsageRumUnitsError>,
4930 > {
4931 let local_configuration = &self.config;
4932 let operation_id = "v1.get_usage_rum_units";
4933
4934 let end_hr = params.end_hr;
4936
4937 let local_client = &self.client;
4938
4939 let local_uri_str = format!(
4940 "{}/api/v1/usage/rum",
4941 local_configuration.get_operation_host(operation_id)
4942 );
4943 let mut local_req_builder =
4944 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4945
4946 local_req_builder = local_req_builder.query(&[(
4947 "start_hr",
4948 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
4949 )]);
4950 if let Some(ref local_query_param) = end_hr {
4951 local_req_builder = local_req_builder.query(&[(
4952 "end_hr",
4953 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
4954 )]);
4955 };
4956
4957 let mut headers = HeaderMap::new();
4959 headers.insert(
4960 "Accept",
4961 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
4962 );
4963
4964 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4966 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4967 Err(e) => {
4968 log::warn!("Failed to parse user agent header: {e}, falling back to default");
4969 headers.insert(
4970 reqwest::header::USER_AGENT,
4971 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4972 )
4973 }
4974 };
4975
4976 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4978 headers.insert(
4979 "DD-API-KEY",
4980 HeaderValue::from_str(local_key.key.as_str())
4981 .expect("failed to parse DD-API-KEY header"),
4982 );
4983 };
4984 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4985 headers.insert(
4986 "DD-APPLICATION-KEY",
4987 HeaderValue::from_str(local_key.key.as_str())
4988 .expect("failed to parse DD-APPLICATION-KEY header"),
4989 );
4990 };
4991
4992 local_req_builder = local_req_builder.headers(headers);
4993 let local_req = local_req_builder.build()?;
4994 log::debug!("request content: {:?}", local_req.body());
4995 let local_resp = local_client.execute(local_req).await?;
4996
4997 let local_status = local_resp.status();
4998 let local_content = local_resp.text().await?;
4999 log::debug!("response content: {}", local_content);
5000
5001 if !local_status.is_client_error() && !local_status.is_server_error() {
5002 match serde_json::from_str::<crate::datadogV1::model::UsageRumUnitsResponse>(
5003 &local_content,
5004 ) {
5005 Ok(e) => {
5006 return Ok(datadog::ResponseContent {
5007 status: local_status,
5008 content: local_content,
5009 entity: Some(e),
5010 })
5011 }
5012 Err(e) => return Err(datadog::Error::Serde(e)),
5013 };
5014 } else {
5015 let local_entity: Option<GetUsageRumUnitsError> =
5016 serde_json::from_str(&local_content).ok();
5017 let local_error = datadog::ResponseContent {
5018 status: local_status,
5019 content: local_content,
5020 entity: local_entity,
5021 };
5022 Err(datadog::Error::ResponseError(local_error))
5023 }
5024 }
5025
5026 pub async fn get_usage_sds(
5029 &self,
5030 start_hr: chrono::DateTime<chrono::Utc>,
5031 params: GetUsageSDSOptionalParams,
5032 ) -> Result<crate::datadogV1::model::UsageSDSResponse, datadog::Error<GetUsageSDSError>> {
5033 match self.get_usage_sds_with_http_info(start_hr, params).await {
5034 Ok(response_content) => {
5035 if let Some(e) = response_content.entity {
5036 Ok(e)
5037 } else {
5038 Err(datadog::Error::Serde(serde::de::Error::custom(
5039 "response content was None",
5040 )))
5041 }
5042 }
5043 Err(err) => Err(err),
5044 }
5045 }
5046
5047 pub async fn get_usage_sds_with_http_info(
5050 &self,
5051 start_hr: chrono::DateTime<chrono::Utc>,
5052 params: GetUsageSDSOptionalParams,
5053 ) -> Result<
5054 datadog::ResponseContent<crate::datadogV1::model::UsageSDSResponse>,
5055 datadog::Error<GetUsageSDSError>,
5056 > {
5057 let local_configuration = &self.config;
5058 let operation_id = "v1.get_usage_sds";
5059
5060 let end_hr = params.end_hr;
5062
5063 let local_client = &self.client;
5064
5065 let local_uri_str = format!(
5066 "{}/api/v1/usage/sds",
5067 local_configuration.get_operation_host(operation_id)
5068 );
5069 let mut local_req_builder =
5070 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5071
5072 local_req_builder = local_req_builder.query(&[(
5073 "start_hr",
5074 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
5075 )]);
5076 if let Some(ref local_query_param) = end_hr {
5077 local_req_builder = local_req_builder.query(&[(
5078 "end_hr",
5079 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
5080 )]);
5081 };
5082
5083 let mut headers = HeaderMap::new();
5085 headers.insert(
5086 "Accept",
5087 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
5088 );
5089
5090 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5092 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5093 Err(e) => {
5094 log::warn!("Failed to parse user agent header: {e}, falling back to default");
5095 headers.insert(
5096 reqwest::header::USER_AGENT,
5097 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5098 )
5099 }
5100 };
5101
5102 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5104 headers.insert(
5105 "DD-API-KEY",
5106 HeaderValue::from_str(local_key.key.as_str())
5107 .expect("failed to parse DD-API-KEY header"),
5108 );
5109 };
5110 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5111 headers.insert(
5112 "DD-APPLICATION-KEY",
5113 HeaderValue::from_str(local_key.key.as_str())
5114 .expect("failed to parse DD-APPLICATION-KEY header"),
5115 );
5116 };
5117
5118 local_req_builder = local_req_builder.headers(headers);
5119 let local_req = local_req_builder.build()?;
5120 log::debug!("request content: {:?}", local_req.body());
5121 let local_resp = local_client.execute(local_req).await?;
5122
5123 let local_status = local_resp.status();
5124 let local_content = local_resp.text().await?;
5125 log::debug!("response content: {}", local_content);
5126
5127 if !local_status.is_client_error() && !local_status.is_server_error() {
5128 match serde_json::from_str::<crate::datadogV1::model::UsageSDSResponse>(&local_content)
5129 {
5130 Ok(e) => {
5131 return Ok(datadog::ResponseContent {
5132 status: local_status,
5133 content: local_content,
5134 entity: Some(e),
5135 })
5136 }
5137 Err(e) => return Err(datadog::Error::Serde(e)),
5138 };
5139 } else {
5140 let local_entity: Option<GetUsageSDSError> = serde_json::from_str(&local_content).ok();
5141 let local_error = datadog::ResponseContent {
5142 status: local_status,
5143 content: local_content,
5144 entity: local_entity,
5145 };
5146 Err(datadog::Error::ResponseError(local_error))
5147 }
5148 }
5149
5150 pub async fn get_usage_snmp(
5153 &self,
5154 start_hr: chrono::DateTime<chrono::Utc>,
5155 params: GetUsageSNMPOptionalParams,
5156 ) -> Result<crate::datadogV1::model::UsageSNMPResponse, datadog::Error<GetUsageSNMPError>> {
5157 match self.get_usage_snmp_with_http_info(start_hr, params).await {
5158 Ok(response_content) => {
5159 if let Some(e) = response_content.entity {
5160 Ok(e)
5161 } else {
5162 Err(datadog::Error::Serde(serde::de::Error::custom(
5163 "response content was None",
5164 )))
5165 }
5166 }
5167 Err(err) => Err(err),
5168 }
5169 }
5170
5171 pub async fn get_usage_snmp_with_http_info(
5174 &self,
5175 start_hr: chrono::DateTime<chrono::Utc>,
5176 params: GetUsageSNMPOptionalParams,
5177 ) -> Result<
5178 datadog::ResponseContent<crate::datadogV1::model::UsageSNMPResponse>,
5179 datadog::Error<GetUsageSNMPError>,
5180 > {
5181 let local_configuration = &self.config;
5182 let operation_id = "v1.get_usage_snmp";
5183
5184 let end_hr = params.end_hr;
5186
5187 let local_client = &self.client;
5188
5189 let local_uri_str = format!(
5190 "{}/api/v1/usage/snmp",
5191 local_configuration.get_operation_host(operation_id)
5192 );
5193 let mut local_req_builder =
5194 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5195
5196 local_req_builder = local_req_builder.query(&[(
5197 "start_hr",
5198 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
5199 )]);
5200 if let Some(ref local_query_param) = end_hr {
5201 local_req_builder = local_req_builder.query(&[(
5202 "end_hr",
5203 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
5204 )]);
5205 };
5206
5207 let mut headers = HeaderMap::new();
5209 headers.insert(
5210 "Accept",
5211 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
5212 );
5213
5214 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5216 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5217 Err(e) => {
5218 log::warn!("Failed to parse user agent header: {e}, falling back to default");
5219 headers.insert(
5220 reqwest::header::USER_AGENT,
5221 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5222 )
5223 }
5224 };
5225
5226 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5228 headers.insert(
5229 "DD-API-KEY",
5230 HeaderValue::from_str(local_key.key.as_str())
5231 .expect("failed to parse DD-API-KEY header"),
5232 );
5233 };
5234 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5235 headers.insert(
5236 "DD-APPLICATION-KEY",
5237 HeaderValue::from_str(local_key.key.as_str())
5238 .expect("failed to parse DD-APPLICATION-KEY header"),
5239 );
5240 };
5241
5242 local_req_builder = local_req_builder.headers(headers);
5243 let local_req = local_req_builder.build()?;
5244 log::debug!("request content: {:?}", local_req.body());
5245 let local_resp = local_client.execute(local_req).await?;
5246
5247 let local_status = local_resp.status();
5248 let local_content = local_resp.text().await?;
5249 log::debug!("response content: {}", local_content);
5250
5251 if !local_status.is_client_error() && !local_status.is_server_error() {
5252 match serde_json::from_str::<crate::datadogV1::model::UsageSNMPResponse>(&local_content)
5253 {
5254 Ok(e) => {
5255 return Ok(datadog::ResponseContent {
5256 status: local_status,
5257 content: local_content,
5258 entity: Some(e),
5259 })
5260 }
5261 Err(e) => return Err(datadog::Error::Serde(e)),
5262 };
5263 } else {
5264 let local_entity: Option<GetUsageSNMPError> = serde_json::from_str(&local_content).ok();
5265 let local_error = datadog::ResponseContent {
5266 status: local_status,
5267 content: local_content,
5268 entity: local_entity,
5269 };
5270 Err(datadog::Error::ResponseError(local_error))
5271 }
5272 }
5273
5274 pub async fn get_usage_summary(
5278 &self,
5279 start_month: chrono::DateTime<chrono::Utc>,
5280 params: GetUsageSummaryOptionalParams,
5281 ) -> Result<crate::datadogV1::model::UsageSummaryResponse, datadog::Error<GetUsageSummaryError>>
5282 {
5283 match self
5284 .get_usage_summary_with_http_info(start_month, params)
5285 .await
5286 {
5287 Ok(response_content) => {
5288 if let Some(e) = response_content.entity {
5289 Ok(e)
5290 } else {
5291 Err(datadog::Error::Serde(serde::de::Error::custom(
5292 "response content was None",
5293 )))
5294 }
5295 }
5296 Err(err) => Err(err),
5297 }
5298 }
5299
5300 pub async fn get_usage_summary_with_http_info(
5304 &self,
5305 start_month: chrono::DateTime<chrono::Utc>,
5306 params: GetUsageSummaryOptionalParams,
5307 ) -> Result<
5308 datadog::ResponseContent<crate::datadogV1::model::UsageSummaryResponse>,
5309 datadog::Error<GetUsageSummaryError>,
5310 > {
5311 let local_configuration = &self.config;
5312 let operation_id = "v1.get_usage_summary";
5313
5314 let end_month = params.end_month;
5316 let include_org_details = params.include_org_details;
5317 let include_connected_accounts = params.include_connected_accounts;
5318
5319 let local_client = &self.client;
5320
5321 let local_uri_str = format!(
5322 "{}/api/v1/usage/summary",
5323 local_configuration.get_operation_host(operation_id)
5324 );
5325 let mut local_req_builder =
5326 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5327
5328 local_req_builder = local_req_builder.query(&[(
5329 "start_month",
5330 &start_month.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
5331 )]);
5332 if let Some(ref local_query_param) = end_month {
5333 local_req_builder = local_req_builder.query(&[(
5334 "end_month",
5335 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
5336 )]);
5337 };
5338 if let Some(ref local_query_param) = include_org_details {
5339 local_req_builder =
5340 local_req_builder.query(&[("include_org_details", &local_query_param.to_string())]);
5341 };
5342 if let Some(ref local_query_param) = include_connected_accounts {
5343 local_req_builder = local_req_builder
5344 .query(&[("include_connected_accounts", &local_query_param.to_string())]);
5345 };
5346
5347 let mut headers = HeaderMap::new();
5349 headers.insert(
5350 "Accept",
5351 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
5352 );
5353
5354 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5356 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5357 Err(e) => {
5358 log::warn!("Failed to parse user agent header: {e}, falling back to default");
5359 headers.insert(
5360 reqwest::header::USER_AGENT,
5361 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5362 )
5363 }
5364 };
5365
5366 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5368 headers.insert(
5369 "DD-API-KEY",
5370 HeaderValue::from_str(local_key.key.as_str())
5371 .expect("failed to parse DD-API-KEY header"),
5372 );
5373 };
5374 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5375 headers.insert(
5376 "DD-APPLICATION-KEY",
5377 HeaderValue::from_str(local_key.key.as_str())
5378 .expect("failed to parse DD-APPLICATION-KEY header"),
5379 );
5380 };
5381
5382 local_req_builder = local_req_builder.headers(headers);
5383 let local_req = local_req_builder.build()?;
5384 log::debug!("request content: {:?}", local_req.body());
5385 let local_resp = local_client.execute(local_req).await?;
5386
5387 let local_status = local_resp.status();
5388 let local_content = local_resp.text().await?;
5389 log::debug!("response content: {}", local_content);
5390
5391 if !local_status.is_client_error() && !local_status.is_server_error() {
5392 match serde_json::from_str::<crate::datadogV1::model::UsageSummaryResponse>(
5393 &local_content,
5394 ) {
5395 Ok(e) => {
5396 return Ok(datadog::ResponseContent {
5397 status: local_status,
5398 content: local_content,
5399 entity: Some(e),
5400 })
5401 }
5402 Err(e) => return Err(datadog::Error::Serde(e)),
5403 };
5404 } else {
5405 let local_entity: Option<GetUsageSummaryError> =
5406 serde_json::from_str(&local_content).ok();
5407 let local_error = datadog::ResponseContent {
5408 status: local_status,
5409 content: local_content,
5410 entity: local_entity,
5411 };
5412 Err(datadog::Error::ResponseError(local_error))
5413 }
5414 }
5415
5416 pub async fn get_usage_synthetics(
5419 &self,
5420 start_hr: chrono::DateTime<chrono::Utc>,
5421 params: GetUsageSyntheticsOptionalParams,
5422 ) -> Result<
5423 crate::datadogV1::model::UsageSyntheticsResponse,
5424 datadog::Error<GetUsageSyntheticsError>,
5425 > {
5426 match self
5427 .get_usage_synthetics_with_http_info(start_hr, params)
5428 .await
5429 {
5430 Ok(response_content) => {
5431 if let Some(e) = response_content.entity {
5432 Ok(e)
5433 } else {
5434 Err(datadog::Error::Serde(serde::de::Error::custom(
5435 "response content was None",
5436 )))
5437 }
5438 }
5439 Err(err) => Err(err),
5440 }
5441 }
5442
5443 pub async fn get_usage_synthetics_with_http_info(
5446 &self,
5447 start_hr: chrono::DateTime<chrono::Utc>,
5448 params: GetUsageSyntheticsOptionalParams,
5449 ) -> Result<
5450 datadog::ResponseContent<crate::datadogV1::model::UsageSyntheticsResponse>,
5451 datadog::Error<GetUsageSyntheticsError>,
5452 > {
5453 let local_configuration = &self.config;
5454 let operation_id = "v1.get_usage_synthetics";
5455
5456 let end_hr = params.end_hr;
5458
5459 let local_client = &self.client;
5460
5461 let local_uri_str = format!(
5462 "{}/api/v1/usage/synthetics",
5463 local_configuration.get_operation_host(operation_id)
5464 );
5465 let mut local_req_builder =
5466 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5467
5468 local_req_builder = local_req_builder.query(&[(
5469 "start_hr",
5470 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
5471 )]);
5472 if let Some(ref local_query_param) = end_hr {
5473 local_req_builder = local_req_builder.query(&[(
5474 "end_hr",
5475 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
5476 )]);
5477 };
5478
5479 let mut headers = HeaderMap::new();
5481 headers.insert(
5482 "Accept",
5483 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
5484 );
5485
5486 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5488 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5489 Err(e) => {
5490 log::warn!("Failed to parse user agent header: {e}, falling back to default");
5491 headers.insert(
5492 reqwest::header::USER_AGENT,
5493 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5494 )
5495 }
5496 };
5497
5498 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5500 headers.insert(
5501 "DD-API-KEY",
5502 HeaderValue::from_str(local_key.key.as_str())
5503 .expect("failed to parse DD-API-KEY header"),
5504 );
5505 };
5506 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5507 headers.insert(
5508 "DD-APPLICATION-KEY",
5509 HeaderValue::from_str(local_key.key.as_str())
5510 .expect("failed to parse DD-APPLICATION-KEY header"),
5511 );
5512 };
5513
5514 local_req_builder = local_req_builder.headers(headers);
5515 let local_req = local_req_builder.build()?;
5516 log::debug!("request content: {:?}", local_req.body());
5517 let local_resp = local_client.execute(local_req).await?;
5518
5519 let local_status = local_resp.status();
5520 let local_content = local_resp.text().await?;
5521 log::debug!("response content: {}", local_content);
5522
5523 if !local_status.is_client_error() && !local_status.is_server_error() {
5524 match serde_json::from_str::<crate::datadogV1::model::UsageSyntheticsResponse>(
5525 &local_content,
5526 ) {
5527 Ok(e) => {
5528 return Ok(datadog::ResponseContent {
5529 status: local_status,
5530 content: local_content,
5531 entity: Some(e),
5532 })
5533 }
5534 Err(e) => return Err(datadog::Error::Serde(e)),
5535 };
5536 } else {
5537 let local_entity: Option<GetUsageSyntheticsError> =
5538 serde_json::from_str(&local_content).ok();
5539 let local_error = datadog::ResponseContent {
5540 status: local_status,
5541 content: local_content,
5542 entity: local_entity,
5543 };
5544 Err(datadog::Error::ResponseError(local_error))
5545 }
5546 }
5547
5548 pub async fn get_usage_synthetics_api(
5551 &self,
5552 start_hr: chrono::DateTime<chrono::Utc>,
5553 params: GetUsageSyntheticsAPIOptionalParams,
5554 ) -> Result<
5555 crate::datadogV1::model::UsageSyntheticsAPIResponse,
5556 datadog::Error<GetUsageSyntheticsAPIError>,
5557 > {
5558 match self
5559 .get_usage_synthetics_api_with_http_info(start_hr, params)
5560 .await
5561 {
5562 Ok(response_content) => {
5563 if let Some(e) = response_content.entity {
5564 Ok(e)
5565 } else {
5566 Err(datadog::Error::Serde(serde::de::Error::custom(
5567 "response content was None",
5568 )))
5569 }
5570 }
5571 Err(err) => Err(err),
5572 }
5573 }
5574
5575 pub async fn get_usage_synthetics_api_with_http_info(
5578 &self,
5579 start_hr: chrono::DateTime<chrono::Utc>,
5580 params: GetUsageSyntheticsAPIOptionalParams,
5581 ) -> Result<
5582 datadog::ResponseContent<crate::datadogV1::model::UsageSyntheticsAPIResponse>,
5583 datadog::Error<GetUsageSyntheticsAPIError>,
5584 > {
5585 let local_configuration = &self.config;
5586 let operation_id = "v1.get_usage_synthetics_api";
5587
5588 let end_hr = params.end_hr;
5590
5591 let local_client = &self.client;
5592
5593 let local_uri_str = format!(
5594 "{}/api/v1/usage/synthetics_api",
5595 local_configuration.get_operation_host(operation_id)
5596 );
5597 let mut local_req_builder =
5598 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5599
5600 local_req_builder = local_req_builder.query(&[(
5601 "start_hr",
5602 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
5603 )]);
5604 if let Some(ref local_query_param) = end_hr {
5605 local_req_builder = local_req_builder.query(&[(
5606 "end_hr",
5607 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
5608 )]);
5609 };
5610
5611 let mut headers = HeaderMap::new();
5613 headers.insert(
5614 "Accept",
5615 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
5616 );
5617
5618 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5620 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5621 Err(e) => {
5622 log::warn!("Failed to parse user agent header: {e}, falling back to default");
5623 headers.insert(
5624 reqwest::header::USER_AGENT,
5625 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5626 )
5627 }
5628 };
5629
5630 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5632 headers.insert(
5633 "DD-API-KEY",
5634 HeaderValue::from_str(local_key.key.as_str())
5635 .expect("failed to parse DD-API-KEY header"),
5636 );
5637 };
5638 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5639 headers.insert(
5640 "DD-APPLICATION-KEY",
5641 HeaderValue::from_str(local_key.key.as_str())
5642 .expect("failed to parse DD-APPLICATION-KEY header"),
5643 );
5644 };
5645
5646 local_req_builder = local_req_builder.headers(headers);
5647 let local_req = local_req_builder.build()?;
5648 log::debug!("request content: {:?}", local_req.body());
5649 let local_resp = local_client.execute(local_req).await?;
5650
5651 let local_status = local_resp.status();
5652 let local_content = local_resp.text().await?;
5653 log::debug!("response content: {}", local_content);
5654
5655 if !local_status.is_client_error() && !local_status.is_server_error() {
5656 match serde_json::from_str::<crate::datadogV1::model::UsageSyntheticsAPIResponse>(
5657 &local_content,
5658 ) {
5659 Ok(e) => {
5660 return Ok(datadog::ResponseContent {
5661 status: local_status,
5662 content: local_content,
5663 entity: Some(e),
5664 })
5665 }
5666 Err(e) => return Err(datadog::Error::Serde(e)),
5667 };
5668 } else {
5669 let local_entity: Option<GetUsageSyntheticsAPIError> =
5670 serde_json::from_str(&local_content).ok();
5671 let local_error = datadog::ResponseContent {
5672 status: local_status,
5673 content: local_content,
5674 entity: local_entity,
5675 };
5676 Err(datadog::Error::ResponseError(local_error))
5677 }
5678 }
5679
5680 pub async fn get_usage_synthetics_browser(
5683 &self,
5684 start_hr: chrono::DateTime<chrono::Utc>,
5685 params: GetUsageSyntheticsBrowserOptionalParams,
5686 ) -> Result<
5687 crate::datadogV1::model::UsageSyntheticsBrowserResponse,
5688 datadog::Error<GetUsageSyntheticsBrowserError>,
5689 > {
5690 match self
5691 .get_usage_synthetics_browser_with_http_info(start_hr, params)
5692 .await
5693 {
5694 Ok(response_content) => {
5695 if let Some(e) = response_content.entity {
5696 Ok(e)
5697 } else {
5698 Err(datadog::Error::Serde(serde::de::Error::custom(
5699 "response content was None",
5700 )))
5701 }
5702 }
5703 Err(err) => Err(err),
5704 }
5705 }
5706
5707 pub async fn get_usage_synthetics_browser_with_http_info(
5710 &self,
5711 start_hr: chrono::DateTime<chrono::Utc>,
5712 params: GetUsageSyntheticsBrowserOptionalParams,
5713 ) -> Result<
5714 datadog::ResponseContent<crate::datadogV1::model::UsageSyntheticsBrowserResponse>,
5715 datadog::Error<GetUsageSyntheticsBrowserError>,
5716 > {
5717 let local_configuration = &self.config;
5718 let operation_id = "v1.get_usage_synthetics_browser";
5719
5720 let end_hr = params.end_hr;
5722
5723 let local_client = &self.client;
5724
5725 let local_uri_str = format!(
5726 "{}/api/v1/usage/synthetics_browser",
5727 local_configuration.get_operation_host(operation_id)
5728 );
5729 let mut local_req_builder =
5730 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5731
5732 local_req_builder = local_req_builder.query(&[(
5733 "start_hr",
5734 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
5735 )]);
5736 if let Some(ref local_query_param) = end_hr {
5737 local_req_builder = local_req_builder.query(&[(
5738 "end_hr",
5739 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
5740 )]);
5741 };
5742
5743 let mut headers = HeaderMap::new();
5745 headers.insert(
5746 "Accept",
5747 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
5748 );
5749
5750 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5752 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5753 Err(e) => {
5754 log::warn!("Failed to parse user agent header: {e}, falling back to default");
5755 headers.insert(
5756 reqwest::header::USER_AGENT,
5757 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5758 )
5759 }
5760 };
5761
5762 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5764 headers.insert(
5765 "DD-API-KEY",
5766 HeaderValue::from_str(local_key.key.as_str())
5767 .expect("failed to parse DD-API-KEY header"),
5768 );
5769 };
5770 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5771 headers.insert(
5772 "DD-APPLICATION-KEY",
5773 HeaderValue::from_str(local_key.key.as_str())
5774 .expect("failed to parse DD-APPLICATION-KEY header"),
5775 );
5776 };
5777
5778 local_req_builder = local_req_builder.headers(headers);
5779 let local_req = local_req_builder.build()?;
5780 log::debug!("request content: {:?}", local_req.body());
5781 let local_resp = local_client.execute(local_req).await?;
5782
5783 let local_status = local_resp.status();
5784 let local_content = local_resp.text().await?;
5785 log::debug!("response content: {}", local_content);
5786
5787 if !local_status.is_client_error() && !local_status.is_server_error() {
5788 match serde_json::from_str::<crate::datadogV1::model::UsageSyntheticsBrowserResponse>(
5789 &local_content,
5790 ) {
5791 Ok(e) => {
5792 return Ok(datadog::ResponseContent {
5793 status: local_status,
5794 content: local_content,
5795 entity: Some(e),
5796 })
5797 }
5798 Err(e) => return Err(datadog::Error::Serde(e)),
5799 };
5800 } else {
5801 let local_entity: Option<GetUsageSyntheticsBrowserError> =
5802 serde_json::from_str(&local_content).ok();
5803 let local_error = datadog::ResponseContent {
5804 status: local_status,
5805 content: local_content,
5806 entity: local_entity,
5807 };
5808 Err(datadog::Error::ResponseError(local_error))
5809 }
5810 }
5811
5812 pub async fn get_usage_timeseries(
5815 &self,
5816 start_hr: chrono::DateTime<chrono::Utc>,
5817 params: GetUsageTimeseriesOptionalParams,
5818 ) -> Result<
5819 crate::datadogV1::model::UsageTimeseriesResponse,
5820 datadog::Error<GetUsageTimeseriesError>,
5821 > {
5822 match self
5823 .get_usage_timeseries_with_http_info(start_hr, params)
5824 .await
5825 {
5826 Ok(response_content) => {
5827 if let Some(e) = response_content.entity {
5828 Ok(e)
5829 } else {
5830 Err(datadog::Error::Serde(serde::de::Error::custom(
5831 "response content was None",
5832 )))
5833 }
5834 }
5835 Err(err) => Err(err),
5836 }
5837 }
5838
5839 pub async fn get_usage_timeseries_with_http_info(
5842 &self,
5843 start_hr: chrono::DateTime<chrono::Utc>,
5844 params: GetUsageTimeseriesOptionalParams,
5845 ) -> Result<
5846 datadog::ResponseContent<crate::datadogV1::model::UsageTimeseriesResponse>,
5847 datadog::Error<GetUsageTimeseriesError>,
5848 > {
5849 let local_configuration = &self.config;
5850 let operation_id = "v1.get_usage_timeseries";
5851
5852 let end_hr = params.end_hr;
5854
5855 let local_client = &self.client;
5856
5857 let local_uri_str = format!(
5858 "{}/api/v1/usage/timeseries",
5859 local_configuration.get_operation_host(operation_id)
5860 );
5861 let mut local_req_builder =
5862 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5863
5864 local_req_builder = local_req_builder.query(&[(
5865 "start_hr",
5866 &start_hr.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
5867 )]);
5868 if let Some(ref local_query_param) = end_hr {
5869 local_req_builder = local_req_builder.query(&[(
5870 "end_hr",
5871 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
5872 )]);
5873 };
5874
5875 let mut headers = HeaderMap::new();
5877 headers.insert(
5878 "Accept",
5879 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
5880 );
5881
5882 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5884 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5885 Err(e) => {
5886 log::warn!("Failed to parse user agent header: {e}, falling back to default");
5887 headers.insert(
5888 reqwest::header::USER_AGENT,
5889 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5890 )
5891 }
5892 };
5893
5894 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5896 headers.insert(
5897 "DD-API-KEY",
5898 HeaderValue::from_str(local_key.key.as_str())
5899 .expect("failed to parse DD-API-KEY header"),
5900 );
5901 };
5902 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5903 headers.insert(
5904 "DD-APPLICATION-KEY",
5905 HeaderValue::from_str(local_key.key.as_str())
5906 .expect("failed to parse DD-APPLICATION-KEY header"),
5907 );
5908 };
5909
5910 local_req_builder = local_req_builder.headers(headers);
5911 let local_req = local_req_builder.build()?;
5912 log::debug!("request content: {:?}", local_req.body());
5913 let local_resp = local_client.execute(local_req).await?;
5914
5915 let local_status = local_resp.status();
5916 let local_content = local_resp.text().await?;
5917 log::debug!("response content: {}", local_content);
5918
5919 if !local_status.is_client_error() && !local_status.is_server_error() {
5920 match serde_json::from_str::<crate::datadogV1::model::UsageTimeseriesResponse>(
5921 &local_content,
5922 ) {
5923 Ok(e) => {
5924 return Ok(datadog::ResponseContent {
5925 status: local_status,
5926 content: local_content,
5927 entity: Some(e),
5928 })
5929 }
5930 Err(e) => return Err(datadog::Error::Serde(e)),
5931 };
5932 } else {
5933 let local_entity: Option<GetUsageTimeseriesError> =
5934 serde_json::from_str(&local_content).ok();
5935 let local_error = datadog::ResponseContent {
5936 status: local_status,
5937 content: local_content,
5938 entity: local_entity,
5939 };
5940 Err(datadog::Error::ResponseError(local_error))
5941 }
5942 }
5943
5944 pub async fn get_usage_top_avg_metrics(
5946 &self,
5947 params: GetUsageTopAvgMetricsOptionalParams,
5948 ) -> Result<
5949 crate::datadogV1::model::UsageTopAvgMetricsResponse,
5950 datadog::Error<GetUsageTopAvgMetricsError>,
5951 > {
5952 match self.get_usage_top_avg_metrics_with_http_info(params).await {
5953 Ok(response_content) => {
5954 if let Some(e) = response_content.entity {
5955 Ok(e)
5956 } else {
5957 Err(datadog::Error::Serde(serde::de::Error::custom(
5958 "response content was None",
5959 )))
5960 }
5961 }
5962 Err(err) => Err(err),
5963 }
5964 }
5965
5966 pub async fn get_usage_top_avg_metrics_with_http_info(
5968 &self,
5969 params: GetUsageTopAvgMetricsOptionalParams,
5970 ) -> Result<
5971 datadog::ResponseContent<crate::datadogV1::model::UsageTopAvgMetricsResponse>,
5972 datadog::Error<GetUsageTopAvgMetricsError>,
5973 > {
5974 let local_configuration = &self.config;
5975 let operation_id = "v1.get_usage_top_avg_metrics";
5976
5977 let month = params.month;
5979 let day = params.day;
5980 let names = params.names;
5981 let limit = params.limit;
5982 let next_record_id = params.next_record_id;
5983
5984 let local_client = &self.client;
5985
5986 let local_uri_str = format!(
5987 "{}/api/v1/usage/top_avg_metrics",
5988 local_configuration.get_operation_host(operation_id)
5989 );
5990 let mut local_req_builder =
5991 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5992
5993 if let Some(ref local_query_param) = month {
5994 local_req_builder = local_req_builder.query(&[(
5995 "month",
5996 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
5997 )]);
5998 };
5999 if let Some(ref local_query_param) = day {
6000 local_req_builder = local_req_builder.query(&[(
6001 "day",
6002 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
6003 )]);
6004 };
6005 if let Some(ref local) = names {
6006 for param in local {
6007 local_req_builder = local_req_builder.query(&[("names", ¶m.to_string())]);
6008 }
6009 };
6010 if let Some(ref local_query_param) = limit {
6011 local_req_builder =
6012 local_req_builder.query(&[("limit", &local_query_param.to_string())]);
6013 };
6014 if let Some(ref local_query_param) = next_record_id {
6015 local_req_builder =
6016 local_req_builder.query(&[("next_record_id", &local_query_param.to_string())]);
6017 };
6018
6019 let mut headers = HeaderMap::new();
6021 headers.insert(
6022 "Accept",
6023 HeaderValue::from_static("application/json;datetime-format=rfc3339"),
6024 );
6025
6026 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
6028 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
6029 Err(e) => {
6030 log::warn!("Failed to parse user agent header: {e}, falling back to default");
6031 headers.insert(
6032 reqwest::header::USER_AGENT,
6033 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
6034 )
6035 }
6036 };
6037
6038 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
6040 headers.insert(
6041 "DD-API-KEY",
6042 HeaderValue::from_str(local_key.key.as_str())
6043 .expect("failed to parse DD-API-KEY header"),
6044 );
6045 };
6046 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
6047 headers.insert(
6048 "DD-APPLICATION-KEY",
6049 HeaderValue::from_str(local_key.key.as_str())
6050 .expect("failed to parse DD-APPLICATION-KEY header"),
6051 );
6052 };
6053
6054 local_req_builder = local_req_builder.headers(headers);
6055 let local_req = local_req_builder.build()?;
6056 log::debug!("request content: {:?}", local_req.body());
6057 let local_resp = local_client.execute(local_req).await?;
6058
6059 let local_status = local_resp.status();
6060 let local_content = local_resp.text().await?;
6061 log::debug!("response content: {}", local_content);
6062
6063 if !local_status.is_client_error() && !local_status.is_server_error() {
6064 match serde_json::from_str::<crate::datadogV1::model::UsageTopAvgMetricsResponse>(
6065 &local_content,
6066 ) {
6067 Ok(e) => {
6068 return Ok(datadog::ResponseContent {
6069 status: local_status,
6070 content: local_content,
6071 entity: Some(e),
6072 })
6073 }
6074 Err(e) => return Err(datadog::Error::Serde(e)),
6075 };
6076 } else {
6077 let local_entity: Option<GetUsageTopAvgMetricsError> =
6078 serde_json::from_str(&local_content).ok();
6079 let local_error = datadog::ResponseContent {
6080 status: local_status,
6081 content: local_content,
6082 entity: local_entity,
6083 };
6084 Err(datadog::Error::ResponseError(local_error))
6085 }
6086 }
6087}