1use crate::datadog;
5use async_stream::try_stream;
6use flate2::{
7 write::{GzEncoder, ZlibEncoder},
8 Compression,
9};
10use futures_core::stream::Stream;
11use log::warn;
12use reqwest::header::{HeaderMap, HeaderValue};
13use serde::{Deserialize, Serialize};
14use std::io::Write;
15
16#[non_exhaustive]
18#[derive(Clone, Default, Debug)]
19pub struct GetFindingOptionalParams {
20 pub snapshot_timestamp: Option<i64>,
22}
23
24impl GetFindingOptionalParams {
25 pub fn snapshot_timestamp(mut self, value: i64) -> Self {
27 self.snapshot_timestamp = Some(value);
28 self
29 }
30}
31
32#[non_exhaustive]
34#[derive(Clone, Default, Debug)]
35pub struct GetResourceEvaluationFiltersOptionalParams {
36 pub cloud_provider: Option<String>,
38 pub account_id: Option<String>,
40 pub skip_cache: Option<bool>,
42}
43
44impl GetResourceEvaluationFiltersOptionalParams {
45 pub fn cloud_provider(mut self, value: String) -> Self {
47 self.cloud_provider = Some(value);
48 self
49 }
50 pub fn account_id(mut self, value: String) -> Self {
52 self.account_id = Some(value);
53 self
54 }
55 pub fn skip_cache(mut self, value: bool) -> Self {
57 self.skip_cache = Some(value);
58 self
59 }
60}
61
62#[non_exhaustive]
64#[derive(Clone, Default, Debug)]
65pub struct GetRuleVersionHistoryOptionalParams {
66 pub page_size: Option<i64>,
68 pub page_number: Option<i64>,
70}
71
72impl GetRuleVersionHistoryOptionalParams {
73 pub fn page_size(mut self, value: i64) -> Self {
75 self.page_size = Some(value);
76 self
77 }
78 pub fn page_number(mut self, value: i64) -> Self {
80 self.page_number = Some(value);
81 self
82 }
83}
84
85#[non_exhaustive]
87#[derive(Clone, Default, Debug)]
88pub struct GetSBOMOptionalParams {
89 pub filter_repo_digest: Option<String>,
91}
92
93impl GetSBOMOptionalParams {
94 pub fn filter_repo_digest(mut self, value: String) -> Self {
96 self.filter_repo_digest = Some(value);
97 self
98 }
99}
100
101#[non_exhaustive]
103#[derive(Clone, Default, Debug)]
104pub struct GetSecurityMonitoringHistsignalsByJobIdOptionalParams {
105 pub filter_query: Option<String>,
107 pub filter_from: Option<chrono::DateTime<chrono::Utc>>,
109 pub filter_to: Option<chrono::DateTime<chrono::Utc>>,
111 pub sort: Option<crate::datadogV2::model::SecurityMonitoringSignalsSort>,
113 pub page_cursor: Option<String>,
115 pub page_limit: Option<i32>,
117}
118
119impl GetSecurityMonitoringHistsignalsByJobIdOptionalParams {
120 pub fn filter_query(mut self, value: String) -> Self {
122 self.filter_query = Some(value);
123 self
124 }
125 pub fn filter_from(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
127 self.filter_from = Some(value);
128 self
129 }
130 pub fn filter_to(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
132 self.filter_to = Some(value);
133 self
134 }
135 pub fn sort(mut self, value: crate::datadogV2::model::SecurityMonitoringSignalsSort) -> Self {
137 self.sort = Some(value);
138 self
139 }
140 pub fn page_cursor(mut self, value: String) -> Self {
142 self.page_cursor = Some(value);
143 self
144 }
145 pub fn page_limit(mut self, value: i32) -> Self {
147 self.page_limit = Some(value);
148 self
149 }
150}
151
152#[non_exhaustive]
154#[derive(Clone, Default, Debug)]
155pub struct ListAssetsSBOMsOptionalParams {
156 pub page_token: Option<String>,
158 pub page_number: Option<i64>,
160 pub filter_asset_type: Option<crate::datadogV2::model::AssetType>,
162 pub filter_asset_name: Option<String>,
164 pub filter_package_name: Option<String>,
166 pub filter_package_version: Option<String>,
168 pub filter_license_name: Option<String>,
170 pub filter_license_type: Option<crate::datadogV2::model::SBOMComponentLicenseType>,
172}
173
174impl ListAssetsSBOMsOptionalParams {
175 pub fn page_token(mut self, value: String) -> Self {
177 self.page_token = Some(value);
178 self
179 }
180 pub fn page_number(mut self, value: i64) -> Self {
182 self.page_number = Some(value);
183 self
184 }
185 pub fn filter_asset_type(mut self, value: crate::datadogV2::model::AssetType) -> Self {
187 self.filter_asset_type = Some(value);
188 self
189 }
190 pub fn filter_asset_name(mut self, value: String) -> Self {
192 self.filter_asset_name = Some(value);
193 self
194 }
195 pub fn filter_package_name(mut self, value: String) -> Self {
197 self.filter_package_name = Some(value);
198 self
199 }
200 pub fn filter_package_version(mut self, value: String) -> Self {
202 self.filter_package_version = Some(value);
203 self
204 }
205 pub fn filter_license_name(mut self, value: String) -> Self {
207 self.filter_license_name = Some(value);
208 self
209 }
210 pub fn filter_license_type(
212 mut self,
213 value: crate::datadogV2::model::SBOMComponentLicenseType,
214 ) -> Self {
215 self.filter_license_type = Some(value);
216 self
217 }
218}
219
220#[non_exhaustive]
222#[derive(Clone, Default, Debug)]
223pub struct ListFindingsOptionalParams {
224 pub page_limit: Option<i64>,
226 pub snapshot_timestamp: Option<i64>,
228 pub page_cursor: Option<String>,
230 pub filter_tags: Option<String>,
232 pub filter_evaluation_changed_at: Option<String>,
234 pub filter_muted: Option<bool>,
236 pub filter_rule_id: Option<String>,
238 pub filter_rule_name: Option<String>,
240 pub filter_resource_type: Option<String>,
242 pub filter_resource_id: Option<String>,
244 pub filter_discovery_timestamp: Option<String>,
246 pub filter_evaluation: Option<crate::datadogV2::model::FindingEvaluation>,
248 pub filter_status: Option<crate::datadogV2::model::FindingStatus>,
250 pub filter_vulnerability_type: Option<Vec<crate::datadogV2::model::FindingVulnerabilityType>>,
252 pub detailed_findings: Option<bool>,
254}
255
256impl ListFindingsOptionalParams {
257 pub fn page_limit(mut self, value: i64) -> Self {
259 self.page_limit = Some(value);
260 self
261 }
262 pub fn snapshot_timestamp(mut self, value: i64) -> Self {
264 self.snapshot_timestamp = Some(value);
265 self
266 }
267 pub fn page_cursor(mut self, value: String) -> Self {
269 self.page_cursor = Some(value);
270 self
271 }
272 pub fn filter_tags(mut self, value: String) -> Self {
274 self.filter_tags = Some(value);
275 self
276 }
277 pub fn filter_evaluation_changed_at(mut self, value: String) -> Self {
279 self.filter_evaluation_changed_at = Some(value);
280 self
281 }
282 pub fn filter_muted(mut self, value: bool) -> Self {
284 self.filter_muted = Some(value);
285 self
286 }
287 pub fn filter_rule_id(mut self, value: String) -> Self {
289 self.filter_rule_id = Some(value);
290 self
291 }
292 pub fn filter_rule_name(mut self, value: String) -> Self {
294 self.filter_rule_name = Some(value);
295 self
296 }
297 pub fn filter_resource_type(mut self, value: String) -> Self {
299 self.filter_resource_type = Some(value);
300 self
301 }
302 pub fn filter_resource_id(mut self, value: String) -> Self {
304 self.filter_resource_id = Some(value);
305 self
306 }
307 pub fn filter_discovery_timestamp(mut self, value: String) -> Self {
309 self.filter_discovery_timestamp = Some(value);
310 self
311 }
312 pub fn filter_evaluation(mut self, value: crate::datadogV2::model::FindingEvaluation) -> Self {
314 self.filter_evaluation = Some(value);
315 self
316 }
317 pub fn filter_status(mut self, value: crate::datadogV2::model::FindingStatus) -> Self {
319 self.filter_status = Some(value);
320 self
321 }
322 pub fn filter_vulnerability_type(
324 mut self,
325 value: Vec<crate::datadogV2::model::FindingVulnerabilityType>,
326 ) -> Self {
327 self.filter_vulnerability_type = Some(value);
328 self
329 }
330 pub fn detailed_findings(mut self, value: bool) -> Self {
332 self.detailed_findings = Some(value);
333 self
334 }
335}
336
337#[non_exhaustive]
339#[derive(Clone, Default, Debug)]
340pub struct ListHistoricalJobsOptionalParams {
341 pub page_size: Option<i64>,
343 pub page_number: Option<i64>,
345 pub sort: Option<String>,
347 pub filter_query: Option<String>,
349}
350
351impl ListHistoricalJobsOptionalParams {
352 pub fn page_size(mut self, value: i64) -> Self {
354 self.page_size = Some(value);
355 self
356 }
357 pub fn page_number(mut self, value: i64) -> Self {
359 self.page_number = Some(value);
360 self
361 }
362 pub fn sort(mut self, value: String) -> Self {
364 self.sort = Some(value);
365 self
366 }
367 pub fn filter_query(mut self, value: String) -> Self {
369 self.filter_query = Some(value);
370 self
371 }
372}
373
374#[non_exhaustive]
376#[derive(Clone, Default, Debug)]
377pub struct ListSecurityMonitoringHistsignalsOptionalParams {
378 pub filter_query: Option<String>,
380 pub filter_from: Option<chrono::DateTime<chrono::Utc>>,
382 pub filter_to: Option<chrono::DateTime<chrono::Utc>>,
384 pub sort: Option<crate::datadogV2::model::SecurityMonitoringSignalsSort>,
386 pub page_cursor: Option<String>,
388 pub page_limit: Option<i32>,
390}
391
392impl ListSecurityMonitoringHistsignalsOptionalParams {
393 pub fn filter_query(mut self, value: String) -> Self {
395 self.filter_query = Some(value);
396 self
397 }
398 pub fn filter_from(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
400 self.filter_from = Some(value);
401 self
402 }
403 pub fn filter_to(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
405 self.filter_to = Some(value);
406 self
407 }
408 pub fn sort(mut self, value: crate::datadogV2::model::SecurityMonitoringSignalsSort) -> Self {
410 self.sort = Some(value);
411 self
412 }
413 pub fn page_cursor(mut self, value: String) -> Self {
415 self.page_cursor = Some(value);
416 self
417 }
418 pub fn page_limit(mut self, value: i32) -> Self {
420 self.page_limit = Some(value);
421 self
422 }
423}
424
425#[non_exhaustive]
427#[derive(Clone, Default, Debug)]
428pub struct ListSecurityMonitoringRulesOptionalParams {
429 pub page_size: Option<i64>,
431 pub page_number: Option<i64>,
433}
434
435impl ListSecurityMonitoringRulesOptionalParams {
436 pub fn page_size(mut self, value: i64) -> Self {
438 self.page_size = Some(value);
439 self
440 }
441 pub fn page_number(mut self, value: i64) -> Self {
443 self.page_number = Some(value);
444 self
445 }
446}
447
448#[non_exhaustive]
450#[derive(Clone, Default, Debug)]
451pub struct ListSecurityMonitoringSignalsOptionalParams {
452 pub filter_query: Option<String>,
454 pub filter_from: Option<chrono::DateTime<chrono::Utc>>,
456 pub filter_to: Option<chrono::DateTime<chrono::Utc>>,
458 pub sort: Option<crate::datadogV2::model::SecurityMonitoringSignalsSort>,
460 pub page_cursor: Option<String>,
462 pub page_limit: Option<i32>,
464}
465
466impl ListSecurityMonitoringSignalsOptionalParams {
467 pub fn filter_query(mut self, value: String) -> Self {
469 self.filter_query = Some(value);
470 self
471 }
472 pub fn filter_from(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
474 self.filter_from = Some(value);
475 self
476 }
477 pub fn filter_to(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
479 self.filter_to = Some(value);
480 self
481 }
482 pub fn sort(mut self, value: crate::datadogV2::model::SecurityMonitoringSignalsSort) -> Self {
484 self.sort = Some(value);
485 self
486 }
487 pub fn page_cursor(mut self, value: String) -> Self {
489 self.page_cursor = Some(value);
490 self
491 }
492 pub fn page_limit(mut self, value: i32) -> Self {
494 self.page_limit = Some(value);
495 self
496 }
497}
498
499#[non_exhaustive]
501#[derive(Clone, Default, Debug)]
502pub struct ListVulnerabilitiesOptionalParams {
503 pub page_token: Option<String>,
505 pub page_number: Option<i64>,
507 pub filter_type: Option<crate::datadogV2::model::VulnerabilityType>,
509 pub filter_cvss_base_score_op: Option<f64>,
511 pub filter_cvss_base_severity: Option<crate::datadogV2::model::VulnerabilitySeverity>,
513 pub filter_cvss_base_vector: Option<String>,
515 pub filter_cvss_datadog_score_op: Option<f64>,
517 pub filter_cvss_datadog_severity: Option<crate::datadogV2::model::VulnerabilitySeverity>,
519 pub filter_cvss_datadog_vector: Option<String>,
521 pub filter_status: Option<crate::datadogV2::model::VulnerabilityStatus>,
523 pub filter_tool: Option<crate::datadogV2::model::VulnerabilityTool>,
525 pub filter_library_name: Option<String>,
527 pub filter_library_version: Option<String>,
529 pub filter_advisory_id: Option<String>,
531 pub filter_risks_exploitation_probability: Option<bool>,
533 pub filter_risks_poc_exploit_available: Option<bool>,
535 pub filter_risks_exploit_available: Option<bool>,
537 pub filter_risks_epss_score_op: Option<f64>,
539 pub filter_risks_epss_severity: Option<crate::datadogV2::model::VulnerabilitySeverity>,
541 pub filter_language: Option<String>,
543 pub filter_ecosystem: Option<crate::datadogV2::model::VulnerabilityEcosystem>,
545 pub filter_code_location_location: Option<String>,
547 pub filter_code_location_file_path: Option<String>,
549 pub filter_code_location_method: Option<String>,
551 pub filter_fix_available: Option<bool>,
553 pub filter_repo_digests: Option<String>,
555 pub filter_origin: Option<String>,
557 pub filter_asset_name: Option<String>,
559 pub filter_asset_type: Option<crate::datadogV2::model::AssetType>,
561 pub filter_asset_version_first: Option<String>,
563 pub filter_asset_version_last: Option<String>,
565 pub filter_asset_repository_url: Option<String>,
567 pub filter_asset_risks_in_production: Option<bool>,
569 pub filter_asset_risks_under_attack: Option<bool>,
571 pub filter_asset_risks_is_publicly_accessible: Option<bool>,
573 pub filter_asset_risks_has_privileged_access: Option<bool>,
575 pub filter_asset_risks_has_access_to_sensitive_data: Option<bool>,
577 pub filter_asset_environments: Option<String>,
579 pub filter_asset_teams: Option<String>,
581 pub filter_asset_arch: Option<String>,
583 pub filter_asset_operating_system_name: Option<String>,
585 pub filter_asset_operating_system_version: Option<String>,
587}
588
589impl ListVulnerabilitiesOptionalParams {
590 pub fn page_token(mut self, value: String) -> Self {
592 self.page_token = Some(value);
593 self
594 }
595 pub fn page_number(mut self, value: i64) -> Self {
597 self.page_number = Some(value);
598 self
599 }
600 pub fn filter_type(mut self, value: crate::datadogV2::model::VulnerabilityType) -> Self {
602 self.filter_type = Some(value);
603 self
604 }
605 pub fn filter_cvss_base_score_op(mut self, value: f64) -> Self {
607 self.filter_cvss_base_score_op = Some(value);
608 self
609 }
610 pub fn filter_cvss_base_severity(
612 mut self,
613 value: crate::datadogV2::model::VulnerabilitySeverity,
614 ) -> Self {
615 self.filter_cvss_base_severity = Some(value);
616 self
617 }
618 pub fn filter_cvss_base_vector(mut self, value: String) -> Self {
620 self.filter_cvss_base_vector = Some(value);
621 self
622 }
623 pub fn filter_cvss_datadog_score_op(mut self, value: f64) -> Self {
625 self.filter_cvss_datadog_score_op = Some(value);
626 self
627 }
628 pub fn filter_cvss_datadog_severity(
630 mut self,
631 value: crate::datadogV2::model::VulnerabilitySeverity,
632 ) -> Self {
633 self.filter_cvss_datadog_severity = Some(value);
634 self
635 }
636 pub fn filter_cvss_datadog_vector(mut self, value: String) -> Self {
638 self.filter_cvss_datadog_vector = Some(value);
639 self
640 }
641 pub fn filter_status(mut self, value: crate::datadogV2::model::VulnerabilityStatus) -> Self {
643 self.filter_status = Some(value);
644 self
645 }
646 pub fn filter_tool(mut self, value: crate::datadogV2::model::VulnerabilityTool) -> Self {
648 self.filter_tool = Some(value);
649 self
650 }
651 pub fn filter_library_name(mut self, value: String) -> Self {
653 self.filter_library_name = Some(value);
654 self
655 }
656 pub fn filter_library_version(mut self, value: String) -> Self {
658 self.filter_library_version = Some(value);
659 self
660 }
661 pub fn filter_advisory_id(mut self, value: String) -> Self {
663 self.filter_advisory_id = Some(value);
664 self
665 }
666 pub fn filter_risks_exploitation_probability(mut self, value: bool) -> Self {
668 self.filter_risks_exploitation_probability = Some(value);
669 self
670 }
671 pub fn filter_risks_poc_exploit_available(mut self, value: bool) -> Self {
673 self.filter_risks_poc_exploit_available = Some(value);
674 self
675 }
676 pub fn filter_risks_exploit_available(mut self, value: bool) -> Self {
678 self.filter_risks_exploit_available = Some(value);
679 self
680 }
681 pub fn filter_risks_epss_score_op(mut self, value: f64) -> Self {
683 self.filter_risks_epss_score_op = Some(value);
684 self
685 }
686 pub fn filter_risks_epss_severity(
688 mut self,
689 value: crate::datadogV2::model::VulnerabilitySeverity,
690 ) -> Self {
691 self.filter_risks_epss_severity = Some(value);
692 self
693 }
694 pub fn filter_language(mut self, value: String) -> Self {
696 self.filter_language = Some(value);
697 self
698 }
699 pub fn filter_ecosystem(
701 mut self,
702 value: crate::datadogV2::model::VulnerabilityEcosystem,
703 ) -> Self {
704 self.filter_ecosystem = Some(value);
705 self
706 }
707 pub fn filter_code_location_location(mut self, value: String) -> Self {
709 self.filter_code_location_location = Some(value);
710 self
711 }
712 pub fn filter_code_location_file_path(mut self, value: String) -> Self {
714 self.filter_code_location_file_path = Some(value);
715 self
716 }
717 pub fn filter_code_location_method(mut self, value: String) -> Self {
719 self.filter_code_location_method = Some(value);
720 self
721 }
722 pub fn filter_fix_available(mut self, value: bool) -> Self {
724 self.filter_fix_available = Some(value);
725 self
726 }
727 pub fn filter_repo_digests(mut self, value: String) -> Self {
729 self.filter_repo_digests = Some(value);
730 self
731 }
732 pub fn filter_origin(mut self, value: String) -> Self {
734 self.filter_origin = Some(value);
735 self
736 }
737 pub fn filter_asset_name(mut self, value: String) -> Self {
739 self.filter_asset_name = Some(value);
740 self
741 }
742 pub fn filter_asset_type(mut self, value: crate::datadogV2::model::AssetType) -> Self {
744 self.filter_asset_type = Some(value);
745 self
746 }
747 pub fn filter_asset_version_first(mut self, value: String) -> Self {
749 self.filter_asset_version_first = Some(value);
750 self
751 }
752 pub fn filter_asset_version_last(mut self, value: String) -> Self {
754 self.filter_asset_version_last = Some(value);
755 self
756 }
757 pub fn filter_asset_repository_url(mut self, value: String) -> Self {
759 self.filter_asset_repository_url = Some(value);
760 self
761 }
762 pub fn filter_asset_risks_in_production(mut self, value: bool) -> Self {
764 self.filter_asset_risks_in_production = Some(value);
765 self
766 }
767 pub fn filter_asset_risks_under_attack(mut self, value: bool) -> Self {
769 self.filter_asset_risks_under_attack = Some(value);
770 self
771 }
772 pub fn filter_asset_risks_is_publicly_accessible(mut self, value: bool) -> Self {
774 self.filter_asset_risks_is_publicly_accessible = Some(value);
775 self
776 }
777 pub fn filter_asset_risks_has_privileged_access(mut self, value: bool) -> Self {
779 self.filter_asset_risks_has_privileged_access = Some(value);
780 self
781 }
782 pub fn filter_asset_risks_has_access_to_sensitive_data(mut self, value: bool) -> Self {
784 self.filter_asset_risks_has_access_to_sensitive_data = Some(value);
785 self
786 }
787 pub fn filter_asset_environments(mut self, value: String) -> Self {
789 self.filter_asset_environments = Some(value);
790 self
791 }
792 pub fn filter_asset_teams(mut self, value: String) -> Self {
794 self.filter_asset_teams = Some(value);
795 self
796 }
797 pub fn filter_asset_arch(mut self, value: String) -> Self {
799 self.filter_asset_arch = Some(value);
800 self
801 }
802 pub fn filter_asset_operating_system_name(mut self, value: String) -> Self {
804 self.filter_asset_operating_system_name = Some(value);
805 self
806 }
807 pub fn filter_asset_operating_system_version(mut self, value: String) -> Self {
809 self.filter_asset_operating_system_version = Some(value);
810 self
811 }
812}
813
814#[non_exhaustive]
816#[derive(Clone, Default, Debug)]
817pub struct ListVulnerableAssetsOptionalParams {
818 pub page_token: Option<String>,
820 pub page_number: Option<i64>,
822 pub filter_name: Option<String>,
824 pub filter_type: Option<crate::datadogV2::model::AssetType>,
826 pub filter_version_first: Option<String>,
828 pub filter_version_last: Option<String>,
830 pub filter_repository_url: Option<String>,
832 pub filter_risks_in_production: Option<bool>,
834 pub filter_risks_under_attack: Option<bool>,
836 pub filter_risks_is_publicly_accessible: Option<bool>,
838 pub filter_risks_has_privileged_access: Option<bool>,
840 pub filter_risks_has_access_to_sensitive_data: Option<bool>,
842 pub filter_environments: Option<String>,
844 pub filter_teams: Option<String>,
846 pub filter_arch: Option<String>,
848 pub filter_operating_system_name: Option<String>,
850 pub filter_operating_system_version: Option<String>,
852}
853
854impl ListVulnerableAssetsOptionalParams {
855 pub fn page_token(mut self, value: String) -> Self {
857 self.page_token = Some(value);
858 self
859 }
860 pub fn page_number(mut self, value: i64) -> Self {
862 self.page_number = Some(value);
863 self
864 }
865 pub fn filter_name(mut self, value: String) -> Self {
867 self.filter_name = Some(value);
868 self
869 }
870 pub fn filter_type(mut self, value: crate::datadogV2::model::AssetType) -> Self {
872 self.filter_type = Some(value);
873 self
874 }
875 pub fn filter_version_first(mut self, value: String) -> Self {
877 self.filter_version_first = Some(value);
878 self
879 }
880 pub fn filter_version_last(mut self, value: String) -> Self {
882 self.filter_version_last = Some(value);
883 self
884 }
885 pub fn filter_repository_url(mut self, value: String) -> Self {
887 self.filter_repository_url = Some(value);
888 self
889 }
890 pub fn filter_risks_in_production(mut self, value: bool) -> Self {
892 self.filter_risks_in_production = Some(value);
893 self
894 }
895 pub fn filter_risks_under_attack(mut self, value: bool) -> Self {
897 self.filter_risks_under_attack = Some(value);
898 self
899 }
900 pub fn filter_risks_is_publicly_accessible(mut self, value: bool) -> Self {
902 self.filter_risks_is_publicly_accessible = Some(value);
903 self
904 }
905 pub fn filter_risks_has_privileged_access(mut self, value: bool) -> Self {
907 self.filter_risks_has_privileged_access = Some(value);
908 self
909 }
910 pub fn filter_risks_has_access_to_sensitive_data(mut self, value: bool) -> Self {
912 self.filter_risks_has_access_to_sensitive_data = Some(value);
913 self
914 }
915 pub fn filter_environments(mut self, value: String) -> Self {
917 self.filter_environments = Some(value);
918 self
919 }
920 pub fn filter_teams(mut self, value: String) -> Self {
922 self.filter_teams = Some(value);
923 self
924 }
925 pub fn filter_arch(mut self, value: String) -> Self {
927 self.filter_arch = Some(value);
928 self
929 }
930 pub fn filter_operating_system_name(mut self, value: String) -> Self {
932 self.filter_operating_system_name = Some(value);
933 self
934 }
935 pub fn filter_operating_system_version(mut self, value: String) -> Self {
937 self.filter_operating_system_version = Some(value);
938 self
939 }
940}
941
942#[non_exhaustive]
944#[derive(Clone, Default, Debug)]
945pub struct SearchSecurityMonitoringHistsignalsOptionalParams {
946 pub body: Option<crate::datadogV2::model::SecurityMonitoringSignalListRequest>,
947}
948
949impl SearchSecurityMonitoringHistsignalsOptionalParams {
950 pub fn body(
951 mut self,
952 value: crate::datadogV2::model::SecurityMonitoringSignalListRequest,
953 ) -> Self {
954 self.body = Some(value);
955 self
956 }
957}
958
959#[non_exhaustive]
961#[derive(Clone, Default, Debug)]
962pub struct SearchSecurityMonitoringSignalsOptionalParams {
963 pub body: Option<crate::datadogV2::model::SecurityMonitoringSignalListRequest>,
964}
965
966impl SearchSecurityMonitoringSignalsOptionalParams {
967 pub fn body(
968 mut self,
969 value: crate::datadogV2::model::SecurityMonitoringSignalListRequest,
970 ) -> Self {
971 self.body = Some(value);
972 self
973 }
974}
975
976#[derive(Debug, Clone, Serialize, Deserialize)]
978#[serde(untagged)]
979pub enum CancelHistoricalJobError {
980 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
981 UnknownValue(serde_json::Value),
982}
983
984#[derive(Debug, Clone, Serialize, Deserialize)]
986#[serde(untagged)]
987pub enum ConvertExistingSecurityMonitoringRuleError {
988 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
989 UnknownValue(serde_json::Value),
990}
991
992#[derive(Debug, Clone, Serialize, Deserialize)]
994#[serde(untagged)]
995pub enum ConvertJobResultToSignalError {
996 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
997 UnknownValue(serde_json::Value),
998}
999
1000#[derive(Debug, Clone, Serialize, Deserialize)]
1002#[serde(untagged)]
1003pub enum ConvertSecurityMonitoringRuleFromJSONToTerraformError {
1004 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1005 UnknownValue(serde_json::Value),
1006}
1007
1008#[derive(Debug, Clone, Serialize, Deserialize)]
1010#[serde(untagged)]
1011pub enum CreateCustomFrameworkError {
1012 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1013 UnknownValue(serde_json::Value),
1014}
1015
1016#[derive(Debug, Clone, Serialize, Deserialize)]
1018#[serde(untagged)]
1019pub enum CreateSecurityFilterError {
1020 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1021 UnknownValue(serde_json::Value),
1022}
1023
1024#[derive(Debug, Clone, Serialize, Deserialize)]
1026#[serde(untagged)]
1027pub enum CreateSecurityMonitoringRuleError {
1028 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1029 UnknownValue(serde_json::Value),
1030}
1031
1032#[derive(Debug, Clone, Serialize, Deserialize)]
1034#[serde(untagged)]
1035pub enum CreateSecurityMonitoringSuppressionError {
1036 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1037 UnknownValue(serde_json::Value),
1038}
1039
1040#[derive(Debug, Clone, Serialize, Deserialize)]
1042#[serde(untagged)]
1043pub enum CreateSignalNotificationRuleError {
1044 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1045 UnknownValue(serde_json::Value),
1046}
1047
1048#[derive(Debug, Clone, Serialize, Deserialize)]
1050#[serde(untagged)]
1051pub enum CreateVulnerabilityNotificationRuleError {
1052 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1053 UnknownValue(serde_json::Value),
1054}
1055
1056#[derive(Debug, Clone, Serialize, Deserialize)]
1058#[serde(untagged)]
1059pub enum DeleteCustomFrameworkError {
1060 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1061 UnknownValue(serde_json::Value),
1062}
1063
1064#[derive(Debug, Clone, Serialize, Deserialize)]
1066#[serde(untagged)]
1067pub enum DeleteHistoricalJobError {
1068 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1069 UnknownValue(serde_json::Value),
1070}
1071
1072#[derive(Debug, Clone, Serialize, Deserialize)]
1074#[serde(untagged)]
1075pub enum DeleteSecurityFilterError {
1076 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1077 UnknownValue(serde_json::Value),
1078}
1079
1080#[derive(Debug, Clone, Serialize, Deserialize)]
1082#[serde(untagged)]
1083pub enum DeleteSecurityMonitoringRuleError {
1084 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1085 UnknownValue(serde_json::Value),
1086}
1087
1088#[derive(Debug, Clone, Serialize, Deserialize)]
1090#[serde(untagged)]
1091pub enum DeleteSecurityMonitoringSuppressionError {
1092 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1093 UnknownValue(serde_json::Value),
1094}
1095
1096#[derive(Debug, Clone, Serialize, Deserialize)]
1098#[serde(untagged)]
1099pub enum DeleteSignalNotificationRuleError {
1100 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1101 UnknownValue(serde_json::Value),
1102}
1103
1104#[derive(Debug, Clone, Serialize, Deserialize)]
1106#[serde(untagged)]
1107pub enum DeleteVulnerabilityNotificationRuleError {
1108 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1109 UnknownValue(serde_json::Value),
1110}
1111
1112#[derive(Debug, Clone, Serialize, Deserialize)]
1114#[serde(untagged)]
1115pub enum EditSecurityMonitoringSignalAssigneeError {
1116 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1117 UnknownValue(serde_json::Value),
1118}
1119
1120#[derive(Debug, Clone, Serialize, Deserialize)]
1122#[serde(untagged)]
1123pub enum EditSecurityMonitoringSignalIncidentsError {
1124 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1125 UnknownValue(serde_json::Value),
1126}
1127
1128#[derive(Debug, Clone, Serialize, Deserialize)]
1130#[serde(untagged)]
1131pub enum EditSecurityMonitoringSignalStateError {
1132 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1133 UnknownValue(serde_json::Value),
1134}
1135
1136#[derive(Debug, Clone, Serialize, Deserialize)]
1138#[serde(untagged)]
1139pub enum GetCustomFrameworkError {
1140 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1141 UnknownValue(serde_json::Value),
1142}
1143
1144#[derive(Debug, Clone, Serialize, Deserialize)]
1146#[serde(untagged)]
1147pub enum GetFindingError {
1148 JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
1149 UnknownValue(serde_json::Value),
1150}
1151
1152#[derive(Debug, Clone, Serialize, Deserialize)]
1154#[serde(untagged)]
1155pub enum GetHistoricalJobError {
1156 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1157 UnknownValue(serde_json::Value),
1158}
1159
1160#[derive(Debug, Clone, Serialize, Deserialize)]
1162#[serde(untagged)]
1163pub enum GetResourceEvaluationFiltersError {
1164 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1165 UnknownValue(serde_json::Value),
1166}
1167
1168#[derive(Debug, Clone, Serialize, Deserialize)]
1170#[serde(untagged)]
1171pub enum GetRuleVersionHistoryError {
1172 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1173 UnknownValue(serde_json::Value),
1174}
1175
1176#[derive(Debug, Clone, Serialize, Deserialize)]
1178#[serde(untagged)]
1179pub enum GetSBOMError {
1180 JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
1181 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1182 UnknownValue(serde_json::Value),
1183}
1184
1185#[derive(Debug, Clone, Serialize, Deserialize)]
1187#[serde(untagged)]
1188pub enum GetSecurityFilterError {
1189 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1190 UnknownValue(serde_json::Value),
1191}
1192
1193#[derive(Debug, Clone, Serialize, Deserialize)]
1195#[serde(untagged)]
1196pub enum GetSecurityMonitoringHistsignalError {
1197 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1198 UnknownValue(serde_json::Value),
1199}
1200
1201#[derive(Debug, Clone, Serialize, Deserialize)]
1203#[serde(untagged)]
1204pub enum GetSecurityMonitoringHistsignalsByJobIdError {
1205 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1206 UnknownValue(serde_json::Value),
1207}
1208
1209#[derive(Debug, Clone, Serialize, Deserialize)]
1211#[serde(untagged)]
1212pub enum GetSecurityMonitoringRuleError {
1213 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1214 UnknownValue(serde_json::Value),
1215}
1216
1217#[derive(Debug, Clone, Serialize, Deserialize)]
1219#[serde(untagged)]
1220pub enum GetSecurityMonitoringSignalError {
1221 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1222 UnknownValue(serde_json::Value),
1223}
1224
1225#[derive(Debug, Clone, Serialize, Deserialize)]
1227#[serde(untagged)]
1228pub enum GetSecurityMonitoringSuppressionError {
1229 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1230 UnknownValue(serde_json::Value),
1231}
1232
1233#[derive(Debug, Clone, Serialize, Deserialize)]
1235#[serde(untagged)]
1236pub enum GetSignalNotificationRuleError {
1237 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1238 UnknownValue(serde_json::Value),
1239}
1240
1241#[derive(Debug, Clone, Serialize, Deserialize)]
1243#[serde(untagged)]
1244pub enum GetSignalNotificationRulesError {
1245 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1246 UnknownValue(serde_json::Value),
1247}
1248
1249#[derive(Debug, Clone, Serialize, Deserialize)]
1251#[serde(untagged)]
1252pub enum GetSuppressionsAffectingFutureRuleError {
1253 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1254 UnknownValue(serde_json::Value),
1255}
1256
1257#[derive(Debug, Clone, Serialize, Deserialize)]
1259#[serde(untagged)]
1260pub enum GetSuppressionsAffectingRuleError {
1261 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1262 UnknownValue(serde_json::Value),
1263}
1264
1265#[derive(Debug, Clone, Serialize, Deserialize)]
1267#[serde(untagged)]
1268pub enum GetVulnerabilityNotificationRuleError {
1269 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1270 UnknownValue(serde_json::Value),
1271}
1272
1273#[derive(Debug, Clone, Serialize, Deserialize)]
1275#[serde(untagged)]
1276pub enum GetVulnerabilityNotificationRulesError {
1277 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1278 UnknownValue(serde_json::Value),
1279}
1280
1281#[derive(Debug, Clone, Serialize, Deserialize)]
1283#[serde(untagged)]
1284pub enum ListAssetsSBOMsError {
1285 JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
1286 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1287 UnknownValue(serde_json::Value),
1288}
1289
1290#[derive(Debug, Clone, Serialize, Deserialize)]
1292#[serde(untagged)]
1293pub enum ListFindingsError {
1294 JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
1295 UnknownValue(serde_json::Value),
1296}
1297
1298#[derive(Debug, Clone, Serialize, Deserialize)]
1300#[serde(untagged)]
1301pub enum ListHistoricalJobsError {
1302 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1303 UnknownValue(serde_json::Value),
1304}
1305
1306#[derive(Debug, Clone, Serialize, Deserialize)]
1308#[serde(untagged)]
1309pub enum ListSecurityFiltersError {
1310 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1311 UnknownValue(serde_json::Value),
1312}
1313
1314#[derive(Debug, Clone, Serialize, Deserialize)]
1316#[serde(untagged)]
1317pub enum ListSecurityMonitoringHistsignalsError {
1318 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1319 UnknownValue(serde_json::Value),
1320}
1321
1322#[derive(Debug, Clone, Serialize, Deserialize)]
1324#[serde(untagged)]
1325pub enum ListSecurityMonitoringRulesError {
1326 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1327 UnknownValue(serde_json::Value),
1328}
1329
1330#[derive(Debug, Clone, Serialize, Deserialize)]
1332#[serde(untagged)]
1333pub enum ListSecurityMonitoringSignalsError {
1334 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1335 UnknownValue(serde_json::Value),
1336}
1337
1338#[derive(Debug, Clone, Serialize, Deserialize)]
1340#[serde(untagged)]
1341pub enum ListSecurityMonitoringSuppressionsError {
1342 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1343 UnknownValue(serde_json::Value),
1344}
1345
1346#[derive(Debug, Clone, Serialize, Deserialize)]
1348#[serde(untagged)]
1349pub enum ListVulnerabilitiesError {
1350 JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
1351 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1352 UnknownValue(serde_json::Value),
1353}
1354
1355#[derive(Debug, Clone, Serialize, Deserialize)]
1357#[serde(untagged)]
1358pub enum ListVulnerableAssetsError {
1359 JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
1360 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1361 UnknownValue(serde_json::Value),
1362}
1363
1364#[derive(Debug, Clone, Serialize, Deserialize)]
1366#[serde(untagged)]
1367pub enum MuteFindingsError {
1368 JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
1369 UnknownValue(serde_json::Value),
1370}
1371
1372#[derive(Debug, Clone, Serialize, Deserialize)]
1374#[serde(untagged)]
1375pub enum PatchSignalNotificationRuleError {
1376 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1377 JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
1378 UnknownValue(serde_json::Value),
1379}
1380
1381#[derive(Debug, Clone, Serialize, Deserialize)]
1383#[serde(untagged)]
1384pub enum PatchVulnerabilityNotificationRuleError {
1385 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1386 JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
1387 UnknownValue(serde_json::Value),
1388}
1389
1390#[derive(Debug, Clone, Serialize, Deserialize)]
1392#[serde(untagged)]
1393pub enum RunHistoricalJobError {
1394 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1395 UnknownValue(serde_json::Value),
1396}
1397
1398#[derive(Debug, Clone, Serialize, Deserialize)]
1400#[serde(untagged)]
1401pub enum SearchSecurityMonitoringHistsignalsError {
1402 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1403 UnknownValue(serde_json::Value),
1404}
1405
1406#[derive(Debug, Clone, Serialize, Deserialize)]
1408#[serde(untagged)]
1409pub enum SearchSecurityMonitoringSignalsError {
1410 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1411 UnknownValue(serde_json::Value),
1412}
1413
1414#[derive(Debug, Clone, Serialize, Deserialize)]
1416#[serde(untagged)]
1417pub enum TestExistingSecurityMonitoringRuleError {
1418 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1419 UnknownValue(serde_json::Value),
1420}
1421
1422#[derive(Debug, Clone, Serialize, Deserialize)]
1424#[serde(untagged)]
1425pub enum TestSecurityMonitoringRuleError {
1426 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1427 UnknownValue(serde_json::Value),
1428}
1429
1430#[derive(Debug, Clone, Serialize, Deserialize)]
1432#[serde(untagged)]
1433pub enum UpdateCustomFrameworkError {
1434 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1435 UnknownValue(serde_json::Value),
1436}
1437
1438#[derive(Debug, Clone, Serialize, Deserialize)]
1440#[serde(untagged)]
1441pub enum UpdateResourceEvaluationFiltersError {
1442 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1443 UnknownValue(serde_json::Value),
1444}
1445
1446#[derive(Debug, Clone, Serialize, Deserialize)]
1448#[serde(untagged)]
1449pub enum UpdateSecurityFilterError {
1450 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1451 UnknownValue(serde_json::Value),
1452}
1453
1454#[derive(Debug, Clone, Serialize, Deserialize)]
1456#[serde(untagged)]
1457pub enum UpdateSecurityMonitoringRuleError {
1458 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1459 UnknownValue(serde_json::Value),
1460}
1461
1462#[derive(Debug, Clone, Serialize, Deserialize)]
1464#[serde(untagged)]
1465pub enum UpdateSecurityMonitoringSuppressionError {
1466 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1467 UnknownValue(serde_json::Value),
1468}
1469
1470#[derive(Debug, Clone, Serialize, Deserialize)]
1472#[serde(untagged)]
1473pub enum ValidateSecurityMonitoringRuleError {
1474 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1475 UnknownValue(serde_json::Value),
1476}
1477
1478#[derive(Debug, Clone, Serialize, Deserialize)]
1480#[serde(untagged)]
1481pub enum ValidateSecurityMonitoringSuppressionError {
1482 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1483 UnknownValue(serde_json::Value),
1484}
1485
1486#[derive(Debug, Clone)]
1488pub struct SecurityMonitoringAPI {
1489 config: datadog::Configuration,
1490 client: reqwest_middleware::ClientWithMiddleware,
1491}
1492
1493impl Default for SecurityMonitoringAPI {
1494 fn default() -> Self {
1495 Self::with_config(datadog::Configuration::default())
1496 }
1497}
1498
1499impl SecurityMonitoringAPI {
1500 pub fn new() -> Self {
1501 Self::default()
1502 }
1503 pub fn with_config(config: datadog::Configuration) -> Self {
1504 let mut reqwest_client_builder = reqwest::Client::builder();
1505
1506 if let Some(proxy_url) = &config.proxy_url {
1507 let proxy = reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL");
1508 reqwest_client_builder = reqwest_client_builder.proxy(proxy);
1509 }
1510
1511 let mut middleware_client_builder =
1512 reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap());
1513
1514 if config.enable_retry {
1515 struct RetryableStatus;
1516 impl reqwest_retry::RetryableStrategy for RetryableStatus {
1517 fn handle(
1518 &self,
1519 res: &Result<reqwest::Response, reqwest_middleware::Error>,
1520 ) -> Option<reqwest_retry::Retryable> {
1521 match res {
1522 Ok(success) => reqwest_retry::default_on_request_success(success),
1523 Err(_) => None,
1524 }
1525 }
1526 }
1527 let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder()
1528 .build_with_max_retries(config.max_retries);
1529
1530 let retry_middleware =
1531 reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy(
1532 backoff_policy,
1533 RetryableStatus,
1534 );
1535
1536 middleware_client_builder = middleware_client_builder.with(retry_middleware);
1537 }
1538
1539 let client = middleware_client_builder.build();
1540
1541 Self { config, client }
1542 }
1543
1544 pub fn with_client_and_config(
1545 config: datadog::Configuration,
1546 client: reqwest_middleware::ClientWithMiddleware,
1547 ) -> Self {
1548 Self { config, client }
1549 }
1550
1551 pub async fn cancel_historical_job(
1553 &self,
1554 job_id: String,
1555 ) -> Result<(), datadog::Error<CancelHistoricalJobError>> {
1556 match self.cancel_historical_job_with_http_info(job_id).await {
1557 Ok(_) => Ok(()),
1558 Err(err) => Err(err),
1559 }
1560 }
1561
1562 pub async fn cancel_historical_job_with_http_info(
1564 &self,
1565 job_id: String,
1566 ) -> Result<datadog::ResponseContent<()>, datadog::Error<CancelHistoricalJobError>> {
1567 let local_configuration = &self.config;
1568 let operation_id = "v2.cancel_historical_job";
1569 if local_configuration.is_unstable_operation_enabled(operation_id) {
1570 warn!("Using unstable operation {operation_id}");
1571 } else {
1572 let local_error = datadog::UnstableOperationDisabledError {
1573 msg: "Operation 'v2.cancel_historical_job' is not enabled".to_string(),
1574 };
1575 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
1576 }
1577
1578 let local_client = &self.client;
1579
1580 let local_uri_str = format!(
1581 "{}/api/v2/siem-historical-detections/jobs/{job_id}/cancel",
1582 local_configuration.get_operation_host(operation_id),
1583 job_id = datadog::urlencode(job_id)
1584 );
1585 let mut local_req_builder =
1586 local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
1587
1588 let mut headers = HeaderMap::new();
1590 headers.insert("Accept", HeaderValue::from_static("*/*"));
1591
1592 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1594 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1595 Err(e) => {
1596 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1597 headers.insert(
1598 reqwest::header::USER_AGENT,
1599 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1600 )
1601 }
1602 };
1603
1604 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1606 headers.insert(
1607 "DD-API-KEY",
1608 HeaderValue::from_str(local_key.key.as_str())
1609 .expect("failed to parse DD-API-KEY header"),
1610 );
1611 };
1612 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1613 headers.insert(
1614 "DD-APPLICATION-KEY",
1615 HeaderValue::from_str(local_key.key.as_str())
1616 .expect("failed to parse DD-APPLICATION-KEY header"),
1617 );
1618 };
1619
1620 local_req_builder = local_req_builder.headers(headers);
1621 let local_req = local_req_builder.build()?;
1622 log::debug!("request content: {:?}", local_req.body());
1623 let local_resp = local_client.execute(local_req).await?;
1624
1625 let local_status = local_resp.status();
1626 let local_content = local_resp.text().await?;
1627 log::debug!("response content: {}", local_content);
1628
1629 if !local_status.is_client_error() && !local_status.is_server_error() {
1630 Ok(datadog::ResponseContent {
1631 status: local_status,
1632 content: local_content,
1633 entity: None,
1634 })
1635 } else {
1636 let local_entity: Option<CancelHistoricalJobError> =
1637 serde_json::from_str(&local_content).ok();
1638 let local_error = datadog::ResponseContent {
1639 status: local_status,
1640 content: local_content,
1641 entity: local_entity,
1642 };
1643 Err(datadog::Error::ResponseError(local_error))
1644 }
1645 }
1646
1647 pub async fn convert_existing_security_monitoring_rule(
1650 &self,
1651 rule_id: String,
1652 ) -> Result<
1653 crate::datadogV2::model::SecurityMonitoringRuleConvertResponse,
1654 datadog::Error<ConvertExistingSecurityMonitoringRuleError>,
1655 > {
1656 match self
1657 .convert_existing_security_monitoring_rule_with_http_info(rule_id)
1658 .await
1659 {
1660 Ok(response_content) => {
1661 if let Some(e) = response_content.entity {
1662 Ok(e)
1663 } else {
1664 Err(datadog::Error::Serde(serde::de::Error::custom(
1665 "response content was None",
1666 )))
1667 }
1668 }
1669 Err(err) => Err(err),
1670 }
1671 }
1672
1673 pub async fn convert_existing_security_monitoring_rule_with_http_info(
1676 &self,
1677 rule_id: String,
1678 ) -> Result<
1679 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleConvertResponse>,
1680 datadog::Error<ConvertExistingSecurityMonitoringRuleError>,
1681 > {
1682 let local_configuration = &self.config;
1683 let operation_id = "v2.convert_existing_security_monitoring_rule";
1684
1685 let local_client = &self.client;
1686
1687 let local_uri_str = format!(
1688 "{}/api/v2/security_monitoring/rules/{rule_id}/convert",
1689 local_configuration.get_operation_host(operation_id),
1690 rule_id = datadog::urlencode(rule_id)
1691 );
1692 let mut local_req_builder =
1693 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1694
1695 let mut headers = HeaderMap::new();
1697 headers.insert("Accept", HeaderValue::from_static("application/json"));
1698
1699 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1701 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1702 Err(e) => {
1703 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1704 headers.insert(
1705 reqwest::header::USER_AGENT,
1706 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1707 )
1708 }
1709 };
1710
1711 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1713 headers.insert(
1714 "DD-API-KEY",
1715 HeaderValue::from_str(local_key.key.as_str())
1716 .expect("failed to parse DD-API-KEY header"),
1717 );
1718 };
1719 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1720 headers.insert(
1721 "DD-APPLICATION-KEY",
1722 HeaderValue::from_str(local_key.key.as_str())
1723 .expect("failed to parse DD-APPLICATION-KEY header"),
1724 );
1725 };
1726
1727 local_req_builder = local_req_builder.headers(headers);
1728 let local_req = local_req_builder.build()?;
1729 log::debug!("request content: {:?}", local_req.body());
1730 let local_resp = local_client.execute(local_req).await?;
1731
1732 let local_status = local_resp.status();
1733 let local_content = local_resp.text().await?;
1734 log::debug!("response content: {}", local_content);
1735
1736 if !local_status.is_client_error() && !local_status.is_server_error() {
1737 match serde_json::from_str::<
1738 crate::datadogV2::model::SecurityMonitoringRuleConvertResponse,
1739 >(&local_content)
1740 {
1741 Ok(e) => {
1742 return Ok(datadog::ResponseContent {
1743 status: local_status,
1744 content: local_content,
1745 entity: Some(e),
1746 })
1747 }
1748 Err(e) => return Err(datadog::Error::Serde(e)),
1749 };
1750 } else {
1751 let local_entity: Option<ConvertExistingSecurityMonitoringRuleError> =
1752 serde_json::from_str(&local_content).ok();
1753 let local_error = datadog::ResponseContent {
1754 status: local_status,
1755 content: local_content,
1756 entity: local_entity,
1757 };
1758 Err(datadog::Error::ResponseError(local_error))
1759 }
1760 }
1761
1762 pub async fn convert_job_result_to_signal(
1764 &self,
1765 body: crate::datadogV2::model::ConvertJobResultsToSignalsRequest,
1766 ) -> Result<(), datadog::Error<ConvertJobResultToSignalError>> {
1767 match self.convert_job_result_to_signal_with_http_info(body).await {
1768 Ok(_) => Ok(()),
1769 Err(err) => Err(err),
1770 }
1771 }
1772
1773 pub async fn convert_job_result_to_signal_with_http_info(
1775 &self,
1776 body: crate::datadogV2::model::ConvertJobResultsToSignalsRequest,
1777 ) -> Result<datadog::ResponseContent<()>, datadog::Error<ConvertJobResultToSignalError>> {
1778 let local_configuration = &self.config;
1779 let operation_id = "v2.convert_job_result_to_signal";
1780 if local_configuration.is_unstable_operation_enabled(operation_id) {
1781 warn!("Using unstable operation {operation_id}");
1782 } else {
1783 let local_error = datadog::UnstableOperationDisabledError {
1784 msg: "Operation 'v2.convert_job_result_to_signal' is not enabled".to_string(),
1785 };
1786 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
1787 }
1788
1789 let local_client = &self.client;
1790
1791 let local_uri_str = format!(
1792 "{}/api/v2/siem-historical-detections/jobs/signal_convert",
1793 local_configuration.get_operation_host(operation_id)
1794 );
1795 let mut local_req_builder =
1796 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
1797
1798 let mut headers = HeaderMap::new();
1800 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1801 headers.insert("Accept", HeaderValue::from_static("*/*"));
1802
1803 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1805 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1806 Err(e) => {
1807 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1808 headers.insert(
1809 reqwest::header::USER_AGENT,
1810 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1811 )
1812 }
1813 };
1814
1815 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1817 headers.insert(
1818 "DD-API-KEY",
1819 HeaderValue::from_str(local_key.key.as_str())
1820 .expect("failed to parse DD-API-KEY header"),
1821 );
1822 };
1823 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1824 headers.insert(
1825 "DD-APPLICATION-KEY",
1826 HeaderValue::from_str(local_key.key.as_str())
1827 .expect("failed to parse DD-APPLICATION-KEY header"),
1828 );
1829 };
1830
1831 let output = Vec::new();
1833 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1834 if body.serialize(&mut ser).is_ok() {
1835 if let Some(content_encoding) = headers.get("Content-Encoding") {
1836 match content_encoding.to_str().unwrap_or_default() {
1837 "gzip" => {
1838 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1839 let _ = enc.write_all(ser.into_inner().as_slice());
1840 match enc.finish() {
1841 Ok(buf) => {
1842 local_req_builder = local_req_builder.body(buf);
1843 }
1844 Err(e) => return Err(datadog::Error::Io(e)),
1845 }
1846 }
1847 "deflate" => {
1848 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1849 let _ = enc.write_all(ser.into_inner().as_slice());
1850 match enc.finish() {
1851 Ok(buf) => {
1852 local_req_builder = local_req_builder.body(buf);
1853 }
1854 Err(e) => return Err(datadog::Error::Io(e)),
1855 }
1856 }
1857 "zstd1" => {
1858 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1859 let _ = enc.write_all(ser.into_inner().as_slice());
1860 match enc.finish() {
1861 Ok(buf) => {
1862 local_req_builder = local_req_builder.body(buf);
1863 }
1864 Err(e) => return Err(datadog::Error::Io(e)),
1865 }
1866 }
1867 _ => {
1868 local_req_builder = local_req_builder.body(ser.into_inner());
1869 }
1870 }
1871 } else {
1872 local_req_builder = local_req_builder.body(ser.into_inner());
1873 }
1874 }
1875
1876 local_req_builder = local_req_builder.headers(headers);
1877 let local_req = local_req_builder.build()?;
1878 log::debug!("request content: {:?}", local_req.body());
1879 let local_resp = local_client.execute(local_req).await?;
1880
1881 let local_status = local_resp.status();
1882 let local_content = local_resp.text().await?;
1883 log::debug!("response content: {}", local_content);
1884
1885 if !local_status.is_client_error() && !local_status.is_server_error() {
1886 Ok(datadog::ResponseContent {
1887 status: local_status,
1888 content: local_content,
1889 entity: None,
1890 })
1891 } else {
1892 let local_entity: Option<ConvertJobResultToSignalError> =
1893 serde_json::from_str(&local_content).ok();
1894 let local_error = datadog::ResponseContent {
1895 status: local_status,
1896 content: local_content,
1897 entity: local_entity,
1898 };
1899 Err(datadog::Error::ResponseError(local_error))
1900 }
1901 }
1902
1903 pub async fn convert_security_monitoring_rule_from_json_to_terraform(
1906 &self,
1907 body: crate::datadogV2::model::SecurityMonitoringRuleConvertPayload,
1908 ) -> Result<
1909 crate::datadogV2::model::SecurityMonitoringRuleConvertResponse,
1910 datadog::Error<ConvertSecurityMonitoringRuleFromJSONToTerraformError>,
1911 > {
1912 match self
1913 .convert_security_monitoring_rule_from_json_to_terraform_with_http_info(body)
1914 .await
1915 {
1916 Ok(response_content) => {
1917 if let Some(e) = response_content.entity {
1918 Ok(e)
1919 } else {
1920 Err(datadog::Error::Serde(serde::de::Error::custom(
1921 "response content was None",
1922 )))
1923 }
1924 }
1925 Err(err) => Err(err),
1926 }
1927 }
1928
1929 pub async fn convert_security_monitoring_rule_from_json_to_terraform_with_http_info(
1932 &self,
1933 body: crate::datadogV2::model::SecurityMonitoringRuleConvertPayload,
1934 ) -> Result<
1935 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleConvertResponse>,
1936 datadog::Error<ConvertSecurityMonitoringRuleFromJSONToTerraformError>,
1937 > {
1938 let local_configuration = &self.config;
1939 let operation_id = "v2.convert_security_monitoring_rule_from_json_to_terraform";
1940
1941 let local_client = &self.client;
1942
1943 let local_uri_str = format!(
1944 "{}/api/v2/security_monitoring/rules/convert",
1945 local_configuration.get_operation_host(operation_id)
1946 );
1947 let mut local_req_builder =
1948 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
1949
1950 let mut headers = HeaderMap::new();
1952 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1953 headers.insert("Accept", HeaderValue::from_static("application/json"));
1954
1955 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1957 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1958 Err(e) => {
1959 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1960 headers.insert(
1961 reqwest::header::USER_AGENT,
1962 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1963 )
1964 }
1965 };
1966
1967 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1969 headers.insert(
1970 "DD-API-KEY",
1971 HeaderValue::from_str(local_key.key.as_str())
1972 .expect("failed to parse DD-API-KEY header"),
1973 );
1974 };
1975 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1976 headers.insert(
1977 "DD-APPLICATION-KEY",
1978 HeaderValue::from_str(local_key.key.as_str())
1979 .expect("failed to parse DD-APPLICATION-KEY header"),
1980 );
1981 };
1982
1983 let output = Vec::new();
1985 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1986 if body.serialize(&mut ser).is_ok() {
1987 if let Some(content_encoding) = headers.get("Content-Encoding") {
1988 match content_encoding.to_str().unwrap_or_default() {
1989 "gzip" => {
1990 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1991 let _ = enc.write_all(ser.into_inner().as_slice());
1992 match enc.finish() {
1993 Ok(buf) => {
1994 local_req_builder = local_req_builder.body(buf);
1995 }
1996 Err(e) => return Err(datadog::Error::Io(e)),
1997 }
1998 }
1999 "deflate" => {
2000 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
2001 let _ = enc.write_all(ser.into_inner().as_slice());
2002 match enc.finish() {
2003 Ok(buf) => {
2004 local_req_builder = local_req_builder.body(buf);
2005 }
2006 Err(e) => return Err(datadog::Error::Io(e)),
2007 }
2008 }
2009 "zstd1" => {
2010 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
2011 let _ = enc.write_all(ser.into_inner().as_slice());
2012 match enc.finish() {
2013 Ok(buf) => {
2014 local_req_builder = local_req_builder.body(buf);
2015 }
2016 Err(e) => return Err(datadog::Error::Io(e)),
2017 }
2018 }
2019 _ => {
2020 local_req_builder = local_req_builder.body(ser.into_inner());
2021 }
2022 }
2023 } else {
2024 local_req_builder = local_req_builder.body(ser.into_inner());
2025 }
2026 }
2027
2028 local_req_builder = local_req_builder.headers(headers);
2029 let local_req = local_req_builder.build()?;
2030 log::debug!("request content: {:?}", local_req.body());
2031 let local_resp = local_client.execute(local_req).await?;
2032
2033 let local_status = local_resp.status();
2034 let local_content = local_resp.text().await?;
2035 log::debug!("response content: {}", local_content);
2036
2037 if !local_status.is_client_error() && !local_status.is_server_error() {
2038 match serde_json::from_str::<
2039 crate::datadogV2::model::SecurityMonitoringRuleConvertResponse,
2040 >(&local_content)
2041 {
2042 Ok(e) => {
2043 return Ok(datadog::ResponseContent {
2044 status: local_status,
2045 content: local_content,
2046 entity: Some(e),
2047 })
2048 }
2049 Err(e) => return Err(datadog::Error::Serde(e)),
2050 };
2051 } else {
2052 let local_entity: Option<ConvertSecurityMonitoringRuleFromJSONToTerraformError> =
2053 serde_json::from_str(&local_content).ok();
2054 let local_error = datadog::ResponseContent {
2055 status: local_status,
2056 content: local_content,
2057 entity: local_entity,
2058 };
2059 Err(datadog::Error::ResponseError(local_error))
2060 }
2061 }
2062
2063 pub async fn create_custom_framework(
2065 &self,
2066 body: crate::datadogV2::model::CreateCustomFrameworkRequest,
2067 ) -> Result<
2068 crate::datadogV2::model::CreateCustomFrameworkResponse,
2069 datadog::Error<CreateCustomFrameworkError>,
2070 > {
2071 match self.create_custom_framework_with_http_info(body).await {
2072 Ok(response_content) => {
2073 if let Some(e) = response_content.entity {
2074 Ok(e)
2075 } else {
2076 Err(datadog::Error::Serde(serde::de::Error::custom(
2077 "response content was None",
2078 )))
2079 }
2080 }
2081 Err(err) => Err(err),
2082 }
2083 }
2084
2085 pub async fn create_custom_framework_with_http_info(
2087 &self,
2088 body: crate::datadogV2::model::CreateCustomFrameworkRequest,
2089 ) -> Result<
2090 datadog::ResponseContent<crate::datadogV2::model::CreateCustomFrameworkResponse>,
2091 datadog::Error<CreateCustomFrameworkError>,
2092 > {
2093 let local_configuration = &self.config;
2094 let operation_id = "v2.create_custom_framework";
2095
2096 let local_client = &self.client;
2097
2098 let local_uri_str = format!(
2099 "{}/api/v2/cloud_security_management/custom_frameworks",
2100 local_configuration.get_operation_host(operation_id)
2101 );
2102 let mut local_req_builder =
2103 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
2104
2105 let mut headers = HeaderMap::new();
2107 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
2108 headers.insert("Accept", HeaderValue::from_static("application/json"));
2109
2110 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2112 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2113 Err(e) => {
2114 log::warn!("Failed to parse user agent header: {e}, falling back to default");
2115 headers.insert(
2116 reqwest::header::USER_AGENT,
2117 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2118 )
2119 }
2120 };
2121
2122 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2124 headers.insert(
2125 "DD-API-KEY",
2126 HeaderValue::from_str(local_key.key.as_str())
2127 .expect("failed to parse DD-API-KEY header"),
2128 );
2129 };
2130 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2131 headers.insert(
2132 "DD-APPLICATION-KEY",
2133 HeaderValue::from_str(local_key.key.as_str())
2134 .expect("failed to parse DD-APPLICATION-KEY header"),
2135 );
2136 };
2137
2138 let output = Vec::new();
2140 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
2141 if body.serialize(&mut ser).is_ok() {
2142 if let Some(content_encoding) = headers.get("Content-Encoding") {
2143 match content_encoding.to_str().unwrap_or_default() {
2144 "gzip" => {
2145 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
2146 let _ = enc.write_all(ser.into_inner().as_slice());
2147 match enc.finish() {
2148 Ok(buf) => {
2149 local_req_builder = local_req_builder.body(buf);
2150 }
2151 Err(e) => return Err(datadog::Error::Io(e)),
2152 }
2153 }
2154 "deflate" => {
2155 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
2156 let _ = enc.write_all(ser.into_inner().as_slice());
2157 match enc.finish() {
2158 Ok(buf) => {
2159 local_req_builder = local_req_builder.body(buf);
2160 }
2161 Err(e) => return Err(datadog::Error::Io(e)),
2162 }
2163 }
2164 "zstd1" => {
2165 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
2166 let _ = enc.write_all(ser.into_inner().as_slice());
2167 match enc.finish() {
2168 Ok(buf) => {
2169 local_req_builder = local_req_builder.body(buf);
2170 }
2171 Err(e) => return Err(datadog::Error::Io(e)),
2172 }
2173 }
2174 _ => {
2175 local_req_builder = local_req_builder.body(ser.into_inner());
2176 }
2177 }
2178 } else {
2179 local_req_builder = local_req_builder.body(ser.into_inner());
2180 }
2181 }
2182
2183 local_req_builder = local_req_builder.headers(headers);
2184 let local_req = local_req_builder.build()?;
2185 log::debug!("request content: {:?}", local_req.body());
2186 let local_resp = local_client.execute(local_req).await?;
2187
2188 let local_status = local_resp.status();
2189 let local_content = local_resp.text().await?;
2190 log::debug!("response content: {}", local_content);
2191
2192 if !local_status.is_client_error() && !local_status.is_server_error() {
2193 match serde_json::from_str::<crate::datadogV2::model::CreateCustomFrameworkResponse>(
2194 &local_content,
2195 ) {
2196 Ok(e) => {
2197 return Ok(datadog::ResponseContent {
2198 status: local_status,
2199 content: local_content,
2200 entity: Some(e),
2201 })
2202 }
2203 Err(e) => return Err(datadog::Error::Serde(e)),
2204 };
2205 } else {
2206 let local_entity: Option<CreateCustomFrameworkError> =
2207 serde_json::from_str(&local_content).ok();
2208 let local_error = datadog::ResponseContent {
2209 status: local_status,
2210 content: local_content,
2211 entity: local_entity,
2212 };
2213 Err(datadog::Error::ResponseError(local_error))
2214 }
2215 }
2216
2217 pub async fn create_security_filter(
2222 &self,
2223 body: crate::datadogV2::model::SecurityFilterCreateRequest,
2224 ) -> Result<
2225 crate::datadogV2::model::SecurityFilterResponse,
2226 datadog::Error<CreateSecurityFilterError>,
2227 > {
2228 match self.create_security_filter_with_http_info(body).await {
2229 Ok(response_content) => {
2230 if let Some(e) = response_content.entity {
2231 Ok(e)
2232 } else {
2233 Err(datadog::Error::Serde(serde::de::Error::custom(
2234 "response content was None",
2235 )))
2236 }
2237 }
2238 Err(err) => Err(err),
2239 }
2240 }
2241
2242 pub async fn create_security_filter_with_http_info(
2247 &self,
2248 body: crate::datadogV2::model::SecurityFilterCreateRequest,
2249 ) -> Result<
2250 datadog::ResponseContent<crate::datadogV2::model::SecurityFilterResponse>,
2251 datadog::Error<CreateSecurityFilterError>,
2252 > {
2253 let local_configuration = &self.config;
2254 let operation_id = "v2.create_security_filter";
2255
2256 let local_client = &self.client;
2257
2258 let local_uri_str = format!(
2259 "{}/api/v2/security_monitoring/configuration/security_filters",
2260 local_configuration.get_operation_host(operation_id)
2261 );
2262 let mut local_req_builder =
2263 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
2264
2265 let mut headers = HeaderMap::new();
2267 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
2268 headers.insert("Accept", HeaderValue::from_static("application/json"));
2269
2270 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2272 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2273 Err(e) => {
2274 log::warn!("Failed to parse user agent header: {e}, falling back to default");
2275 headers.insert(
2276 reqwest::header::USER_AGENT,
2277 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2278 )
2279 }
2280 };
2281
2282 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2284 headers.insert(
2285 "DD-API-KEY",
2286 HeaderValue::from_str(local_key.key.as_str())
2287 .expect("failed to parse DD-API-KEY header"),
2288 );
2289 };
2290 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2291 headers.insert(
2292 "DD-APPLICATION-KEY",
2293 HeaderValue::from_str(local_key.key.as_str())
2294 .expect("failed to parse DD-APPLICATION-KEY header"),
2295 );
2296 };
2297
2298 let output = Vec::new();
2300 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
2301 if body.serialize(&mut ser).is_ok() {
2302 if let Some(content_encoding) = headers.get("Content-Encoding") {
2303 match content_encoding.to_str().unwrap_or_default() {
2304 "gzip" => {
2305 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
2306 let _ = enc.write_all(ser.into_inner().as_slice());
2307 match enc.finish() {
2308 Ok(buf) => {
2309 local_req_builder = local_req_builder.body(buf);
2310 }
2311 Err(e) => return Err(datadog::Error::Io(e)),
2312 }
2313 }
2314 "deflate" => {
2315 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
2316 let _ = enc.write_all(ser.into_inner().as_slice());
2317 match enc.finish() {
2318 Ok(buf) => {
2319 local_req_builder = local_req_builder.body(buf);
2320 }
2321 Err(e) => return Err(datadog::Error::Io(e)),
2322 }
2323 }
2324 "zstd1" => {
2325 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
2326 let _ = enc.write_all(ser.into_inner().as_slice());
2327 match enc.finish() {
2328 Ok(buf) => {
2329 local_req_builder = local_req_builder.body(buf);
2330 }
2331 Err(e) => return Err(datadog::Error::Io(e)),
2332 }
2333 }
2334 _ => {
2335 local_req_builder = local_req_builder.body(ser.into_inner());
2336 }
2337 }
2338 } else {
2339 local_req_builder = local_req_builder.body(ser.into_inner());
2340 }
2341 }
2342
2343 local_req_builder = local_req_builder.headers(headers);
2344 let local_req = local_req_builder.build()?;
2345 log::debug!("request content: {:?}", local_req.body());
2346 let local_resp = local_client.execute(local_req).await?;
2347
2348 let local_status = local_resp.status();
2349 let local_content = local_resp.text().await?;
2350 log::debug!("response content: {}", local_content);
2351
2352 if !local_status.is_client_error() && !local_status.is_server_error() {
2353 match serde_json::from_str::<crate::datadogV2::model::SecurityFilterResponse>(
2354 &local_content,
2355 ) {
2356 Ok(e) => {
2357 return Ok(datadog::ResponseContent {
2358 status: local_status,
2359 content: local_content,
2360 entity: Some(e),
2361 })
2362 }
2363 Err(e) => return Err(datadog::Error::Serde(e)),
2364 };
2365 } else {
2366 let local_entity: Option<CreateSecurityFilterError> =
2367 serde_json::from_str(&local_content).ok();
2368 let local_error = datadog::ResponseContent {
2369 status: local_status,
2370 content: local_content,
2371 entity: local_entity,
2372 };
2373 Err(datadog::Error::ResponseError(local_error))
2374 }
2375 }
2376
2377 pub async fn create_security_monitoring_rule(
2379 &self,
2380 body: crate::datadogV2::model::SecurityMonitoringRuleCreatePayload,
2381 ) -> Result<
2382 crate::datadogV2::model::SecurityMonitoringRuleResponse,
2383 datadog::Error<CreateSecurityMonitoringRuleError>,
2384 > {
2385 match self
2386 .create_security_monitoring_rule_with_http_info(body)
2387 .await
2388 {
2389 Ok(response_content) => {
2390 if let Some(e) = response_content.entity {
2391 Ok(e)
2392 } else {
2393 Err(datadog::Error::Serde(serde::de::Error::custom(
2394 "response content was None",
2395 )))
2396 }
2397 }
2398 Err(err) => Err(err),
2399 }
2400 }
2401
2402 pub async fn create_security_monitoring_rule_with_http_info(
2404 &self,
2405 body: crate::datadogV2::model::SecurityMonitoringRuleCreatePayload,
2406 ) -> Result<
2407 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleResponse>,
2408 datadog::Error<CreateSecurityMonitoringRuleError>,
2409 > {
2410 let local_configuration = &self.config;
2411 let operation_id = "v2.create_security_monitoring_rule";
2412
2413 let local_client = &self.client;
2414
2415 let local_uri_str = format!(
2416 "{}/api/v2/security_monitoring/rules",
2417 local_configuration.get_operation_host(operation_id)
2418 );
2419 let mut local_req_builder =
2420 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
2421
2422 let mut headers = HeaderMap::new();
2424 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
2425 headers.insert("Accept", HeaderValue::from_static("application/json"));
2426
2427 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2429 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2430 Err(e) => {
2431 log::warn!("Failed to parse user agent header: {e}, falling back to default");
2432 headers.insert(
2433 reqwest::header::USER_AGENT,
2434 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2435 )
2436 }
2437 };
2438
2439 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2441 headers.insert(
2442 "DD-API-KEY",
2443 HeaderValue::from_str(local_key.key.as_str())
2444 .expect("failed to parse DD-API-KEY header"),
2445 );
2446 };
2447 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2448 headers.insert(
2449 "DD-APPLICATION-KEY",
2450 HeaderValue::from_str(local_key.key.as_str())
2451 .expect("failed to parse DD-APPLICATION-KEY header"),
2452 );
2453 };
2454
2455 let output = Vec::new();
2457 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
2458 if body.serialize(&mut ser).is_ok() {
2459 if let Some(content_encoding) = headers.get("Content-Encoding") {
2460 match content_encoding.to_str().unwrap_or_default() {
2461 "gzip" => {
2462 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
2463 let _ = enc.write_all(ser.into_inner().as_slice());
2464 match enc.finish() {
2465 Ok(buf) => {
2466 local_req_builder = local_req_builder.body(buf);
2467 }
2468 Err(e) => return Err(datadog::Error::Io(e)),
2469 }
2470 }
2471 "deflate" => {
2472 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
2473 let _ = enc.write_all(ser.into_inner().as_slice());
2474 match enc.finish() {
2475 Ok(buf) => {
2476 local_req_builder = local_req_builder.body(buf);
2477 }
2478 Err(e) => return Err(datadog::Error::Io(e)),
2479 }
2480 }
2481 "zstd1" => {
2482 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
2483 let _ = enc.write_all(ser.into_inner().as_slice());
2484 match enc.finish() {
2485 Ok(buf) => {
2486 local_req_builder = local_req_builder.body(buf);
2487 }
2488 Err(e) => return Err(datadog::Error::Io(e)),
2489 }
2490 }
2491 _ => {
2492 local_req_builder = local_req_builder.body(ser.into_inner());
2493 }
2494 }
2495 } else {
2496 local_req_builder = local_req_builder.body(ser.into_inner());
2497 }
2498 }
2499
2500 local_req_builder = local_req_builder.headers(headers);
2501 let local_req = local_req_builder.build()?;
2502 log::debug!("request content: {:?}", local_req.body());
2503 let local_resp = local_client.execute(local_req).await?;
2504
2505 let local_status = local_resp.status();
2506 let local_content = local_resp.text().await?;
2507 log::debug!("response content: {}", local_content);
2508
2509 if !local_status.is_client_error() && !local_status.is_server_error() {
2510 match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringRuleResponse>(
2511 &local_content,
2512 ) {
2513 Ok(e) => {
2514 return Ok(datadog::ResponseContent {
2515 status: local_status,
2516 content: local_content,
2517 entity: Some(e),
2518 })
2519 }
2520 Err(e) => return Err(datadog::Error::Serde(e)),
2521 };
2522 } else {
2523 let local_entity: Option<CreateSecurityMonitoringRuleError> =
2524 serde_json::from_str(&local_content).ok();
2525 let local_error = datadog::ResponseContent {
2526 status: local_status,
2527 content: local_content,
2528 entity: local_entity,
2529 };
2530 Err(datadog::Error::ResponseError(local_error))
2531 }
2532 }
2533
2534 pub async fn create_security_monitoring_suppression(
2536 &self,
2537 body: crate::datadogV2::model::SecurityMonitoringSuppressionCreateRequest,
2538 ) -> Result<
2539 crate::datadogV2::model::SecurityMonitoringSuppressionResponse,
2540 datadog::Error<CreateSecurityMonitoringSuppressionError>,
2541 > {
2542 match self
2543 .create_security_monitoring_suppression_with_http_info(body)
2544 .await
2545 {
2546 Ok(response_content) => {
2547 if let Some(e) = response_content.entity {
2548 Ok(e)
2549 } else {
2550 Err(datadog::Error::Serde(serde::de::Error::custom(
2551 "response content was None",
2552 )))
2553 }
2554 }
2555 Err(err) => Err(err),
2556 }
2557 }
2558
2559 pub async fn create_security_monitoring_suppression_with_http_info(
2561 &self,
2562 body: crate::datadogV2::model::SecurityMonitoringSuppressionCreateRequest,
2563 ) -> Result<
2564 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSuppressionResponse>,
2565 datadog::Error<CreateSecurityMonitoringSuppressionError>,
2566 > {
2567 let local_configuration = &self.config;
2568 let operation_id = "v2.create_security_monitoring_suppression";
2569
2570 let local_client = &self.client;
2571
2572 let local_uri_str = format!(
2573 "{}/api/v2/security_monitoring/configuration/suppressions",
2574 local_configuration.get_operation_host(operation_id)
2575 );
2576 let mut local_req_builder =
2577 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
2578
2579 let mut headers = HeaderMap::new();
2581 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
2582 headers.insert("Accept", HeaderValue::from_static("application/json"));
2583
2584 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2586 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2587 Err(e) => {
2588 log::warn!("Failed to parse user agent header: {e}, falling back to default");
2589 headers.insert(
2590 reqwest::header::USER_AGENT,
2591 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2592 )
2593 }
2594 };
2595
2596 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2598 headers.insert(
2599 "DD-API-KEY",
2600 HeaderValue::from_str(local_key.key.as_str())
2601 .expect("failed to parse DD-API-KEY header"),
2602 );
2603 };
2604 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2605 headers.insert(
2606 "DD-APPLICATION-KEY",
2607 HeaderValue::from_str(local_key.key.as_str())
2608 .expect("failed to parse DD-APPLICATION-KEY header"),
2609 );
2610 };
2611
2612 let output = Vec::new();
2614 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
2615 if body.serialize(&mut ser).is_ok() {
2616 if let Some(content_encoding) = headers.get("Content-Encoding") {
2617 match content_encoding.to_str().unwrap_or_default() {
2618 "gzip" => {
2619 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
2620 let _ = enc.write_all(ser.into_inner().as_slice());
2621 match enc.finish() {
2622 Ok(buf) => {
2623 local_req_builder = local_req_builder.body(buf);
2624 }
2625 Err(e) => return Err(datadog::Error::Io(e)),
2626 }
2627 }
2628 "deflate" => {
2629 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
2630 let _ = enc.write_all(ser.into_inner().as_slice());
2631 match enc.finish() {
2632 Ok(buf) => {
2633 local_req_builder = local_req_builder.body(buf);
2634 }
2635 Err(e) => return Err(datadog::Error::Io(e)),
2636 }
2637 }
2638 "zstd1" => {
2639 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
2640 let _ = enc.write_all(ser.into_inner().as_slice());
2641 match enc.finish() {
2642 Ok(buf) => {
2643 local_req_builder = local_req_builder.body(buf);
2644 }
2645 Err(e) => return Err(datadog::Error::Io(e)),
2646 }
2647 }
2648 _ => {
2649 local_req_builder = local_req_builder.body(ser.into_inner());
2650 }
2651 }
2652 } else {
2653 local_req_builder = local_req_builder.body(ser.into_inner());
2654 }
2655 }
2656
2657 local_req_builder = local_req_builder.headers(headers);
2658 let local_req = local_req_builder.build()?;
2659 log::debug!("request content: {:?}", local_req.body());
2660 let local_resp = local_client.execute(local_req).await?;
2661
2662 let local_status = local_resp.status();
2663 let local_content = local_resp.text().await?;
2664 log::debug!("response content: {}", local_content);
2665
2666 if !local_status.is_client_error() && !local_status.is_server_error() {
2667 match serde_json::from_str::<
2668 crate::datadogV2::model::SecurityMonitoringSuppressionResponse,
2669 >(&local_content)
2670 {
2671 Ok(e) => {
2672 return Ok(datadog::ResponseContent {
2673 status: local_status,
2674 content: local_content,
2675 entity: Some(e),
2676 })
2677 }
2678 Err(e) => return Err(datadog::Error::Serde(e)),
2679 };
2680 } else {
2681 let local_entity: Option<CreateSecurityMonitoringSuppressionError> =
2682 serde_json::from_str(&local_content).ok();
2683 let local_error = datadog::ResponseContent {
2684 status: local_status,
2685 content: local_content,
2686 entity: local_entity,
2687 };
2688 Err(datadog::Error::ResponseError(local_error))
2689 }
2690 }
2691
2692 pub async fn create_signal_notification_rule(
2694 &self,
2695 body: crate::datadogV2::model::CreateNotificationRuleParameters,
2696 ) -> Result<
2697 crate::datadogV2::model::NotificationRuleResponse,
2698 datadog::Error<CreateSignalNotificationRuleError>,
2699 > {
2700 match self
2701 .create_signal_notification_rule_with_http_info(body)
2702 .await
2703 {
2704 Ok(response_content) => {
2705 if let Some(e) = response_content.entity {
2706 Ok(e)
2707 } else {
2708 Err(datadog::Error::Serde(serde::de::Error::custom(
2709 "response content was None",
2710 )))
2711 }
2712 }
2713 Err(err) => Err(err),
2714 }
2715 }
2716
2717 pub async fn create_signal_notification_rule_with_http_info(
2719 &self,
2720 body: crate::datadogV2::model::CreateNotificationRuleParameters,
2721 ) -> Result<
2722 datadog::ResponseContent<crate::datadogV2::model::NotificationRuleResponse>,
2723 datadog::Error<CreateSignalNotificationRuleError>,
2724 > {
2725 let local_configuration = &self.config;
2726 let operation_id = "v2.create_signal_notification_rule";
2727
2728 let local_client = &self.client;
2729
2730 let local_uri_str = format!(
2731 "{}/api/v2/security/signals/notification_rules",
2732 local_configuration.get_operation_host(operation_id)
2733 );
2734 let mut local_req_builder =
2735 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
2736
2737 let mut headers = HeaderMap::new();
2739 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
2740 headers.insert("Accept", HeaderValue::from_static("application/json"));
2741
2742 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2744 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2745 Err(e) => {
2746 log::warn!("Failed to parse user agent header: {e}, falling back to default");
2747 headers.insert(
2748 reqwest::header::USER_AGENT,
2749 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2750 )
2751 }
2752 };
2753
2754 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2756 headers.insert(
2757 "DD-API-KEY",
2758 HeaderValue::from_str(local_key.key.as_str())
2759 .expect("failed to parse DD-API-KEY header"),
2760 );
2761 };
2762 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2763 headers.insert(
2764 "DD-APPLICATION-KEY",
2765 HeaderValue::from_str(local_key.key.as_str())
2766 .expect("failed to parse DD-APPLICATION-KEY header"),
2767 );
2768 };
2769
2770 let output = Vec::new();
2772 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
2773 if body.serialize(&mut ser).is_ok() {
2774 if let Some(content_encoding) = headers.get("Content-Encoding") {
2775 match content_encoding.to_str().unwrap_or_default() {
2776 "gzip" => {
2777 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
2778 let _ = enc.write_all(ser.into_inner().as_slice());
2779 match enc.finish() {
2780 Ok(buf) => {
2781 local_req_builder = local_req_builder.body(buf);
2782 }
2783 Err(e) => return Err(datadog::Error::Io(e)),
2784 }
2785 }
2786 "deflate" => {
2787 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
2788 let _ = enc.write_all(ser.into_inner().as_slice());
2789 match enc.finish() {
2790 Ok(buf) => {
2791 local_req_builder = local_req_builder.body(buf);
2792 }
2793 Err(e) => return Err(datadog::Error::Io(e)),
2794 }
2795 }
2796 "zstd1" => {
2797 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
2798 let _ = enc.write_all(ser.into_inner().as_slice());
2799 match enc.finish() {
2800 Ok(buf) => {
2801 local_req_builder = local_req_builder.body(buf);
2802 }
2803 Err(e) => return Err(datadog::Error::Io(e)),
2804 }
2805 }
2806 _ => {
2807 local_req_builder = local_req_builder.body(ser.into_inner());
2808 }
2809 }
2810 } else {
2811 local_req_builder = local_req_builder.body(ser.into_inner());
2812 }
2813 }
2814
2815 local_req_builder = local_req_builder.headers(headers);
2816 let local_req = local_req_builder.build()?;
2817 log::debug!("request content: {:?}", local_req.body());
2818 let local_resp = local_client.execute(local_req).await?;
2819
2820 let local_status = local_resp.status();
2821 let local_content = local_resp.text().await?;
2822 log::debug!("response content: {}", local_content);
2823
2824 if !local_status.is_client_error() && !local_status.is_server_error() {
2825 match serde_json::from_str::<crate::datadogV2::model::NotificationRuleResponse>(
2826 &local_content,
2827 ) {
2828 Ok(e) => {
2829 return Ok(datadog::ResponseContent {
2830 status: local_status,
2831 content: local_content,
2832 entity: Some(e),
2833 })
2834 }
2835 Err(e) => return Err(datadog::Error::Serde(e)),
2836 };
2837 } else {
2838 let local_entity: Option<CreateSignalNotificationRuleError> =
2839 serde_json::from_str(&local_content).ok();
2840 let local_error = datadog::ResponseContent {
2841 status: local_status,
2842 content: local_content,
2843 entity: local_entity,
2844 };
2845 Err(datadog::Error::ResponseError(local_error))
2846 }
2847 }
2848
2849 pub async fn create_vulnerability_notification_rule(
2851 &self,
2852 body: crate::datadogV2::model::CreateNotificationRuleParameters,
2853 ) -> Result<
2854 crate::datadogV2::model::NotificationRuleResponse,
2855 datadog::Error<CreateVulnerabilityNotificationRuleError>,
2856 > {
2857 match self
2858 .create_vulnerability_notification_rule_with_http_info(body)
2859 .await
2860 {
2861 Ok(response_content) => {
2862 if let Some(e) = response_content.entity {
2863 Ok(e)
2864 } else {
2865 Err(datadog::Error::Serde(serde::de::Error::custom(
2866 "response content was None",
2867 )))
2868 }
2869 }
2870 Err(err) => Err(err),
2871 }
2872 }
2873
2874 pub async fn create_vulnerability_notification_rule_with_http_info(
2876 &self,
2877 body: crate::datadogV2::model::CreateNotificationRuleParameters,
2878 ) -> Result<
2879 datadog::ResponseContent<crate::datadogV2::model::NotificationRuleResponse>,
2880 datadog::Error<CreateVulnerabilityNotificationRuleError>,
2881 > {
2882 let local_configuration = &self.config;
2883 let operation_id = "v2.create_vulnerability_notification_rule";
2884
2885 let local_client = &self.client;
2886
2887 let local_uri_str = format!(
2888 "{}/api/v2/security/vulnerabilities/notification_rules",
2889 local_configuration.get_operation_host(operation_id)
2890 );
2891 let mut local_req_builder =
2892 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
2893
2894 let mut headers = HeaderMap::new();
2896 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
2897 headers.insert("Accept", HeaderValue::from_static("application/json"));
2898
2899 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2901 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2902 Err(e) => {
2903 log::warn!("Failed to parse user agent header: {e}, falling back to default");
2904 headers.insert(
2905 reqwest::header::USER_AGENT,
2906 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2907 )
2908 }
2909 };
2910
2911 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2913 headers.insert(
2914 "DD-API-KEY",
2915 HeaderValue::from_str(local_key.key.as_str())
2916 .expect("failed to parse DD-API-KEY header"),
2917 );
2918 };
2919 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2920 headers.insert(
2921 "DD-APPLICATION-KEY",
2922 HeaderValue::from_str(local_key.key.as_str())
2923 .expect("failed to parse DD-APPLICATION-KEY header"),
2924 );
2925 };
2926
2927 let output = Vec::new();
2929 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
2930 if body.serialize(&mut ser).is_ok() {
2931 if let Some(content_encoding) = headers.get("Content-Encoding") {
2932 match content_encoding.to_str().unwrap_or_default() {
2933 "gzip" => {
2934 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
2935 let _ = enc.write_all(ser.into_inner().as_slice());
2936 match enc.finish() {
2937 Ok(buf) => {
2938 local_req_builder = local_req_builder.body(buf);
2939 }
2940 Err(e) => return Err(datadog::Error::Io(e)),
2941 }
2942 }
2943 "deflate" => {
2944 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
2945 let _ = enc.write_all(ser.into_inner().as_slice());
2946 match enc.finish() {
2947 Ok(buf) => {
2948 local_req_builder = local_req_builder.body(buf);
2949 }
2950 Err(e) => return Err(datadog::Error::Io(e)),
2951 }
2952 }
2953 "zstd1" => {
2954 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
2955 let _ = enc.write_all(ser.into_inner().as_slice());
2956 match enc.finish() {
2957 Ok(buf) => {
2958 local_req_builder = local_req_builder.body(buf);
2959 }
2960 Err(e) => return Err(datadog::Error::Io(e)),
2961 }
2962 }
2963 _ => {
2964 local_req_builder = local_req_builder.body(ser.into_inner());
2965 }
2966 }
2967 } else {
2968 local_req_builder = local_req_builder.body(ser.into_inner());
2969 }
2970 }
2971
2972 local_req_builder = local_req_builder.headers(headers);
2973 let local_req = local_req_builder.build()?;
2974 log::debug!("request content: {:?}", local_req.body());
2975 let local_resp = local_client.execute(local_req).await?;
2976
2977 let local_status = local_resp.status();
2978 let local_content = local_resp.text().await?;
2979 log::debug!("response content: {}", local_content);
2980
2981 if !local_status.is_client_error() && !local_status.is_server_error() {
2982 match serde_json::from_str::<crate::datadogV2::model::NotificationRuleResponse>(
2983 &local_content,
2984 ) {
2985 Ok(e) => {
2986 return Ok(datadog::ResponseContent {
2987 status: local_status,
2988 content: local_content,
2989 entity: Some(e),
2990 })
2991 }
2992 Err(e) => return Err(datadog::Error::Serde(e)),
2993 };
2994 } else {
2995 let local_entity: Option<CreateVulnerabilityNotificationRuleError> =
2996 serde_json::from_str(&local_content).ok();
2997 let local_error = datadog::ResponseContent {
2998 status: local_status,
2999 content: local_content,
3000 entity: local_entity,
3001 };
3002 Err(datadog::Error::ResponseError(local_error))
3003 }
3004 }
3005
3006 pub async fn delete_custom_framework(
3008 &self,
3009 handle: String,
3010 version: String,
3011 ) -> Result<
3012 crate::datadogV2::model::DeleteCustomFrameworkResponse,
3013 datadog::Error<DeleteCustomFrameworkError>,
3014 > {
3015 match self
3016 .delete_custom_framework_with_http_info(handle, version)
3017 .await
3018 {
3019 Ok(response_content) => {
3020 if let Some(e) = response_content.entity {
3021 Ok(e)
3022 } else {
3023 Err(datadog::Error::Serde(serde::de::Error::custom(
3024 "response content was None",
3025 )))
3026 }
3027 }
3028 Err(err) => Err(err),
3029 }
3030 }
3031
3032 pub async fn delete_custom_framework_with_http_info(
3034 &self,
3035 handle: String,
3036 version: String,
3037 ) -> Result<
3038 datadog::ResponseContent<crate::datadogV2::model::DeleteCustomFrameworkResponse>,
3039 datadog::Error<DeleteCustomFrameworkError>,
3040 > {
3041 let local_configuration = &self.config;
3042 let operation_id = "v2.delete_custom_framework";
3043
3044 let local_client = &self.client;
3045
3046 let local_uri_str = format!(
3047 "{}/api/v2/cloud_security_management/custom_frameworks/{handle}/{version}",
3048 local_configuration.get_operation_host(operation_id),
3049 handle = datadog::urlencode(handle),
3050 version = datadog::urlencode(version)
3051 );
3052 let mut local_req_builder =
3053 local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
3054
3055 let mut headers = HeaderMap::new();
3057 headers.insert("Accept", HeaderValue::from_static("application/json"));
3058
3059 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3061 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3062 Err(e) => {
3063 log::warn!("Failed to parse user agent header: {e}, falling back to default");
3064 headers.insert(
3065 reqwest::header::USER_AGENT,
3066 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3067 )
3068 }
3069 };
3070
3071 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3073 headers.insert(
3074 "DD-API-KEY",
3075 HeaderValue::from_str(local_key.key.as_str())
3076 .expect("failed to parse DD-API-KEY header"),
3077 );
3078 };
3079 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3080 headers.insert(
3081 "DD-APPLICATION-KEY",
3082 HeaderValue::from_str(local_key.key.as_str())
3083 .expect("failed to parse DD-APPLICATION-KEY header"),
3084 );
3085 };
3086
3087 local_req_builder = local_req_builder.headers(headers);
3088 let local_req = local_req_builder.build()?;
3089 log::debug!("request content: {:?}", local_req.body());
3090 let local_resp = local_client.execute(local_req).await?;
3091
3092 let local_status = local_resp.status();
3093 let local_content = local_resp.text().await?;
3094 log::debug!("response content: {}", local_content);
3095
3096 if !local_status.is_client_error() && !local_status.is_server_error() {
3097 match serde_json::from_str::<crate::datadogV2::model::DeleteCustomFrameworkResponse>(
3098 &local_content,
3099 ) {
3100 Ok(e) => {
3101 return Ok(datadog::ResponseContent {
3102 status: local_status,
3103 content: local_content,
3104 entity: Some(e),
3105 })
3106 }
3107 Err(e) => return Err(datadog::Error::Serde(e)),
3108 };
3109 } else {
3110 let local_entity: Option<DeleteCustomFrameworkError> =
3111 serde_json::from_str(&local_content).ok();
3112 let local_error = datadog::ResponseContent {
3113 status: local_status,
3114 content: local_content,
3115 entity: local_entity,
3116 };
3117 Err(datadog::Error::ResponseError(local_error))
3118 }
3119 }
3120
3121 pub async fn delete_historical_job(
3123 &self,
3124 job_id: String,
3125 ) -> Result<(), datadog::Error<DeleteHistoricalJobError>> {
3126 match self.delete_historical_job_with_http_info(job_id).await {
3127 Ok(_) => Ok(()),
3128 Err(err) => Err(err),
3129 }
3130 }
3131
3132 pub async fn delete_historical_job_with_http_info(
3134 &self,
3135 job_id: String,
3136 ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteHistoricalJobError>> {
3137 let local_configuration = &self.config;
3138 let operation_id = "v2.delete_historical_job";
3139 if local_configuration.is_unstable_operation_enabled(operation_id) {
3140 warn!("Using unstable operation {operation_id}");
3141 } else {
3142 let local_error = datadog::UnstableOperationDisabledError {
3143 msg: "Operation 'v2.delete_historical_job' is not enabled".to_string(),
3144 };
3145 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
3146 }
3147
3148 let local_client = &self.client;
3149
3150 let local_uri_str = format!(
3151 "{}/api/v2/siem-historical-detections/jobs/{job_id}",
3152 local_configuration.get_operation_host(operation_id),
3153 job_id = datadog::urlencode(job_id)
3154 );
3155 let mut local_req_builder =
3156 local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
3157
3158 let mut headers = HeaderMap::new();
3160 headers.insert("Accept", HeaderValue::from_static("*/*"));
3161
3162 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3164 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3165 Err(e) => {
3166 log::warn!("Failed to parse user agent header: {e}, falling back to default");
3167 headers.insert(
3168 reqwest::header::USER_AGENT,
3169 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3170 )
3171 }
3172 };
3173
3174 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3176 headers.insert(
3177 "DD-API-KEY",
3178 HeaderValue::from_str(local_key.key.as_str())
3179 .expect("failed to parse DD-API-KEY header"),
3180 );
3181 };
3182 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3183 headers.insert(
3184 "DD-APPLICATION-KEY",
3185 HeaderValue::from_str(local_key.key.as_str())
3186 .expect("failed to parse DD-APPLICATION-KEY header"),
3187 );
3188 };
3189
3190 local_req_builder = local_req_builder.headers(headers);
3191 let local_req = local_req_builder.build()?;
3192 log::debug!("request content: {:?}", local_req.body());
3193 let local_resp = local_client.execute(local_req).await?;
3194
3195 let local_status = local_resp.status();
3196 let local_content = local_resp.text().await?;
3197 log::debug!("response content: {}", local_content);
3198
3199 if !local_status.is_client_error() && !local_status.is_server_error() {
3200 Ok(datadog::ResponseContent {
3201 status: local_status,
3202 content: local_content,
3203 entity: None,
3204 })
3205 } else {
3206 let local_entity: Option<DeleteHistoricalJobError> =
3207 serde_json::from_str(&local_content).ok();
3208 let local_error = datadog::ResponseContent {
3209 status: local_status,
3210 content: local_content,
3211 entity: local_entity,
3212 };
3213 Err(datadog::Error::ResponseError(local_error))
3214 }
3215 }
3216
3217 pub async fn delete_security_filter(
3219 &self,
3220 security_filter_id: String,
3221 ) -> Result<(), datadog::Error<DeleteSecurityFilterError>> {
3222 match self
3223 .delete_security_filter_with_http_info(security_filter_id)
3224 .await
3225 {
3226 Ok(_) => Ok(()),
3227 Err(err) => Err(err),
3228 }
3229 }
3230
3231 pub async fn delete_security_filter_with_http_info(
3233 &self,
3234 security_filter_id: String,
3235 ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteSecurityFilterError>> {
3236 let local_configuration = &self.config;
3237 let operation_id = "v2.delete_security_filter";
3238
3239 let local_client = &self.client;
3240
3241 let local_uri_str = format!(
3242 "{}/api/v2/security_monitoring/configuration/security_filters/{security_filter_id}",
3243 local_configuration.get_operation_host(operation_id),
3244 security_filter_id = datadog::urlencode(security_filter_id)
3245 );
3246 let mut local_req_builder =
3247 local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
3248
3249 let mut headers = HeaderMap::new();
3251 headers.insert("Accept", HeaderValue::from_static("*/*"));
3252
3253 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3255 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3256 Err(e) => {
3257 log::warn!("Failed to parse user agent header: {e}, falling back to default");
3258 headers.insert(
3259 reqwest::header::USER_AGENT,
3260 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3261 )
3262 }
3263 };
3264
3265 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3267 headers.insert(
3268 "DD-API-KEY",
3269 HeaderValue::from_str(local_key.key.as_str())
3270 .expect("failed to parse DD-API-KEY header"),
3271 );
3272 };
3273 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3274 headers.insert(
3275 "DD-APPLICATION-KEY",
3276 HeaderValue::from_str(local_key.key.as_str())
3277 .expect("failed to parse DD-APPLICATION-KEY header"),
3278 );
3279 };
3280
3281 local_req_builder = local_req_builder.headers(headers);
3282 let local_req = local_req_builder.build()?;
3283 log::debug!("request content: {:?}", local_req.body());
3284 let local_resp = local_client.execute(local_req).await?;
3285
3286 let local_status = local_resp.status();
3287 let local_content = local_resp.text().await?;
3288 log::debug!("response content: {}", local_content);
3289
3290 if !local_status.is_client_error() && !local_status.is_server_error() {
3291 Ok(datadog::ResponseContent {
3292 status: local_status,
3293 content: local_content,
3294 entity: None,
3295 })
3296 } else {
3297 let local_entity: Option<DeleteSecurityFilterError> =
3298 serde_json::from_str(&local_content).ok();
3299 let local_error = datadog::ResponseContent {
3300 status: local_status,
3301 content: local_content,
3302 entity: local_entity,
3303 };
3304 Err(datadog::Error::ResponseError(local_error))
3305 }
3306 }
3307
3308 pub async fn delete_security_monitoring_rule(
3310 &self,
3311 rule_id: String,
3312 ) -> Result<(), datadog::Error<DeleteSecurityMonitoringRuleError>> {
3313 match self
3314 .delete_security_monitoring_rule_with_http_info(rule_id)
3315 .await
3316 {
3317 Ok(_) => Ok(()),
3318 Err(err) => Err(err),
3319 }
3320 }
3321
3322 pub async fn delete_security_monitoring_rule_with_http_info(
3324 &self,
3325 rule_id: String,
3326 ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteSecurityMonitoringRuleError>>
3327 {
3328 let local_configuration = &self.config;
3329 let operation_id = "v2.delete_security_monitoring_rule";
3330
3331 let local_client = &self.client;
3332
3333 let local_uri_str = format!(
3334 "{}/api/v2/security_monitoring/rules/{rule_id}",
3335 local_configuration.get_operation_host(operation_id),
3336 rule_id = datadog::urlencode(rule_id)
3337 );
3338 let mut local_req_builder =
3339 local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
3340
3341 let mut headers = HeaderMap::new();
3343 headers.insert("Accept", HeaderValue::from_static("*/*"));
3344
3345 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3347 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3348 Err(e) => {
3349 log::warn!("Failed to parse user agent header: {e}, falling back to default");
3350 headers.insert(
3351 reqwest::header::USER_AGENT,
3352 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3353 )
3354 }
3355 };
3356
3357 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3359 headers.insert(
3360 "DD-API-KEY",
3361 HeaderValue::from_str(local_key.key.as_str())
3362 .expect("failed to parse DD-API-KEY header"),
3363 );
3364 };
3365 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3366 headers.insert(
3367 "DD-APPLICATION-KEY",
3368 HeaderValue::from_str(local_key.key.as_str())
3369 .expect("failed to parse DD-APPLICATION-KEY header"),
3370 );
3371 };
3372
3373 local_req_builder = local_req_builder.headers(headers);
3374 let local_req = local_req_builder.build()?;
3375 log::debug!("request content: {:?}", local_req.body());
3376 let local_resp = local_client.execute(local_req).await?;
3377
3378 let local_status = local_resp.status();
3379 let local_content = local_resp.text().await?;
3380 log::debug!("response content: {}", local_content);
3381
3382 if !local_status.is_client_error() && !local_status.is_server_error() {
3383 Ok(datadog::ResponseContent {
3384 status: local_status,
3385 content: local_content,
3386 entity: None,
3387 })
3388 } else {
3389 let local_entity: Option<DeleteSecurityMonitoringRuleError> =
3390 serde_json::from_str(&local_content).ok();
3391 let local_error = datadog::ResponseContent {
3392 status: local_status,
3393 content: local_content,
3394 entity: local_entity,
3395 };
3396 Err(datadog::Error::ResponseError(local_error))
3397 }
3398 }
3399
3400 pub async fn delete_security_monitoring_suppression(
3402 &self,
3403 suppression_id: String,
3404 ) -> Result<(), datadog::Error<DeleteSecurityMonitoringSuppressionError>> {
3405 match self
3406 .delete_security_monitoring_suppression_with_http_info(suppression_id)
3407 .await
3408 {
3409 Ok(_) => Ok(()),
3410 Err(err) => Err(err),
3411 }
3412 }
3413
3414 pub async fn delete_security_monitoring_suppression_with_http_info(
3416 &self,
3417 suppression_id: String,
3418 ) -> Result<
3419 datadog::ResponseContent<()>,
3420 datadog::Error<DeleteSecurityMonitoringSuppressionError>,
3421 > {
3422 let local_configuration = &self.config;
3423 let operation_id = "v2.delete_security_monitoring_suppression";
3424
3425 let local_client = &self.client;
3426
3427 let local_uri_str = format!(
3428 "{}/api/v2/security_monitoring/configuration/suppressions/{suppression_id}",
3429 local_configuration.get_operation_host(operation_id),
3430 suppression_id = datadog::urlencode(suppression_id)
3431 );
3432 let mut local_req_builder =
3433 local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
3434
3435 let mut headers = HeaderMap::new();
3437 headers.insert("Accept", HeaderValue::from_static("*/*"));
3438
3439 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3441 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3442 Err(e) => {
3443 log::warn!("Failed to parse user agent header: {e}, falling back to default");
3444 headers.insert(
3445 reqwest::header::USER_AGENT,
3446 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3447 )
3448 }
3449 };
3450
3451 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3453 headers.insert(
3454 "DD-API-KEY",
3455 HeaderValue::from_str(local_key.key.as_str())
3456 .expect("failed to parse DD-API-KEY header"),
3457 );
3458 };
3459 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3460 headers.insert(
3461 "DD-APPLICATION-KEY",
3462 HeaderValue::from_str(local_key.key.as_str())
3463 .expect("failed to parse DD-APPLICATION-KEY header"),
3464 );
3465 };
3466
3467 local_req_builder = local_req_builder.headers(headers);
3468 let local_req = local_req_builder.build()?;
3469 log::debug!("request content: {:?}", local_req.body());
3470 let local_resp = local_client.execute(local_req).await?;
3471
3472 let local_status = local_resp.status();
3473 let local_content = local_resp.text().await?;
3474 log::debug!("response content: {}", local_content);
3475
3476 if !local_status.is_client_error() && !local_status.is_server_error() {
3477 Ok(datadog::ResponseContent {
3478 status: local_status,
3479 content: local_content,
3480 entity: None,
3481 })
3482 } else {
3483 let local_entity: Option<DeleteSecurityMonitoringSuppressionError> =
3484 serde_json::from_str(&local_content).ok();
3485 let local_error = datadog::ResponseContent {
3486 status: local_status,
3487 content: local_content,
3488 entity: local_entity,
3489 };
3490 Err(datadog::Error::ResponseError(local_error))
3491 }
3492 }
3493
3494 pub async fn delete_signal_notification_rule(
3496 &self,
3497 id: String,
3498 ) -> Result<(), datadog::Error<DeleteSignalNotificationRuleError>> {
3499 match self
3500 .delete_signal_notification_rule_with_http_info(id)
3501 .await
3502 {
3503 Ok(_) => Ok(()),
3504 Err(err) => Err(err),
3505 }
3506 }
3507
3508 pub async fn delete_signal_notification_rule_with_http_info(
3510 &self,
3511 id: String,
3512 ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteSignalNotificationRuleError>>
3513 {
3514 let local_configuration = &self.config;
3515 let operation_id = "v2.delete_signal_notification_rule";
3516
3517 let local_client = &self.client;
3518
3519 let local_uri_str = format!(
3520 "{}/api/v2/security/signals/notification_rules/{id}",
3521 local_configuration.get_operation_host(operation_id),
3522 id = datadog::urlencode(id)
3523 );
3524 let mut local_req_builder =
3525 local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
3526
3527 let mut headers = HeaderMap::new();
3529 headers.insert("Accept", HeaderValue::from_static("*/*"));
3530
3531 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3533 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3534 Err(e) => {
3535 log::warn!("Failed to parse user agent header: {e}, falling back to default");
3536 headers.insert(
3537 reqwest::header::USER_AGENT,
3538 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3539 )
3540 }
3541 };
3542
3543 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3545 headers.insert(
3546 "DD-API-KEY",
3547 HeaderValue::from_str(local_key.key.as_str())
3548 .expect("failed to parse DD-API-KEY header"),
3549 );
3550 };
3551 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3552 headers.insert(
3553 "DD-APPLICATION-KEY",
3554 HeaderValue::from_str(local_key.key.as_str())
3555 .expect("failed to parse DD-APPLICATION-KEY header"),
3556 );
3557 };
3558
3559 local_req_builder = local_req_builder.headers(headers);
3560 let local_req = local_req_builder.build()?;
3561 log::debug!("request content: {:?}", local_req.body());
3562 let local_resp = local_client.execute(local_req).await?;
3563
3564 let local_status = local_resp.status();
3565 let local_content = local_resp.text().await?;
3566 log::debug!("response content: {}", local_content);
3567
3568 if !local_status.is_client_error() && !local_status.is_server_error() {
3569 Ok(datadog::ResponseContent {
3570 status: local_status,
3571 content: local_content,
3572 entity: None,
3573 })
3574 } else {
3575 let local_entity: Option<DeleteSignalNotificationRuleError> =
3576 serde_json::from_str(&local_content).ok();
3577 let local_error = datadog::ResponseContent {
3578 status: local_status,
3579 content: local_content,
3580 entity: local_entity,
3581 };
3582 Err(datadog::Error::ResponseError(local_error))
3583 }
3584 }
3585
3586 pub async fn delete_vulnerability_notification_rule(
3588 &self,
3589 id: String,
3590 ) -> Result<(), datadog::Error<DeleteVulnerabilityNotificationRuleError>> {
3591 match self
3592 .delete_vulnerability_notification_rule_with_http_info(id)
3593 .await
3594 {
3595 Ok(_) => Ok(()),
3596 Err(err) => Err(err),
3597 }
3598 }
3599
3600 pub async fn delete_vulnerability_notification_rule_with_http_info(
3602 &self,
3603 id: String,
3604 ) -> Result<
3605 datadog::ResponseContent<()>,
3606 datadog::Error<DeleteVulnerabilityNotificationRuleError>,
3607 > {
3608 let local_configuration = &self.config;
3609 let operation_id = "v2.delete_vulnerability_notification_rule";
3610
3611 let local_client = &self.client;
3612
3613 let local_uri_str = format!(
3614 "{}/api/v2/security/vulnerabilities/notification_rules/{id}",
3615 local_configuration.get_operation_host(operation_id),
3616 id = datadog::urlencode(id)
3617 );
3618 let mut local_req_builder =
3619 local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
3620
3621 let mut headers = HeaderMap::new();
3623 headers.insert("Accept", HeaderValue::from_static("*/*"));
3624
3625 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3627 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3628 Err(e) => {
3629 log::warn!("Failed to parse user agent header: {e}, falling back to default");
3630 headers.insert(
3631 reqwest::header::USER_AGENT,
3632 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3633 )
3634 }
3635 };
3636
3637 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3639 headers.insert(
3640 "DD-API-KEY",
3641 HeaderValue::from_str(local_key.key.as_str())
3642 .expect("failed to parse DD-API-KEY header"),
3643 );
3644 };
3645 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3646 headers.insert(
3647 "DD-APPLICATION-KEY",
3648 HeaderValue::from_str(local_key.key.as_str())
3649 .expect("failed to parse DD-APPLICATION-KEY header"),
3650 );
3651 };
3652
3653 local_req_builder = local_req_builder.headers(headers);
3654 let local_req = local_req_builder.build()?;
3655 log::debug!("request content: {:?}", local_req.body());
3656 let local_resp = local_client.execute(local_req).await?;
3657
3658 let local_status = local_resp.status();
3659 let local_content = local_resp.text().await?;
3660 log::debug!("response content: {}", local_content);
3661
3662 if !local_status.is_client_error() && !local_status.is_server_error() {
3663 Ok(datadog::ResponseContent {
3664 status: local_status,
3665 content: local_content,
3666 entity: None,
3667 })
3668 } else {
3669 let local_entity: Option<DeleteVulnerabilityNotificationRuleError> =
3670 serde_json::from_str(&local_content).ok();
3671 let local_error = datadog::ResponseContent {
3672 status: local_status,
3673 content: local_content,
3674 entity: local_entity,
3675 };
3676 Err(datadog::Error::ResponseError(local_error))
3677 }
3678 }
3679
3680 pub async fn edit_security_monitoring_signal_assignee(
3682 &self,
3683 signal_id: String,
3684 body: crate::datadogV2::model::SecurityMonitoringSignalAssigneeUpdateRequest,
3685 ) -> Result<
3686 crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
3687 datadog::Error<EditSecurityMonitoringSignalAssigneeError>,
3688 > {
3689 match self
3690 .edit_security_monitoring_signal_assignee_with_http_info(signal_id, body)
3691 .await
3692 {
3693 Ok(response_content) => {
3694 if let Some(e) = response_content.entity {
3695 Ok(e)
3696 } else {
3697 Err(datadog::Error::Serde(serde::de::Error::custom(
3698 "response content was None",
3699 )))
3700 }
3701 }
3702 Err(err) => Err(err),
3703 }
3704 }
3705
3706 pub async fn edit_security_monitoring_signal_assignee_with_http_info(
3708 &self,
3709 signal_id: String,
3710 body: crate::datadogV2::model::SecurityMonitoringSignalAssigneeUpdateRequest,
3711 ) -> Result<
3712 datadog::ResponseContent<
3713 crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
3714 >,
3715 datadog::Error<EditSecurityMonitoringSignalAssigneeError>,
3716 > {
3717 let local_configuration = &self.config;
3718 let operation_id = "v2.edit_security_monitoring_signal_assignee";
3719
3720 let local_client = &self.client;
3721
3722 let local_uri_str = format!(
3723 "{}/api/v2/security_monitoring/signals/{signal_id}/assignee",
3724 local_configuration.get_operation_host(operation_id),
3725 signal_id = datadog::urlencode(signal_id)
3726 );
3727 let mut local_req_builder =
3728 local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
3729
3730 let mut headers = HeaderMap::new();
3732 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
3733 headers.insert("Accept", HeaderValue::from_static("application/json"));
3734
3735 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3737 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3738 Err(e) => {
3739 log::warn!("Failed to parse user agent header: {e}, falling back to default");
3740 headers.insert(
3741 reqwest::header::USER_AGENT,
3742 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3743 )
3744 }
3745 };
3746
3747 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3749 headers.insert(
3750 "DD-API-KEY",
3751 HeaderValue::from_str(local_key.key.as_str())
3752 .expect("failed to parse DD-API-KEY header"),
3753 );
3754 };
3755 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3756 headers.insert(
3757 "DD-APPLICATION-KEY",
3758 HeaderValue::from_str(local_key.key.as_str())
3759 .expect("failed to parse DD-APPLICATION-KEY header"),
3760 );
3761 };
3762
3763 let output = Vec::new();
3765 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
3766 if body.serialize(&mut ser).is_ok() {
3767 if let Some(content_encoding) = headers.get("Content-Encoding") {
3768 match content_encoding.to_str().unwrap_or_default() {
3769 "gzip" => {
3770 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
3771 let _ = enc.write_all(ser.into_inner().as_slice());
3772 match enc.finish() {
3773 Ok(buf) => {
3774 local_req_builder = local_req_builder.body(buf);
3775 }
3776 Err(e) => return Err(datadog::Error::Io(e)),
3777 }
3778 }
3779 "deflate" => {
3780 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
3781 let _ = enc.write_all(ser.into_inner().as_slice());
3782 match enc.finish() {
3783 Ok(buf) => {
3784 local_req_builder = local_req_builder.body(buf);
3785 }
3786 Err(e) => return Err(datadog::Error::Io(e)),
3787 }
3788 }
3789 "zstd1" => {
3790 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
3791 let _ = enc.write_all(ser.into_inner().as_slice());
3792 match enc.finish() {
3793 Ok(buf) => {
3794 local_req_builder = local_req_builder.body(buf);
3795 }
3796 Err(e) => return Err(datadog::Error::Io(e)),
3797 }
3798 }
3799 _ => {
3800 local_req_builder = local_req_builder.body(ser.into_inner());
3801 }
3802 }
3803 } else {
3804 local_req_builder = local_req_builder.body(ser.into_inner());
3805 }
3806 }
3807
3808 local_req_builder = local_req_builder.headers(headers);
3809 let local_req = local_req_builder.build()?;
3810 log::debug!("request content: {:?}", local_req.body());
3811 let local_resp = local_client.execute(local_req).await?;
3812
3813 let local_status = local_resp.status();
3814 let local_content = local_resp.text().await?;
3815 log::debug!("response content: {}", local_content);
3816
3817 if !local_status.is_client_error() && !local_status.is_server_error() {
3818 match serde_json::from_str::<
3819 crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
3820 >(&local_content)
3821 {
3822 Ok(e) => {
3823 return Ok(datadog::ResponseContent {
3824 status: local_status,
3825 content: local_content,
3826 entity: Some(e),
3827 })
3828 }
3829 Err(e) => return Err(datadog::Error::Serde(e)),
3830 };
3831 } else {
3832 let local_entity: Option<EditSecurityMonitoringSignalAssigneeError> =
3833 serde_json::from_str(&local_content).ok();
3834 let local_error = datadog::ResponseContent {
3835 status: local_status,
3836 content: local_content,
3837 entity: local_entity,
3838 };
3839 Err(datadog::Error::ResponseError(local_error))
3840 }
3841 }
3842
3843 pub async fn edit_security_monitoring_signal_incidents(
3845 &self,
3846 signal_id: String,
3847 body: crate::datadogV2::model::SecurityMonitoringSignalIncidentsUpdateRequest,
3848 ) -> Result<
3849 crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
3850 datadog::Error<EditSecurityMonitoringSignalIncidentsError>,
3851 > {
3852 match self
3853 .edit_security_monitoring_signal_incidents_with_http_info(signal_id, body)
3854 .await
3855 {
3856 Ok(response_content) => {
3857 if let Some(e) = response_content.entity {
3858 Ok(e)
3859 } else {
3860 Err(datadog::Error::Serde(serde::de::Error::custom(
3861 "response content was None",
3862 )))
3863 }
3864 }
3865 Err(err) => Err(err),
3866 }
3867 }
3868
3869 pub async fn edit_security_monitoring_signal_incidents_with_http_info(
3871 &self,
3872 signal_id: String,
3873 body: crate::datadogV2::model::SecurityMonitoringSignalIncidentsUpdateRequest,
3874 ) -> Result<
3875 datadog::ResponseContent<
3876 crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
3877 >,
3878 datadog::Error<EditSecurityMonitoringSignalIncidentsError>,
3879 > {
3880 let local_configuration = &self.config;
3881 let operation_id = "v2.edit_security_monitoring_signal_incidents";
3882
3883 let local_client = &self.client;
3884
3885 let local_uri_str = format!(
3886 "{}/api/v2/security_monitoring/signals/{signal_id}/incidents",
3887 local_configuration.get_operation_host(operation_id),
3888 signal_id = datadog::urlencode(signal_id)
3889 );
3890 let mut local_req_builder =
3891 local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
3892
3893 let mut headers = HeaderMap::new();
3895 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
3896 headers.insert("Accept", HeaderValue::from_static("application/json"));
3897
3898 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3900 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3901 Err(e) => {
3902 log::warn!("Failed to parse user agent header: {e}, falling back to default");
3903 headers.insert(
3904 reqwest::header::USER_AGENT,
3905 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3906 )
3907 }
3908 };
3909
3910 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3912 headers.insert(
3913 "DD-API-KEY",
3914 HeaderValue::from_str(local_key.key.as_str())
3915 .expect("failed to parse DD-API-KEY header"),
3916 );
3917 };
3918 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3919 headers.insert(
3920 "DD-APPLICATION-KEY",
3921 HeaderValue::from_str(local_key.key.as_str())
3922 .expect("failed to parse DD-APPLICATION-KEY header"),
3923 );
3924 };
3925
3926 let output = Vec::new();
3928 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
3929 if body.serialize(&mut ser).is_ok() {
3930 if let Some(content_encoding) = headers.get("Content-Encoding") {
3931 match content_encoding.to_str().unwrap_or_default() {
3932 "gzip" => {
3933 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
3934 let _ = enc.write_all(ser.into_inner().as_slice());
3935 match enc.finish() {
3936 Ok(buf) => {
3937 local_req_builder = local_req_builder.body(buf);
3938 }
3939 Err(e) => return Err(datadog::Error::Io(e)),
3940 }
3941 }
3942 "deflate" => {
3943 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
3944 let _ = enc.write_all(ser.into_inner().as_slice());
3945 match enc.finish() {
3946 Ok(buf) => {
3947 local_req_builder = local_req_builder.body(buf);
3948 }
3949 Err(e) => return Err(datadog::Error::Io(e)),
3950 }
3951 }
3952 "zstd1" => {
3953 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
3954 let _ = enc.write_all(ser.into_inner().as_slice());
3955 match enc.finish() {
3956 Ok(buf) => {
3957 local_req_builder = local_req_builder.body(buf);
3958 }
3959 Err(e) => return Err(datadog::Error::Io(e)),
3960 }
3961 }
3962 _ => {
3963 local_req_builder = local_req_builder.body(ser.into_inner());
3964 }
3965 }
3966 } else {
3967 local_req_builder = local_req_builder.body(ser.into_inner());
3968 }
3969 }
3970
3971 local_req_builder = local_req_builder.headers(headers);
3972 let local_req = local_req_builder.build()?;
3973 log::debug!("request content: {:?}", local_req.body());
3974 let local_resp = local_client.execute(local_req).await?;
3975
3976 let local_status = local_resp.status();
3977 let local_content = local_resp.text().await?;
3978 log::debug!("response content: {}", local_content);
3979
3980 if !local_status.is_client_error() && !local_status.is_server_error() {
3981 match serde_json::from_str::<
3982 crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
3983 >(&local_content)
3984 {
3985 Ok(e) => {
3986 return Ok(datadog::ResponseContent {
3987 status: local_status,
3988 content: local_content,
3989 entity: Some(e),
3990 })
3991 }
3992 Err(e) => return Err(datadog::Error::Serde(e)),
3993 };
3994 } else {
3995 let local_entity: Option<EditSecurityMonitoringSignalIncidentsError> =
3996 serde_json::from_str(&local_content).ok();
3997 let local_error = datadog::ResponseContent {
3998 status: local_status,
3999 content: local_content,
4000 entity: local_entity,
4001 };
4002 Err(datadog::Error::ResponseError(local_error))
4003 }
4004 }
4005
4006 pub async fn edit_security_monitoring_signal_state(
4008 &self,
4009 signal_id: String,
4010 body: crate::datadogV2::model::SecurityMonitoringSignalStateUpdateRequest,
4011 ) -> Result<
4012 crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
4013 datadog::Error<EditSecurityMonitoringSignalStateError>,
4014 > {
4015 match self
4016 .edit_security_monitoring_signal_state_with_http_info(signal_id, body)
4017 .await
4018 {
4019 Ok(response_content) => {
4020 if let Some(e) = response_content.entity {
4021 Ok(e)
4022 } else {
4023 Err(datadog::Error::Serde(serde::de::Error::custom(
4024 "response content was None",
4025 )))
4026 }
4027 }
4028 Err(err) => Err(err),
4029 }
4030 }
4031
4032 pub async fn edit_security_monitoring_signal_state_with_http_info(
4034 &self,
4035 signal_id: String,
4036 body: crate::datadogV2::model::SecurityMonitoringSignalStateUpdateRequest,
4037 ) -> Result<
4038 datadog::ResponseContent<
4039 crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
4040 >,
4041 datadog::Error<EditSecurityMonitoringSignalStateError>,
4042 > {
4043 let local_configuration = &self.config;
4044 let operation_id = "v2.edit_security_monitoring_signal_state";
4045
4046 let local_client = &self.client;
4047
4048 let local_uri_str = format!(
4049 "{}/api/v2/security_monitoring/signals/{signal_id}/state",
4050 local_configuration.get_operation_host(operation_id),
4051 signal_id = datadog::urlencode(signal_id)
4052 );
4053 let mut local_req_builder =
4054 local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
4055
4056 let mut headers = HeaderMap::new();
4058 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
4059 headers.insert("Accept", HeaderValue::from_static("application/json"));
4060
4061 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4063 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4064 Err(e) => {
4065 log::warn!("Failed to parse user agent header: {e}, falling back to default");
4066 headers.insert(
4067 reqwest::header::USER_AGENT,
4068 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4069 )
4070 }
4071 };
4072
4073 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4075 headers.insert(
4076 "DD-API-KEY",
4077 HeaderValue::from_str(local_key.key.as_str())
4078 .expect("failed to parse DD-API-KEY header"),
4079 );
4080 };
4081 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4082 headers.insert(
4083 "DD-APPLICATION-KEY",
4084 HeaderValue::from_str(local_key.key.as_str())
4085 .expect("failed to parse DD-APPLICATION-KEY header"),
4086 );
4087 };
4088
4089 let output = Vec::new();
4091 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
4092 if body.serialize(&mut ser).is_ok() {
4093 if let Some(content_encoding) = headers.get("Content-Encoding") {
4094 match content_encoding.to_str().unwrap_or_default() {
4095 "gzip" => {
4096 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
4097 let _ = enc.write_all(ser.into_inner().as_slice());
4098 match enc.finish() {
4099 Ok(buf) => {
4100 local_req_builder = local_req_builder.body(buf);
4101 }
4102 Err(e) => return Err(datadog::Error::Io(e)),
4103 }
4104 }
4105 "deflate" => {
4106 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
4107 let _ = enc.write_all(ser.into_inner().as_slice());
4108 match enc.finish() {
4109 Ok(buf) => {
4110 local_req_builder = local_req_builder.body(buf);
4111 }
4112 Err(e) => return Err(datadog::Error::Io(e)),
4113 }
4114 }
4115 "zstd1" => {
4116 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
4117 let _ = enc.write_all(ser.into_inner().as_slice());
4118 match enc.finish() {
4119 Ok(buf) => {
4120 local_req_builder = local_req_builder.body(buf);
4121 }
4122 Err(e) => return Err(datadog::Error::Io(e)),
4123 }
4124 }
4125 _ => {
4126 local_req_builder = local_req_builder.body(ser.into_inner());
4127 }
4128 }
4129 } else {
4130 local_req_builder = local_req_builder.body(ser.into_inner());
4131 }
4132 }
4133
4134 local_req_builder = local_req_builder.headers(headers);
4135 let local_req = local_req_builder.build()?;
4136 log::debug!("request content: {:?}", local_req.body());
4137 let local_resp = local_client.execute(local_req).await?;
4138
4139 let local_status = local_resp.status();
4140 let local_content = local_resp.text().await?;
4141 log::debug!("response content: {}", local_content);
4142
4143 if !local_status.is_client_error() && !local_status.is_server_error() {
4144 match serde_json::from_str::<
4145 crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
4146 >(&local_content)
4147 {
4148 Ok(e) => {
4149 return Ok(datadog::ResponseContent {
4150 status: local_status,
4151 content: local_content,
4152 entity: Some(e),
4153 })
4154 }
4155 Err(e) => return Err(datadog::Error::Serde(e)),
4156 };
4157 } else {
4158 let local_entity: Option<EditSecurityMonitoringSignalStateError> =
4159 serde_json::from_str(&local_content).ok();
4160 let local_error = datadog::ResponseContent {
4161 status: local_status,
4162 content: local_content,
4163 entity: local_entity,
4164 };
4165 Err(datadog::Error::ResponseError(local_error))
4166 }
4167 }
4168
4169 pub async fn get_custom_framework(
4171 &self,
4172 handle: String,
4173 version: String,
4174 ) -> Result<
4175 crate::datadogV2::model::GetCustomFrameworkResponse,
4176 datadog::Error<GetCustomFrameworkError>,
4177 > {
4178 match self
4179 .get_custom_framework_with_http_info(handle, version)
4180 .await
4181 {
4182 Ok(response_content) => {
4183 if let Some(e) = response_content.entity {
4184 Ok(e)
4185 } else {
4186 Err(datadog::Error::Serde(serde::de::Error::custom(
4187 "response content was None",
4188 )))
4189 }
4190 }
4191 Err(err) => Err(err),
4192 }
4193 }
4194
4195 pub async fn get_custom_framework_with_http_info(
4197 &self,
4198 handle: String,
4199 version: String,
4200 ) -> Result<
4201 datadog::ResponseContent<crate::datadogV2::model::GetCustomFrameworkResponse>,
4202 datadog::Error<GetCustomFrameworkError>,
4203 > {
4204 let local_configuration = &self.config;
4205 let operation_id = "v2.get_custom_framework";
4206
4207 let local_client = &self.client;
4208
4209 let local_uri_str = format!(
4210 "{}/api/v2/cloud_security_management/custom_frameworks/{handle}/{version}",
4211 local_configuration.get_operation_host(operation_id),
4212 handle = datadog::urlencode(handle),
4213 version = datadog::urlencode(version)
4214 );
4215 let mut local_req_builder =
4216 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4217
4218 let mut headers = HeaderMap::new();
4220 headers.insert("Accept", HeaderValue::from_static("application/json"));
4221
4222 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4224 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4225 Err(e) => {
4226 log::warn!("Failed to parse user agent header: {e}, falling back to default");
4227 headers.insert(
4228 reqwest::header::USER_AGENT,
4229 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4230 )
4231 }
4232 };
4233
4234 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4236 headers.insert(
4237 "DD-API-KEY",
4238 HeaderValue::from_str(local_key.key.as_str())
4239 .expect("failed to parse DD-API-KEY header"),
4240 );
4241 };
4242 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4243 headers.insert(
4244 "DD-APPLICATION-KEY",
4245 HeaderValue::from_str(local_key.key.as_str())
4246 .expect("failed to parse DD-APPLICATION-KEY header"),
4247 );
4248 };
4249
4250 local_req_builder = local_req_builder.headers(headers);
4251 let local_req = local_req_builder.build()?;
4252 log::debug!("request content: {:?}", local_req.body());
4253 let local_resp = local_client.execute(local_req).await?;
4254
4255 let local_status = local_resp.status();
4256 let local_content = local_resp.text().await?;
4257 log::debug!("response content: {}", local_content);
4258
4259 if !local_status.is_client_error() && !local_status.is_server_error() {
4260 match serde_json::from_str::<crate::datadogV2::model::GetCustomFrameworkResponse>(
4261 &local_content,
4262 ) {
4263 Ok(e) => {
4264 return Ok(datadog::ResponseContent {
4265 status: local_status,
4266 content: local_content,
4267 entity: Some(e),
4268 })
4269 }
4270 Err(e) => return Err(datadog::Error::Serde(e)),
4271 };
4272 } else {
4273 let local_entity: Option<GetCustomFrameworkError> =
4274 serde_json::from_str(&local_content).ok();
4275 let local_error = datadog::ResponseContent {
4276 status: local_status,
4277 content: local_content,
4278 entity: local_entity,
4279 };
4280 Err(datadog::Error::ResponseError(local_error))
4281 }
4282 }
4283
4284 pub async fn get_finding(
4286 &self,
4287 finding_id: String,
4288 params: GetFindingOptionalParams,
4289 ) -> Result<crate::datadogV2::model::GetFindingResponse, datadog::Error<GetFindingError>> {
4290 match self.get_finding_with_http_info(finding_id, params).await {
4291 Ok(response_content) => {
4292 if let Some(e) = response_content.entity {
4293 Ok(e)
4294 } else {
4295 Err(datadog::Error::Serde(serde::de::Error::custom(
4296 "response content was None",
4297 )))
4298 }
4299 }
4300 Err(err) => Err(err),
4301 }
4302 }
4303
4304 pub async fn get_finding_with_http_info(
4306 &self,
4307 finding_id: String,
4308 params: GetFindingOptionalParams,
4309 ) -> Result<
4310 datadog::ResponseContent<crate::datadogV2::model::GetFindingResponse>,
4311 datadog::Error<GetFindingError>,
4312 > {
4313 let local_configuration = &self.config;
4314 let operation_id = "v2.get_finding";
4315 if local_configuration.is_unstable_operation_enabled(operation_id) {
4316 warn!("Using unstable operation {operation_id}");
4317 } else {
4318 let local_error = datadog::UnstableOperationDisabledError {
4319 msg: "Operation 'v2.get_finding' is not enabled".to_string(),
4320 };
4321 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
4322 }
4323
4324 let snapshot_timestamp = params.snapshot_timestamp;
4326
4327 let local_client = &self.client;
4328
4329 let local_uri_str = format!(
4330 "{}/api/v2/posture_management/findings/{finding_id}",
4331 local_configuration.get_operation_host(operation_id),
4332 finding_id = datadog::urlencode(finding_id)
4333 );
4334 let mut local_req_builder =
4335 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4336
4337 if let Some(ref local_query_param) = snapshot_timestamp {
4338 local_req_builder =
4339 local_req_builder.query(&[("snapshot_timestamp", &local_query_param.to_string())]);
4340 };
4341
4342 let mut headers = HeaderMap::new();
4344 headers.insert("Accept", HeaderValue::from_static("application/json"));
4345
4346 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4348 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4349 Err(e) => {
4350 log::warn!("Failed to parse user agent header: {e}, falling back to default");
4351 headers.insert(
4352 reqwest::header::USER_AGENT,
4353 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4354 )
4355 }
4356 };
4357
4358 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4360 headers.insert(
4361 "DD-API-KEY",
4362 HeaderValue::from_str(local_key.key.as_str())
4363 .expect("failed to parse DD-API-KEY header"),
4364 );
4365 };
4366 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4367 headers.insert(
4368 "DD-APPLICATION-KEY",
4369 HeaderValue::from_str(local_key.key.as_str())
4370 .expect("failed to parse DD-APPLICATION-KEY header"),
4371 );
4372 };
4373
4374 local_req_builder = local_req_builder.headers(headers);
4375 let local_req = local_req_builder.build()?;
4376 log::debug!("request content: {:?}", local_req.body());
4377 let local_resp = local_client.execute(local_req).await?;
4378
4379 let local_status = local_resp.status();
4380 let local_content = local_resp.text().await?;
4381 log::debug!("response content: {}", local_content);
4382
4383 if !local_status.is_client_error() && !local_status.is_server_error() {
4384 match serde_json::from_str::<crate::datadogV2::model::GetFindingResponse>(
4385 &local_content,
4386 ) {
4387 Ok(e) => {
4388 return Ok(datadog::ResponseContent {
4389 status: local_status,
4390 content: local_content,
4391 entity: Some(e),
4392 })
4393 }
4394 Err(e) => return Err(datadog::Error::Serde(e)),
4395 };
4396 } else {
4397 let local_entity: Option<GetFindingError> = serde_json::from_str(&local_content).ok();
4398 let local_error = datadog::ResponseContent {
4399 status: local_status,
4400 content: local_content,
4401 entity: local_entity,
4402 };
4403 Err(datadog::Error::ResponseError(local_error))
4404 }
4405 }
4406
4407 pub async fn get_historical_job(
4409 &self,
4410 job_id: String,
4411 ) -> Result<crate::datadogV2::model::HistoricalJobResponse, datadog::Error<GetHistoricalJobError>>
4412 {
4413 match self.get_historical_job_with_http_info(job_id).await {
4414 Ok(response_content) => {
4415 if let Some(e) = response_content.entity {
4416 Ok(e)
4417 } else {
4418 Err(datadog::Error::Serde(serde::de::Error::custom(
4419 "response content was None",
4420 )))
4421 }
4422 }
4423 Err(err) => Err(err),
4424 }
4425 }
4426
4427 pub async fn get_historical_job_with_http_info(
4429 &self,
4430 job_id: String,
4431 ) -> Result<
4432 datadog::ResponseContent<crate::datadogV2::model::HistoricalJobResponse>,
4433 datadog::Error<GetHistoricalJobError>,
4434 > {
4435 let local_configuration = &self.config;
4436 let operation_id = "v2.get_historical_job";
4437 if local_configuration.is_unstable_operation_enabled(operation_id) {
4438 warn!("Using unstable operation {operation_id}");
4439 } else {
4440 let local_error = datadog::UnstableOperationDisabledError {
4441 msg: "Operation 'v2.get_historical_job' is not enabled".to_string(),
4442 };
4443 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
4444 }
4445
4446 let local_client = &self.client;
4447
4448 let local_uri_str = format!(
4449 "{}/api/v2/siem-historical-detections/jobs/{job_id}",
4450 local_configuration.get_operation_host(operation_id),
4451 job_id = datadog::urlencode(job_id)
4452 );
4453 let mut local_req_builder =
4454 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4455
4456 let mut headers = HeaderMap::new();
4458 headers.insert("Accept", HeaderValue::from_static("application/json"));
4459
4460 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4462 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4463 Err(e) => {
4464 log::warn!("Failed to parse user agent header: {e}, falling back to default");
4465 headers.insert(
4466 reqwest::header::USER_AGENT,
4467 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4468 )
4469 }
4470 };
4471
4472 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4474 headers.insert(
4475 "DD-API-KEY",
4476 HeaderValue::from_str(local_key.key.as_str())
4477 .expect("failed to parse DD-API-KEY header"),
4478 );
4479 };
4480 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4481 headers.insert(
4482 "DD-APPLICATION-KEY",
4483 HeaderValue::from_str(local_key.key.as_str())
4484 .expect("failed to parse DD-APPLICATION-KEY header"),
4485 );
4486 };
4487
4488 local_req_builder = local_req_builder.headers(headers);
4489 let local_req = local_req_builder.build()?;
4490 log::debug!("request content: {:?}", local_req.body());
4491 let local_resp = local_client.execute(local_req).await?;
4492
4493 let local_status = local_resp.status();
4494 let local_content = local_resp.text().await?;
4495 log::debug!("response content: {}", local_content);
4496
4497 if !local_status.is_client_error() && !local_status.is_server_error() {
4498 match serde_json::from_str::<crate::datadogV2::model::HistoricalJobResponse>(
4499 &local_content,
4500 ) {
4501 Ok(e) => {
4502 return Ok(datadog::ResponseContent {
4503 status: local_status,
4504 content: local_content,
4505 entity: Some(e),
4506 })
4507 }
4508 Err(e) => return Err(datadog::Error::Serde(e)),
4509 };
4510 } else {
4511 let local_entity: Option<GetHistoricalJobError> =
4512 serde_json::from_str(&local_content).ok();
4513 let local_error = datadog::ResponseContent {
4514 status: local_status,
4515 content: local_content,
4516 entity: local_entity,
4517 };
4518 Err(datadog::Error::ResponseError(local_error))
4519 }
4520 }
4521
4522 pub async fn get_resource_evaluation_filters(
4524 &self,
4525 params: GetResourceEvaluationFiltersOptionalParams,
4526 ) -> Result<
4527 crate::datadogV2::model::GetResourceEvaluationFiltersResponse,
4528 datadog::Error<GetResourceEvaluationFiltersError>,
4529 > {
4530 match self
4531 .get_resource_evaluation_filters_with_http_info(params)
4532 .await
4533 {
4534 Ok(response_content) => {
4535 if let Some(e) = response_content.entity {
4536 Ok(e)
4537 } else {
4538 Err(datadog::Error::Serde(serde::de::Error::custom(
4539 "response content was None",
4540 )))
4541 }
4542 }
4543 Err(err) => Err(err),
4544 }
4545 }
4546
4547 pub async fn get_resource_evaluation_filters_with_http_info(
4549 &self,
4550 params: GetResourceEvaluationFiltersOptionalParams,
4551 ) -> Result<
4552 datadog::ResponseContent<crate::datadogV2::model::GetResourceEvaluationFiltersResponse>,
4553 datadog::Error<GetResourceEvaluationFiltersError>,
4554 > {
4555 let local_configuration = &self.config;
4556 let operation_id = "v2.get_resource_evaluation_filters";
4557
4558 let cloud_provider = params.cloud_provider;
4560 let account_id = params.account_id;
4561 let skip_cache = params.skip_cache;
4562
4563 let local_client = &self.client;
4564
4565 let local_uri_str = format!(
4566 "{}/api/v2/cloud_security_management/resource_filters",
4567 local_configuration.get_operation_host(operation_id)
4568 );
4569 let mut local_req_builder =
4570 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4571
4572 if let Some(ref local_query_param) = cloud_provider {
4573 local_req_builder =
4574 local_req_builder.query(&[("cloud_provider", &local_query_param.to_string())]);
4575 };
4576 if let Some(ref local_query_param) = account_id {
4577 local_req_builder =
4578 local_req_builder.query(&[("account_id", &local_query_param.to_string())]);
4579 };
4580 if let Some(ref local_query_param) = skip_cache {
4581 local_req_builder =
4582 local_req_builder.query(&[("skip_cache", &local_query_param.to_string())]);
4583 };
4584
4585 let mut headers = HeaderMap::new();
4587 headers.insert("Accept", HeaderValue::from_static("application/json"));
4588
4589 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4591 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4592 Err(e) => {
4593 log::warn!("Failed to parse user agent header: {e}, falling back to default");
4594 headers.insert(
4595 reqwest::header::USER_AGENT,
4596 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4597 )
4598 }
4599 };
4600
4601 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4603 headers.insert(
4604 "DD-API-KEY",
4605 HeaderValue::from_str(local_key.key.as_str())
4606 .expect("failed to parse DD-API-KEY header"),
4607 );
4608 };
4609 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4610 headers.insert(
4611 "DD-APPLICATION-KEY",
4612 HeaderValue::from_str(local_key.key.as_str())
4613 .expect("failed to parse DD-APPLICATION-KEY header"),
4614 );
4615 };
4616
4617 local_req_builder = local_req_builder.headers(headers);
4618 let local_req = local_req_builder.build()?;
4619 log::debug!("request content: {:?}", local_req.body());
4620 let local_resp = local_client.execute(local_req).await?;
4621
4622 let local_status = local_resp.status();
4623 let local_content = local_resp.text().await?;
4624 log::debug!("response content: {}", local_content);
4625
4626 if !local_status.is_client_error() && !local_status.is_server_error() {
4627 match serde_json::from_str::<
4628 crate::datadogV2::model::GetResourceEvaluationFiltersResponse,
4629 >(&local_content)
4630 {
4631 Ok(e) => {
4632 return Ok(datadog::ResponseContent {
4633 status: local_status,
4634 content: local_content,
4635 entity: Some(e),
4636 })
4637 }
4638 Err(e) => return Err(datadog::Error::Serde(e)),
4639 };
4640 } else {
4641 let local_entity: Option<GetResourceEvaluationFiltersError> =
4642 serde_json::from_str(&local_content).ok();
4643 let local_error = datadog::ResponseContent {
4644 status: local_status,
4645 content: local_content,
4646 entity: local_entity,
4647 };
4648 Err(datadog::Error::ResponseError(local_error))
4649 }
4650 }
4651
4652 pub async fn get_rule_version_history(
4654 &self,
4655 rule_id: String,
4656 params: GetRuleVersionHistoryOptionalParams,
4657 ) -> Result<
4658 crate::datadogV2::model::GetRuleVersionHistoryResponse,
4659 datadog::Error<GetRuleVersionHistoryError>,
4660 > {
4661 match self
4662 .get_rule_version_history_with_http_info(rule_id, params)
4663 .await
4664 {
4665 Ok(response_content) => {
4666 if let Some(e) = response_content.entity {
4667 Ok(e)
4668 } else {
4669 Err(datadog::Error::Serde(serde::de::Error::custom(
4670 "response content was None",
4671 )))
4672 }
4673 }
4674 Err(err) => Err(err),
4675 }
4676 }
4677
4678 pub async fn get_rule_version_history_with_http_info(
4680 &self,
4681 rule_id: String,
4682 params: GetRuleVersionHistoryOptionalParams,
4683 ) -> Result<
4684 datadog::ResponseContent<crate::datadogV2::model::GetRuleVersionHistoryResponse>,
4685 datadog::Error<GetRuleVersionHistoryError>,
4686 > {
4687 let local_configuration = &self.config;
4688 let operation_id = "v2.get_rule_version_history";
4689 if local_configuration.is_unstable_operation_enabled(operation_id) {
4690 warn!("Using unstable operation {operation_id}");
4691 } else {
4692 let local_error = datadog::UnstableOperationDisabledError {
4693 msg: "Operation 'v2.get_rule_version_history' is not enabled".to_string(),
4694 };
4695 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
4696 }
4697
4698 let page_size = params.page_size;
4700 let page_number = params.page_number;
4701
4702 let local_client = &self.client;
4703
4704 let local_uri_str = format!(
4705 "{}/api/v2/security_monitoring/rules/{rule_id}/version_history",
4706 local_configuration.get_operation_host(operation_id),
4707 rule_id = datadog::urlencode(rule_id)
4708 );
4709 let mut local_req_builder =
4710 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4711
4712 if let Some(ref local_query_param) = page_size {
4713 local_req_builder =
4714 local_req_builder.query(&[("page[size]", &local_query_param.to_string())]);
4715 };
4716 if let Some(ref local_query_param) = page_number {
4717 local_req_builder =
4718 local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
4719 };
4720
4721 let mut headers = HeaderMap::new();
4723 headers.insert("Accept", HeaderValue::from_static("application/json"));
4724
4725 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4727 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4728 Err(e) => {
4729 log::warn!("Failed to parse user agent header: {e}, falling back to default");
4730 headers.insert(
4731 reqwest::header::USER_AGENT,
4732 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4733 )
4734 }
4735 };
4736
4737 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4739 headers.insert(
4740 "DD-API-KEY",
4741 HeaderValue::from_str(local_key.key.as_str())
4742 .expect("failed to parse DD-API-KEY header"),
4743 );
4744 };
4745 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4746 headers.insert(
4747 "DD-APPLICATION-KEY",
4748 HeaderValue::from_str(local_key.key.as_str())
4749 .expect("failed to parse DD-APPLICATION-KEY header"),
4750 );
4751 };
4752
4753 local_req_builder = local_req_builder.headers(headers);
4754 let local_req = local_req_builder.build()?;
4755 log::debug!("request content: {:?}", local_req.body());
4756 let local_resp = local_client.execute(local_req).await?;
4757
4758 let local_status = local_resp.status();
4759 let local_content = local_resp.text().await?;
4760 log::debug!("response content: {}", local_content);
4761
4762 if !local_status.is_client_error() && !local_status.is_server_error() {
4763 match serde_json::from_str::<crate::datadogV2::model::GetRuleVersionHistoryResponse>(
4764 &local_content,
4765 ) {
4766 Ok(e) => {
4767 return Ok(datadog::ResponseContent {
4768 status: local_status,
4769 content: local_content,
4770 entity: Some(e),
4771 })
4772 }
4773 Err(e) => return Err(datadog::Error::Serde(e)),
4774 };
4775 } else {
4776 let local_entity: Option<GetRuleVersionHistoryError> =
4777 serde_json::from_str(&local_content).ok();
4778 let local_error = datadog::ResponseContent {
4779 status: local_status,
4780 content: local_content,
4781 entity: local_entity,
4782 };
4783 Err(datadog::Error::ResponseError(local_error))
4784 }
4785 }
4786
4787 pub async fn get_sbom(
4790 &self,
4791 asset_type: crate::datadogV2::model::AssetType,
4792 filter_asset_name: String,
4793 params: GetSBOMOptionalParams,
4794 ) -> Result<crate::datadogV2::model::GetSBOMResponse, datadog::Error<GetSBOMError>> {
4795 match self
4796 .get_sbom_with_http_info(asset_type, filter_asset_name, params)
4797 .await
4798 {
4799 Ok(response_content) => {
4800 if let Some(e) = response_content.entity {
4801 Ok(e)
4802 } else {
4803 Err(datadog::Error::Serde(serde::de::Error::custom(
4804 "response content was None",
4805 )))
4806 }
4807 }
4808 Err(err) => Err(err),
4809 }
4810 }
4811
4812 pub async fn get_sbom_with_http_info(
4815 &self,
4816 asset_type: crate::datadogV2::model::AssetType,
4817 filter_asset_name: String,
4818 params: GetSBOMOptionalParams,
4819 ) -> Result<
4820 datadog::ResponseContent<crate::datadogV2::model::GetSBOMResponse>,
4821 datadog::Error<GetSBOMError>,
4822 > {
4823 let local_configuration = &self.config;
4824 let operation_id = "v2.get_sbom";
4825 if local_configuration.is_unstable_operation_enabled(operation_id) {
4826 warn!("Using unstable operation {operation_id}");
4827 } else {
4828 let local_error = datadog::UnstableOperationDisabledError {
4829 msg: "Operation 'v2.get_sbom' is not enabled".to_string(),
4830 };
4831 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
4832 }
4833
4834 let filter_repo_digest = params.filter_repo_digest;
4836
4837 let local_client = &self.client;
4838
4839 let local_uri_str = format!(
4840 "{}/api/v2/security/sboms/{asset_type}",
4841 local_configuration.get_operation_host(operation_id),
4842 asset_type = datadog::urlencode(asset_type.to_string())
4843 );
4844 let mut local_req_builder =
4845 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4846
4847 local_req_builder =
4848 local_req_builder.query(&[("filter[asset_name]", &filter_asset_name.to_string())]);
4849 if let Some(ref local_query_param) = filter_repo_digest {
4850 local_req_builder =
4851 local_req_builder.query(&[("filter[repo_digest]", &local_query_param.to_string())]);
4852 };
4853
4854 let mut headers = HeaderMap::new();
4856 headers.insert("Accept", HeaderValue::from_static("application/json"));
4857
4858 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4860 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4861 Err(e) => {
4862 log::warn!("Failed to parse user agent header: {e}, falling back to default");
4863 headers.insert(
4864 reqwest::header::USER_AGENT,
4865 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4866 )
4867 }
4868 };
4869
4870 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4872 headers.insert(
4873 "DD-API-KEY",
4874 HeaderValue::from_str(local_key.key.as_str())
4875 .expect("failed to parse DD-API-KEY header"),
4876 );
4877 };
4878 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4879 headers.insert(
4880 "DD-APPLICATION-KEY",
4881 HeaderValue::from_str(local_key.key.as_str())
4882 .expect("failed to parse DD-APPLICATION-KEY header"),
4883 );
4884 };
4885
4886 local_req_builder = local_req_builder.headers(headers);
4887 let local_req = local_req_builder.build()?;
4888 log::debug!("request content: {:?}", local_req.body());
4889 let local_resp = local_client.execute(local_req).await?;
4890
4891 let local_status = local_resp.status();
4892 let local_content = local_resp.text().await?;
4893 log::debug!("response content: {}", local_content);
4894
4895 if !local_status.is_client_error() && !local_status.is_server_error() {
4896 match serde_json::from_str::<crate::datadogV2::model::GetSBOMResponse>(&local_content) {
4897 Ok(e) => {
4898 return Ok(datadog::ResponseContent {
4899 status: local_status,
4900 content: local_content,
4901 entity: Some(e),
4902 })
4903 }
4904 Err(e) => return Err(datadog::Error::Serde(e)),
4905 };
4906 } else {
4907 let local_entity: Option<GetSBOMError> = serde_json::from_str(&local_content).ok();
4908 let local_error = datadog::ResponseContent {
4909 status: local_status,
4910 content: local_content,
4911 entity: local_entity,
4912 };
4913 Err(datadog::Error::ResponseError(local_error))
4914 }
4915 }
4916
4917 pub async fn get_security_filter(
4922 &self,
4923 security_filter_id: String,
4924 ) -> Result<
4925 crate::datadogV2::model::SecurityFilterResponse,
4926 datadog::Error<GetSecurityFilterError>,
4927 > {
4928 match self
4929 .get_security_filter_with_http_info(security_filter_id)
4930 .await
4931 {
4932 Ok(response_content) => {
4933 if let Some(e) = response_content.entity {
4934 Ok(e)
4935 } else {
4936 Err(datadog::Error::Serde(serde::de::Error::custom(
4937 "response content was None",
4938 )))
4939 }
4940 }
4941 Err(err) => Err(err),
4942 }
4943 }
4944
4945 pub async fn get_security_filter_with_http_info(
4950 &self,
4951 security_filter_id: String,
4952 ) -> Result<
4953 datadog::ResponseContent<crate::datadogV2::model::SecurityFilterResponse>,
4954 datadog::Error<GetSecurityFilterError>,
4955 > {
4956 let local_configuration = &self.config;
4957 let operation_id = "v2.get_security_filter";
4958
4959 let local_client = &self.client;
4960
4961 let local_uri_str = format!(
4962 "{}/api/v2/security_monitoring/configuration/security_filters/{security_filter_id}",
4963 local_configuration.get_operation_host(operation_id),
4964 security_filter_id = datadog::urlencode(security_filter_id)
4965 );
4966 let mut local_req_builder =
4967 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4968
4969 let mut headers = HeaderMap::new();
4971 headers.insert("Accept", HeaderValue::from_static("application/json"));
4972
4973 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4975 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4976 Err(e) => {
4977 log::warn!("Failed to parse user agent header: {e}, falling back to default");
4978 headers.insert(
4979 reqwest::header::USER_AGENT,
4980 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4981 )
4982 }
4983 };
4984
4985 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4987 headers.insert(
4988 "DD-API-KEY",
4989 HeaderValue::from_str(local_key.key.as_str())
4990 .expect("failed to parse DD-API-KEY header"),
4991 );
4992 };
4993 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4994 headers.insert(
4995 "DD-APPLICATION-KEY",
4996 HeaderValue::from_str(local_key.key.as_str())
4997 .expect("failed to parse DD-APPLICATION-KEY header"),
4998 );
4999 };
5000
5001 local_req_builder = local_req_builder.headers(headers);
5002 let local_req = local_req_builder.build()?;
5003 log::debug!("request content: {:?}", local_req.body());
5004 let local_resp = local_client.execute(local_req).await?;
5005
5006 let local_status = local_resp.status();
5007 let local_content = local_resp.text().await?;
5008 log::debug!("response content: {}", local_content);
5009
5010 if !local_status.is_client_error() && !local_status.is_server_error() {
5011 match serde_json::from_str::<crate::datadogV2::model::SecurityFilterResponse>(
5012 &local_content,
5013 ) {
5014 Ok(e) => {
5015 return Ok(datadog::ResponseContent {
5016 status: local_status,
5017 content: local_content,
5018 entity: Some(e),
5019 })
5020 }
5021 Err(e) => return Err(datadog::Error::Serde(e)),
5022 };
5023 } else {
5024 let local_entity: Option<GetSecurityFilterError> =
5025 serde_json::from_str(&local_content).ok();
5026 let local_error = datadog::ResponseContent {
5027 status: local_status,
5028 content: local_content,
5029 entity: local_entity,
5030 };
5031 Err(datadog::Error::ResponseError(local_error))
5032 }
5033 }
5034
5035 pub async fn get_security_monitoring_histsignal(
5037 &self,
5038 histsignal_id: String,
5039 ) -> Result<
5040 crate::datadogV2::model::SecurityMonitoringSignalResponse,
5041 datadog::Error<GetSecurityMonitoringHistsignalError>,
5042 > {
5043 match self
5044 .get_security_monitoring_histsignal_with_http_info(histsignal_id)
5045 .await
5046 {
5047 Ok(response_content) => {
5048 if let Some(e) = response_content.entity {
5049 Ok(e)
5050 } else {
5051 Err(datadog::Error::Serde(serde::de::Error::custom(
5052 "response content was None",
5053 )))
5054 }
5055 }
5056 Err(err) => Err(err),
5057 }
5058 }
5059
5060 pub async fn get_security_monitoring_histsignal_with_http_info(
5062 &self,
5063 histsignal_id: String,
5064 ) -> Result<
5065 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSignalResponse>,
5066 datadog::Error<GetSecurityMonitoringHistsignalError>,
5067 > {
5068 let local_configuration = &self.config;
5069 let operation_id = "v2.get_security_monitoring_histsignal";
5070 if local_configuration.is_unstable_operation_enabled(operation_id) {
5071 warn!("Using unstable operation {operation_id}");
5072 } else {
5073 let local_error = datadog::UnstableOperationDisabledError {
5074 msg: "Operation 'v2.get_security_monitoring_histsignal' is not enabled".to_string(),
5075 };
5076 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
5077 }
5078
5079 let local_client = &self.client;
5080
5081 let local_uri_str = format!(
5082 "{}/api/v2/siem-historical-detections/histsignals/{histsignal_id}",
5083 local_configuration.get_operation_host(operation_id),
5084 histsignal_id = datadog::urlencode(histsignal_id)
5085 );
5086 let mut local_req_builder =
5087 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5088
5089 let mut headers = HeaderMap::new();
5091 headers.insert("Accept", HeaderValue::from_static("application/json"));
5092
5093 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5095 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5096 Err(e) => {
5097 log::warn!("Failed to parse user agent header: {e}, falling back to default");
5098 headers.insert(
5099 reqwest::header::USER_AGENT,
5100 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5101 )
5102 }
5103 };
5104
5105 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5107 headers.insert(
5108 "DD-API-KEY",
5109 HeaderValue::from_str(local_key.key.as_str())
5110 .expect("failed to parse DD-API-KEY header"),
5111 );
5112 };
5113 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5114 headers.insert(
5115 "DD-APPLICATION-KEY",
5116 HeaderValue::from_str(local_key.key.as_str())
5117 .expect("failed to parse DD-APPLICATION-KEY header"),
5118 );
5119 };
5120
5121 local_req_builder = local_req_builder.headers(headers);
5122 let local_req = local_req_builder.build()?;
5123 log::debug!("request content: {:?}", local_req.body());
5124 let local_resp = local_client.execute(local_req).await?;
5125
5126 let local_status = local_resp.status();
5127 let local_content = local_resp.text().await?;
5128 log::debug!("response content: {}", local_content);
5129
5130 if !local_status.is_client_error() && !local_status.is_server_error() {
5131 match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringSignalResponse>(
5132 &local_content,
5133 ) {
5134 Ok(e) => {
5135 return Ok(datadog::ResponseContent {
5136 status: local_status,
5137 content: local_content,
5138 entity: Some(e),
5139 })
5140 }
5141 Err(e) => return Err(datadog::Error::Serde(e)),
5142 };
5143 } else {
5144 let local_entity: Option<GetSecurityMonitoringHistsignalError> =
5145 serde_json::from_str(&local_content).ok();
5146 let local_error = datadog::ResponseContent {
5147 status: local_status,
5148 content: local_content,
5149 entity: local_entity,
5150 };
5151 Err(datadog::Error::ResponseError(local_error))
5152 }
5153 }
5154
5155 pub async fn get_security_monitoring_histsignals_by_job_id(
5157 &self,
5158 job_id: String,
5159 params: GetSecurityMonitoringHistsignalsByJobIdOptionalParams,
5160 ) -> Result<
5161 crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
5162 datadog::Error<GetSecurityMonitoringHistsignalsByJobIdError>,
5163 > {
5164 match self
5165 .get_security_monitoring_histsignals_by_job_id_with_http_info(job_id, params)
5166 .await
5167 {
5168 Ok(response_content) => {
5169 if let Some(e) = response_content.entity {
5170 Ok(e)
5171 } else {
5172 Err(datadog::Error::Serde(serde::de::Error::custom(
5173 "response content was None",
5174 )))
5175 }
5176 }
5177 Err(err) => Err(err),
5178 }
5179 }
5180
5181 pub async fn get_security_monitoring_histsignals_by_job_id_with_http_info(
5183 &self,
5184 job_id: String,
5185 params: GetSecurityMonitoringHistsignalsByJobIdOptionalParams,
5186 ) -> Result<
5187 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSignalsListResponse>,
5188 datadog::Error<GetSecurityMonitoringHistsignalsByJobIdError>,
5189 > {
5190 let local_configuration = &self.config;
5191 let operation_id = "v2.get_security_monitoring_histsignals_by_job_id";
5192 if local_configuration.is_unstable_operation_enabled(operation_id) {
5193 warn!("Using unstable operation {operation_id}");
5194 } else {
5195 let local_error = datadog::UnstableOperationDisabledError {
5196 msg: "Operation 'v2.get_security_monitoring_histsignals_by_job_id' is not enabled"
5197 .to_string(),
5198 };
5199 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
5200 }
5201
5202 let filter_query = params.filter_query;
5204 let filter_from = params.filter_from;
5205 let filter_to = params.filter_to;
5206 let sort = params.sort;
5207 let page_cursor = params.page_cursor;
5208 let page_limit = params.page_limit;
5209
5210 let local_client = &self.client;
5211
5212 let local_uri_str = format!(
5213 "{}/api/v2/siem-historical-detections/jobs/{job_id}/histsignals",
5214 local_configuration.get_operation_host(operation_id),
5215 job_id = datadog::urlencode(job_id)
5216 );
5217 let mut local_req_builder =
5218 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5219
5220 if let Some(ref local_query_param) = filter_query {
5221 local_req_builder =
5222 local_req_builder.query(&[("filter[query]", &local_query_param.to_string())]);
5223 };
5224 if let Some(ref local_query_param) = filter_from {
5225 local_req_builder = local_req_builder.query(&[(
5226 "filter[from]",
5227 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
5228 )]);
5229 };
5230 if let Some(ref local_query_param) = filter_to {
5231 local_req_builder = local_req_builder.query(&[(
5232 "filter[to]",
5233 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
5234 )]);
5235 };
5236 if let Some(ref local_query_param) = sort {
5237 local_req_builder =
5238 local_req_builder.query(&[("sort", &local_query_param.to_string())]);
5239 };
5240 if let Some(ref local_query_param) = page_cursor {
5241 local_req_builder =
5242 local_req_builder.query(&[("page[cursor]", &local_query_param.to_string())]);
5243 };
5244 if let Some(ref local_query_param) = page_limit {
5245 local_req_builder =
5246 local_req_builder.query(&[("page[limit]", &local_query_param.to_string())]);
5247 };
5248
5249 let mut headers = HeaderMap::new();
5251 headers.insert("Accept", HeaderValue::from_static("application/json"));
5252
5253 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5255 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5256 Err(e) => {
5257 log::warn!("Failed to parse user agent header: {e}, falling back to default");
5258 headers.insert(
5259 reqwest::header::USER_AGENT,
5260 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5261 )
5262 }
5263 };
5264
5265 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5267 headers.insert(
5268 "DD-API-KEY",
5269 HeaderValue::from_str(local_key.key.as_str())
5270 .expect("failed to parse DD-API-KEY header"),
5271 );
5272 };
5273 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5274 headers.insert(
5275 "DD-APPLICATION-KEY",
5276 HeaderValue::from_str(local_key.key.as_str())
5277 .expect("failed to parse DD-APPLICATION-KEY header"),
5278 );
5279 };
5280
5281 local_req_builder = local_req_builder.headers(headers);
5282 let local_req = local_req_builder.build()?;
5283 log::debug!("request content: {:?}", local_req.body());
5284 let local_resp = local_client.execute(local_req).await?;
5285
5286 let local_status = local_resp.status();
5287 let local_content = local_resp.text().await?;
5288 log::debug!("response content: {}", local_content);
5289
5290 if !local_status.is_client_error() && !local_status.is_server_error() {
5291 match serde_json::from_str::<
5292 crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
5293 >(&local_content)
5294 {
5295 Ok(e) => {
5296 return Ok(datadog::ResponseContent {
5297 status: local_status,
5298 content: local_content,
5299 entity: Some(e),
5300 })
5301 }
5302 Err(e) => return Err(datadog::Error::Serde(e)),
5303 };
5304 } else {
5305 let local_entity: Option<GetSecurityMonitoringHistsignalsByJobIdError> =
5306 serde_json::from_str(&local_content).ok();
5307 let local_error = datadog::ResponseContent {
5308 status: local_status,
5309 content: local_content,
5310 entity: local_entity,
5311 };
5312 Err(datadog::Error::ResponseError(local_error))
5313 }
5314 }
5315
5316 pub async fn get_security_monitoring_rule(
5318 &self,
5319 rule_id: String,
5320 ) -> Result<
5321 crate::datadogV2::model::SecurityMonitoringRuleResponse,
5322 datadog::Error<GetSecurityMonitoringRuleError>,
5323 > {
5324 match self
5325 .get_security_monitoring_rule_with_http_info(rule_id)
5326 .await
5327 {
5328 Ok(response_content) => {
5329 if let Some(e) = response_content.entity {
5330 Ok(e)
5331 } else {
5332 Err(datadog::Error::Serde(serde::de::Error::custom(
5333 "response content was None",
5334 )))
5335 }
5336 }
5337 Err(err) => Err(err),
5338 }
5339 }
5340
5341 pub async fn get_security_monitoring_rule_with_http_info(
5343 &self,
5344 rule_id: String,
5345 ) -> Result<
5346 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleResponse>,
5347 datadog::Error<GetSecurityMonitoringRuleError>,
5348 > {
5349 let local_configuration = &self.config;
5350 let operation_id = "v2.get_security_monitoring_rule";
5351
5352 let local_client = &self.client;
5353
5354 let local_uri_str = format!(
5355 "{}/api/v2/security_monitoring/rules/{rule_id}",
5356 local_configuration.get_operation_host(operation_id),
5357 rule_id = datadog::urlencode(rule_id)
5358 );
5359 let mut local_req_builder =
5360 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5361
5362 let mut headers = HeaderMap::new();
5364 headers.insert("Accept", HeaderValue::from_static("application/json"));
5365
5366 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5368 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5369 Err(e) => {
5370 log::warn!("Failed to parse user agent header: {e}, falling back to default");
5371 headers.insert(
5372 reqwest::header::USER_AGENT,
5373 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5374 )
5375 }
5376 };
5377
5378 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5380 headers.insert(
5381 "DD-API-KEY",
5382 HeaderValue::from_str(local_key.key.as_str())
5383 .expect("failed to parse DD-API-KEY header"),
5384 );
5385 };
5386 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5387 headers.insert(
5388 "DD-APPLICATION-KEY",
5389 HeaderValue::from_str(local_key.key.as_str())
5390 .expect("failed to parse DD-APPLICATION-KEY header"),
5391 );
5392 };
5393
5394 local_req_builder = local_req_builder.headers(headers);
5395 let local_req = local_req_builder.build()?;
5396 log::debug!("request content: {:?}", local_req.body());
5397 let local_resp = local_client.execute(local_req).await?;
5398
5399 let local_status = local_resp.status();
5400 let local_content = local_resp.text().await?;
5401 log::debug!("response content: {}", local_content);
5402
5403 if !local_status.is_client_error() && !local_status.is_server_error() {
5404 match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringRuleResponse>(
5405 &local_content,
5406 ) {
5407 Ok(e) => {
5408 return Ok(datadog::ResponseContent {
5409 status: local_status,
5410 content: local_content,
5411 entity: Some(e),
5412 })
5413 }
5414 Err(e) => return Err(datadog::Error::Serde(e)),
5415 };
5416 } else {
5417 let local_entity: Option<GetSecurityMonitoringRuleError> =
5418 serde_json::from_str(&local_content).ok();
5419 let local_error = datadog::ResponseContent {
5420 status: local_status,
5421 content: local_content,
5422 entity: local_entity,
5423 };
5424 Err(datadog::Error::ResponseError(local_error))
5425 }
5426 }
5427
5428 pub async fn get_security_monitoring_signal(
5430 &self,
5431 signal_id: String,
5432 ) -> Result<
5433 crate::datadogV2::model::SecurityMonitoringSignalResponse,
5434 datadog::Error<GetSecurityMonitoringSignalError>,
5435 > {
5436 match self
5437 .get_security_monitoring_signal_with_http_info(signal_id)
5438 .await
5439 {
5440 Ok(response_content) => {
5441 if let Some(e) = response_content.entity {
5442 Ok(e)
5443 } else {
5444 Err(datadog::Error::Serde(serde::de::Error::custom(
5445 "response content was None",
5446 )))
5447 }
5448 }
5449 Err(err) => Err(err),
5450 }
5451 }
5452
5453 pub async fn get_security_monitoring_signal_with_http_info(
5455 &self,
5456 signal_id: String,
5457 ) -> Result<
5458 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSignalResponse>,
5459 datadog::Error<GetSecurityMonitoringSignalError>,
5460 > {
5461 let local_configuration = &self.config;
5462 let operation_id = "v2.get_security_monitoring_signal";
5463
5464 let local_client = &self.client;
5465
5466 let local_uri_str = format!(
5467 "{}/api/v2/security_monitoring/signals/{signal_id}",
5468 local_configuration.get_operation_host(operation_id),
5469 signal_id = datadog::urlencode(signal_id)
5470 );
5471 let mut local_req_builder =
5472 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5473
5474 let mut headers = HeaderMap::new();
5476 headers.insert("Accept", HeaderValue::from_static("application/json"));
5477
5478 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5480 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5481 Err(e) => {
5482 log::warn!("Failed to parse user agent header: {e}, falling back to default");
5483 headers.insert(
5484 reqwest::header::USER_AGENT,
5485 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5486 )
5487 }
5488 };
5489
5490 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5492 headers.insert(
5493 "DD-API-KEY",
5494 HeaderValue::from_str(local_key.key.as_str())
5495 .expect("failed to parse DD-API-KEY header"),
5496 );
5497 };
5498 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5499 headers.insert(
5500 "DD-APPLICATION-KEY",
5501 HeaderValue::from_str(local_key.key.as_str())
5502 .expect("failed to parse DD-APPLICATION-KEY header"),
5503 );
5504 };
5505
5506 local_req_builder = local_req_builder.headers(headers);
5507 let local_req = local_req_builder.build()?;
5508 log::debug!("request content: {:?}", local_req.body());
5509 let local_resp = local_client.execute(local_req).await?;
5510
5511 let local_status = local_resp.status();
5512 let local_content = local_resp.text().await?;
5513 log::debug!("response content: {}", local_content);
5514
5515 if !local_status.is_client_error() && !local_status.is_server_error() {
5516 match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringSignalResponse>(
5517 &local_content,
5518 ) {
5519 Ok(e) => {
5520 return Ok(datadog::ResponseContent {
5521 status: local_status,
5522 content: local_content,
5523 entity: Some(e),
5524 })
5525 }
5526 Err(e) => return Err(datadog::Error::Serde(e)),
5527 };
5528 } else {
5529 let local_entity: Option<GetSecurityMonitoringSignalError> =
5530 serde_json::from_str(&local_content).ok();
5531 let local_error = datadog::ResponseContent {
5532 status: local_status,
5533 content: local_content,
5534 entity: local_entity,
5535 };
5536 Err(datadog::Error::ResponseError(local_error))
5537 }
5538 }
5539
5540 pub async fn get_security_monitoring_suppression(
5542 &self,
5543 suppression_id: String,
5544 ) -> Result<
5545 crate::datadogV2::model::SecurityMonitoringSuppressionResponse,
5546 datadog::Error<GetSecurityMonitoringSuppressionError>,
5547 > {
5548 match self
5549 .get_security_monitoring_suppression_with_http_info(suppression_id)
5550 .await
5551 {
5552 Ok(response_content) => {
5553 if let Some(e) = response_content.entity {
5554 Ok(e)
5555 } else {
5556 Err(datadog::Error::Serde(serde::de::Error::custom(
5557 "response content was None",
5558 )))
5559 }
5560 }
5561 Err(err) => Err(err),
5562 }
5563 }
5564
5565 pub async fn get_security_monitoring_suppression_with_http_info(
5567 &self,
5568 suppression_id: String,
5569 ) -> Result<
5570 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSuppressionResponse>,
5571 datadog::Error<GetSecurityMonitoringSuppressionError>,
5572 > {
5573 let local_configuration = &self.config;
5574 let operation_id = "v2.get_security_monitoring_suppression";
5575
5576 let local_client = &self.client;
5577
5578 let local_uri_str = format!(
5579 "{}/api/v2/security_monitoring/configuration/suppressions/{suppression_id}",
5580 local_configuration.get_operation_host(operation_id),
5581 suppression_id = datadog::urlencode(suppression_id)
5582 );
5583 let mut local_req_builder =
5584 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5585
5586 let mut headers = HeaderMap::new();
5588 headers.insert("Accept", HeaderValue::from_static("application/json"));
5589
5590 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5592 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5593 Err(e) => {
5594 log::warn!("Failed to parse user agent header: {e}, falling back to default");
5595 headers.insert(
5596 reqwest::header::USER_AGENT,
5597 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5598 )
5599 }
5600 };
5601
5602 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5604 headers.insert(
5605 "DD-API-KEY",
5606 HeaderValue::from_str(local_key.key.as_str())
5607 .expect("failed to parse DD-API-KEY header"),
5608 );
5609 };
5610 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5611 headers.insert(
5612 "DD-APPLICATION-KEY",
5613 HeaderValue::from_str(local_key.key.as_str())
5614 .expect("failed to parse DD-APPLICATION-KEY header"),
5615 );
5616 };
5617
5618 local_req_builder = local_req_builder.headers(headers);
5619 let local_req = local_req_builder.build()?;
5620 log::debug!("request content: {:?}", local_req.body());
5621 let local_resp = local_client.execute(local_req).await?;
5622
5623 let local_status = local_resp.status();
5624 let local_content = local_resp.text().await?;
5625 log::debug!("response content: {}", local_content);
5626
5627 if !local_status.is_client_error() && !local_status.is_server_error() {
5628 match serde_json::from_str::<
5629 crate::datadogV2::model::SecurityMonitoringSuppressionResponse,
5630 >(&local_content)
5631 {
5632 Ok(e) => {
5633 return Ok(datadog::ResponseContent {
5634 status: local_status,
5635 content: local_content,
5636 entity: Some(e),
5637 })
5638 }
5639 Err(e) => return Err(datadog::Error::Serde(e)),
5640 };
5641 } else {
5642 let local_entity: Option<GetSecurityMonitoringSuppressionError> =
5643 serde_json::from_str(&local_content).ok();
5644 let local_error = datadog::ResponseContent {
5645 status: local_status,
5646 content: local_content,
5647 entity: local_entity,
5648 };
5649 Err(datadog::Error::ResponseError(local_error))
5650 }
5651 }
5652
5653 pub async fn get_signal_notification_rule(
5655 &self,
5656 id: String,
5657 ) -> Result<
5658 crate::datadogV2::model::NotificationRuleResponse,
5659 datadog::Error<GetSignalNotificationRuleError>,
5660 > {
5661 match self.get_signal_notification_rule_with_http_info(id).await {
5662 Ok(response_content) => {
5663 if let Some(e) = response_content.entity {
5664 Ok(e)
5665 } else {
5666 Err(datadog::Error::Serde(serde::de::Error::custom(
5667 "response content was None",
5668 )))
5669 }
5670 }
5671 Err(err) => Err(err),
5672 }
5673 }
5674
5675 pub async fn get_signal_notification_rule_with_http_info(
5677 &self,
5678 id: String,
5679 ) -> Result<
5680 datadog::ResponseContent<crate::datadogV2::model::NotificationRuleResponse>,
5681 datadog::Error<GetSignalNotificationRuleError>,
5682 > {
5683 let local_configuration = &self.config;
5684 let operation_id = "v2.get_signal_notification_rule";
5685
5686 let local_client = &self.client;
5687
5688 let local_uri_str = format!(
5689 "{}/api/v2/security/signals/notification_rules/{id}",
5690 local_configuration.get_operation_host(operation_id),
5691 id = datadog::urlencode(id)
5692 );
5693 let mut local_req_builder =
5694 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5695
5696 let mut headers = HeaderMap::new();
5698 headers.insert("Accept", HeaderValue::from_static("application/json"));
5699
5700 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5702 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5703 Err(e) => {
5704 log::warn!("Failed to parse user agent header: {e}, falling back to default");
5705 headers.insert(
5706 reqwest::header::USER_AGENT,
5707 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5708 )
5709 }
5710 };
5711
5712 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5714 headers.insert(
5715 "DD-API-KEY",
5716 HeaderValue::from_str(local_key.key.as_str())
5717 .expect("failed to parse DD-API-KEY header"),
5718 );
5719 };
5720 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5721 headers.insert(
5722 "DD-APPLICATION-KEY",
5723 HeaderValue::from_str(local_key.key.as_str())
5724 .expect("failed to parse DD-APPLICATION-KEY header"),
5725 );
5726 };
5727
5728 local_req_builder = local_req_builder.headers(headers);
5729 let local_req = local_req_builder.build()?;
5730 log::debug!("request content: {:?}", local_req.body());
5731 let local_resp = local_client.execute(local_req).await?;
5732
5733 let local_status = local_resp.status();
5734 let local_content = local_resp.text().await?;
5735 log::debug!("response content: {}", local_content);
5736
5737 if !local_status.is_client_error() && !local_status.is_server_error() {
5738 match serde_json::from_str::<crate::datadogV2::model::NotificationRuleResponse>(
5739 &local_content,
5740 ) {
5741 Ok(e) => {
5742 return Ok(datadog::ResponseContent {
5743 status: local_status,
5744 content: local_content,
5745 entity: Some(e),
5746 })
5747 }
5748 Err(e) => return Err(datadog::Error::Serde(e)),
5749 };
5750 } else {
5751 let local_entity: Option<GetSignalNotificationRuleError> =
5752 serde_json::from_str(&local_content).ok();
5753 let local_error = datadog::ResponseContent {
5754 status: local_status,
5755 content: local_content,
5756 entity: local_entity,
5757 };
5758 Err(datadog::Error::ResponseError(local_error))
5759 }
5760 }
5761
5762 pub async fn get_signal_notification_rules(
5764 &self,
5765 ) -> Result<
5766 std::collections::BTreeMap<String, serde_json::Value>,
5767 datadog::Error<GetSignalNotificationRulesError>,
5768 > {
5769 match self.get_signal_notification_rules_with_http_info().await {
5770 Ok(response_content) => {
5771 if let Some(e) = response_content.entity {
5772 Ok(e)
5773 } else {
5774 Err(datadog::Error::Serde(serde::de::Error::custom(
5775 "response content was None",
5776 )))
5777 }
5778 }
5779 Err(err) => Err(err),
5780 }
5781 }
5782
5783 pub async fn get_signal_notification_rules_with_http_info(
5785 &self,
5786 ) -> Result<
5787 datadog::ResponseContent<std::collections::BTreeMap<String, serde_json::Value>>,
5788 datadog::Error<GetSignalNotificationRulesError>,
5789 > {
5790 let local_configuration = &self.config;
5791 let operation_id = "v2.get_signal_notification_rules";
5792
5793 let local_client = &self.client;
5794
5795 let local_uri_str = format!(
5796 "{}/api/v2/security/signals/notification_rules",
5797 local_configuration.get_operation_host(operation_id)
5798 );
5799 let mut local_req_builder =
5800 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5801
5802 let mut headers = HeaderMap::new();
5804 headers.insert("Accept", HeaderValue::from_static("application/json"));
5805
5806 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5808 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5809 Err(e) => {
5810 log::warn!("Failed to parse user agent header: {e}, falling back to default");
5811 headers.insert(
5812 reqwest::header::USER_AGENT,
5813 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5814 )
5815 }
5816 };
5817
5818 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5820 headers.insert(
5821 "DD-API-KEY",
5822 HeaderValue::from_str(local_key.key.as_str())
5823 .expect("failed to parse DD-API-KEY header"),
5824 );
5825 };
5826 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5827 headers.insert(
5828 "DD-APPLICATION-KEY",
5829 HeaderValue::from_str(local_key.key.as_str())
5830 .expect("failed to parse DD-APPLICATION-KEY header"),
5831 );
5832 };
5833
5834 local_req_builder = local_req_builder.headers(headers);
5835 let local_req = local_req_builder.build()?;
5836 log::debug!("request content: {:?}", local_req.body());
5837 let local_resp = local_client.execute(local_req).await?;
5838
5839 let local_status = local_resp.status();
5840 let local_content = local_resp.text().await?;
5841 log::debug!("response content: {}", local_content);
5842
5843 if !local_status.is_client_error() && !local_status.is_server_error() {
5844 match serde_json::from_str::<std::collections::BTreeMap<String, serde_json::Value>>(
5845 &local_content,
5846 ) {
5847 Ok(e) => {
5848 return Ok(datadog::ResponseContent {
5849 status: local_status,
5850 content: local_content,
5851 entity: Some(e),
5852 })
5853 }
5854 Err(e) => return Err(datadog::Error::Serde(e)),
5855 };
5856 } else {
5857 let local_entity: Option<GetSignalNotificationRulesError> =
5858 serde_json::from_str(&local_content).ok();
5859 let local_error = datadog::ResponseContent {
5860 status: local_status,
5861 content: local_content,
5862 entity: local_entity,
5863 };
5864 Err(datadog::Error::ResponseError(local_error))
5865 }
5866 }
5867
5868 pub async fn get_suppressions_affecting_future_rule(
5870 &self,
5871 body: crate::datadogV2::model::SecurityMonitoringRuleCreatePayload,
5872 ) -> Result<
5873 crate::datadogV2::model::SecurityMonitoringSuppressionsResponse,
5874 datadog::Error<GetSuppressionsAffectingFutureRuleError>,
5875 > {
5876 match self
5877 .get_suppressions_affecting_future_rule_with_http_info(body)
5878 .await
5879 {
5880 Ok(response_content) => {
5881 if let Some(e) = response_content.entity {
5882 Ok(e)
5883 } else {
5884 Err(datadog::Error::Serde(serde::de::Error::custom(
5885 "response content was None",
5886 )))
5887 }
5888 }
5889 Err(err) => Err(err),
5890 }
5891 }
5892
5893 pub async fn get_suppressions_affecting_future_rule_with_http_info(
5895 &self,
5896 body: crate::datadogV2::model::SecurityMonitoringRuleCreatePayload,
5897 ) -> Result<
5898 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSuppressionsResponse>,
5899 datadog::Error<GetSuppressionsAffectingFutureRuleError>,
5900 > {
5901 let local_configuration = &self.config;
5902 let operation_id = "v2.get_suppressions_affecting_future_rule";
5903
5904 let local_client = &self.client;
5905
5906 let local_uri_str = format!(
5907 "{}/api/v2/security_monitoring/configuration/suppressions/rules",
5908 local_configuration.get_operation_host(operation_id)
5909 );
5910 let mut local_req_builder =
5911 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
5912
5913 let mut headers = HeaderMap::new();
5915 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
5916 headers.insert("Accept", HeaderValue::from_static("application/json"));
5917
5918 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5920 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5921 Err(e) => {
5922 log::warn!("Failed to parse user agent header: {e}, falling back to default");
5923 headers.insert(
5924 reqwest::header::USER_AGENT,
5925 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5926 )
5927 }
5928 };
5929
5930 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5932 headers.insert(
5933 "DD-API-KEY",
5934 HeaderValue::from_str(local_key.key.as_str())
5935 .expect("failed to parse DD-API-KEY header"),
5936 );
5937 };
5938 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5939 headers.insert(
5940 "DD-APPLICATION-KEY",
5941 HeaderValue::from_str(local_key.key.as_str())
5942 .expect("failed to parse DD-APPLICATION-KEY header"),
5943 );
5944 };
5945
5946 let output = Vec::new();
5948 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
5949 if body.serialize(&mut ser).is_ok() {
5950 if let Some(content_encoding) = headers.get("Content-Encoding") {
5951 match content_encoding.to_str().unwrap_or_default() {
5952 "gzip" => {
5953 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
5954 let _ = enc.write_all(ser.into_inner().as_slice());
5955 match enc.finish() {
5956 Ok(buf) => {
5957 local_req_builder = local_req_builder.body(buf);
5958 }
5959 Err(e) => return Err(datadog::Error::Io(e)),
5960 }
5961 }
5962 "deflate" => {
5963 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
5964 let _ = enc.write_all(ser.into_inner().as_slice());
5965 match enc.finish() {
5966 Ok(buf) => {
5967 local_req_builder = local_req_builder.body(buf);
5968 }
5969 Err(e) => return Err(datadog::Error::Io(e)),
5970 }
5971 }
5972 "zstd1" => {
5973 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
5974 let _ = enc.write_all(ser.into_inner().as_slice());
5975 match enc.finish() {
5976 Ok(buf) => {
5977 local_req_builder = local_req_builder.body(buf);
5978 }
5979 Err(e) => return Err(datadog::Error::Io(e)),
5980 }
5981 }
5982 _ => {
5983 local_req_builder = local_req_builder.body(ser.into_inner());
5984 }
5985 }
5986 } else {
5987 local_req_builder = local_req_builder.body(ser.into_inner());
5988 }
5989 }
5990
5991 local_req_builder = local_req_builder.headers(headers);
5992 let local_req = local_req_builder.build()?;
5993 log::debug!("request content: {:?}", local_req.body());
5994 let local_resp = local_client.execute(local_req).await?;
5995
5996 let local_status = local_resp.status();
5997 let local_content = local_resp.text().await?;
5998 log::debug!("response content: {}", local_content);
5999
6000 if !local_status.is_client_error() && !local_status.is_server_error() {
6001 match serde_json::from_str::<
6002 crate::datadogV2::model::SecurityMonitoringSuppressionsResponse,
6003 >(&local_content)
6004 {
6005 Ok(e) => {
6006 return Ok(datadog::ResponseContent {
6007 status: local_status,
6008 content: local_content,
6009 entity: Some(e),
6010 })
6011 }
6012 Err(e) => return Err(datadog::Error::Serde(e)),
6013 };
6014 } else {
6015 let local_entity: Option<GetSuppressionsAffectingFutureRuleError> =
6016 serde_json::from_str(&local_content).ok();
6017 let local_error = datadog::ResponseContent {
6018 status: local_status,
6019 content: local_content,
6020 entity: local_entity,
6021 };
6022 Err(datadog::Error::ResponseError(local_error))
6023 }
6024 }
6025
6026 pub async fn get_suppressions_affecting_rule(
6028 &self,
6029 rule_id: String,
6030 ) -> Result<
6031 crate::datadogV2::model::SecurityMonitoringSuppressionsResponse,
6032 datadog::Error<GetSuppressionsAffectingRuleError>,
6033 > {
6034 match self
6035 .get_suppressions_affecting_rule_with_http_info(rule_id)
6036 .await
6037 {
6038 Ok(response_content) => {
6039 if let Some(e) = response_content.entity {
6040 Ok(e)
6041 } else {
6042 Err(datadog::Error::Serde(serde::de::Error::custom(
6043 "response content was None",
6044 )))
6045 }
6046 }
6047 Err(err) => Err(err),
6048 }
6049 }
6050
6051 pub async fn get_suppressions_affecting_rule_with_http_info(
6053 &self,
6054 rule_id: String,
6055 ) -> Result<
6056 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSuppressionsResponse>,
6057 datadog::Error<GetSuppressionsAffectingRuleError>,
6058 > {
6059 let local_configuration = &self.config;
6060 let operation_id = "v2.get_suppressions_affecting_rule";
6061
6062 let local_client = &self.client;
6063
6064 let local_uri_str = format!(
6065 "{}/api/v2/security_monitoring/configuration/suppressions/rules/{rule_id}",
6066 local_configuration.get_operation_host(operation_id),
6067 rule_id = datadog::urlencode(rule_id)
6068 );
6069 let mut local_req_builder =
6070 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
6071
6072 let mut headers = HeaderMap::new();
6074 headers.insert("Accept", HeaderValue::from_static("application/json"));
6075
6076 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
6078 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
6079 Err(e) => {
6080 log::warn!("Failed to parse user agent header: {e}, falling back to default");
6081 headers.insert(
6082 reqwest::header::USER_AGENT,
6083 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
6084 )
6085 }
6086 };
6087
6088 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
6090 headers.insert(
6091 "DD-API-KEY",
6092 HeaderValue::from_str(local_key.key.as_str())
6093 .expect("failed to parse DD-API-KEY header"),
6094 );
6095 };
6096 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
6097 headers.insert(
6098 "DD-APPLICATION-KEY",
6099 HeaderValue::from_str(local_key.key.as_str())
6100 .expect("failed to parse DD-APPLICATION-KEY header"),
6101 );
6102 };
6103
6104 local_req_builder = local_req_builder.headers(headers);
6105 let local_req = local_req_builder.build()?;
6106 log::debug!("request content: {:?}", local_req.body());
6107 let local_resp = local_client.execute(local_req).await?;
6108
6109 let local_status = local_resp.status();
6110 let local_content = local_resp.text().await?;
6111 log::debug!("response content: {}", local_content);
6112
6113 if !local_status.is_client_error() && !local_status.is_server_error() {
6114 match serde_json::from_str::<
6115 crate::datadogV2::model::SecurityMonitoringSuppressionsResponse,
6116 >(&local_content)
6117 {
6118 Ok(e) => {
6119 return Ok(datadog::ResponseContent {
6120 status: local_status,
6121 content: local_content,
6122 entity: Some(e),
6123 })
6124 }
6125 Err(e) => return Err(datadog::Error::Serde(e)),
6126 };
6127 } else {
6128 let local_entity: Option<GetSuppressionsAffectingRuleError> =
6129 serde_json::from_str(&local_content).ok();
6130 let local_error = datadog::ResponseContent {
6131 status: local_status,
6132 content: local_content,
6133 entity: local_entity,
6134 };
6135 Err(datadog::Error::ResponseError(local_error))
6136 }
6137 }
6138
6139 pub async fn get_vulnerability_notification_rule(
6141 &self,
6142 id: String,
6143 ) -> Result<
6144 crate::datadogV2::model::NotificationRuleResponse,
6145 datadog::Error<GetVulnerabilityNotificationRuleError>,
6146 > {
6147 match self
6148 .get_vulnerability_notification_rule_with_http_info(id)
6149 .await
6150 {
6151 Ok(response_content) => {
6152 if let Some(e) = response_content.entity {
6153 Ok(e)
6154 } else {
6155 Err(datadog::Error::Serde(serde::de::Error::custom(
6156 "response content was None",
6157 )))
6158 }
6159 }
6160 Err(err) => Err(err),
6161 }
6162 }
6163
6164 pub async fn get_vulnerability_notification_rule_with_http_info(
6166 &self,
6167 id: String,
6168 ) -> Result<
6169 datadog::ResponseContent<crate::datadogV2::model::NotificationRuleResponse>,
6170 datadog::Error<GetVulnerabilityNotificationRuleError>,
6171 > {
6172 let local_configuration = &self.config;
6173 let operation_id = "v2.get_vulnerability_notification_rule";
6174
6175 let local_client = &self.client;
6176
6177 let local_uri_str = format!(
6178 "{}/api/v2/security/vulnerabilities/notification_rules/{id}",
6179 local_configuration.get_operation_host(operation_id),
6180 id = datadog::urlencode(id)
6181 );
6182 let mut local_req_builder =
6183 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
6184
6185 let mut headers = HeaderMap::new();
6187 headers.insert("Accept", HeaderValue::from_static("application/json"));
6188
6189 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
6191 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
6192 Err(e) => {
6193 log::warn!("Failed to parse user agent header: {e}, falling back to default");
6194 headers.insert(
6195 reqwest::header::USER_AGENT,
6196 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
6197 )
6198 }
6199 };
6200
6201 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
6203 headers.insert(
6204 "DD-API-KEY",
6205 HeaderValue::from_str(local_key.key.as_str())
6206 .expect("failed to parse DD-API-KEY header"),
6207 );
6208 };
6209 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
6210 headers.insert(
6211 "DD-APPLICATION-KEY",
6212 HeaderValue::from_str(local_key.key.as_str())
6213 .expect("failed to parse DD-APPLICATION-KEY header"),
6214 );
6215 };
6216
6217 local_req_builder = local_req_builder.headers(headers);
6218 let local_req = local_req_builder.build()?;
6219 log::debug!("request content: {:?}", local_req.body());
6220 let local_resp = local_client.execute(local_req).await?;
6221
6222 let local_status = local_resp.status();
6223 let local_content = local_resp.text().await?;
6224 log::debug!("response content: {}", local_content);
6225
6226 if !local_status.is_client_error() && !local_status.is_server_error() {
6227 match serde_json::from_str::<crate::datadogV2::model::NotificationRuleResponse>(
6228 &local_content,
6229 ) {
6230 Ok(e) => {
6231 return Ok(datadog::ResponseContent {
6232 status: local_status,
6233 content: local_content,
6234 entity: Some(e),
6235 })
6236 }
6237 Err(e) => return Err(datadog::Error::Serde(e)),
6238 };
6239 } else {
6240 let local_entity: Option<GetVulnerabilityNotificationRuleError> =
6241 serde_json::from_str(&local_content).ok();
6242 let local_error = datadog::ResponseContent {
6243 status: local_status,
6244 content: local_content,
6245 entity: local_entity,
6246 };
6247 Err(datadog::Error::ResponseError(local_error))
6248 }
6249 }
6250
6251 pub async fn get_vulnerability_notification_rules(
6253 &self,
6254 ) -> Result<
6255 std::collections::BTreeMap<String, serde_json::Value>,
6256 datadog::Error<GetVulnerabilityNotificationRulesError>,
6257 > {
6258 match self
6259 .get_vulnerability_notification_rules_with_http_info()
6260 .await
6261 {
6262 Ok(response_content) => {
6263 if let Some(e) = response_content.entity {
6264 Ok(e)
6265 } else {
6266 Err(datadog::Error::Serde(serde::de::Error::custom(
6267 "response content was None",
6268 )))
6269 }
6270 }
6271 Err(err) => Err(err),
6272 }
6273 }
6274
6275 pub async fn get_vulnerability_notification_rules_with_http_info(
6277 &self,
6278 ) -> Result<
6279 datadog::ResponseContent<std::collections::BTreeMap<String, serde_json::Value>>,
6280 datadog::Error<GetVulnerabilityNotificationRulesError>,
6281 > {
6282 let local_configuration = &self.config;
6283 let operation_id = "v2.get_vulnerability_notification_rules";
6284
6285 let local_client = &self.client;
6286
6287 let local_uri_str = format!(
6288 "{}/api/v2/security/vulnerabilities/notification_rules",
6289 local_configuration.get_operation_host(operation_id)
6290 );
6291 let mut local_req_builder =
6292 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
6293
6294 let mut headers = HeaderMap::new();
6296 headers.insert("Accept", HeaderValue::from_static("application/json"));
6297
6298 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
6300 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
6301 Err(e) => {
6302 log::warn!("Failed to parse user agent header: {e}, falling back to default");
6303 headers.insert(
6304 reqwest::header::USER_AGENT,
6305 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
6306 )
6307 }
6308 };
6309
6310 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
6312 headers.insert(
6313 "DD-API-KEY",
6314 HeaderValue::from_str(local_key.key.as_str())
6315 .expect("failed to parse DD-API-KEY header"),
6316 );
6317 };
6318 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
6319 headers.insert(
6320 "DD-APPLICATION-KEY",
6321 HeaderValue::from_str(local_key.key.as_str())
6322 .expect("failed to parse DD-APPLICATION-KEY header"),
6323 );
6324 };
6325
6326 local_req_builder = local_req_builder.headers(headers);
6327 let local_req = local_req_builder.build()?;
6328 log::debug!("request content: {:?}", local_req.body());
6329 let local_resp = local_client.execute(local_req).await?;
6330
6331 let local_status = local_resp.status();
6332 let local_content = local_resp.text().await?;
6333 log::debug!("response content: {}", local_content);
6334
6335 if !local_status.is_client_error() && !local_status.is_server_error() {
6336 match serde_json::from_str::<std::collections::BTreeMap<String, serde_json::Value>>(
6337 &local_content,
6338 ) {
6339 Ok(e) => {
6340 return Ok(datadog::ResponseContent {
6341 status: local_status,
6342 content: local_content,
6343 entity: Some(e),
6344 })
6345 }
6346 Err(e) => return Err(datadog::Error::Serde(e)),
6347 };
6348 } else {
6349 let local_entity: Option<GetVulnerabilityNotificationRulesError> =
6350 serde_json::from_str(&local_content).ok();
6351 let local_error = datadog::ResponseContent {
6352 status: local_status,
6353 content: local_content,
6354 entity: local_entity,
6355 };
6356 Err(datadog::Error::ResponseError(local_error))
6357 }
6358 }
6359
6360 pub async fn list_assets_sbo_ms(
6374 &self,
6375 params: ListAssetsSBOMsOptionalParams,
6376 ) -> Result<
6377 crate::datadogV2::model::ListAssetsSBOMsResponse,
6378 datadog::Error<ListAssetsSBOMsError>,
6379 > {
6380 match self.list_assets_sbo_ms_with_http_info(params).await {
6381 Ok(response_content) => {
6382 if let Some(e) = response_content.entity {
6383 Ok(e)
6384 } else {
6385 Err(datadog::Error::Serde(serde::de::Error::custom(
6386 "response content was None",
6387 )))
6388 }
6389 }
6390 Err(err) => Err(err),
6391 }
6392 }
6393
6394 pub async fn list_assets_sbo_ms_with_http_info(
6408 &self,
6409 params: ListAssetsSBOMsOptionalParams,
6410 ) -> Result<
6411 datadog::ResponseContent<crate::datadogV2::model::ListAssetsSBOMsResponse>,
6412 datadog::Error<ListAssetsSBOMsError>,
6413 > {
6414 let local_configuration = &self.config;
6415 let operation_id = "v2.list_assets_sbo_ms";
6416 if local_configuration.is_unstable_operation_enabled(operation_id) {
6417 warn!("Using unstable operation {operation_id}");
6418 } else {
6419 let local_error = datadog::UnstableOperationDisabledError {
6420 msg: "Operation 'v2.list_assets_sbo_ms' is not enabled".to_string(),
6421 };
6422 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
6423 }
6424
6425 let page_token = params.page_token;
6427 let page_number = params.page_number;
6428 let filter_asset_type = params.filter_asset_type;
6429 let filter_asset_name = params.filter_asset_name;
6430 let filter_package_name = params.filter_package_name;
6431 let filter_package_version = params.filter_package_version;
6432 let filter_license_name = params.filter_license_name;
6433 let filter_license_type = params.filter_license_type;
6434
6435 let local_client = &self.client;
6436
6437 let local_uri_str = format!(
6438 "{}/api/v2/security/sboms",
6439 local_configuration.get_operation_host(operation_id)
6440 );
6441 let mut local_req_builder =
6442 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
6443
6444 if let Some(ref local_query_param) = page_token {
6445 local_req_builder =
6446 local_req_builder.query(&[("page[token]", &local_query_param.to_string())]);
6447 };
6448 if let Some(ref local_query_param) = page_number {
6449 local_req_builder =
6450 local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
6451 };
6452 if let Some(ref local_query_param) = filter_asset_type {
6453 local_req_builder =
6454 local_req_builder.query(&[("filter[asset_type]", &local_query_param.to_string())]);
6455 };
6456 if let Some(ref local_query_param) = filter_asset_name {
6457 local_req_builder =
6458 local_req_builder.query(&[("filter[asset_name]", &local_query_param.to_string())]);
6459 };
6460 if let Some(ref local_query_param) = filter_package_name {
6461 local_req_builder = local_req_builder
6462 .query(&[("filter[package_name]", &local_query_param.to_string())]);
6463 };
6464 if let Some(ref local_query_param) = filter_package_version {
6465 local_req_builder = local_req_builder
6466 .query(&[("filter[package_version]", &local_query_param.to_string())]);
6467 };
6468 if let Some(ref local_query_param) = filter_license_name {
6469 local_req_builder = local_req_builder
6470 .query(&[("filter[license_name]", &local_query_param.to_string())]);
6471 };
6472 if let Some(ref local_query_param) = filter_license_type {
6473 local_req_builder = local_req_builder
6474 .query(&[("filter[license_type]", &local_query_param.to_string())]);
6475 };
6476
6477 let mut headers = HeaderMap::new();
6479 headers.insert("Accept", HeaderValue::from_static("application/json"));
6480
6481 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
6483 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
6484 Err(e) => {
6485 log::warn!("Failed to parse user agent header: {e}, falling back to default");
6486 headers.insert(
6487 reqwest::header::USER_AGENT,
6488 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
6489 )
6490 }
6491 };
6492
6493 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
6495 headers.insert(
6496 "DD-API-KEY",
6497 HeaderValue::from_str(local_key.key.as_str())
6498 .expect("failed to parse DD-API-KEY header"),
6499 );
6500 };
6501 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
6502 headers.insert(
6503 "DD-APPLICATION-KEY",
6504 HeaderValue::from_str(local_key.key.as_str())
6505 .expect("failed to parse DD-APPLICATION-KEY header"),
6506 );
6507 };
6508
6509 local_req_builder = local_req_builder.headers(headers);
6510 let local_req = local_req_builder.build()?;
6511 log::debug!("request content: {:?}", local_req.body());
6512 let local_resp = local_client.execute(local_req).await?;
6513
6514 let local_status = local_resp.status();
6515 let local_content = local_resp.text().await?;
6516 log::debug!("response content: {}", local_content);
6517
6518 if !local_status.is_client_error() && !local_status.is_server_error() {
6519 match serde_json::from_str::<crate::datadogV2::model::ListAssetsSBOMsResponse>(
6520 &local_content,
6521 ) {
6522 Ok(e) => {
6523 return Ok(datadog::ResponseContent {
6524 status: local_status,
6525 content: local_content,
6526 entity: Some(e),
6527 })
6528 }
6529 Err(e) => return Err(datadog::Error::Serde(e)),
6530 };
6531 } else {
6532 let local_entity: Option<ListAssetsSBOMsError> =
6533 serde_json::from_str(&local_content).ok();
6534 let local_error = datadog::ResponseContent {
6535 status: local_status,
6536 content: local_content,
6537 entity: local_entity,
6538 };
6539 Err(datadog::Error::ResponseError(local_error))
6540 }
6541 }
6542
6543 pub async fn list_findings(
6589 &self,
6590 params: ListFindingsOptionalParams,
6591 ) -> Result<crate::datadogV2::model::ListFindingsResponse, datadog::Error<ListFindingsError>>
6592 {
6593 match self.list_findings_with_http_info(params).await {
6594 Ok(response_content) => {
6595 if let Some(e) = response_content.entity {
6596 Ok(e)
6597 } else {
6598 Err(datadog::Error::Serde(serde::de::Error::custom(
6599 "response content was None",
6600 )))
6601 }
6602 }
6603 Err(err) => Err(err),
6604 }
6605 }
6606
6607 pub fn list_findings_with_pagination(
6608 &self,
6609 mut params: ListFindingsOptionalParams,
6610 ) -> impl Stream<
6611 Item = Result<crate::datadogV2::model::Finding, datadog::Error<ListFindingsError>>,
6612 > + '_ {
6613 try_stream! {
6614 let mut page_size: i64 = 100;
6615 if params.page_limit.is_none() {
6616 params.page_limit = Some(page_size);
6617 } else {
6618 page_size = params.page_limit.unwrap().clone();
6619 }
6620 loop {
6621 let resp = self.list_findings(params.clone()).await?;
6622
6623 let r = resp.data;
6624 let count = r.len();
6625 for team in r {
6626 yield team;
6627 }
6628
6629 if count < page_size as usize {
6630 break;
6631 }
6632 let Some(page) = resp.meta.page else { break };
6633 let Some(cursor) = page.cursor else { break };
6634
6635 params.page_cursor = Some(cursor);
6636 }
6637 }
6638 }
6639
6640 pub async fn list_findings_with_http_info(
6686 &self,
6687 params: ListFindingsOptionalParams,
6688 ) -> Result<
6689 datadog::ResponseContent<crate::datadogV2::model::ListFindingsResponse>,
6690 datadog::Error<ListFindingsError>,
6691 > {
6692 let local_configuration = &self.config;
6693 let operation_id = "v2.list_findings";
6694 if local_configuration.is_unstable_operation_enabled(operation_id) {
6695 warn!("Using unstable operation {operation_id}");
6696 } else {
6697 let local_error = datadog::UnstableOperationDisabledError {
6698 msg: "Operation 'v2.list_findings' is not enabled".to_string(),
6699 };
6700 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
6701 }
6702
6703 let page_limit = params.page_limit;
6705 let snapshot_timestamp = params.snapshot_timestamp;
6706 let page_cursor = params.page_cursor;
6707 let filter_tags = params.filter_tags;
6708 let filter_evaluation_changed_at = params.filter_evaluation_changed_at;
6709 let filter_muted = params.filter_muted;
6710 let filter_rule_id = params.filter_rule_id;
6711 let filter_rule_name = params.filter_rule_name;
6712 let filter_resource_type = params.filter_resource_type;
6713 let filter_resource_id = params.filter_resource_id;
6714 let filter_discovery_timestamp = params.filter_discovery_timestamp;
6715 let filter_evaluation = params.filter_evaluation;
6716 let filter_status = params.filter_status;
6717 let filter_vulnerability_type = params.filter_vulnerability_type;
6718 let detailed_findings = params.detailed_findings;
6719
6720 let local_client = &self.client;
6721
6722 let local_uri_str = format!(
6723 "{}/api/v2/posture_management/findings",
6724 local_configuration.get_operation_host(operation_id)
6725 );
6726 let mut local_req_builder =
6727 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
6728
6729 if let Some(ref local_query_param) = page_limit {
6730 local_req_builder =
6731 local_req_builder.query(&[("page[limit]", &local_query_param.to_string())]);
6732 };
6733 if let Some(ref local_query_param) = snapshot_timestamp {
6734 local_req_builder =
6735 local_req_builder.query(&[("snapshot_timestamp", &local_query_param.to_string())]);
6736 };
6737 if let Some(ref local_query_param) = page_cursor {
6738 local_req_builder =
6739 local_req_builder.query(&[("page[cursor]", &local_query_param.to_string())]);
6740 };
6741 if let Some(ref local_query_param) = filter_tags {
6742 local_req_builder =
6743 local_req_builder.query(&[("filter[tags]", &local_query_param.to_string())]);
6744 };
6745 if let Some(ref local_query_param) = filter_evaluation_changed_at {
6746 local_req_builder = local_req_builder.query(&[(
6747 "filter[evaluation_changed_at]",
6748 &local_query_param.to_string(),
6749 )]);
6750 };
6751 if let Some(ref local_query_param) = filter_muted {
6752 local_req_builder =
6753 local_req_builder.query(&[("filter[muted]", &local_query_param.to_string())]);
6754 };
6755 if let Some(ref local_query_param) = filter_rule_id {
6756 local_req_builder =
6757 local_req_builder.query(&[("filter[rule_id]", &local_query_param.to_string())]);
6758 };
6759 if let Some(ref local_query_param) = filter_rule_name {
6760 local_req_builder =
6761 local_req_builder.query(&[("filter[rule_name]", &local_query_param.to_string())]);
6762 };
6763 if let Some(ref local_query_param) = filter_resource_type {
6764 local_req_builder = local_req_builder
6765 .query(&[("filter[resource_type]", &local_query_param.to_string())]);
6766 };
6767 if let Some(ref local_query_param) = filter_resource_id {
6768 local_req_builder = local_req_builder
6769 .query(&[("filter[@resource_id]", &local_query_param.to_string())]);
6770 };
6771 if let Some(ref local_query_param) = filter_discovery_timestamp {
6772 local_req_builder = local_req_builder.query(&[(
6773 "filter[discovery_timestamp]",
6774 &local_query_param.to_string(),
6775 )]);
6776 };
6777 if let Some(ref local_query_param) = filter_evaluation {
6778 local_req_builder =
6779 local_req_builder.query(&[("filter[evaluation]", &local_query_param.to_string())]);
6780 };
6781 if let Some(ref local_query_param) = filter_status {
6782 local_req_builder =
6783 local_req_builder.query(&[("filter[status]", &local_query_param.to_string())]);
6784 };
6785 if let Some(ref local) = filter_vulnerability_type {
6786 for param in local {
6787 local_req_builder =
6788 local_req_builder.query(&[("filter[vulnerability_type]", ¶m.to_string())]);
6789 }
6790 };
6791 if let Some(ref local_query_param) = detailed_findings {
6792 local_req_builder =
6793 local_req_builder.query(&[("detailed_findings", &local_query_param.to_string())]);
6794 };
6795
6796 let mut headers = HeaderMap::new();
6798 headers.insert("Accept", HeaderValue::from_static("application/json"));
6799
6800 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
6802 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
6803 Err(e) => {
6804 log::warn!("Failed to parse user agent header: {e}, falling back to default");
6805 headers.insert(
6806 reqwest::header::USER_AGENT,
6807 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
6808 )
6809 }
6810 };
6811
6812 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
6814 headers.insert(
6815 "DD-API-KEY",
6816 HeaderValue::from_str(local_key.key.as_str())
6817 .expect("failed to parse DD-API-KEY header"),
6818 );
6819 };
6820 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
6821 headers.insert(
6822 "DD-APPLICATION-KEY",
6823 HeaderValue::from_str(local_key.key.as_str())
6824 .expect("failed to parse DD-APPLICATION-KEY header"),
6825 );
6826 };
6827
6828 local_req_builder = local_req_builder.headers(headers);
6829 let local_req = local_req_builder.build()?;
6830 log::debug!("request content: {:?}", local_req.body());
6831 let local_resp = local_client.execute(local_req).await?;
6832
6833 let local_status = local_resp.status();
6834 let local_content = local_resp.text().await?;
6835 log::debug!("response content: {}", local_content);
6836
6837 if !local_status.is_client_error() && !local_status.is_server_error() {
6838 match serde_json::from_str::<crate::datadogV2::model::ListFindingsResponse>(
6839 &local_content,
6840 ) {
6841 Ok(e) => {
6842 return Ok(datadog::ResponseContent {
6843 status: local_status,
6844 content: local_content,
6845 entity: Some(e),
6846 })
6847 }
6848 Err(e) => return Err(datadog::Error::Serde(e)),
6849 };
6850 } else {
6851 let local_entity: Option<ListFindingsError> = serde_json::from_str(&local_content).ok();
6852 let local_error = datadog::ResponseContent {
6853 status: local_status,
6854 content: local_content,
6855 entity: local_entity,
6856 };
6857 Err(datadog::Error::ResponseError(local_error))
6858 }
6859 }
6860
6861 pub async fn list_historical_jobs(
6863 &self,
6864 params: ListHistoricalJobsOptionalParams,
6865 ) -> Result<
6866 crate::datadogV2::model::ListHistoricalJobsResponse,
6867 datadog::Error<ListHistoricalJobsError>,
6868 > {
6869 match self.list_historical_jobs_with_http_info(params).await {
6870 Ok(response_content) => {
6871 if let Some(e) = response_content.entity {
6872 Ok(e)
6873 } else {
6874 Err(datadog::Error::Serde(serde::de::Error::custom(
6875 "response content was None",
6876 )))
6877 }
6878 }
6879 Err(err) => Err(err),
6880 }
6881 }
6882
6883 pub async fn list_historical_jobs_with_http_info(
6885 &self,
6886 params: ListHistoricalJobsOptionalParams,
6887 ) -> Result<
6888 datadog::ResponseContent<crate::datadogV2::model::ListHistoricalJobsResponse>,
6889 datadog::Error<ListHistoricalJobsError>,
6890 > {
6891 let local_configuration = &self.config;
6892 let operation_id = "v2.list_historical_jobs";
6893 if local_configuration.is_unstable_operation_enabled(operation_id) {
6894 warn!("Using unstable operation {operation_id}");
6895 } else {
6896 let local_error = datadog::UnstableOperationDisabledError {
6897 msg: "Operation 'v2.list_historical_jobs' is not enabled".to_string(),
6898 };
6899 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
6900 }
6901
6902 let page_size = params.page_size;
6904 let page_number = params.page_number;
6905 let sort = params.sort;
6906 let filter_query = params.filter_query;
6907
6908 let local_client = &self.client;
6909
6910 let local_uri_str = format!(
6911 "{}/api/v2/siem-historical-detections/jobs",
6912 local_configuration.get_operation_host(operation_id)
6913 );
6914 let mut local_req_builder =
6915 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
6916
6917 if let Some(ref local_query_param) = page_size {
6918 local_req_builder =
6919 local_req_builder.query(&[("page[size]", &local_query_param.to_string())]);
6920 };
6921 if let Some(ref local_query_param) = page_number {
6922 local_req_builder =
6923 local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
6924 };
6925 if let Some(ref local_query_param) = sort {
6926 local_req_builder =
6927 local_req_builder.query(&[("sort", &local_query_param.to_string())]);
6928 };
6929 if let Some(ref local_query_param) = filter_query {
6930 local_req_builder =
6931 local_req_builder.query(&[("filter[query]", &local_query_param.to_string())]);
6932 };
6933
6934 let mut headers = HeaderMap::new();
6936 headers.insert("Accept", HeaderValue::from_static("application/json"));
6937
6938 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
6940 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
6941 Err(e) => {
6942 log::warn!("Failed to parse user agent header: {e}, falling back to default");
6943 headers.insert(
6944 reqwest::header::USER_AGENT,
6945 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
6946 )
6947 }
6948 };
6949
6950 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
6952 headers.insert(
6953 "DD-API-KEY",
6954 HeaderValue::from_str(local_key.key.as_str())
6955 .expect("failed to parse DD-API-KEY header"),
6956 );
6957 };
6958 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
6959 headers.insert(
6960 "DD-APPLICATION-KEY",
6961 HeaderValue::from_str(local_key.key.as_str())
6962 .expect("failed to parse DD-APPLICATION-KEY header"),
6963 );
6964 };
6965
6966 local_req_builder = local_req_builder.headers(headers);
6967 let local_req = local_req_builder.build()?;
6968 log::debug!("request content: {:?}", local_req.body());
6969 let local_resp = local_client.execute(local_req).await?;
6970
6971 let local_status = local_resp.status();
6972 let local_content = local_resp.text().await?;
6973 log::debug!("response content: {}", local_content);
6974
6975 if !local_status.is_client_error() && !local_status.is_server_error() {
6976 match serde_json::from_str::<crate::datadogV2::model::ListHistoricalJobsResponse>(
6977 &local_content,
6978 ) {
6979 Ok(e) => {
6980 return Ok(datadog::ResponseContent {
6981 status: local_status,
6982 content: local_content,
6983 entity: Some(e),
6984 })
6985 }
6986 Err(e) => return Err(datadog::Error::Serde(e)),
6987 };
6988 } else {
6989 let local_entity: Option<ListHistoricalJobsError> =
6990 serde_json::from_str(&local_content).ok();
6991 let local_error = datadog::ResponseContent {
6992 status: local_status,
6993 content: local_content,
6994 entity: local_entity,
6995 };
6996 Err(datadog::Error::ResponseError(local_error))
6997 }
6998 }
6999
7000 pub async fn list_security_filters(
7002 &self,
7003 ) -> Result<
7004 crate::datadogV2::model::SecurityFiltersResponse,
7005 datadog::Error<ListSecurityFiltersError>,
7006 > {
7007 match self.list_security_filters_with_http_info().await {
7008 Ok(response_content) => {
7009 if let Some(e) = response_content.entity {
7010 Ok(e)
7011 } else {
7012 Err(datadog::Error::Serde(serde::de::Error::custom(
7013 "response content was None",
7014 )))
7015 }
7016 }
7017 Err(err) => Err(err),
7018 }
7019 }
7020
7021 pub async fn list_security_filters_with_http_info(
7023 &self,
7024 ) -> Result<
7025 datadog::ResponseContent<crate::datadogV2::model::SecurityFiltersResponse>,
7026 datadog::Error<ListSecurityFiltersError>,
7027 > {
7028 let local_configuration = &self.config;
7029 let operation_id = "v2.list_security_filters";
7030
7031 let local_client = &self.client;
7032
7033 let local_uri_str = format!(
7034 "{}/api/v2/security_monitoring/configuration/security_filters",
7035 local_configuration.get_operation_host(operation_id)
7036 );
7037 let mut local_req_builder =
7038 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
7039
7040 let mut headers = HeaderMap::new();
7042 headers.insert("Accept", HeaderValue::from_static("application/json"));
7043
7044 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
7046 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
7047 Err(e) => {
7048 log::warn!("Failed to parse user agent header: {e}, falling back to default");
7049 headers.insert(
7050 reqwest::header::USER_AGENT,
7051 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
7052 )
7053 }
7054 };
7055
7056 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
7058 headers.insert(
7059 "DD-API-KEY",
7060 HeaderValue::from_str(local_key.key.as_str())
7061 .expect("failed to parse DD-API-KEY header"),
7062 );
7063 };
7064 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
7065 headers.insert(
7066 "DD-APPLICATION-KEY",
7067 HeaderValue::from_str(local_key.key.as_str())
7068 .expect("failed to parse DD-APPLICATION-KEY header"),
7069 );
7070 };
7071
7072 local_req_builder = local_req_builder.headers(headers);
7073 let local_req = local_req_builder.build()?;
7074 log::debug!("request content: {:?}", local_req.body());
7075 let local_resp = local_client.execute(local_req).await?;
7076
7077 let local_status = local_resp.status();
7078 let local_content = local_resp.text().await?;
7079 log::debug!("response content: {}", local_content);
7080
7081 if !local_status.is_client_error() && !local_status.is_server_error() {
7082 match serde_json::from_str::<crate::datadogV2::model::SecurityFiltersResponse>(
7083 &local_content,
7084 ) {
7085 Ok(e) => {
7086 return Ok(datadog::ResponseContent {
7087 status: local_status,
7088 content: local_content,
7089 entity: Some(e),
7090 })
7091 }
7092 Err(e) => return Err(datadog::Error::Serde(e)),
7093 };
7094 } else {
7095 let local_entity: Option<ListSecurityFiltersError> =
7096 serde_json::from_str(&local_content).ok();
7097 let local_error = datadog::ResponseContent {
7098 status: local_status,
7099 content: local_content,
7100 entity: local_entity,
7101 };
7102 Err(datadog::Error::ResponseError(local_error))
7103 }
7104 }
7105
7106 pub async fn list_security_monitoring_histsignals(
7108 &self,
7109 params: ListSecurityMonitoringHistsignalsOptionalParams,
7110 ) -> Result<
7111 crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
7112 datadog::Error<ListSecurityMonitoringHistsignalsError>,
7113 > {
7114 match self
7115 .list_security_monitoring_histsignals_with_http_info(params)
7116 .await
7117 {
7118 Ok(response_content) => {
7119 if let Some(e) = response_content.entity {
7120 Ok(e)
7121 } else {
7122 Err(datadog::Error::Serde(serde::de::Error::custom(
7123 "response content was None",
7124 )))
7125 }
7126 }
7127 Err(err) => Err(err),
7128 }
7129 }
7130
7131 pub async fn list_security_monitoring_histsignals_with_http_info(
7133 &self,
7134 params: ListSecurityMonitoringHistsignalsOptionalParams,
7135 ) -> Result<
7136 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSignalsListResponse>,
7137 datadog::Error<ListSecurityMonitoringHistsignalsError>,
7138 > {
7139 let local_configuration = &self.config;
7140 let operation_id = "v2.list_security_monitoring_histsignals";
7141 if local_configuration.is_unstable_operation_enabled(operation_id) {
7142 warn!("Using unstable operation {operation_id}");
7143 } else {
7144 let local_error = datadog::UnstableOperationDisabledError {
7145 msg: "Operation 'v2.list_security_monitoring_histsignals' is not enabled"
7146 .to_string(),
7147 };
7148 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
7149 }
7150
7151 let filter_query = params.filter_query;
7153 let filter_from = params.filter_from;
7154 let filter_to = params.filter_to;
7155 let sort = params.sort;
7156 let page_cursor = params.page_cursor;
7157 let page_limit = params.page_limit;
7158
7159 let local_client = &self.client;
7160
7161 let local_uri_str = format!(
7162 "{}/api/v2/siem-historical-detections/histsignals",
7163 local_configuration.get_operation_host(operation_id)
7164 );
7165 let mut local_req_builder =
7166 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
7167
7168 if let Some(ref local_query_param) = filter_query {
7169 local_req_builder =
7170 local_req_builder.query(&[("filter[query]", &local_query_param.to_string())]);
7171 };
7172 if let Some(ref local_query_param) = filter_from {
7173 local_req_builder = local_req_builder.query(&[(
7174 "filter[from]",
7175 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
7176 )]);
7177 };
7178 if let Some(ref local_query_param) = filter_to {
7179 local_req_builder = local_req_builder.query(&[(
7180 "filter[to]",
7181 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
7182 )]);
7183 };
7184 if let Some(ref local_query_param) = sort {
7185 local_req_builder =
7186 local_req_builder.query(&[("sort", &local_query_param.to_string())]);
7187 };
7188 if let Some(ref local_query_param) = page_cursor {
7189 local_req_builder =
7190 local_req_builder.query(&[("page[cursor]", &local_query_param.to_string())]);
7191 };
7192 if let Some(ref local_query_param) = page_limit {
7193 local_req_builder =
7194 local_req_builder.query(&[("page[limit]", &local_query_param.to_string())]);
7195 };
7196
7197 let mut headers = HeaderMap::new();
7199 headers.insert("Accept", HeaderValue::from_static("application/json"));
7200
7201 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
7203 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
7204 Err(e) => {
7205 log::warn!("Failed to parse user agent header: {e}, falling back to default");
7206 headers.insert(
7207 reqwest::header::USER_AGENT,
7208 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
7209 )
7210 }
7211 };
7212
7213 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
7215 headers.insert(
7216 "DD-API-KEY",
7217 HeaderValue::from_str(local_key.key.as_str())
7218 .expect("failed to parse DD-API-KEY header"),
7219 );
7220 };
7221 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
7222 headers.insert(
7223 "DD-APPLICATION-KEY",
7224 HeaderValue::from_str(local_key.key.as_str())
7225 .expect("failed to parse DD-APPLICATION-KEY header"),
7226 );
7227 };
7228
7229 local_req_builder = local_req_builder.headers(headers);
7230 let local_req = local_req_builder.build()?;
7231 log::debug!("request content: {:?}", local_req.body());
7232 let local_resp = local_client.execute(local_req).await?;
7233
7234 let local_status = local_resp.status();
7235 let local_content = local_resp.text().await?;
7236 log::debug!("response content: {}", local_content);
7237
7238 if !local_status.is_client_error() && !local_status.is_server_error() {
7239 match serde_json::from_str::<
7240 crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
7241 >(&local_content)
7242 {
7243 Ok(e) => {
7244 return Ok(datadog::ResponseContent {
7245 status: local_status,
7246 content: local_content,
7247 entity: Some(e),
7248 })
7249 }
7250 Err(e) => return Err(datadog::Error::Serde(e)),
7251 };
7252 } else {
7253 let local_entity: Option<ListSecurityMonitoringHistsignalsError> =
7254 serde_json::from_str(&local_content).ok();
7255 let local_error = datadog::ResponseContent {
7256 status: local_status,
7257 content: local_content,
7258 entity: local_entity,
7259 };
7260 Err(datadog::Error::ResponseError(local_error))
7261 }
7262 }
7263
7264 pub async fn list_security_monitoring_rules(
7266 &self,
7267 params: ListSecurityMonitoringRulesOptionalParams,
7268 ) -> Result<
7269 crate::datadogV2::model::SecurityMonitoringListRulesResponse,
7270 datadog::Error<ListSecurityMonitoringRulesError>,
7271 > {
7272 match self
7273 .list_security_monitoring_rules_with_http_info(params)
7274 .await
7275 {
7276 Ok(response_content) => {
7277 if let Some(e) = response_content.entity {
7278 Ok(e)
7279 } else {
7280 Err(datadog::Error::Serde(serde::de::Error::custom(
7281 "response content was None",
7282 )))
7283 }
7284 }
7285 Err(err) => Err(err),
7286 }
7287 }
7288
7289 pub async fn list_security_monitoring_rules_with_http_info(
7291 &self,
7292 params: ListSecurityMonitoringRulesOptionalParams,
7293 ) -> Result<
7294 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringListRulesResponse>,
7295 datadog::Error<ListSecurityMonitoringRulesError>,
7296 > {
7297 let local_configuration = &self.config;
7298 let operation_id = "v2.list_security_monitoring_rules";
7299
7300 let page_size = params.page_size;
7302 let page_number = params.page_number;
7303
7304 let local_client = &self.client;
7305
7306 let local_uri_str = format!(
7307 "{}/api/v2/security_monitoring/rules",
7308 local_configuration.get_operation_host(operation_id)
7309 );
7310 let mut local_req_builder =
7311 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
7312
7313 if let Some(ref local_query_param) = page_size {
7314 local_req_builder =
7315 local_req_builder.query(&[("page[size]", &local_query_param.to_string())]);
7316 };
7317 if let Some(ref local_query_param) = page_number {
7318 local_req_builder =
7319 local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
7320 };
7321
7322 let mut headers = HeaderMap::new();
7324 headers.insert("Accept", HeaderValue::from_static("application/json"));
7325
7326 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
7328 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
7329 Err(e) => {
7330 log::warn!("Failed to parse user agent header: {e}, falling back to default");
7331 headers.insert(
7332 reqwest::header::USER_AGENT,
7333 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
7334 )
7335 }
7336 };
7337
7338 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
7340 headers.insert(
7341 "DD-API-KEY",
7342 HeaderValue::from_str(local_key.key.as_str())
7343 .expect("failed to parse DD-API-KEY header"),
7344 );
7345 };
7346 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
7347 headers.insert(
7348 "DD-APPLICATION-KEY",
7349 HeaderValue::from_str(local_key.key.as_str())
7350 .expect("failed to parse DD-APPLICATION-KEY header"),
7351 );
7352 };
7353
7354 local_req_builder = local_req_builder.headers(headers);
7355 let local_req = local_req_builder.build()?;
7356 log::debug!("request content: {:?}", local_req.body());
7357 let local_resp = local_client.execute(local_req).await?;
7358
7359 let local_status = local_resp.status();
7360 let local_content = local_resp.text().await?;
7361 log::debug!("response content: {}", local_content);
7362
7363 if !local_status.is_client_error() && !local_status.is_server_error() {
7364 match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringListRulesResponse>(
7365 &local_content,
7366 ) {
7367 Ok(e) => {
7368 return Ok(datadog::ResponseContent {
7369 status: local_status,
7370 content: local_content,
7371 entity: Some(e),
7372 })
7373 }
7374 Err(e) => return Err(datadog::Error::Serde(e)),
7375 };
7376 } else {
7377 let local_entity: Option<ListSecurityMonitoringRulesError> =
7378 serde_json::from_str(&local_content).ok();
7379 let local_error = datadog::ResponseContent {
7380 status: local_status,
7381 content: local_content,
7382 entity: local_entity,
7383 };
7384 Err(datadog::Error::ResponseError(local_error))
7385 }
7386 }
7387
7388 pub async fn list_security_monitoring_signals(
7392 &self,
7393 params: ListSecurityMonitoringSignalsOptionalParams,
7394 ) -> Result<
7395 crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
7396 datadog::Error<ListSecurityMonitoringSignalsError>,
7397 > {
7398 match self
7399 .list_security_monitoring_signals_with_http_info(params)
7400 .await
7401 {
7402 Ok(response_content) => {
7403 if let Some(e) = response_content.entity {
7404 Ok(e)
7405 } else {
7406 Err(datadog::Error::Serde(serde::de::Error::custom(
7407 "response content was None",
7408 )))
7409 }
7410 }
7411 Err(err) => Err(err),
7412 }
7413 }
7414
7415 pub fn list_security_monitoring_signals_with_pagination(
7416 &self,
7417 mut params: ListSecurityMonitoringSignalsOptionalParams,
7418 ) -> impl Stream<
7419 Item = Result<
7420 crate::datadogV2::model::SecurityMonitoringSignal,
7421 datadog::Error<ListSecurityMonitoringSignalsError>,
7422 >,
7423 > + '_ {
7424 try_stream! {
7425 let mut page_size: i32 = 10;
7426 if params.page_limit.is_none() {
7427 params.page_limit = Some(page_size);
7428 } else {
7429 page_size = params.page_limit.unwrap().clone();
7430 }
7431 loop {
7432 let resp = self.list_security_monitoring_signals(params.clone()).await?;
7433 let Some(data) = resp.data else { break };
7434
7435 let r = data;
7436 let count = r.len();
7437 for team in r {
7438 yield team;
7439 }
7440
7441 if count < page_size as usize {
7442 break;
7443 }
7444 let Some(meta) = resp.meta else { break };
7445 let Some(page) = meta.page else { break };
7446 let Some(after) = page.after else { break };
7447
7448 params.page_cursor = Some(after);
7449 }
7450 }
7451 }
7452
7453 pub async fn list_security_monitoring_signals_with_http_info(
7457 &self,
7458 params: ListSecurityMonitoringSignalsOptionalParams,
7459 ) -> Result<
7460 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSignalsListResponse>,
7461 datadog::Error<ListSecurityMonitoringSignalsError>,
7462 > {
7463 let local_configuration = &self.config;
7464 let operation_id = "v2.list_security_monitoring_signals";
7465
7466 let filter_query = params.filter_query;
7468 let filter_from = params.filter_from;
7469 let filter_to = params.filter_to;
7470 let sort = params.sort;
7471 let page_cursor = params.page_cursor;
7472 let page_limit = params.page_limit;
7473
7474 let local_client = &self.client;
7475
7476 let local_uri_str = format!(
7477 "{}/api/v2/security_monitoring/signals",
7478 local_configuration.get_operation_host(operation_id)
7479 );
7480 let mut local_req_builder =
7481 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
7482
7483 if let Some(ref local_query_param) = filter_query {
7484 local_req_builder =
7485 local_req_builder.query(&[("filter[query]", &local_query_param.to_string())]);
7486 };
7487 if let Some(ref local_query_param) = filter_from {
7488 local_req_builder = local_req_builder.query(&[(
7489 "filter[from]",
7490 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
7491 )]);
7492 };
7493 if let Some(ref local_query_param) = filter_to {
7494 local_req_builder = local_req_builder.query(&[(
7495 "filter[to]",
7496 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
7497 )]);
7498 };
7499 if let Some(ref local_query_param) = sort {
7500 local_req_builder =
7501 local_req_builder.query(&[("sort", &local_query_param.to_string())]);
7502 };
7503 if let Some(ref local_query_param) = page_cursor {
7504 local_req_builder =
7505 local_req_builder.query(&[("page[cursor]", &local_query_param.to_string())]);
7506 };
7507 if let Some(ref local_query_param) = page_limit {
7508 local_req_builder =
7509 local_req_builder.query(&[("page[limit]", &local_query_param.to_string())]);
7510 };
7511
7512 let mut headers = HeaderMap::new();
7514 headers.insert("Accept", HeaderValue::from_static("application/json"));
7515
7516 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
7518 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
7519 Err(e) => {
7520 log::warn!("Failed to parse user agent header: {e}, falling back to default");
7521 headers.insert(
7522 reqwest::header::USER_AGENT,
7523 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
7524 )
7525 }
7526 };
7527
7528 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
7530 headers.insert(
7531 "DD-API-KEY",
7532 HeaderValue::from_str(local_key.key.as_str())
7533 .expect("failed to parse DD-API-KEY header"),
7534 );
7535 };
7536 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
7537 headers.insert(
7538 "DD-APPLICATION-KEY",
7539 HeaderValue::from_str(local_key.key.as_str())
7540 .expect("failed to parse DD-APPLICATION-KEY header"),
7541 );
7542 };
7543
7544 local_req_builder = local_req_builder.headers(headers);
7545 let local_req = local_req_builder.build()?;
7546 log::debug!("request content: {:?}", local_req.body());
7547 let local_resp = local_client.execute(local_req).await?;
7548
7549 let local_status = local_resp.status();
7550 let local_content = local_resp.text().await?;
7551 log::debug!("response content: {}", local_content);
7552
7553 if !local_status.is_client_error() && !local_status.is_server_error() {
7554 match serde_json::from_str::<
7555 crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
7556 >(&local_content)
7557 {
7558 Ok(e) => {
7559 return Ok(datadog::ResponseContent {
7560 status: local_status,
7561 content: local_content,
7562 entity: Some(e),
7563 })
7564 }
7565 Err(e) => return Err(datadog::Error::Serde(e)),
7566 };
7567 } else {
7568 let local_entity: Option<ListSecurityMonitoringSignalsError> =
7569 serde_json::from_str(&local_content).ok();
7570 let local_error = datadog::ResponseContent {
7571 status: local_status,
7572 content: local_content,
7573 entity: local_entity,
7574 };
7575 Err(datadog::Error::ResponseError(local_error))
7576 }
7577 }
7578
7579 pub async fn list_security_monitoring_suppressions(
7581 &self,
7582 ) -> Result<
7583 crate::datadogV2::model::SecurityMonitoringSuppressionsResponse,
7584 datadog::Error<ListSecurityMonitoringSuppressionsError>,
7585 > {
7586 match self
7587 .list_security_monitoring_suppressions_with_http_info()
7588 .await
7589 {
7590 Ok(response_content) => {
7591 if let Some(e) = response_content.entity {
7592 Ok(e)
7593 } else {
7594 Err(datadog::Error::Serde(serde::de::Error::custom(
7595 "response content was None",
7596 )))
7597 }
7598 }
7599 Err(err) => Err(err),
7600 }
7601 }
7602
7603 pub async fn list_security_monitoring_suppressions_with_http_info(
7605 &self,
7606 ) -> Result<
7607 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSuppressionsResponse>,
7608 datadog::Error<ListSecurityMonitoringSuppressionsError>,
7609 > {
7610 let local_configuration = &self.config;
7611 let operation_id = "v2.list_security_monitoring_suppressions";
7612
7613 let local_client = &self.client;
7614
7615 let local_uri_str = format!(
7616 "{}/api/v2/security_monitoring/configuration/suppressions",
7617 local_configuration.get_operation_host(operation_id)
7618 );
7619 let mut local_req_builder =
7620 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
7621
7622 let mut headers = HeaderMap::new();
7624 headers.insert("Accept", HeaderValue::from_static("application/json"));
7625
7626 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
7628 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
7629 Err(e) => {
7630 log::warn!("Failed to parse user agent header: {e}, falling back to default");
7631 headers.insert(
7632 reqwest::header::USER_AGENT,
7633 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
7634 )
7635 }
7636 };
7637
7638 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
7640 headers.insert(
7641 "DD-API-KEY",
7642 HeaderValue::from_str(local_key.key.as_str())
7643 .expect("failed to parse DD-API-KEY header"),
7644 );
7645 };
7646 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
7647 headers.insert(
7648 "DD-APPLICATION-KEY",
7649 HeaderValue::from_str(local_key.key.as_str())
7650 .expect("failed to parse DD-APPLICATION-KEY header"),
7651 );
7652 };
7653
7654 local_req_builder = local_req_builder.headers(headers);
7655 let local_req = local_req_builder.build()?;
7656 log::debug!("request content: {:?}", local_req.body());
7657 let local_resp = local_client.execute(local_req).await?;
7658
7659 let local_status = local_resp.status();
7660 let local_content = local_resp.text().await?;
7661 log::debug!("response content: {}", local_content);
7662
7663 if !local_status.is_client_error() && !local_status.is_server_error() {
7664 match serde_json::from_str::<
7665 crate::datadogV2::model::SecurityMonitoringSuppressionsResponse,
7666 >(&local_content)
7667 {
7668 Ok(e) => {
7669 return Ok(datadog::ResponseContent {
7670 status: local_status,
7671 content: local_content,
7672 entity: Some(e),
7673 })
7674 }
7675 Err(e) => return Err(datadog::Error::Serde(e)),
7676 };
7677 } else {
7678 let local_entity: Option<ListSecurityMonitoringSuppressionsError> =
7679 serde_json::from_str(&local_content).ok();
7680 let local_error = datadog::ResponseContent {
7681 status: local_status,
7682 content: local_content,
7683 entity: local_entity,
7684 };
7685 Err(datadog::Error::ResponseError(local_error))
7686 }
7687 }
7688
7689 pub async fn list_vulnerabilities(
7771 &self,
7772 params: ListVulnerabilitiesOptionalParams,
7773 ) -> Result<
7774 crate::datadogV2::model::ListVulnerabilitiesResponse,
7775 datadog::Error<ListVulnerabilitiesError>,
7776 > {
7777 match self.list_vulnerabilities_with_http_info(params).await {
7778 Ok(response_content) => {
7779 if let Some(e) = response_content.entity {
7780 Ok(e)
7781 } else {
7782 Err(datadog::Error::Serde(serde::de::Error::custom(
7783 "response content was None",
7784 )))
7785 }
7786 }
7787 Err(err) => Err(err),
7788 }
7789 }
7790
7791 pub async fn list_vulnerabilities_with_http_info(
7873 &self,
7874 params: ListVulnerabilitiesOptionalParams,
7875 ) -> Result<
7876 datadog::ResponseContent<crate::datadogV2::model::ListVulnerabilitiesResponse>,
7877 datadog::Error<ListVulnerabilitiesError>,
7878 > {
7879 let local_configuration = &self.config;
7880 let operation_id = "v2.list_vulnerabilities";
7881 if local_configuration.is_unstable_operation_enabled(operation_id) {
7882 warn!("Using unstable operation {operation_id}");
7883 } else {
7884 let local_error = datadog::UnstableOperationDisabledError {
7885 msg: "Operation 'v2.list_vulnerabilities' is not enabled".to_string(),
7886 };
7887 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
7888 }
7889
7890 let page_token = params.page_token;
7892 let page_number = params.page_number;
7893 let filter_type = params.filter_type;
7894 let filter_cvss_base_score_op = params.filter_cvss_base_score_op;
7895 let filter_cvss_base_severity = params.filter_cvss_base_severity;
7896 let filter_cvss_base_vector = params.filter_cvss_base_vector;
7897 let filter_cvss_datadog_score_op = params.filter_cvss_datadog_score_op;
7898 let filter_cvss_datadog_severity = params.filter_cvss_datadog_severity;
7899 let filter_cvss_datadog_vector = params.filter_cvss_datadog_vector;
7900 let filter_status = params.filter_status;
7901 let filter_tool = params.filter_tool;
7902 let filter_library_name = params.filter_library_name;
7903 let filter_library_version = params.filter_library_version;
7904 let filter_advisory_id = params.filter_advisory_id;
7905 let filter_risks_exploitation_probability = params.filter_risks_exploitation_probability;
7906 let filter_risks_poc_exploit_available = params.filter_risks_poc_exploit_available;
7907 let filter_risks_exploit_available = params.filter_risks_exploit_available;
7908 let filter_risks_epss_score_op = params.filter_risks_epss_score_op;
7909 let filter_risks_epss_severity = params.filter_risks_epss_severity;
7910 let filter_language = params.filter_language;
7911 let filter_ecosystem = params.filter_ecosystem;
7912 let filter_code_location_location = params.filter_code_location_location;
7913 let filter_code_location_file_path = params.filter_code_location_file_path;
7914 let filter_code_location_method = params.filter_code_location_method;
7915 let filter_fix_available = params.filter_fix_available;
7916 let filter_repo_digests = params.filter_repo_digests;
7917 let filter_origin = params.filter_origin;
7918 let filter_asset_name = params.filter_asset_name;
7919 let filter_asset_type = params.filter_asset_type;
7920 let filter_asset_version_first = params.filter_asset_version_first;
7921 let filter_asset_version_last = params.filter_asset_version_last;
7922 let filter_asset_repository_url = params.filter_asset_repository_url;
7923 let filter_asset_risks_in_production = params.filter_asset_risks_in_production;
7924 let filter_asset_risks_under_attack = params.filter_asset_risks_under_attack;
7925 let filter_asset_risks_is_publicly_accessible =
7926 params.filter_asset_risks_is_publicly_accessible;
7927 let filter_asset_risks_has_privileged_access =
7928 params.filter_asset_risks_has_privileged_access;
7929 let filter_asset_risks_has_access_to_sensitive_data =
7930 params.filter_asset_risks_has_access_to_sensitive_data;
7931 let filter_asset_environments = params.filter_asset_environments;
7932 let filter_asset_teams = params.filter_asset_teams;
7933 let filter_asset_arch = params.filter_asset_arch;
7934 let filter_asset_operating_system_name = params.filter_asset_operating_system_name;
7935 let filter_asset_operating_system_version = params.filter_asset_operating_system_version;
7936
7937 let local_client = &self.client;
7938
7939 let local_uri_str = format!(
7940 "{}/api/v2/security/vulnerabilities",
7941 local_configuration.get_operation_host(operation_id)
7942 );
7943 let mut local_req_builder =
7944 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
7945
7946 if let Some(ref local_query_param) = page_token {
7947 local_req_builder =
7948 local_req_builder.query(&[("page[token]", &local_query_param.to_string())]);
7949 };
7950 if let Some(ref local_query_param) = page_number {
7951 local_req_builder =
7952 local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
7953 };
7954 if let Some(ref local_query_param) = filter_type {
7955 local_req_builder =
7956 local_req_builder.query(&[("filter[type]", &local_query_param.to_string())]);
7957 };
7958 if let Some(ref local_query_param) = filter_cvss_base_score_op {
7959 local_req_builder = local_req_builder.query(&[(
7960 "filter[cvss.base.score][`$op`]",
7961 &local_query_param.to_string(),
7962 )]);
7963 };
7964 if let Some(ref local_query_param) = filter_cvss_base_severity {
7965 local_req_builder = local_req_builder
7966 .query(&[("filter[cvss.base.severity]", &local_query_param.to_string())]);
7967 };
7968 if let Some(ref local_query_param) = filter_cvss_base_vector {
7969 local_req_builder = local_req_builder
7970 .query(&[("filter[cvss.base.vector]", &local_query_param.to_string())]);
7971 };
7972 if let Some(ref local_query_param) = filter_cvss_datadog_score_op {
7973 local_req_builder = local_req_builder.query(&[(
7974 "filter[cvss.datadog.score][`$op`]",
7975 &local_query_param.to_string(),
7976 )]);
7977 };
7978 if let Some(ref local_query_param) = filter_cvss_datadog_severity {
7979 local_req_builder = local_req_builder.query(&[(
7980 "filter[cvss.datadog.severity]",
7981 &local_query_param.to_string(),
7982 )]);
7983 };
7984 if let Some(ref local_query_param) = filter_cvss_datadog_vector {
7985 local_req_builder = local_req_builder.query(&[(
7986 "filter[cvss.datadog.vector]",
7987 &local_query_param.to_string(),
7988 )]);
7989 };
7990 if let Some(ref local_query_param) = filter_status {
7991 local_req_builder =
7992 local_req_builder.query(&[("filter[status]", &local_query_param.to_string())]);
7993 };
7994 if let Some(ref local_query_param) = filter_tool {
7995 local_req_builder =
7996 local_req_builder.query(&[("filter[tool]", &local_query_param.to_string())]);
7997 };
7998 if let Some(ref local_query_param) = filter_library_name {
7999 local_req_builder = local_req_builder
8000 .query(&[("filter[library.name]", &local_query_param.to_string())]);
8001 };
8002 if let Some(ref local_query_param) = filter_library_version {
8003 local_req_builder = local_req_builder
8004 .query(&[("filter[library.version]", &local_query_param.to_string())]);
8005 };
8006 if let Some(ref local_query_param) = filter_advisory_id {
8007 local_req_builder =
8008 local_req_builder.query(&[("filter[advisory_id]", &local_query_param.to_string())]);
8009 };
8010 if let Some(ref local_query_param) = filter_risks_exploitation_probability {
8011 local_req_builder = local_req_builder.query(&[(
8012 "filter[risks.exploitation_probability]",
8013 &local_query_param.to_string(),
8014 )]);
8015 };
8016 if let Some(ref local_query_param) = filter_risks_poc_exploit_available {
8017 local_req_builder = local_req_builder.query(&[(
8018 "filter[risks.poc_exploit_available]",
8019 &local_query_param.to_string(),
8020 )]);
8021 };
8022 if let Some(ref local_query_param) = filter_risks_exploit_available {
8023 local_req_builder = local_req_builder.query(&[(
8024 "filter[risks.exploit_available]",
8025 &local_query_param.to_string(),
8026 )]);
8027 };
8028 if let Some(ref local_query_param) = filter_risks_epss_score_op {
8029 local_req_builder = local_req_builder.query(&[(
8030 "filter[risks.epss.score][`$op`]",
8031 &local_query_param.to_string(),
8032 )]);
8033 };
8034 if let Some(ref local_query_param) = filter_risks_epss_severity {
8035 local_req_builder = local_req_builder.query(&[(
8036 "filter[risks.epss.severity]",
8037 &local_query_param.to_string(),
8038 )]);
8039 };
8040 if let Some(ref local_query_param) = filter_language {
8041 local_req_builder =
8042 local_req_builder.query(&[("filter[language]", &local_query_param.to_string())]);
8043 };
8044 if let Some(ref local_query_param) = filter_ecosystem {
8045 local_req_builder =
8046 local_req_builder.query(&[("filter[ecosystem]", &local_query_param.to_string())]);
8047 };
8048 if let Some(ref local_query_param) = filter_code_location_location {
8049 local_req_builder = local_req_builder.query(&[(
8050 "filter[code_location.location]",
8051 &local_query_param.to_string(),
8052 )]);
8053 };
8054 if let Some(ref local_query_param) = filter_code_location_file_path {
8055 local_req_builder = local_req_builder.query(&[(
8056 "filter[code_location.file_path]",
8057 &local_query_param.to_string(),
8058 )]);
8059 };
8060 if let Some(ref local_query_param) = filter_code_location_method {
8061 local_req_builder = local_req_builder.query(&[(
8062 "filter[code_location.method]",
8063 &local_query_param.to_string(),
8064 )]);
8065 };
8066 if let Some(ref local_query_param) = filter_fix_available {
8067 local_req_builder = local_req_builder
8068 .query(&[("filter[fix_available]", &local_query_param.to_string())]);
8069 };
8070 if let Some(ref local_query_param) = filter_repo_digests {
8071 local_req_builder = local_req_builder
8072 .query(&[("filter[repo_digests]", &local_query_param.to_string())]);
8073 };
8074 if let Some(ref local_query_param) = filter_origin {
8075 local_req_builder =
8076 local_req_builder.query(&[("filter[origin]", &local_query_param.to_string())]);
8077 };
8078 if let Some(ref local_query_param) = filter_asset_name {
8079 local_req_builder =
8080 local_req_builder.query(&[("filter[asset.name]", &local_query_param.to_string())]);
8081 };
8082 if let Some(ref local_query_param) = filter_asset_type {
8083 local_req_builder =
8084 local_req_builder.query(&[("filter[asset.type]", &local_query_param.to_string())]);
8085 };
8086 if let Some(ref local_query_param) = filter_asset_version_first {
8087 local_req_builder = local_req_builder.query(&[(
8088 "filter[asset.version.first]",
8089 &local_query_param.to_string(),
8090 )]);
8091 };
8092 if let Some(ref local_query_param) = filter_asset_version_last {
8093 local_req_builder = local_req_builder
8094 .query(&[("filter[asset.version.last]", &local_query_param.to_string())]);
8095 };
8096 if let Some(ref local_query_param) = filter_asset_repository_url {
8097 local_req_builder = local_req_builder.query(&[(
8098 "filter[asset.repository_url]",
8099 &local_query_param.to_string(),
8100 )]);
8101 };
8102 if let Some(ref local_query_param) = filter_asset_risks_in_production {
8103 local_req_builder = local_req_builder.query(&[(
8104 "filter[asset.risks.in_production]",
8105 &local_query_param.to_string(),
8106 )]);
8107 };
8108 if let Some(ref local_query_param) = filter_asset_risks_under_attack {
8109 local_req_builder = local_req_builder.query(&[(
8110 "filter[asset.risks.under_attack]",
8111 &local_query_param.to_string(),
8112 )]);
8113 };
8114 if let Some(ref local_query_param) = filter_asset_risks_is_publicly_accessible {
8115 local_req_builder = local_req_builder.query(&[(
8116 "filter[asset.risks.is_publicly_accessible]",
8117 &local_query_param.to_string(),
8118 )]);
8119 };
8120 if let Some(ref local_query_param) = filter_asset_risks_has_privileged_access {
8121 local_req_builder = local_req_builder.query(&[(
8122 "filter[asset.risks.has_privileged_access]",
8123 &local_query_param.to_string(),
8124 )]);
8125 };
8126 if let Some(ref local_query_param) = filter_asset_risks_has_access_to_sensitive_data {
8127 local_req_builder = local_req_builder.query(&[(
8128 "filter[asset.risks.has_access_to_sensitive_data]",
8129 &local_query_param.to_string(),
8130 )]);
8131 };
8132 if let Some(ref local_query_param) = filter_asset_environments {
8133 local_req_builder = local_req_builder
8134 .query(&[("filter[asset.environments]", &local_query_param.to_string())]);
8135 };
8136 if let Some(ref local_query_param) = filter_asset_teams {
8137 local_req_builder =
8138 local_req_builder.query(&[("filter[asset.teams]", &local_query_param.to_string())]);
8139 };
8140 if let Some(ref local_query_param) = filter_asset_arch {
8141 local_req_builder =
8142 local_req_builder.query(&[("filter[asset.arch]", &local_query_param.to_string())]);
8143 };
8144 if let Some(ref local_query_param) = filter_asset_operating_system_name {
8145 local_req_builder = local_req_builder.query(&[(
8146 "filter[asset.operating_system.name]",
8147 &local_query_param.to_string(),
8148 )]);
8149 };
8150 if let Some(ref local_query_param) = filter_asset_operating_system_version {
8151 local_req_builder = local_req_builder.query(&[(
8152 "filter[asset.operating_system.version]",
8153 &local_query_param.to_string(),
8154 )]);
8155 };
8156
8157 let mut headers = HeaderMap::new();
8159 headers.insert("Accept", HeaderValue::from_static("application/json"));
8160
8161 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
8163 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
8164 Err(e) => {
8165 log::warn!("Failed to parse user agent header: {e}, falling back to default");
8166 headers.insert(
8167 reqwest::header::USER_AGENT,
8168 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
8169 )
8170 }
8171 };
8172
8173 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
8175 headers.insert(
8176 "DD-API-KEY",
8177 HeaderValue::from_str(local_key.key.as_str())
8178 .expect("failed to parse DD-API-KEY header"),
8179 );
8180 };
8181 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
8182 headers.insert(
8183 "DD-APPLICATION-KEY",
8184 HeaderValue::from_str(local_key.key.as_str())
8185 .expect("failed to parse DD-APPLICATION-KEY header"),
8186 );
8187 };
8188
8189 local_req_builder = local_req_builder.headers(headers);
8190 let local_req = local_req_builder.build()?;
8191 log::debug!("request content: {:?}", local_req.body());
8192 let local_resp = local_client.execute(local_req).await?;
8193
8194 let local_status = local_resp.status();
8195 let local_content = local_resp.text().await?;
8196 log::debug!("response content: {}", local_content);
8197
8198 if !local_status.is_client_error() && !local_status.is_server_error() {
8199 match serde_json::from_str::<crate::datadogV2::model::ListVulnerabilitiesResponse>(
8200 &local_content,
8201 ) {
8202 Ok(e) => {
8203 return Ok(datadog::ResponseContent {
8204 status: local_status,
8205 content: local_content,
8206 entity: Some(e),
8207 })
8208 }
8209 Err(e) => return Err(datadog::Error::Serde(e)),
8210 };
8211 } else {
8212 let local_entity: Option<ListVulnerabilitiesError> =
8213 serde_json::from_str(&local_content).ok();
8214 let local_error = datadog::ResponseContent {
8215 status: local_status,
8216 content: local_content,
8217 entity: local_entity,
8218 };
8219 Err(datadog::Error::ResponseError(local_error))
8220 }
8221 }
8222
8223 pub async fn list_vulnerable_assets(
8238 &self,
8239 params: ListVulnerableAssetsOptionalParams,
8240 ) -> Result<
8241 crate::datadogV2::model::ListVulnerableAssetsResponse,
8242 datadog::Error<ListVulnerableAssetsError>,
8243 > {
8244 match self.list_vulnerable_assets_with_http_info(params).await {
8245 Ok(response_content) => {
8246 if let Some(e) = response_content.entity {
8247 Ok(e)
8248 } else {
8249 Err(datadog::Error::Serde(serde::de::Error::custom(
8250 "response content was None",
8251 )))
8252 }
8253 }
8254 Err(err) => Err(err),
8255 }
8256 }
8257
8258 pub async fn list_vulnerable_assets_with_http_info(
8273 &self,
8274 params: ListVulnerableAssetsOptionalParams,
8275 ) -> Result<
8276 datadog::ResponseContent<crate::datadogV2::model::ListVulnerableAssetsResponse>,
8277 datadog::Error<ListVulnerableAssetsError>,
8278 > {
8279 let local_configuration = &self.config;
8280 let operation_id = "v2.list_vulnerable_assets";
8281 if local_configuration.is_unstable_operation_enabled(operation_id) {
8282 warn!("Using unstable operation {operation_id}");
8283 } else {
8284 let local_error = datadog::UnstableOperationDisabledError {
8285 msg: "Operation 'v2.list_vulnerable_assets' is not enabled".to_string(),
8286 };
8287 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
8288 }
8289
8290 let page_token = params.page_token;
8292 let page_number = params.page_number;
8293 let filter_name = params.filter_name;
8294 let filter_type = params.filter_type;
8295 let filter_version_first = params.filter_version_first;
8296 let filter_version_last = params.filter_version_last;
8297 let filter_repository_url = params.filter_repository_url;
8298 let filter_risks_in_production = params.filter_risks_in_production;
8299 let filter_risks_under_attack = params.filter_risks_under_attack;
8300 let filter_risks_is_publicly_accessible = params.filter_risks_is_publicly_accessible;
8301 let filter_risks_has_privileged_access = params.filter_risks_has_privileged_access;
8302 let filter_risks_has_access_to_sensitive_data =
8303 params.filter_risks_has_access_to_sensitive_data;
8304 let filter_environments = params.filter_environments;
8305 let filter_teams = params.filter_teams;
8306 let filter_arch = params.filter_arch;
8307 let filter_operating_system_name = params.filter_operating_system_name;
8308 let filter_operating_system_version = params.filter_operating_system_version;
8309
8310 let local_client = &self.client;
8311
8312 let local_uri_str = format!(
8313 "{}/api/v2/security/assets",
8314 local_configuration.get_operation_host(operation_id)
8315 );
8316 let mut local_req_builder =
8317 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
8318
8319 if let Some(ref local_query_param) = page_token {
8320 local_req_builder =
8321 local_req_builder.query(&[("page[token]", &local_query_param.to_string())]);
8322 };
8323 if let Some(ref local_query_param) = page_number {
8324 local_req_builder =
8325 local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
8326 };
8327 if let Some(ref local_query_param) = filter_name {
8328 local_req_builder =
8329 local_req_builder.query(&[("filter[name]", &local_query_param.to_string())]);
8330 };
8331 if let Some(ref local_query_param) = filter_type {
8332 local_req_builder =
8333 local_req_builder.query(&[("filter[type]", &local_query_param.to_string())]);
8334 };
8335 if let Some(ref local_query_param) = filter_version_first {
8336 local_req_builder = local_req_builder
8337 .query(&[("filter[version.first]", &local_query_param.to_string())]);
8338 };
8339 if let Some(ref local_query_param) = filter_version_last {
8340 local_req_builder = local_req_builder
8341 .query(&[("filter[version.last]", &local_query_param.to_string())]);
8342 };
8343 if let Some(ref local_query_param) = filter_repository_url {
8344 local_req_builder = local_req_builder
8345 .query(&[("filter[repository_url]", &local_query_param.to_string())]);
8346 };
8347 if let Some(ref local_query_param) = filter_risks_in_production {
8348 local_req_builder = local_req_builder.query(&[(
8349 "filter[risks.in_production]",
8350 &local_query_param.to_string(),
8351 )]);
8352 };
8353 if let Some(ref local_query_param) = filter_risks_under_attack {
8354 local_req_builder = local_req_builder
8355 .query(&[("filter[risks.under_attack]", &local_query_param.to_string())]);
8356 };
8357 if let Some(ref local_query_param) = filter_risks_is_publicly_accessible {
8358 local_req_builder = local_req_builder.query(&[(
8359 "filter[risks.is_publicly_accessible]",
8360 &local_query_param.to_string(),
8361 )]);
8362 };
8363 if let Some(ref local_query_param) = filter_risks_has_privileged_access {
8364 local_req_builder = local_req_builder.query(&[(
8365 "filter[risks.has_privileged_access]",
8366 &local_query_param.to_string(),
8367 )]);
8368 };
8369 if let Some(ref local_query_param) = filter_risks_has_access_to_sensitive_data {
8370 local_req_builder = local_req_builder.query(&[(
8371 "filter[risks.has_access_to_sensitive_data]",
8372 &local_query_param.to_string(),
8373 )]);
8374 };
8375 if let Some(ref local_query_param) = filter_environments {
8376 local_req_builder = local_req_builder
8377 .query(&[("filter[environments]", &local_query_param.to_string())]);
8378 };
8379 if let Some(ref local_query_param) = filter_teams {
8380 local_req_builder =
8381 local_req_builder.query(&[("filter[teams]", &local_query_param.to_string())]);
8382 };
8383 if let Some(ref local_query_param) = filter_arch {
8384 local_req_builder =
8385 local_req_builder.query(&[("filter[arch]", &local_query_param.to_string())]);
8386 };
8387 if let Some(ref local_query_param) = filter_operating_system_name {
8388 local_req_builder = local_req_builder.query(&[(
8389 "filter[operating_system.name]",
8390 &local_query_param.to_string(),
8391 )]);
8392 };
8393 if let Some(ref local_query_param) = filter_operating_system_version {
8394 local_req_builder = local_req_builder.query(&[(
8395 "filter[operating_system.version]",
8396 &local_query_param.to_string(),
8397 )]);
8398 };
8399
8400 let mut headers = HeaderMap::new();
8402 headers.insert("Accept", HeaderValue::from_static("application/json"));
8403
8404 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
8406 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
8407 Err(e) => {
8408 log::warn!("Failed to parse user agent header: {e}, falling back to default");
8409 headers.insert(
8410 reqwest::header::USER_AGENT,
8411 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
8412 )
8413 }
8414 };
8415
8416 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
8418 headers.insert(
8419 "DD-API-KEY",
8420 HeaderValue::from_str(local_key.key.as_str())
8421 .expect("failed to parse DD-API-KEY header"),
8422 );
8423 };
8424 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
8425 headers.insert(
8426 "DD-APPLICATION-KEY",
8427 HeaderValue::from_str(local_key.key.as_str())
8428 .expect("failed to parse DD-APPLICATION-KEY header"),
8429 );
8430 };
8431
8432 local_req_builder = local_req_builder.headers(headers);
8433 let local_req = local_req_builder.build()?;
8434 log::debug!("request content: {:?}", local_req.body());
8435 let local_resp = local_client.execute(local_req).await?;
8436
8437 let local_status = local_resp.status();
8438 let local_content = local_resp.text().await?;
8439 log::debug!("response content: {}", local_content);
8440
8441 if !local_status.is_client_error() && !local_status.is_server_error() {
8442 match serde_json::from_str::<crate::datadogV2::model::ListVulnerableAssetsResponse>(
8443 &local_content,
8444 ) {
8445 Ok(e) => {
8446 return Ok(datadog::ResponseContent {
8447 status: local_status,
8448 content: local_content,
8449 entity: Some(e),
8450 })
8451 }
8452 Err(e) => return Err(datadog::Error::Serde(e)),
8453 };
8454 } else {
8455 let local_entity: Option<ListVulnerableAssetsError> =
8456 serde_json::from_str(&local_content).ok();
8457 let local_error = datadog::ResponseContent {
8458 status: local_status,
8459 content: local_content,
8460 entity: local_entity,
8461 };
8462 Err(datadog::Error::ResponseError(local_error))
8463 }
8464 }
8465
8466 pub async fn mute_findings(
8468 &self,
8469 body: crate::datadogV2::model::BulkMuteFindingsRequest,
8470 ) -> Result<crate::datadogV2::model::BulkMuteFindingsResponse, datadog::Error<MuteFindingsError>>
8471 {
8472 match self.mute_findings_with_http_info(body).await {
8473 Ok(response_content) => {
8474 if let Some(e) = response_content.entity {
8475 Ok(e)
8476 } else {
8477 Err(datadog::Error::Serde(serde::de::Error::custom(
8478 "response content was None",
8479 )))
8480 }
8481 }
8482 Err(err) => Err(err),
8483 }
8484 }
8485
8486 pub async fn mute_findings_with_http_info(
8488 &self,
8489 body: crate::datadogV2::model::BulkMuteFindingsRequest,
8490 ) -> Result<
8491 datadog::ResponseContent<crate::datadogV2::model::BulkMuteFindingsResponse>,
8492 datadog::Error<MuteFindingsError>,
8493 > {
8494 let local_configuration = &self.config;
8495 let operation_id = "v2.mute_findings";
8496 if local_configuration.is_unstable_operation_enabled(operation_id) {
8497 warn!("Using unstable operation {operation_id}");
8498 } else {
8499 let local_error = datadog::UnstableOperationDisabledError {
8500 msg: "Operation 'v2.mute_findings' is not enabled".to_string(),
8501 };
8502 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
8503 }
8504
8505 let local_client = &self.client;
8506
8507 let local_uri_str = format!(
8508 "{}/api/v2/posture_management/findings",
8509 local_configuration.get_operation_host(operation_id)
8510 );
8511 let mut local_req_builder =
8512 local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
8513
8514 let mut headers = HeaderMap::new();
8516 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
8517 headers.insert("Accept", HeaderValue::from_static("application/json"));
8518
8519 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
8521 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
8522 Err(e) => {
8523 log::warn!("Failed to parse user agent header: {e}, falling back to default");
8524 headers.insert(
8525 reqwest::header::USER_AGENT,
8526 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
8527 )
8528 }
8529 };
8530
8531 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
8533 headers.insert(
8534 "DD-API-KEY",
8535 HeaderValue::from_str(local_key.key.as_str())
8536 .expect("failed to parse DD-API-KEY header"),
8537 );
8538 };
8539 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
8540 headers.insert(
8541 "DD-APPLICATION-KEY",
8542 HeaderValue::from_str(local_key.key.as_str())
8543 .expect("failed to parse DD-APPLICATION-KEY header"),
8544 );
8545 };
8546
8547 let output = Vec::new();
8549 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
8550 if body.serialize(&mut ser).is_ok() {
8551 if let Some(content_encoding) = headers.get("Content-Encoding") {
8552 match content_encoding.to_str().unwrap_or_default() {
8553 "gzip" => {
8554 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
8555 let _ = enc.write_all(ser.into_inner().as_slice());
8556 match enc.finish() {
8557 Ok(buf) => {
8558 local_req_builder = local_req_builder.body(buf);
8559 }
8560 Err(e) => return Err(datadog::Error::Io(e)),
8561 }
8562 }
8563 "deflate" => {
8564 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
8565 let _ = enc.write_all(ser.into_inner().as_slice());
8566 match enc.finish() {
8567 Ok(buf) => {
8568 local_req_builder = local_req_builder.body(buf);
8569 }
8570 Err(e) => return Err(datadog::Error::Io(e)),
8571 }
8572 }
8573 "zstd1" => {
8574 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
8575 let _ = enc.write_all(ser.into_inner().as_slice());
8576 match enc.finish() {
8577 Ok(buf) => {
8578 local_req_builder = local_req_builder.body(buf);
8579 }
8580 Err(e) => return Err(datadog::Error::Io(e)),
8581 }
8582 }
8583 _ => {
8584 local_req_builder = local_req_builder.body(ser.into_inner());
8585 }
8586 }
8587 } else {
8588 local_req_builder = local_req_builder.body(ser.into_inner());
8589 }
8590 }
8591
8592 local_req_builder = local_req_builder.headers(headers);
8593 let local_req = local_req_builder.build()?;
8594 log::debug!("request content: {:?}", local_req.body());
8595 let local_resp = local_client.execute(local_req).await?;
8596
8597 let local_status = local_resp.status();
8598 let local_content = local_resp.text().await?;
8599 log::debug!("response content: {}", local_content);
8600
8601 if !local_status.is_client_error() && !local_status.is_server_error() {
8602 match serde_json::from_str::<crate::datadogV2::model::BulkMuteFindingsResponse>(
8603 &local_content,
8604 ) {
8605 Ok(e) => {
8606 return Ok(datadog::ResponseContent {
8607 status: local_status,
8608 content: local_content,
8609 entity: Some(e),
8610 })
8611 }
8612 Err(e) => return Err(datadog::Error::Serde(e)),
8613 };
8614 } else {
8615 let local_entity: Option<MuteFindingsError> = serde_json::from_str(&local_content).ok();
8616 let local_error = datadog::ResponseContent {
8617 status: local_status,
8618 content: local_content,
8619 entity: local_entity,
8620 };
8621 Err(datadog::Error::ResponseError(local_error))
8622 }
8623 }
8624
8625 pub async fn patch_signal_notification_rule(
8627 &self,
8628 id: String,
8629 body: crate::datadogV2::model::PatchNotificationRuleParameters,
8630 ) -> Result<
8631 crate::datadogV2::model::NotificationRuleResponse,
8632 datadog::Error<PatchSignalNotificationRuleError>,
8633 > {
8634 match self
8635 .patch_signal_notification_rule_with_http_info(id, body)
8636 .await
8637 {
8638 Ok(response_content) => {
8639 if let Some(e) = response_content.entity {
8640 Ok(e)
8641 } else {
8642 Err(datadog::Error::Serde(serde::de::Error::custom(
8643 "response content was None",
8644 )))
8645 }
8646 }
8647 Err(err) => Err(err),
8648 }
8649 }
8650
8651 pub async fn patch_signal_notification_rule_with_http_info(
8653 &self,
8654 id: String,
8655 body: crate::datadogV2::model::PatchNotificationRuleParameters,
8656 ) -> Result<
8657 datadog::ResponseContent<crate::datadogV2::model::NotificationRuleResponse>,
8658 datadog::Error<PatchSignalNotificationRuleError>,
8659 > {
8660 let local_configuration = &self.config;
8661 let operation_id = "v2.patch_signal_notification_rule";
8662
8663 let local_client = &self.client;
8664
8665 let local_uri_str = format!(
8666 "{}/api/v2/security/signals/notification_rules/{id}",
8667 local_configuration.get_operation_host(operation_id),
8668 id = datadog::urlencode(id)
8669 );
8670 let mut local_req_builder =
8671 local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
8672
8673 let mut headers = HeaderMap::new();
8675 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
8676 headers.insert("Accept", HeaderValue::from_static("application/json"));
8677
8678 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
8680 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
8681 Err(e) => {
8682 log::warn!("Failed to parse user agent header: {e}, falling back to default");
8683 headers.insert(
8684 reqwest::header::USER_AGENT,
8685 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
8686 )
8687 }
8688 };
8689
8690 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
8692 headers.insert(
8693 "DD-API-KEY",
8694 HeaderValue::from_str(local_key.key.as_str())
8695 .expect("failed to parse DD-API-KEY header"),
8696 );
8697 };
8698 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
8699 headers.insert(
8700 "DD-APPLICATION-KEY",
8701 HeaderValue::from_str(local_key.key.as_str())
8702 .expect("failed to parse DD-APPLICATION-KEY header"),
8703 );
8704 };
8705
8706 let output = Vec::new();
8708 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
8709 if body.serialize(&mut ser).is_ok() {
8710 if let Some(content_encoding) = headers.get("Content-Encoding") {
8711 match content_encoding.to_str().unwrap_or_default() {
8712 "gzip" => {
8713 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
8714 let _ = enc.write_all(ser.into_inner().as_slice());
8715 match enc.finish() {
8716 Ok(buf) => {
8717 local_req_builder = local_req_builder.body(buf);
8718 }
8719 Err(e) => return Err(datadog::Error::Io(e)),
8720 }
8721 }
8722 "deflate" => {
8723 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
8724 let _ = enc.write_all(ser.into_inner().as_slice());
8725 match enc.finish() {
8726 Ok(buf) => {
8727 local_req_builder = local_req_builder.body(buf);
8728 }
8729 Err(e) => return Err(datadog::Error::Io(e)),
8730 }
8731 }
8732 "zstd1" => {
8733 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
8734 let _ = enc.write_all(ser.into_inner().as_slice());
8735 match enc.finish() {
8736 Ok(buf) => {
8737 local_req_builder = local_req_builder.body(buf);
8738 }
8739 Err(e) => return Err(datadog::Error::Io(e)),
8740 }
8741 }
8742 _ => {
8743 local_req_builder = local_req_builder.body(ser.into_inner());
8744 }
8745 }
8746 } else {
8747 local_req_builder = local_req_builder.body(ser.into_inner());
8748 }
8749 }
8750
8751 local_req_builder = local_req_builder.headers(headers);
8752 let local_req = local_req_builder.build()?;
8753 log::debug!("request content: {:?}", local_req.body());
8754 let local_resp = local_client.execute(local_req).await?;
8755
8756 let local_status = local_resp.status();
8757 let local_content = local_resp.text().await?;
8758 log::debug!("response content: {}", local_content);
8759
8760 if !local_status.is_client_error() && !local_status.is_server_error() {
8761 match serde_json::from_str::<crate::datadogV2::model::NotificationRuleResponse>(
8762 &local_content,
8763 ) {
8764 Ok(e) => {
8765 return Ok(datadog::ResponseContent {
8766 status: local_status,
8767 content: local_content,
8768 entity: Some(e),
8769 })
8770 }
8771 Err(e) => return Err(datadog::Error::Serde(e)),
8772 };
8773 } else {
8774 let local_entity: Option<PatchSignalNotificationRuleError> =
8775 serde_json::from_str(&local_content).ok();
8776 let local_error = datadog::ResponseContent {
8777 status: local_status,
8778 content: local_content,
8779 entity: local_entity,
8780 };
8781 Err(datadog::Error::ResponseError(local_error))
8782 }
8783 }
8784
8785 pub async fn patch_vulnerability_notification_rule(
8787 &self,
8788 id: String,
8789 body: crate::datadogV2::model::PatchNotificationRuleParameters,
8790 ) -> Result<
8791 crate::datadogV2::model::NotificationRuleResponse,
8792 datadog::Error<PatchVulnerabilityNotificationRuleError>,
8793 > {
8794 match self
8795 .patch_vulnerability_notification_rule_with_http_info(id, body)
8796 .await
8797 {
8798 Ok(response_content) => {
8799 if let Some(e) = response_content.entity {
8800 Ok(e)
8801 } else {
8802 Err(datadog::Error::Serde(serde::de::Error::custom(
8803 "response content was None",
8804 )))
8805 }
8806 }
8807 Err(err) => Err(err),
8808 }
8809 }
8810
8811 pub async fn patch_vulnerability_notification_rule_with_http_info(
8813 &self,
8814 id: String,
8815 body: crate::datadogV2::model::PatchNotificationRuleParameters,
8816 ) -> Result<
8817 datadog::ResponseContent<crate::datadogV2::model::NotificationRuleResponse>,
8818 datadog::Error<PatchVulnerabilityNotificationRuleError>,
8819 > {
8820 let local_configuration = &self.config;
8821 let operation_id = "v2.patch_vulnerability_notification_rule";
8822
8823 let local_client = &self.client;
8824
8825 let local_uri_str = format!(
8826 "{}/api/v2/security/vulnerabilities/notification_rules/{id}",
8827 local_configuration.get_operation_host(operation_id),
8828 id = datadog::urlencode(id)
8829 );
8830 let mut local_req_builder =
8831 local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
8832
8833 let mut headers = HeaderMap::new();
8835 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
8836 headers.insert("Accept", HeaderValue::from_static("application/json"));
8837
8838 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
8840 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
8841 Err(e) => {
8842 log::warn!("Failed to parse user agent header: {e}, falling back to default");
8843 headers.insert(
8844 reqwest::header::USER_AGENT,
8845 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
8846 )
8847 }
8848 };
8849
8850 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
8852 headers.insert(
8853 "DD-API-KEY",
8854 HeaderValue::from_str(local_key.key.as_str())
8855 .expect("failed to parse DD-API-KEY header"),
8856 );
8857 };
8858 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
8859 headers.insert(
8860 "DD-APPLICATION-KEY",
8861 HeaderValue::from_str(local_key.key.as_str())
8862 .expect("failed to parse DD-APPLICATION-KEY header"),
8863 );
8864 };
8865
8866 let output = Vec::new();
8868 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
8869 if body.serialize(&mut ser).is_ok() {
8870 if let Some(content_encoding) = headers.get("Content-Encoding") {
8871 match content_encoding.to_str().unwrap_or_default() {
8872 "gzip" => {
8873 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
8874 let _ = enc.write_all(ser.into_inner().as_slice());
8875 match enc.finish() {
8876 Ok(buf) => {
8877 local_req_builder = local_req_builder.body(buf);
8878 }
8879 Err(e) => return Err(datadog::Error::Io(e)),
8880 }
8881 }
8882 "deflate" => {
8883 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
8884 let _ = enc.write_all(ser.into_inner().as_slice());
8885 match enc.finish() {
8886 Ok(buf) => {
8887 local_req_builder = local_req_builder.body(buf);
8888 }
8889 Err(e) => return Err(datadog::Error::Io(e)),
8890 }
8891 }
8892 "zstd1" => {
8893 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
8894 let _ = enc.write_all(ser.into_inner().as_slice());
8895 match enc.finish() {
8896 Ok(buf) => {
8897 local_req_builder = local_req_builder.body(buf);
8898 }
8899 Err(e) => return Err(datadog::Error::Io(e)),
8900 }
8901 }
8902 _ => {
8903 local_req_builder = local_req_builder.body(ser.into_inner());
8904 }
8905 }
8906 } else {
8907 local_req_builder = local_req_builder.body(ser.into_inner());
8908 }
8909 }
8910
8911 local_req_builder = local_req_builder.headers(headers);
8912 let local_req = local_req_builder.build()?;
8913 log::debug!("request content: {:?}", local_req.body());
8914 let local_resp = local_client.execute(local_req).await?;
8915
8916 let local_status = local_resp.status();
8917 let local_content = local_resp.text().await?;
8918 log::debug!("response content: {}", local_content);
8919
8920 if !local_status.is_client_error() && !local_status.is_server_error() {
8921 match serde_json::from_str::<crate::datadogV2::model::NotificationRuleResponse>(
8922 &local_content,
8923 ) {
8924 Ok(e) => {
8925 return Ok(datadog::ResponseContent {
8926 status: local_status,
8927 content: local_content,
8928 entity: Some(e),
8929 })
8930 }
8931 Err(e) => return Err(datadog::Error::Serde(e)),
8932 };
8933 } else {
8934 let local_entity: Option<PatchVulnerabilityNotificationRuleError> =
8935 serde_json::from_str(&local_content).ok();
8936 let local_error = datadog::ResponseContent {
8937 status: local_status,
8938 content: local_content,
8939 entity: local_entity,
8940 };
8941 Err(datadog::Error::ResponseError(local_error))
8942 }
8943 }
8944
8945 pub async fn run_historical_job(
8947 &self,
8948 body: crate::datadogV2::model::RunHistoricalJobRequest,
8949 ) -> Result<crate::datadogV2::model::JobCreateResponse, datadog::Error<RunHistoricalJobError>>
8950 {
8951 match self.run_historical_job_with_http_info(body).await {
8952 Ok(response_content) => {
8953 if let Some(e) = response_content.entity {
8954 Ok(e)
8955 } else {
8956 Err(datadog::Error::Serde(serde::de::Error::custom(
8957 "response content was None",
8958 )))
8959 }
8960 }
8961 Err(err) => Err(err),
8962 }
8963 }
8964
8965 pub async fn run_historical_job_with_http_info(
8967 &self,
8968 body: crate::datadogV2::model::RunHistoricalJobRequest,
8969 ) -> Result<
8970 datadog::ResponseContent<crate::datadogV2::model::JobCreateResponse>,
8971 datadog::Error<RunHistoricalJobError>,
8972 > {
8973 let local_configuration = &self.config;
8974 let operation_id = "v2.run_historical_job";
8975 if local_configuration.is_unstable_operation_enabled(operation_id) {
8976 warn!("Using unstable operation {operation_id}");
8977 } else {
8978 let local_error = datadog::UnstableOperationDisabledError {
8979 msg: "Operation 'v2.run_historical_job' is not enabled".to_string(),
8980 };
8981 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
8982 }
8983
8984 let local_client = &self.client;
8985
8986 let local_uri_str = format!(
8987 "{}/api/v2/siem-historical-detections/jobs",
8988 local_configuration.get_operation_host(operation_id)
8989 );
8990 let mut local_req_builder =
8991 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
8992
8993 let mut headers = HeaderMap::new();
8995 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
8996 headers.insert("Accept", HeaderValue::from_static("application/json"));
8997
8998 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
9000 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
9001 Err(e) => {
9002 log::warn!("Failed to parse user agent header: {e}, falling back to default");
9003 headers.insert(
9004 reqwest::header::USER_AGENT,
9005 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
9006 )
9007 }
9008 };
9009
9010 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
9012 headers.insert(
9013 "DD-API-KEY",
9014 HeaderValue::from_str(local_key.key.as_str())
9015 .expect("failed to parse DD-API-KEY header"),
9016 );
9017 };
9018 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
9019 headers.insert(
9020 "DD-APPLICATION-KEY",
9021 HeaderValue::from_str(local_key.key.as_str())
9022 .expect("failed to parse DD-APPLICATION-KEY header"),
9023 );
9024 };
9025
9026 let output = Vec::new();
9028 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
9029 if body.serialize(&mut ser).is_ok() {
9030 if let Some(content_encoding) = headers.get("Content-Encoding") {
9031 match content_encoding.to_str().unwrap_or_default() {
9032 "gzip" => {
9033 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
9034 let _ = enc.write_all(ser.into_inner().as_slice());
9035 match enc.finish() {
9036 Ok(buf) => {
9037 local_req_builder = local_req_builder.body(buf);
9038 }
9039 Err(e) => return Err(datadog::Error::Io(e)),
9040 }
9041 }
9042 "deflate" => {
9043 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
9044 let _ = enc.write_all(ser.into_inner().as_slice());
9045 match enc.finish() {
9046 Ok(buf) => {
9047 local_req_builder = local_req_builder.body(buf);
9048 }
9049 Err(e) => return Err(datadog::Error::Io(e)),
9050 }
9051 }
9052 "zstd1" => {
9053 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
9054 let _ = enc.write_all(ser.into_inner().as_slice());
9055 match enc.finish() {
9056 Ok(buf) => {
9057 local_req_builder = local_req_builder.body(buf);
9058 }
9059 Err(e) => return Err(datadog::Error::Io(e)),
9060 }
9061 }
9062 _ => {
9063 local_req_builder = local_req_builder.body(ser.into_inner());
9064 }
9065 }
9066 } else {
9067 local_req_builder = local_req_builder.body(ser.into_inner());
9068 }
9069 }
9070
9071 local_req_builder = local_req_builder.headers(headers);
9072 let local_req = local_req_builder.build()?;
9073 log::debug!("request content: {:?}", local_req.body());
9074 let local_resp = local_client.execute(local_req).await?;
9075
9076 let local_status = local_resp.status();
9077 let local_content = local_resp.text().await?;
9078 log::debug!("response content: {}", local_content);
9079
9080 if !local_status.is_client_error() && !local_status.is_server_error() {
9081 match serde_json::from_str::<crate::datadogV2::model::JobCreateResponse>(&local_content)
9082 {
9083 Ok(e) => {
9084 return Ok(datadog::ResponseContent {
9085 status: local_status,
9086 content: local_content,
9087 entity: Some(e),
9088 })
9089 }
9090 Err(e) => return Err(datadog::Error::Serde(e)),
9091 };
9092 } else {
9093 let local_entity: Option<RunHistoricalJobError> =
9094 serde_json::from_str(&local_content).ok();
9095 let local_error = datadog::ResponseContent {
9096 status: local_status,
9097 content: local_content,
9098 entity: local_entity,
9099 };
9100 Err(datadog::Error::ResponseError(local_error))
9101 }
9102 }
9103
9104 pub async fn search_security_monitoring_histsignals(
9106 &self,
9107 params: SearchSecurityMonitoringHistsignalsOptionalParams,
9108 ) -> Result<
9109 crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
9110 datadog::Error<SearchSecurityMonitoringHistsignalsError>,
9111 > {
9112 match self
9113 .search_security_monitoring_histsignals_with_http_info(params)
9114 .await
9115 {
9116 Ok(response_content) => {
9117 if let Some(e) = response_content.entity {
9118 Ok(e)
9119 } else {
9120 Err(datadog::Error::Serde(serde::de::Error::custom(
9121 "response content was None",
9122 )))
9123 }
9124 }
9125 Err(err) => Err(err),
9126 }
9127 }
9128
9129 pub async fn search_security_monitoring_histsignals_with_http_info(
9131 &self,
9132 params: SearchSecurityMonitoringHistsignalsOptionalParams,
9133 ) -> Result<
9134 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSignalsListResponse>,
9135 datadog::Error<SearchSecurityMonitoringHistsignalsError>,
9136 > {
9137 let local_configuration = &self.config;
9138 let operation_id = "v2.search_security_monitoring_histsignals";
9139 if local_configuration.is_unstable_operation_enabled(operation_id) {
9140 warn!("Using unstable operation {operation_id}");
9141 } else {
9142 let local_error = datadog::UnstableOperationDisabledError {
9143 msg: "Operation 'v2.search_security_monitoring_histsignals' is not enabled"
9144 .to_string(),
9145 };
9146 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
9147 }
9148
9149 let body = params.body;
9151
9152 let local_client = &self.client;
9153
9154 let local_uri_str = format!(
9155 "{}/api/v2/siem-historical-detections/histsignals/search",
9156 local_configuration.get_operation_host(operation_id)
9157 );
9158 let mut local_req_builder =
9159 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
9160
9161 let mut headers = HeaderMap::new();
9163 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
9164 headers.insert("Accept", HeaderValue::from_static("application/json"));
9165
9166 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
9168 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
9169 Err(e) => {
9170 log::warn!("Failed to parse user agent header: {e}, falling back to default");
9171 headers.insert(
9172 reqwest::header::USER_AGENT,
9173 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
9174 )
9175 }
9176 };
9177
9178 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
9180 headers.insert(
9181 "DD-API-KEY",
9182 HeaderValue::from_str(local_key.key.as_str())
9183 .expect("failed to parse DD-API-KEY header"),
9184 );
9185 };
9186 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
9187 headers.insert(
9188 "DD-APPLICATION-KEY",
9189 HeaderValue::from_str(local_key.key.as_str())
9190 .expect("failed to parse DD-APPLICATION-KEY header"),
9191 );
9192 };
9193
9194 let output = Vec::new();
9196 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
9197 if body.serialize(&mut ser).is_ok() {
9198 if let Some(content_encoding) = headers.get("Content-Encoding") {
9199 match content_encoding.to_str().unwrap_or_default() {
9200 "gzip" => {
9201 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
9202 let _ = enc.write_all(ser.into_inner().as_slice());
9203 match enc.finish() {
9204 Ok(buf) => {
9205 local_req_builder = local_req_builder.body(buf);
9206 }
9207 Err(e) => return Err(datadog::Error::Io(e)),
9208 }
9209 }
9210 "deflate" => {
9211 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
9212 let _ = enc.write_all(ser.into_inner().as_slice());
9213 match enc.finish() {
9214 Ok(buf) => {
9215 local_req_builder = local_req_builder.body(buf);
9216 }
9217 Err(e) => return Err(datadog::Error::Io(e)),
9218 }
9219 }
9220 "zstd1" => {
9221 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
9222 let _ = enc.write_all(ser.into_inner().as_slice());
9223 match enc.finish() {
9224 Ok(buf) => {
9225 local_req_builder = local_req_builder.body(buf);
9226 }
9227 Err(e) => return Err(datadog::Error::Io(e)),
9228 }
9229 }
9230 _ => {
9231 local_req_builder = local_req_builder.body(ser.into_inner());
9232 }
9233 }
9234 } else {
9235 local_req_builder = local_req_builder.body(ser.into_inner());
9236 }
9237 }
9238
9239 local_req_builder = local_req_builder.headers(headers);
9240 let local_req = local_req_builder.build()?;
9241 log::debug!("request content: {:?}", local_req.body());
9242 let local_resp = local_client.execute(local_req).await?;
9243
9244 let local_status = local_resp.status();
9245 let local_content = local_resp.text().await?;
9246 log::debug!("response content: {}", local_content);
9247
9248 if !local_status.is_client_error() && !local_status.is_server_error() {
9249 match serde_json::from_str::<
9250 crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
9251 >(&local_content)
9252 {
9253 Ok(e) => {
9254 return Ok(datadog::ResponseContent {
9255 status: local_status,
9256 content: local_content,
9257 entity: Some(e),
9258 })
9259 }
9260 Err(e) => return Err(datadog::Error::Serde(e)),
9261 };
9262 } else {
9263 let local_entity: Option<SearchSecurityMonitoringHistsignalsError> =
9264 serde_json::from_str(&local_content).ok();
9265 let local_error = datadog::ResponseContent {
9266 status: local_status,
9267 content: local_content,
9268 entity: local_entity,
9269 };
9270 Err(datadog::Error::ResponseError(local_error))
9271 }
9272 }
9273
9274 pub async fn search_security_monitoring_signals(
9278 &self,
9279 params: SearchSecurityMonitoringSignalsOptionalParams,
9280 ) -> Result<
9281 crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
9282 datadog::Error<SearchSecurityMonitoringSignalsError>,
9283 > {
9284 match self
9285 .search_security_monitoring_signals_with_http_info(params)
9286 .await
9287 {
9288 Ok(response_content) => {
9289 if let Some(e) = response_content.entity {
9290 Ok(e)
9291 } else {
9292 Err(datadog::Error::Serde(serde::de::Error::custom(
9293 "response content was None",
9294 )))
9295 }
9296 }
9297 Err(err) => Err(err),
9298 }
9299 }
9300
9301 pub fn search_security_monitoring_signals_with_pagination(
9302 &self,
9303 mut params: SearchSecurityMonitoringSignalsOptionalParams,
9304 ) -> impl Stream<
9305 Item = Result<
9306 crate::datadogV2::model::SecurityMonitoringSignal,
9307 datadog::Error<SearchSecurityMonitoringSignalsError>,
9308 >,
9309 > + '_ {
9310 try_stream! {
9311 let mut page_size: i32 = 10;
9312 if params.body.is_none() {
9313 params.body = Some(crate::datadogV2::model::SecurityMonitoringSignalListRequest::new());
9314 }
9315 if params.body.as_ref().unwrap().page.is_none() {
9316 params.body.as_mut().unwrap().page = Some(crate::datadogV2::model::SecurityMonitoringSignalListRequestPage::new());
9317 }
9318 if params.body.as_ref().unwrap().page.as_ref().unwrap().limit.is_none() {
9319 params.body.as_mut().unwrap().page.as_mut().unwrap().limit = Some(page_size);
9320 } else {
9321 page_size = params.body.as_ref().unwrap().page.as_ref().unwrap().limit.unwrap().clone();
9322 }
9323 loop {
9324 let resp = self.search_security_monitoring_signals(params.clone()).await?;
9325 let Some(data) = resp.data else { break };
9326
9327 let r = data;
9328 let count = r.len();
9329 for team in r {
9330 yield team;
9331 }
9332
9333 if count < page_size as usize {
9334 break;
9335 }
9336 let Some(meta) = resp.meta else { break };
9337 let Some(page) = meta.page else { break };
9338 let Some(after) = page.after else { break };
9339
9340 params.body.as_mut().unwrap().page.as_mut().unwrap().cursor = Some(after);
9341 }
9342 }
9343 }
9344
9345 pub async fn search_security_monitoring_signals_with_http_info(
9349 &self,
9350 params: SearchSecurityMonitoringSignalsOptionalParams,
9351 ) -> Result<
9352 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSignalsListResponse>,
9353 datadog::Error<SearchSecurityMonitoringSignalsError>,
9354 > {
9355 let local_configuration = &self.config;
9356 let operation_id = "v2.search_security_monitoring_signals";
9357
9358 let body = params.body;
9360
9361 let local_client = &self.client;
9362
9363 let local_uri_str = format!(
9364 "{}/api/v2/security_monitoring/signals/search",
9365 local_configuration.get_operation_host(operation_id)
9366 );
9367 let mut local_req_builder =
9368 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
9369
9370 let mut headers = HeaderMap::new();
9372 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
9373 headers.insert("Accept", HeaderValue::from_static("application/json"));
9374
9375 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
9377 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
9378 Err(e) => {
9379 log::warn!("Failed to parse user agent header: {e}, falling back to default");
9380 headers.insert(
9381 reqwest::header::USER_AGENT,
9382 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
9383 )
9384 }
9385 };
9386
9387 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
9389 headers.insert(
9390 "DD-API-KEY",
9391 HeaderValue::from_str(local_key.key.as_str())
9392 .expect("failed to parse DD-API-KEY header"),
9393 );
9394 };
9395 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
9396 headers.insert(
9397 "DD-APPLICATION-KEY",
9398 HeaderValue::from_str(local_key.key.as_str())
9399 .expect("failed to parse DD-APPLICATION-KEY header"),
9400 );
9401 };
9402
9403 let output = Vec::new();
9405 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
9406 if body.serialize(&mut ser).is_ok() {
9407 if let Some(content_encoding) = headers.get("Content-Encoding") {
9408 match content_encoding.to_str().unwrap_or_default() {
9409 "gzip" => {
9410 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
9411 let _ = enc.write_all(ser.into_inner().as_slice());
9412 match enc.finish() {
9413 Ok(buf) => {
9414 local_req_builder = local_req_builder.body(buf);
9415 }
9416 Err(e) => return Err(datadog::Error::Io(e)),
9417 }
9418 }
9419 "deflate" => {
9420 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
9421 let _ = enc.write_all(ser.into_inner().as_slice());
9422 match enc.finish() {
9423 Ok(buf) => {
9424 local_req_builder = local_req_builder.body(buf);
9425 }
9426 Err(e) => return Err(datadog::Error::Io(e)),
9427 }
9428 }
9429 "zstd1" => {
9430 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
9431 let _ = enc.write_all(ser.into_inner().as_slice());
9432 match enc.finish() {
9433 Ok(buf) => {
9434 local_req_builder = local_req_builder.body(buf);
9435 }
9436 Err(e) => return Err(datadog::Error::Io(e)),
9437 }
9438 }
9439 _ => {
9440 local_req_builder = local_req_builder.body(ser.into_inner());
9441 }
9442 }
9443 } else {
9444 local_req_builder = local_req_builder.body(ser.into_inner());
9445 }
9446 }
9447
9448 local_req_builder = local_req_builder.headers(headers);
9449 let local_req = local_req_builder.build()?;
9450 log::debug!("request content: {:?}", local_req.body());
9451 let local_resp = local_client.execute(local_req).await?;
9452
9453 let local_status = local_resp.status();
9454 let local_content = local_resp.text().await?;
9455 log::debug!("response content: {}", local_content);
9456
9457 if !local_status.is_client_error() && !local_status.is_server_error() {
9458 match serde_json::from_str::<
9459 crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
9460 >(&local_content)
9461 {
9462 Ok(e) => {
9463 return Ok(datadog::ResponseContent {
9464 status: local_status,
9465 content: local_content,
9466 entity: Some(e),
9467 })
9468 }
9469 Err(e) => return Err(datadog::Error::Serde(e)),
9470 };
9471 } else {
9472 let local_entity: Option<SearchSecurityMonitoringSignalsError> =
9473 serde_json::from_str(&local_content).ok();
9474 let local_error = datadog::ResponseContent {
9475 status: local_status,
9476 content: local_content,
9477 entity: local_entity,
9478 };
9479 Err(datadog::Error::ResponseError(local_error))
9480 }
9481 }
9482
9483 pub async fn test_existing_security_monitoring_rule(
9485 &self,
9486 rule_id: String,
9487 body: crate::datadogV2::model::SecurityMonitoringRuleTestRequest,
9488 ) -> Result<
9489 crate::datadogV2::model::SecurityMonitoringRuleTestResponse,
9490 datadog::Error<TestExistingSecurityMonitoringRuleError>,
9491 > {
9492 match self
9493 .test_existing_security_monitoring_rule_with_http_info(rule_id, body)
9494 .await
9495 {
9496 Ok(response_content) => {
9497 if let Some(e) = response_content.entity {
9498 Ok(e)
9499 } else {
9500 Err(datadog::Error::Serde(serde::de::Error::custom(
9501 "response content was None",
9502 )))
9503 }
9504 }
9505 Err(err) => Err(err),
9506 }
9507 }
9508
9509 pub async fn test_existing_security_monitoring_rule_with_http_info(
9511 &self,
9512 rule_id: String,
9513 body: crate::datadogV2::model::SecurityMonitoringRuleTestRequest,
9514 ) -> Result<
9515 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleTestResponse>,
9516 datadog::Error<TestExistingSecurityMonitoringRuleError>,
9517 > {
9518 let local_configuration = &self.config;
9519 let operation_id = "v2.test_existing_security_monitoring_rule";
9520
9521 let local_client = &self.client;
9522
9523 let local_uri_str = format!(
9524 "{}/api/v2/security_monitoring/rules/{rule_id}/test",
9525 local_configuration.get_operation_host(operation_id),
9526 rule_id = datadog::urlencode(rule_id)
9527 );
9528 let mut local_req_builder =
9529 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
9530
9531 let mut headers = HeaderMap::new();
9533 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
9534 headers.insert("Accept", HeaderValue::from_static("application/json"));
9535
9536 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
9538 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
9539 Err(e) => {
9540 log::warn!("Failed to parse user agent header: {e}, falling back to default");
9541 headers.insert(
9542 reqwest::header::USER_AGENT,
9543 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
9544 )
9545 }
9546 };
9547
9548 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
9550 headers.insert(
9551 "DD-API-KEY",
9552 HeaderValue::from_str(local_key.key.as_str())
9553 .expect("failed to parse DD-API-KEY header"),
9554 );
9555 };
9556 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
9557 headers.insert(
9558 "DD-APPLICATION-KEY",
9559 HeaderValue::from_str(local_key.key.as_str())
9560 .expect("failed to parse DD-APPLICATION-KEY header"),
9561 );
9562 };
9563
9564 let output = Vec::new();
9566 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
9567 if body.serialize(&mut ser).is_ok() {
9568 if let Some(content_encoding) = headers.get("Content-Encoding") {
9569 match content_encoding.to_str().unwrap_or_default() {
9570 "gzip" => {
9571 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
9572 let _ = enc.write_all(ser.into_inner().as_slice());
9573 match enc.finish() {
9574 Ok(buf) => {
9575 local_req_builder = local_req_builder.body(buf);
9576 }
9577 Err(e) => return Err(datadog::Error::Io(e)),
9578 }
9579 }
9580 "deflate" => {
9581 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
9582 let _ = enc.write_all(ser.into_inner().as_slice());
9583 match enc.finish() {
9584 Ok(buf) => {
9585 local_req_builder = local_req_builder.body(buf);
9586 }
9587 Err(e) => return Err(datadog::Error::Io(e)),
9588 }
9589 }
9590 "zstd1" => {
9591 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
9592 let _ = enc.write_all(ser.into_inner().as_slice());
9593 match enc.finish() {
9594 Ok(buf) => {
9595 local_req_builder = local_req_builder.body(buf);
9596 }
9597 Err(e) => return Err(datadog::Error::Io(e)),
9598 }
9599 }
9600 _ => {
9601 local_req_builder = local_req_builder.body(ser.into_inner());
9602 }
9603 }
9604 } else {
9605 local_req_builder = local_req_builder.body(ser.into_inner());
9606 }
9607 }
9608
9609 local_req_builder = local_req_builder.headers(headers);
9610 let local_req = local_req_builder.build()?;
9611 log::debug!("request content: {:?}", local_req.body());
9612 let local_resp = local_client.execute(local_req).await?;
9613
9614 let local_status = local_resp.status();
9615 let local_content = local_resp.text().await?;
9616 log::debug!("response content: {}", local_content);
9617
9618 if !local_status.is_client_error() && !local_status.is_server_error() {
9619 match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringRuleTestResponse>(
9620 &local_content,
9621 ) {
9622 Ok(e) => {
9623 return Ok(datadog::ResponseContent {
9624 status: local_status,
9625 content: local_content,
9626 entity: Some(e),
9627 })
9628 }
9629 Err(e) => return Err(datadog::Error::Serde(e)),
9630 };
9631 } else {
9632 let local_entity: Option<TestExistingSecurityMonitoringRuleError> =
9633 serde_json::from_str(&local_content).ok();
9634 let local_error = datadog::ResponseContent {
9635 status: local_status,
9636 content: local_content,
9637 entity: local_entity,
9638 };
9639 Err(datadog::Error::ResponseError(local_error))
9640 }
9641 }
9642
9643 pub async fn test_security_monitoring_rule(
9645 &self,
9646 body: crate::datadogV2::model::SecurityMonitoringRuleTestRequest,
9647 ) -> Result<
9648 crate::datadogV2::model::SecurityMonitoringRuleTestResponse,
9649 datadog::Error<TestSecurityMonitoringRuleError>,
9650 > {
9651 match self
9652 .test_security_monitoring_rule_with_http_info(body)
9653 .await
9654 {
9655 Ok(response_content) => {
9656 if let Some(e) = response_content.entity {
9657 Ok(e)
9658 } else {
9659 Err(datadog::Error::Serde(serde::de::Error::custom(
9660 "response content was None",
9661 )))
9662 }
9663 }
9664 Err(err) => Err(err),
9665 }
9666 }
9667
9668 pub async fn test_security_monitoring_rule_with_http_info(
9670 &self,
9671 body: crate::datadogV2::model::SecurityMonitoringRuleTestRequest,
9672 ) -> Result<
9673 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleTestResponse>,
9674 datadog::Error<TestSecurityMonitoringRuleError>,
9675 > {
9676 let local_configuration = &self.config;
9677 let operation_id = "v2.test_security_monitoring_rule";
9678
9679 let local_client = &self.client;
9680
9681 let local_uri_str = format!(
9682 "{}/api/v2/security_monitoring/rules/test",
9683 local_configuration.get_operation_host(operation_id)
9684 );
9685 let mut local_req_builder =
9686 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
9687
9688 let mut headers = HeaderMap::new();
9690 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
9691 headers.insert("Accept", HeaderValue::from_static("application/json"));
9692
9693 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
9695 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
9696 Err(e) => {
9697 log::warn!("Failed to parse user agent header: {e}, falling back to default");
9698 headers.insert(
9699 reqwest::header::USER_AGENT,
9700 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
9701 )
9702 }
9703 };
9704
9705 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
9707 headers.insert(
9708 "DD-API-KEY",
9709 HeaderValue::from_str(local_key.key.as_str())
9710 .expect("failed to parse DD-API-KEY header"),
9711 );
9712 };
9713 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
9714 headers.insert(
9715 "DD-APPLICATION-KEY",
9716 HeaderValue::from_str(local_key.key.as_str())
9717 .expect("failed to parse DD-APPLICATION-KEY header"),
9718 );
9719 };
9720
9721 let output = Vec::new();
9723 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
9724 if body.serialize(&mut ser).is_ok() {
9725 if let Some(content_encoding) = headers.get("Content-Encoding") {
9726 match content_encoding.to_str().unwrap_or_default() {
9727 "gzip" => {
9728 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
9729 let _ = enc.write_all(ser.into_inner().as_slice());
9730 match enc.finish() {
9731 Ok(buf) => {
9732 local_req_builder = local_req_builder.body(buf);
9733 }
9734 Err(e) => return Err(datadog::Error::Io(e)),
9735 }
9736 }
9737 "deflate" => {
9738 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
9739 let _ = enc.write_all(ser.into_inner().as_slice());
9740 match enc.finish() {
9741 Ok(buf) => {
9742 local_req_builder = local_req_builder.body(buf);
9743 }
9744 Err(e) => return Err(datadog::Error::Io(e)),
9745 }
9746 }
9747 "zstd1" => {
9748 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
9749 let _ = enc.write_all(ser.into_inner().as_slice());
9750 match enc.finish() {
9751 Ok(buf) => {
9752 local_req_builder = local_req_builder.body(buf);
9753 }
9754 Err(e) => return Err(datadog::Error::Io(e)),
9755 }
9756 }
9757 _ => {
9758 local_req_builder = local_req_builder.body(ser.into_inner());
9759 }
9760 }
9761 } else {
9762 local_req_builder = local_req_builder.body(ser.into_inner());
9763 }
9764 }
9765
9766 local_req_builder = local_req_builder.headers(headers);
9767 let local_req = local_req_builder.build()?;
9768 log::debug!("request content: {:?}", local_req.body());
9769 let local_resp = local_client.execute(local_req).await?;
9770
9771 let local_status = local_resp.status();
9772 let local_content = local_resp.text().await?;
9773 log::debug!("response content: {}", local_content);
9774
9775 if !local_status.is_client_error() && !local_status.is_server_error() {
9776 match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringRuleTestResponse>(
9777 &local_content,
9778 ) {
9779 Ok(e) => {
9780 return Ok(datadog::ResponseContent {
9781 status: local_status,
9782 content: local_content,
9783 entity: Some(e),
9784 })
9785 }
9786 Err(e) => return Err(datadog::Error::Serde(e)),
9787 };
9788 } else {
9789 let local_entity: Option<TestSecurityMonitoringRuleError> =
9790 serde_json::from_str(&local_content).ok();
9791 let local_error = datadog::ResponseContent {
9792 status: local_status,
9793 content: local_content,
9794 entity: local_entity,
9795 };
9796 Err(datadog::Error::ResponseError(local_error))
9797 }
9798 }
9799
9800 pub async fn update_custom_framework(
9802 &self,
9803 handle: String,
9804 version: String,
9805 body: crate::datadogV2::model::UpdateCustomFrameworkRequest,
9806 ) -> Result<
9807 crate::datadogV2::model::UpdateCustomFrameworkResponse,
9808 datadog::Error<UpdateCustomFrameworkError>,
9809 > {
9810 match self
9811 .update_custom_framework_with_http_info(handle, version, body)
9812 .await
9813 {
9814 Ok(response_content) => {
9815 if let Some(e) = response_content.entity {
9816 Ok(e)
9817 } else {
9818 Err(datadog::Error::Serde(serde::de::Error::custom(
9819 "response content was None",
9820 )))
9821 }
9822 }
9823 Err(err) => Err(err),
9824 }
9825 }
9826
9827 pub async fn update_custom_framework_with_http_info(
9829 &self,
9830 handle: String,
9831 version: String,
9832 body: crate::datadogV2::model::UpdateCustomFrameworkRequest,
9833 ) -> Result<
9834 datadog::ResponseContent<crate::datadogV2::model::UpdateCustomFrameworkResponse>,
9835 datadog::Error<UpdateCustomFrameworkError>,
9836 > {
9837 let local_configuration = &self.config;
9838 let operation_id = "v2.update_custom_framework";
9839
9840 let local_client = &self.client;
9841
9842 let local_uri_str = format!(
9843 "{}/api/v2/cloud_security_management/custom_frameworks/{handle}/{version}",
9844 local_configuration.get_operation_host(operation_id),
9845 handle = datadog::urlencode(handle),
9846 version = datadog::urlencode(version)
9847 );
9848 let mut local_req_builder =
9849 local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
9850
9851 let mut headers = HeaderMap::new();
9853 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
9854 headers.insert("Accept", HeaderValue::from_static("application/json"));
9855
9856 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
9858 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
9859 Err(e) => {
9860 log::warn!("Failed to parse user agent header: {e}, falling back to default");
9861 headers.insert(
9862 reqwest::header::USER_AGENT,
9863 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
9864 )
9865 }
9866 };
9867
9868 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
9870 headers.insert(
9871 "DD-API-KEY",
9872 HeaderValue::from_str(local_key.key.as_str())
9873 .expect("failed to parse DD-API-KEY header"),
9874 );
9875 };
9876 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
9877 headers.insert(
9878 "DD-APPLICATION-KEY",
9879 HeaderValue::from_str(local_key.key.as_str())
9880 .expect("failed to parse DD-APPLICATION-KEY header"),
9881 );
9882 };
9883
9884 let output = Vec::new();
9886 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
9887 if body.serialize(&mut ser).is_ok() {
9888 if let Some(content_encoding) = headers.get("Content-Encoding") {
9889 match content_encoding.to_str().unwrap_or_default() {
9890 "gzip" => {
9891 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
9892 let _ = enc.write_all(ser.into_inner().as_slice());
9893 match enc.finish() {
9894 Ok(buf) => {
9895 local_req_builder = local_req_builder.body(buf);
9896 }
9897 Err(e) => return Err(datadog::Error::Io(e)),
9898 }
9899 }
9900 "deflate" => {
9901 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
9902 let _ = enc.write_all(ser.into_inner().as_slice());
9903 match enc.finish() {
9904 Ok(buf) => {
9905 local_req_builder = local_req_builder.body(buf);
9906 }
9907 Err(e) => return Err(datadog::Error::Io(e)),
9908 }
9909 }
9910 "zstd1" => {
9911 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
9912 let _ = enc.write_all(ser.into_inner().as_slice());
9913 match enc.finish() {
9914 Ok(buf) => {
9915 local_req_builder = local_req_builder.body(buf);
9916 }
9917 Err(e) => return Err(datadog::Error::Io(e)),
9918 }
9919 }
9920 _ => {
9921 local_req_builder = local_req_builder.body(ser.into_inner());
9922 }
9923 }
9924 } else {
9925 local_req_builder = local_req_builder.body(ser.into_inner());
9926 }
9927 }
9928
9929 local_req_builder = local_req_builder.headers(headers);
9930 let local_req = local_req_builder.build()?;
9931 log::debug!("request content: {:?}", local_req.body());
9932 let local_resp = local_client.execute(local_req).await?;
9933
9934 let local_status = local_resp.status();
9935 let local_content = local_resp.text().await?;
9936 log::debug!("response content: {}", local_content);
9937
9938 if !local_status.is_client_error() && !local_status.is_server_error() {
9939 match serde_json::from_str::<crate::datadogV2::model::UpdateCustomFrameworkResponse>(
9940 &local_content,
9941 ) {
9942 Ok(e) => {
9943 return Ok(datadog::ResponseContent {
9944 status: local_status,
9945 content: local_content,
9946 entity: Some(e),
9947 })
9948 }
9949 Err(e) => return Err(datadog::Error::Serde(e)),
9950 };
9951 } else {
9952 let local_entity: Option<UpdateCustomFrameworkError> =
9953 serde_json::from_str(&local_content).ok();
9954 let local_error = datadog::ResponseContent {
9955 status: local_status,
9956 content: local_content,
9957 entity: local_entity,
9958 };
9959 Err(datadog::Error::ResponseError(local_error))
9960 }
9961 }
9962
9963 pub async fn update_resource_evaluation_filters(
9965 &self,
9966 body: crate::datadogV2::model::UpdateResourceEvaluationFiltersRequest,
9967 ) -> Result<
9968 crate::datadogV2::model::UpdateResourceEvaluationFiltersResponse,
9969 datadog::Error<UpdateResourceEvaluationFiltersError>,
9970 > {
9971 match self
9972 .update_resource_evaluation_filters_with_http_info(body)
9973 .await
9974 {
9975 Ok(response_content) => {
9976 if let Some(e) = response_content.entity {
9977 Ok(e)
9978 } else {
9979 Err(datadog::Error::Serde(serde::de::Error::custom(
9980 "response content was None",
9981 )))
9982 }
9983 }
9984 Err(err) => Err(err),
9985 }
9986 }
9987
9988 pub async fn update_resource_evaluation_filters_with_http_info(
9990 &self,
9991 body: crate::datadogV2::model::UpdateResourceEvaluationFiltersRequest,
9992 ) -> Result<
9993 datadog::ResponseContent<crate::datadogV2::model::UpdateResourceEvaluationFiltersResponse>,
9994 datadog::Error<UpdateResourceEvaluationFiltersError>,
9995 > {
9996 let local_configuration = &self.config;
9997 let operation_id = "v2.update_resource_evaluation_filters";
9998
9999 let local_client = &self.client;
10000
10001 let local_uri_str = format!(
10002 "{}/api/v2/cloud_security_management/resource_filters",
10003 local_configuration.get_operation_host(operation_id)
10004 );
10005 let mut local_req_builder =
10006 local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
10007
10008 let mut headers = HeaderMap::new();
10010 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
10011 headers.insert("Accept", HeaderValue::from_static("application/json"));
10012
10013 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
10015 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
10016 Err(e) => {
10017 log::warn!("Failed to parse user agent header: {e}, falling back to default");
10018 headers.insert(
10019 reqwest::header::USER_AGENT,
10020 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
10021 )
10022 }
10023 };
10024
10025 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
10027 headers.insert(
10028 "DD-API-KEY",
10029 HeaderValue::from_str(local_key.key.as_str())
10030 .expect("failed to parse DD-API-KEY header"),
10031 );
10032 };
10033 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
10034 headers.insert(
10035 "DD-APPLICATION-KEY",
10036 HeaderValue::from_str(local_key.key.as_str())
10037 .expect("failed to parse DD-APPLICATION-KEY header"),
10038 );
10039 };
10040
10041 let output = Vec::new();
10043 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
10044 if body.serialize(&mut ser).is_ok() {
10045 if let Some(content_encoding) = headers.get("Content-Encoding") {
10046 match content_encoding.to_str().unwrap_or_default() {
10047 "gzip" => {
10048 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
10049 let _ = enc.write_all(ser.into_inner().as_slice());
10050 match enc.finish() {
10051 Ok(buf) => {
10052 local_req_builder = local_req_builder.body(buf);
10053 }
10054 Err(e) => return Err(datadog::Error::Io(e)),
10055 }
10056 }
10057 "deflate" => {
10058 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
10059 let _ = enc.write_all(ser.into_inner().as_slice());
10060 match enc.finish() {
10061 Ok(buf) => {
10062 local_req_builder = local_req_builder.body(buf);
10063 }
10064 Err(e) => return Err(datadog::Error::Io(e)),
10065 }
10066 }
10067 "zstd1" => {
10068 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
10069 let _ = enc.write_all(ser.into_inner().as_slice());
10070 match enc.finish() {
10071 Ok(buf) => {
10072 local_req_builder = local_req_builder.body(buf);
10073 }
10074 Err(e) => return Err(datadog::Error::Io(e)),
10075 }
10076 }
10077 _ => {
10078 local_req_builder = local_req_builder.body(ser.into_inner());
10079 }
10080 }
10081 } else {
10082 local_req_builder = local_req_builder.body(ser.into_inner());
10083 }
10084 }
10085
10086 local_req_builder = local_req_builder.headers(headers);
10087 let local_req = local_req_builder.build()?;
10088 log::debug!("request content: {:?}", local_req.body());
10089 let local_resp = local_client.execute(local_req).await?;
10090
10091 let local_status = local_resp.status();
10092 let local_content = local_resp.text().await?;
10093 log::debug!("response content: {}", local_content);
10094
10095 if !local_status.is_client_error() && !local_status.is_server_error() {
10096 match serde_json::from_str::<
10097 crate::datadogV2::model::UpdateResourceEvaluationFiltersResponse,
10098 >(&local_content)
10099 {
10100 Ok(e) => {
10101 return Ok(datadog::ResponseContent {
10102 status: local_status,
10103 content: local_content,
10104 entity: Some(e),
10105 })
10106 }
10107 Err(e) => return Err(datadog::Error::Serde(e)),
10108 };
10109 } else {
10110 let local_entity: Option<UpdateResourceEvaluationFiltersError> =
10111 serde_json::from_str(&local_content).ok();
10112 let local_error = datadog::ResponseContent {
10113 status: local_status,
10114 content: local_content,
10115 entity: local_entity,
10116 };
10117 Err(datadog::Error::ResponseError(local_error))
10118 }
10119 }
10120
10121 pub async fn update_security_filter(
10124 &self,
10125 security_filter_id: String,
10126 body: crate::datadogV2::model::SecurityFilterUpdateRequest,
10127 ) -> Result<
10128 crate::datadogV2::model::SecurityFilterResponse,
10129 datadog::Error<UpdateSecurityFilterError>,
10130 > {
10131 match self
10132 .update_security_filter_with_http_info(security_filter_id, body)
10133 .await
10134 {
10135 Ok(response_content) => {
10136 if let Some(e) = response_content.entity {
10137 Ok(e)
10138 } else {
10139 Err(datadog::Error::Serde(serde::de::Error::custom(
10140 "response content was None",
10141 )))
10142 }
10143 }
10144 Err(err) => Err(err),
10145 }
10146 }
10147
10148 pub async fn update_security_filter_with_http_info(
10151 &self,
10152 security_filter_id: String,
10153 body: crate::datadogV2::model::SecurityFilterUpdateRequest,
10154 ) -> Result<
10155 datadog::ResponseContent<crate::datadogV2::model::SecurityFilterResponse>,
10156 datadog::Error<UpdateSecurityFilterError>,
10157 > {
10158 let local_configuration = &self.config;
10159 let operation_id = "v2.update_security_filter";
10160
10161 let local_client = &self.client;
10162
10163 let local_uri_str = format!(
10164 "{}/api/v2/security_monitoring/configuration/security_filters/{security_filter_id}",
10165 local_configuration.get_operation_host(operation_id),
10166 security_filter_id = datadog::urlencode(security_filter_id)
10167 );
10168 let mut local_req_builder =
10169 local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
10170
10171 let mut headers = HeaderMap::new();
10173 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
10174 headers.insert("Accept", HeaderValue::from_static("application/json"));
10175
10176 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
10178 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
10179 Err(e) => {
10180 log::warn!("Failed to parse user agent header: {e}, falling back to default");
10181 headers.insert(
10182 reqwest::header::USER_AGENT,
10183 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
10184 )
10185 }
10186 };
10187
10188 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
10190 headers.insert(
10191 "DD-API-KEY",
10192 HeaderValue::from_str(local_key.key.as_str())
10193 .expect("failed to parse DD-API-KEY header"),
10194 );
10195 };
10196 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
10197 headers.insert(
10198 "DD-APPLICATION-KEY",
10199 HeaderValue::from_str(local_key.key.as_str())
10200 .expect("failed to parse DD-APPLICATION-KEY header"),
10201 );
10202 };
10203
10204 let output = Vec::new();
10206 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
10207 if body.serialize(&mut ser).is_ok() {
10208 if let Some(content_encoding) = headers.get("Content-Encoding") {
10209 match content_encoding.to_str().unwrap_or_default() {
10210 "gzip" => {
10211 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
10212 let _ = enc.write_all(ser.into_inner().as_slice());
10213 match enc.finish() {
10214 Ok(buf) => {
10215 local_req_builder = local_req_builder.body(buf);
10216 }
10217 Err(e) => return Err(datadog::Error::Io(e)),
10218 }
10219 }
10220 "deflate" => {
10221 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
10222 let _ = enc.write_all(ser.into_inner().as_slice());
10223 match enc.finish() {
10224 Ok(buf) => {
10225 local_req_builder = local_req_builder.body(buf);
10226 }
10227 Err(e) => return Err(datadog::Error::Io(e)),
10228 }
10229 }
10230 "zstd1" => {
10231 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
10232 let _ = enc.write_all(ser.into_inner().as_slice());
10233 match enc.finish() {
10234 Ok(buf) => {
10235 local_req_builder = local_req_builder.body(buf);
10236 }
10237 Err(e) => return Err(datadog::Error::Io(e)),
10238 }
10239 }
10240 _ => {
10241 local_req_builder = local_req_builder.body(ser.into_inner());
10242 }
10243 }
10244 } else {
10245 local_req_builder = local_req_builder.body(ser.into_inner());
10246 }
10247 }
10248
10249 local_req_builder = local_req_builder.headers(headers);
10250 let local_req = local_req_builder.build()?;
10251 log::debug!("request content: {:?}", local_req.body());
10252 let local_resp = local_client.execute(local_req).await?;
10253
10254 let local_status = local_resp.status();
10255 let local_content = local_resp.text().await?;
10256 log::debug!("response content: {}", local_content);
10257
10258 if !local_status.is_client_error() && !local_status.is_server_error() {
10259 match serde_json::from_str::<crate::datadogV2::model::SecurityFilterResponse>(
10260 &local_content,
10261 ) {
10262 Ok(e) => {
10263 return Ok(datadog::ResponseContent {
10264 status: local_status,
10265 content: local_content,
10266 entity: Some(e),
10267 })
10268 }
10269 Err(e) => return Err(datadog::Error::Serde(e)),
10270 };
10271 } else {
10272 let local_entity: Option<UpdateSecurityFilterError> =
10273 serde_json::from_str(&local_content).ok();
10274 let local_error = datadog::ResponseContent {
10275 status: local_status,
10276 content: local_content,
10277 entity: local_entity,
10278 };
10279 Err(datadog::Error::ResponseError(local_error))
10280 }
10281 }
10282
10283 pub async fn update_security_monitoring_rule(
10288 &self,
10289 rule_id: String,
10290 body: crate::datadogV2::model::SecurityMonitoringRuleUpdatePayload,
10291 ) -> Result<
10292 crate::datadogV2::model::SecurityMonitoringRuleResponse,
10293 datadog::Error<UpdateSecurityMonitoringRuleError>,
10294 > {
10295 match self
10296 .update_security_monitoring_rule_with_http_info(rule_id, body)
10297 .await
10298 {
10299 Ok(response_content) => {
10300 if let Some(e) = response_content.entity {
10301 Ok(e)
10302 } else {
10303 Err(datadog::Error::Serde(serde::de::Error::custom(
10304 "response content was None",
10305 )))
10306 }
10307 }
10308 Err(err) => Err(err),
10309 }
10310 }
10311
10312 pub async fn update_security_monitoring_rule_with_http_info(
10317 &self,
10318 rule_id: String,
10319 body: crate::datadogV2::model::SecurityMonitoringRuleUpdatePayload,
10320 ) -> Result<
10321 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleResponse>,
10322 datadog::Error<UpdateSecurityMonitoringRuleError>,
10323 > {
10324 let local_configuration = &self.config;
10325 let operation_id = "v2.update_security_monitoring_rule";
10326
10327 let local_client = &self.client;
10328
10329 let local_uri_str = format!(
10330 "{}/api/v2/security_monitoring/rules/{rule_id}",
10331 local_configuration.get_operation_host(operation_id),
10332 rule_id = datadog::urlencode(rule_id)
10333 );
10334 let mut local_req_builder =
10335 local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
10336
10337 let mut headers = HeaderMap::new();
10339 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
10340 headers.insert("Accept", HeaderValue::from_static("application/json"));
10341
10342 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
10344 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
10345 Err(e) => {
10346 log::warn!("Failed to parse user agent header: {e}, falling back to default");
10347 headers.insert(
10348 reqwest::header::USER_AGENT,
10349 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
10350 )
10351 }
10352 };
10353
10354 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
10356 headers.insert(
10357 "DD-API-KEY",
10358 HeaderValue::from_str(local_key.key.as_str())
10359 .expect("failed to parse DD-API-KEY header"),
10360 );
10361 };
10362 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
10363 headers.insert(
10364 "DD-APPLICATION-KEY",
10365 HeaderValue::from_str(local_key.key.as_str())
10366 .expect("failed to parse DD-APPLICATION-KEY header"),
10367 );
10368 };
10369
10370 let output = Vec::new();
10372 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
10373 if body.serialize(&mut ser).is_ok() {
10374 if let Some(content_encoding) = headers.get("Content-Encoding") {
10375 match content_encoding.to_str().unwrap_or_default() {
10376 "gzip" => {
10377 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
10378 let _ = enc.write_all(ser.into_inner().as_slice());
10379 match enc.finish() {
10380 Ok(buf) => {
10381 local_req_builder = local_req_builder.body(buf);
10382 }
10383 Err(e) => return Err(datadog::Error::Io(e)),
10384 }
10385 }
10386 "deflate" => {
10387 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
10388 let _ = enc.write_all(ser.into_inner().as_slice());
10389 match enc.finish() {
10390 Ok(buf) => {
10391 local_req_builder = local_req_builder.body(buf);
10392 }
10393 Err(e) => return Err(datadog::Error::Io(e)),
10394 }
10395 }
10396 "zstd1" => {
10397 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
10398 let _ = enc.write_all(ser.into_inner().as_slice());
10399 match enc.finish() {
10400 Ok(buf) => {
10401 local_req_builder = local_req_builder.body(buf);
10402 }
10403 Err(e) => return Err(datadog::Error::Io(e)),
10404 }
10405 }
10406 _ => {
10407 local_req_builder = local_req_builder.body(ser.into_inner());
10408 }
10409 }
10410 } else {
10411 local_req_builder = local_req_builder.body(ser.into_inner());
10412 }
10413 }
10414
10415 local_req_builder = local_req_builder.headers(headers);
10416 let local_req = local_req_builder.build()?;
10417 log::debug!("request content: {:?}", local_req.body());
10418 let local_resp = local_client.execute(local_req).await?;
10419
10420 let local_status = local_resp.status();
10421 let local_content = local_resp.text().await?;
10422 log::debug!("response content: {}", local_content);
10423
10424 if !local_status.is_client_error() && !local_status.is_server_error() {
10425 match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringRuleResponse>(
10426 &local_content,
10427 ) {
10428 Ok(e) => {
10429 return Ok(datadog::ResponseContent {
10430 status: local_status,
10431 content: local_content,
10432 entity: Some(e),
10433 })
10434 }
10435 Err(e) => return Err(datadog::Error::Serde(e)),
10436 };
10437 } else {
10438 let local_entity: Option<UpdateSecurityMonitoringRuleError> =
10439 serde_json::from_str(&local_content).ok();
10440 let local_error = datadog::ResponseContent {
10441 status: local_status,
10442 content: local_content,
10443 entity: local_entity,
10444 };
10445 Err(datadog::Error::ResponseError(local_error))
10446 }
10447 }
10448
10449 pub async fn update_security_monitoring_suppression(
10451 &self,
10452 suppression_id: String,
10453 body: crate::datadogV2::model::SecurityMonitoringSuppressionUpdateRequest,
10454 ) -> Result<
10455 crate::datadogV2::model::SecurityMonitoringSuppressionResponse,
10456 datadog::Error<UpdateSecurityMonitoringSuppressionError>,
10457 > {
10458 match self
10459 .update_security_monitoring_suppression_with_http_info(suppression_id, body)
10460 .await
10461 {
10462 Ok(response_content) => {
10463 if let Some(e) = response_content.entity {
10464 Ok(e)
10465 } else {
10466 Err(datadog::Error::Serde(serde::de::Error::custom(
10467 "response content was None",
10468 )))
10469 }
10470 }
10471 Err(err) => Err(err),
10472 }
10473 }
10474
10475 pub async fn update_security_monitoring_suppression_with_http_info(
10477 &self,
10478 suppression_id: String,
10479 body: crate::datadogV2::model::SecurityMonitoringSuppressionUpdateRequest,
10480 ) -> Result<
10481 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSuppressionResponse>,
10482 datadog::Error<UpdateSecurityMonitoringSuppressionError>,
10483 > {
10484 let local_configuration = &self.config;
10485 let operation_id = "v2.update_security_monitoring_suppression";
10486
10487 let local_client = &self.client;
10488
10489 let local_uri_str = format!(
10490 "{}/api/v2/security_monitoring/configuration/suppressions/{suppression_id}",
10491 local_configuration.get_operation_host(operation_id),
10492 suppression_id = datadog::urlencode(suppression_id)
10493 );
10494 let mut local_req_builder =
10495 local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
10496
10497 let mut headers = HeaderMap::new();
10499 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
10500 headers.insert("Accept", HeaderValue::from_static("application/json"));
10501
10502 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
10504 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
10505 Err(e) => {
10506 log::warn!("Failed to parse user agent header: {e}, falling back to default");
10507 headers.insert(
10508 reqwest::header::USER_AGENT,
10509 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
10510 )
10511 }
10512 };
10513
10514 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
10516 headers.insert(
10517 "DD-API-KEY",
10518 HeaderValue::from_str(local_key.key.as_str())
10519 .expect("failed to parse DD-API-KEY header"),
10520 );
10521 };
10522 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
10523 headers.insert(
10524 "DD-APPLICATION-KEY",
10525 HeaderValue::from_str(local_key.key.as_str())
10526 .expect("failed to parse DD-APPLICATION-KEY header"),
10527 );
10528 };
10529
10530 let output = Vec::new();
10532 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
10533 if body.serialize(&mut ser).is_ok() {
10534 if let Some(content_encoding) = headers.get("Content-Encoding") {
10535 match content_encoding.to_str().unwrap_or_default() {
10536 "gzip" => {
10537 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
10538 let _ = enc.write_all(ser.into_inner().as_slice());
10539 match enc.finish() {
10540 Ok(buf) => {
10541 local_req_builder = local_req_builder.body(buf);
10542 }
10543 Err(e) => return Err(datadog::Error::Io(e)),
10544 }
10545 }
10546 "deflate" => {
10547 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
10548 let _ = enc.write_all(ser.into_inner().as_slice());
10549 match enc.finish() {
10550 Ok(buf) => {
10551 local_req_builder = local_req_builder.body(buf);
10552 }
10553 Err(e) => return Err(datadog::Error::Io(e)),
10554 }
10555 }
10556 "zstd1" => {
10557 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
10558 let _ = enc.write_all(ser.into_inner().as_slice());
10559 match enc.finish() {
10560 Ok(buf) => {
10561 local_req_builder = local_req_builder.body(buf);
10562 }
10563 Err(e) => return Err(datadog::Error::Io(e)),
10564 }
10565 }
10566 _ => {
10567 local_req_builder = local_req_builder.body(ser.into_inner());
10568 }
10569 }
10570 } else {
10571 local_req_builder = local_req_builder.body(ser.into_inner());
10572 }
10573 }
10574
10575 local_req_builder = local_req_builder.headers(headers);
10576 let local_req = local_req_builder.build()?;
10577 log::debug!("request content: {:?}", local_req.body());
10578 let local_resp = local_client.execute(local_req).await?;
10579
10580 let local_status = local_resp.status();
10581 let local_content = local_resp.text().await?;
10582 log::debug!("response content: {}", local_content);
10583
10584 if !local_status.is_client_error() && !local_status.is_server_error() {
10585 match serde_json::from_str::<
10586 crate::datadogV2::model::SecurityMonitoringSuppressionResponse,
10587 >(&local_content)
10588 {
10589 Ok(e) => {
10590 return Ok(datadog::ResponseContent {
10591 status: local_status,
10592 content: local_content,
10593 entity: Some(e),
10594 })
10595 }
10596 Err(e) => return Err(datadog::Error::Serde(e)),
10597 };
10598 } else {
10599 let local_entity: Option<UpdateSecurityMonitoringSuppressionError> =
10600 serde_json::from_str(&local_content).ok();
10601 let local_error = datadog::ResponseContent {
10602 status: local_status,
10603 content: local_content,
10604 entity: local_entity,
10605 };
10606 Err(datadog::Error::ResponseError(local_error))
10607 }
10608 }
10609
10610 pub async fn validate_security_monitoring_rule(
10612 &self,
10613 body: crate::datadogV2::model::SecurityMonitoringRuleValidatePayload,
10614 ) -> Result<(), datadog::Error<ValidateSecurityMonitoringRuleError>> {
10615 match self
10616 .validate_security_monitoring_rule_with_http_info(body)
10617 .await
10618 {
10619 Ok(_) => Ok(()),
10620 Err(err) => Err(err),
10621 }
10622 }
10623
10624 pub async fn validate_security_monitoring_rule_with_http_info(
10626 &self,
10627 body: crate::datadogV2::model::SecurityMonitoringRuleValidatePayload,
10628 ) -> Result<datadog::ResponseContent<()>, datadog::Error<ValidateSecurityMonitoringRuleError>>
10629 {
10630 let local_configuration = &self.config;
10631 let operation_id = "v2.validate_security_monitoring_rule";
10632
10633 let local_client = &self.client;
10634
10635 let local_uri_str = format!(
10636 "{}/api/v2/security_monitoring/rules/validation",
10637 local_configuration.get_operation_host(operation_id)
10638 );
10639 let mut local_req_builder =
10640 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
10641
10642 let mut headers = HeaderMap::new();
10644 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
10645 headers.insert("Accept", HeaderValue::from_static("*/*"));
10646
10647 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
10649 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
10650 Err(e) => {
10651 log::warn!("Failed to parse user agent header: {e}, falling back to default");
10652 headers.insert(
10653 reqwest::header::USER_AGENT,
10654 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
10655 )
10656 }
10657 };
10658
10659 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
10661 headers.insert(
10662 "DD-API-KEY",
10663 HeaderValue::from_str(local_key.key.as_str())
10664 .expect("failed to parse DD-API-KEY header"),
10665 );
10666 };
10667 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
10668 headers.insert(
10669 "DD-APPLICATION-KEY",
10670 HeaderValue::from_str(local_key.key.as_str())
10671 .expect("failed to parse DD-APPLICATION-KEY header"),
10672 );
10673 };
10674
10675 let output = Vec::new();
10677 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
10678 if body.serialize(&mut ser).is_ok() {
10679 if let Some(content_encoding) = headers.get("Content-Encoding") {
10680 match content_encoding.to_str().unwrap_or_default() {
10681 "gzip" => {
10682 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
10683 let _ = enc.write_all(ser.into_inner().as_slice());
10684 match enc.finish() {
10685 Ok(buf) => {
10686 local_req_builder = local_req_builder.body(buf);
10687 }
10688 Err(e) => return Err(datadog::Error::Io(e)),
10689 }
10690 }
10691 "deflate" => {
10692 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
10693 let _ = enc.write_all(ser.into_inner().as_slice());
10694 match enc.finish() {
10695 Ok(buf) => {
10696 local_req_builder = local_req_builder.body(buf);
10697 }
10698 Err(e) => return Err(datadog::Error::Io(e)),
10699 }
10700 }
10701 "zstd1" => {
10702 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
10703 let _ = enc.write_all(ser.into_inner().as_slice());
10704 match enc.finish() {
10705 Ok(buf) => {
10706 local_req_builder = local_req_builder.body(buf);
10707 }
10708 Err(e) => return Err(datadog::Error::Io(e)),
10709 }
10710 }
10711 _ => {
10712 local_req_builder = local_req_builder.body(ser.into_inner());
10713 }
10714 }
10715 } else {
10716 local_req_builder = local_req_builder.body(ser.into_inner());
10717 }
10718 }
10719
10720 local_req_builder = local_req_builder.headers(headers);
10721 let local_req = local_req_builder.build()?;
10722 log::debug!("request content: {:?}", local_req.body());
10723 let local_resp = local_client.execute(local_req).await?;
10724
10725 let local_status = local_resp.status();
10726 let local_content = local_resp.text().await?;
10727 log::debug!("response content: {}", local_content);
10728
10729 if !local_status.is_client_error() && !local_status.is_server_error() {
10730 Ok(datadog::ResponseContent {
10731 status: local_status,
10732 content: local_content,
10733 entity: None,
10734 })
10735 } else {
10736 let local_entity: Option<ValidateSecurityMonitoringRuleError> =
10737 serde_json::from_str(&local_content).ok();
10738 let local_error = datadog::ResponseContent {
10739 status: local_status,
10740 content: local_content,
10741 entity: local_entity,
10742 };
10743 Err(datadog::Error::ResponseError(local_error))
10744 }
10745 }
10746
10747 pub async fn validate_security_monitoring_suppression(
10749 &self,
10750 body: crate::datadogV2::model::SecurityMonitoringSuppressionCreateRequest,
10751 ) -> Result<(), datadog::Error<ValidateSecurityMonitoringSuppressionError>> {
10752 match self
10753 .validate_security_monitoring_suppression_with_http_info(body)
10754 .await
10755 {
10756 Ok(_) => Ok(()),
10757 Err(err) => Err(err),
10758 }
10759 }
10760
10761 pub async fn validate_security_monitoring_suppression_with_http_info(
10763 &self,
10764 body: crate::datadogV2::model::SecurityMonitoringSuppressionCreateRequest,
10765 ) -> Result<
10766 datadog::ResponseContent<()>,
10767 datadog::Error<ValidateSecurityMonitoringSuppressionError>,
10768 > {
10769 let local_configuration = &self.config;
10770 let operation_id = "v2.validate_security_monitoring_suppression";
10771
10772 let local_client = &self.client;
10773
10774 let local_uri_str = format!(
10775 "{}/api/v2/security_monitoring/configuration/suppressions/validation",
10776 local_configuration.get_operation_host(operation_id)
10777 );
10778 let mut local_req_builder =
10779 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
10780
10781 let mut headers = HeaderMap::new();
10783 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
10784 headers.insert("Accept", HeaderValue::from_static("*/*"));
10785
10786 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
10788 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
10789 Err(e) => {
10790 log::warn!("Failed to parse user agent header: {e}, falling back to default");
10791 headers.insert(
10792 reqwest::header::USER_AGENT,
10793 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
10794 )
10795 }
10796 };
10797
10798 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
10800 headers.insert(
10801 "DD-API-KEY",
10802 HeaderValue::from_str(local_key.key.as_str())
10803 .expect("failed to parse DD-API-KEY header"),
10804 );
10805 };
10806 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
10807 headers.insert(
10808 "DD-APPLICATION-KEY",
10809 HeaderValue::from_str(local_key.key.as_str())
10810 .expect("failed to parse DD-APPLICATION-KEY header"),
10811 );
10812 };
10813
10814 let output = Vec::new();
10816 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
10817 if body.serialize(&mut ser).is_ok() {
10818 if let Some(content_encoding) = headers.get("Content-Encoding") {
10819 match content_encoding.to_str().unwrap_or_default() {
10820 "gzip" => {
10821 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
10822 let _ = enc.write_all(ser.into_inner().as_slice());
10823 match enc.finish() {
10824 Ok(buf) => {
10825 local_req_builder = local_req_builder.body(buf);
10826 }
10827 Err(e) => return Err(datadog::Error::Io(e)),
10828 }
10829 }
10830 "deflate" => {
10831 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
10832 let _ = enc.write_all(ser.into_inner().as_slice());
10833 match enc.finish() {
10834 Ok(buf) => {
10835 local_req_builder = local_req_builder.body(buf);
10836 }
10837 Err(e) => return Err(datadog::Error::Io(e)),
10838 }
10839 }
10840 "zstd1" => {
10841 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
10842 let _ = enc.write_all(ser.into_inner().as_slice());
10843 match enc.finish() {
10844 Ok(buf) => {
10845 local_req_builder = local_req_builder.body(buf);
10846 }
10847 Err(e) => return Err(datadog::Error::Io(e)),
10848 }
10849 }
10850 _ => {
10851 local_req_builder = local_req_builder.body(ser.into_inner());
10852 }
10853 }
10854 } else {
10855 local_req_builder = local_req_builder.body(ser.into_inner());
10856 }
10857 }
10858
10859 local_req_builder = local_req_builder.headers(headers);
10860 let local_req = local_req_builder.build()?;
10861 log::debug!("request content: {:?}", local_req.body());
10862 let local_resp = local_client.execute(local_req).await?;
10863
10864 let local_status = local_resp.status();
10865 let local_content = local_resp.text().await?;
10866 log::debug!("response content: {}", local_content);
10867
10868 if !local_status.is_client_error() && !local_status.is_server_error() {
10869 Ok(datadog::ResponseContent {
10870 status: local_status,
10871 content: local_content,
10872 entity: None,
10873 })
10874 } else {
10875 let local_entity: Option<ValidateSecurityMonitoringSuppressionError> =
10876 serde_json::from_str(&local_content).ok();
10877 let local_error = datadog::ResponseContent {
10878 status: local_status,
10879 content: local_content,
10880 entity: local_entity,
10881 };
10882 Err(datadog::Error::ResponseError(local_error))
10883 }
10884 }
10885}