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 ListAssetsSBOMsOptionalParams {
105 pub page_token: Option<String>,
107 pub page_number: Option<i64>,
109 pub filter_asset_type: Option<crate::datadogV2::model::AssetType>,
111 pub filter_asset_name: Option<String>,
113 pub filter_package_name: Option<String>,
115 pub filter_package_version: Option<String>,
117 pub filter_license_name: Option<String>,
119 pub filter_license_type: Option<crate::datadogV2::model::SBOMComponentLicenseType>,
121}
122
123impl ListAssetsSBOMsOptionalParams {
124 pub fn page_token(mut self, value: String) -> Self {
126 self.page_token = Some(value);
127 self
128 }
129 pub fn page_number(mut self, value: i64) -> Self {
131 self.page_number = Some(value);
132 self
133 }
134 pub fn filter_asset_type(mut self, value: crate::datadogV2::model::AssetType) -> Self {
136 self.filter_asset_type = Some(value);
137 self
138 }
139 pub fn filter_asset_name(mut self, value: String) -> Self {
141 self.filter_asset_name = Some(value);
142 self
143 }
144 pub fn filter_package_name(mut self, value: String) -> Self {
146 self.filter_package_name = Some(value);
147 self
148 }
149 pub fn filter_package_version(mut self, value: String) -> Self {
151 self.filter_package_version = Some(value);
152 self
153 }
154 pub fn filter_license_name(mut self, value: String) -> Self {
156 self.filter_license_name = Some(value);
157 self
158 }
159 pub fn filter_license_type(
161 mut self,
162 value: crate::datadogV2::model::SBOMComponentLicenseType,
163 ) -> Self {
164 self.filter_license_type = Some(value);
165 self
166 }
167}
168
169#[non_exhaustive]
171#[derive(Clone, Default, Debug)]
172pub struct ListFindingsOptionalParams {
173 pub page_limit: Option<i64>,
175 pub snapshot_timestamp: Option<i64>,
177 pub page_cursor: Option<String>,
179 pub filter_tags: Option<String>,
181 pub filter_evaluation_changed_at: Option<String>,
183 pub filter_muted: Option<bool>,
185 pub filter_rule_id: Option<String>,
187 pub filter_rule_name: Option<String>,
189 pub filter_resource_type: Option<String>,
191 pub filter_resource_id: Option<String>,
193 pub filter_discovery_timestamp: Option<String>,
195 pub filter_evaluation: Option<crate::datadogV2::model::FindingEvaluation>,
197 pub filter_status: Option<crate::datadogV2::model::FindingStatus>,
199 pub filter_vulnerability_type: Option<Vec<crate::datadogV2::model::FindingVulnerabilityType>>,
201 pub detailed_findings: Option<bool>,
203}
204
205impl ListFindingsOptionalParams {
206 pub fn page_limit(mut self, value: i64) -> Self {
208 self.page_limit = Some(value);
209 self
210 }
211 pub fn snapshot_timestamp(mut self, value: i64) -> Self {
213 self.snapshot_timestamp = Some(value);
214 self
215 }
216 pub fn page_cursor(mut self, value: String) -> Self {
218 self.page_cursor = Some(value);
219 self
220 }
221 pub fn filter_tags(mut self, value: String) -> Self {
223 self.filter_tags = Some(value);
224 self
225 }
226 pub fn filter_evaluation_changed_at(mut self, value: String) -> Self {
228 self.filter_evaluation_changed_at = Some(value);
229 self
230 }
231 pub fn filter_muted(mut self, value: bool) -> Self {
233 self.filter_muted = Some(value);
234 self
235 }
236 pub fn filter_rule_id(mut self, value: String) -> Self {
238 self.filter_rule_id = Some(value);
239 self
240 }
241 pub fn filter_rule_name(mut self, value: String) -> Self {
243 self.filter_rule_name = Some(value);
244 self
245 }
246 pub fn filter_resource_type(mut self, value: String) -> Self {
248 self.filter_resource_type = Some(value);
249 self
250 }
251 pub fn filter_resource_id(mut self, value: String) -> Self {
253 self.filter_resource_id = Some(value);
254 self
255 }
256 pub fn filter_discovery_timestamp(mut self, value: String) -> Self {
258 self.filter_discovery_timestamp = Some(value);
259 self
260 }
261 pub fn filter_evaluation(mut self, value: crate::datadogV2::model::FindingEvaluation) -> Self {
263 self.filter_evaluation = Some(value);
264 self
265 }
266 pub fn filter_status(mut self, value: crate::datadogV2::model::FindingStatus) -> Self {
268 self.filter_status = Some(value);
269 self
270 }
271 pub fn filter_vulnerability_type(
273 mut self,
274 value: Vec<crate::datadogV2::model::FindingVulnerabilityType>,
275 ) -> Self {
276 self.filter_vulnerability_type = Some(value);
277 self
278 }
279 pub fn detailed_findings(mut self, value: bool) -> Self {
281 self.detailed_findings = Some(value);
282 self
283 }
284}
285
286#[non_exhaustive]
288#[derive(Clone, Default, Debug)]
289pub struct ListHistoricalJobsOptionalParams {
290 pub page_size: Option<i64>,
292 pub page_number: Option<i64>,
294 pub sort: Option<String>,
296 pub filter_query: Option<String>,
298}
299
300impl ListHistoricalJobsOptionalParams {
301 pub fn page_size(mut self, value: i64) -> Self {
303 self.page_size = Some(value);
304 self
305 }
306 pub fn page_number(mut self, value: i64) -> Self {
308 self.page_number = Some(value);
309 self
310 }
311 pub fn sort(mut self, value: String) -> Self {
313 self.sort = Some(value);
314 self
315 }
316 pub fn filter_query(mut self, value: String) -> Self {
318 self.filter_query = Some(value);
319 self
320 }
321}
322
323#[non_exhaustive]
325#[derive(Clone, Default, Debug)]
326pub struct ListSecurityMonitoringRulesOptionalParams {
327 pub page_size: Option<i64>,
329 pub page_number: Option<i64>,
331}
332
333impl ListSecurityMonitoringRulesOptionalParams {
334 pub fn page_size(mut self, value: i64) -> Self {
336 self.page_size = Some(value);
337 self
338 }
339 pub fn page_number(mut self, value: i64) -> Self {
341 self.page_number = Some(value);
342 self
343 }
344}
345
346#[non_exhaustive]
348#[derive(Clone, Default, Debug)]
349pub struct ListSecurityMonitoringSignalsOptionalParams {
350 pub filter_query: Option<String>,
352 pub filter_from: Option<chrono::DateTime<chrono::Utc>>,
354 pub filter_to: Option<chrono::DateTime<chrono::Utc>>,
356 pub sort: Option<crate::datadogV2::model::SecurityMonitoringSignalsSort>,
358 pub page_cursor: Option<String>,
360 pub page_limit: Option<i32>,
362}
363
364impl ListSecurityMonitoringSignalsOptionalParams {
365 pub fn filter_query(mut self, value: String) -> Self {
367 self.filter_query = Some(value);
368 self
369 }
370 pub fn filter_from(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
372 self.filter_from = Some(value);
373 self
374 }
375 pub fn filter_to(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
377 self.filter_to = Some(value);
378 self
379 }
380 pub fn sort(mut self, value: crate::datadogV2::model::SecurityMonitoringSignalsSort) -> Self {
382 self.sort = Some(value);
383 self
384 }
385 pub fn page_cursor(mut self, value: String) -> Self {
387 self.page_cursor = Some(value);
388 self
389 }
390 pub fn page_limit(mut self, value: i32) -> Self {
392 self.page_limit = Some(value);
393 self
394 }
395}
396
397#[non_exhaustive]
399#[derive(Clone, Default, Debug)]
400pub struct ListVulnerabilitiesOptionalParams {
401 pub page_token: Option<String>,
403 pub page_number: Option<i64>,
405 pub filter_type: Option<crate::datadogV2::model::VulnerabilityType>,
407 pub filter_cvss_base_score_op: Option<f64>,
409 pub filter_cvss_base_severity: Option<crate::datadogV2::model::VulnerabilitySeverity>,
411 pub filter_cvss_base_vector: Option<String>,
413 pub filter_cvss_datadog_score_op: Option<f64>,
415 pub filter_cvss_datadog_severity: Option<crate::datadogV2::model::VulnerabilitySeverity>,
417 pub filter_cvss_datadog_vector: Option<String>,
419 pub filter_status: Option<crate::datadogV2::model::VulnerabilityStatus>,
421 pub filter_tool: Option<crate::datadogV2::model::VulnerabilityTool>,
423 pub filter_library_name: Option<String>,
425 pub filter_library_version: Option<String>,
427 pub filter_advisory_id: Option<String>,
429 pub filter_risks_exploitation_probability: Option<bool>,
431 pub filter_risks_poc_exploit_available: Option<bool>,
433 pub filter_risks_exploit_available: Option<bool>,
435 pub filter_risks_epss_score_op: Option<f64>,
437 pub filter_risks_epss_severity: Option<crate::datadogV2::model::VulnerabilitySeverity>,
439 pub filter_language: Option<String>,
441 pub filter_ecosystem: Option<crate::datadogV2::model::VulnerabilityEcosystem>,
443 pub filter_code_location_location: Option<String>,
445 pub filter_code_location_file_path: Option<String>,
447 pub filter_code_location_method: Option<String>,
449 pub filter_fix_available: Option<bool>,
451 pub filter_repo_digests: Option<String>,
453 pub filter_origin: Option<String>,
455 pub filter_asset_name: Option<String>,
457 pub filter_asset_type: Option<crate::datadogV2::model::AssetType>,
459 pub filter_asset_version_first: Option<String>,
461 pub filter_asset_version_last: Option<String>,
463 pub filter_asset_repository_url: Option<String>,
465 pub filter_asset_risks_in_production: Option<bool>,
467 pub filter_asset_risks_under_attack: Option<bool>,
469 pub filter_asset_risks_is_publicly_accessible: Option<bool>,
471 pub filter_asset_risks_has_privileged_access: Option<bool>,
473 pub filter_asset_risks_has_access_to_sensitive_data: Option<bool>,
475 pub filter_asset_environments: Option<String>,
477 pub filter_asset_teams: Option<String>,
479 pub filter_asset_arch: Option<String>,
481 pub filter_asset_operating_system_name: Option<String>,
483 pub filter_asset_operating_system_version: Option<String>,
485}
486
487impl ListVulnerabilitiesOptionalParams {
488 pub fn page_token(mut self, value: String) -> Self {
490 self.page_token = Some(value);
491 self
492 }
493 pub fn page_number(mut self, value: i64) -> Self {
495 self.page_number = Some(value);
496 self
497 }
498 pub fn filter_type(mut self, value: crate::datadogV2::model::VulnerabilityType) -> Self {
500 self.filter_type = Some(value);
501 self
502 }
503 pub fn filter_cvss_base_score_op(mut self, value: f64) -> Self {
505 self.filter_cvss_base_score_op = Some(value);
506 self
507 }
508 pub fn filter_cvss_base_severity(
510 mut self,
511 value: crate::datadogV2::model::VulnerabilitySeverity,
512 ) -> Self {
513 self.filter_cvss_base_severity = Some(value);
514 self
515 }
516 pub fn filter_cvss_base_vector(mut self, value: String) -> Self {
518 self.filter_cvss_base_vector = Some(value);
519 self
520 }
521 pub fn filter_cvss_datadog_score_op(mut self, value: f64) -> Self {
523 self.filter_cvss_datadog_score_op = Some(value);
524 self
525 }
526 pub fn filter_cvss_datadog_severity(
528 mut self,
529 value: crate::datadogV2::model::VulnerabilitySeverity,
530 ) -> Self {
531 self.filter_cvss_datadog_severity = Some(value);
532 self
533 }
534 pub fn filter_cvss_datadog_vector(mut self, value: String) -> Self {
536 self.filter_cvss_datadog_vector = Some(value);
537 self
538 }
539 pub fn filter_status(mut self, value: crate::datadogV2::model::VulnerabilityStatus) -> Self {
541 self.filter_status = Some(value);
542 self
543 }
544 pub fn filter_tool(mut self, value: crate::datadogV2::model::VulnerabilityTool) -> Self {
546 self.filter_tool = Some(value);
547 self
548 }
549 pub fn filter_library_name(mut self, value: String) -> Self {
551 self.filter_library_name = Some(value);
552 self
553 }
554 pub fn filter_library_version(mut self, value: String) -> Self {
556 self.filter_library_version = Some(value);
557 self
558 }
559 pub fn filter_advisory_id(mut self, value: String) -> Self {
561 self.filter_advisory_id = Some(value);
562 self
563 }
564 pub fn filter_risks_exploitation_probability(mut self, value: bool) -> Self {
566 self.filter_risks_exploitation_probability = Some(value);
567 self
568 }
569 pub fn filter_risks_poc_exploit_available(mut self, value: bool) -> Self {
571 self.filter_risks_poc_exploit_available = Some(value);
572 self
573 }
574 pub fn filter_risks_exploit_available(mut self, value: bool) -> Self {
576 self.filter_risks_exploit_available = Some(value);
577 self
578 }
579 pub fn filter_risks_epss_score_op(mut self, value: f64) -> Self {
581 self.filter_risks_epss_score_op = Some(value);
582 self
583 }
584 pub fn filter_risks_epss_severity(
586 mut self,
587 value: crate::datadogV2::model::VulnerabilitySeverity,
588 ) -> Self {
589 self.filter_risks_epss_severity = Some(value);
590 self
591 }
592 pub fn filter_language(mut self, value: String) -> Self {
594 self.filter_language = Some(value);
595 self
596 }
597 pub fn filter_ecosystem(
599 mut self,
600 value: crate::datadogV2::model::VulnerabilityEcosystem,
601 ) -> Self {
602 self.filter_ecosystem = Some(value);
603 self
604 }
605 pub fn filter_code_location_location(mut self, value: String) -> Self {
607 self.filter_code_location_location = Some(value);
608 self
609 }
610 pub fn filter_code_location_file_path(mut self, value: String) -> Self {
612 self.filter_code_location_file_path = Some(value);
613 self
614 }
615 pub fn filter_code_location_method(mut self, value: String) -> Self {
617 self.filter_code_location_method = Some(value);
618 self
619 }
620 pub fn filter_fix_available(mut self, value: bool) -> Self {
622 self.filter_fix_available = Some(value);
623 self
624 }
625 pub fn filter_repo_digests(mut self, value: String) -> Self {
627 self.filter_repo_digests = Some(value);
628 self
629 }
630 pub fn filter_origin(mut self, value: String) -> Self {
632 self.filter_origin = Some(value);
633 self
634 }
635 pub fn filter_asset_name(mut self, value: String) -> Self {
637 self.filter_asset_name = Some(value);
638 self
639 }
640 pub fn filter_asset_type(mut self, value: crate::datadogV2::model::AssetType) -> Self {
642 self.filter_asset_type = Some(value);
643 self
644 }
645 pub fn filter_asset_version_first(mut self, value: String) -> Self {
647 self.filter_asset_version_first = Some(value);
648 self
649 }
650 pub fn filter_asset_version_last(mut self, value: String) -> Self {
652 self.filter_asset_version_last = Some(value);
653 self
654 }
655 pub fn filter_asset_repository_url(mut self, value: String) -> Self {
657 self.filter_asset_repository_url = Some(value);
658 self
659 }
660 pub fn filter_asset_risks_in_production(mut self, value: bool) -> Self {
662 self.filter_asset_risks_in_production = Some(value);
663 self
664 }
665 pub fn filter_asset_risks_under_attack(mut self, value: bool) -> Self {
667 self.filter_asset_risks_under_attack = Some(value);
668 self
669 }
670 pub fn filter_asset_risks_is_publicly_accessible(mut self, value: bool) -> Self {
672 self.filter_asset_risks_is_publicly_accessible = Some(value);
673 self
674 }
675 pub fn filter_asset_risks_has_privileged_access(mut self, value: bool) -> Self {
677 self.filter_asset_risks_has_privileged_access = Some(value);
678 self
679 }
680 pub fn filter_asset_risks_has_access_to_sensitive_data(mut self, value: bool) -> Self {
682 self.filter_asset_risks_has_access_to_sensitive_data = Some(value);
683 self
684 }
685 pub fn filter_asset_environments(mut self, value: String) -> Self {
687 self.filter_asset_environments = Some(value);
688 self
689 }
690 pub fn filter_asset_teams(mut self, value: String) -> Self {
692 self.filter_asset_teams = Some(value);
693 self
694 }
695 pub fn filter_asset_arch(mut self, value: String) -> Self {
697 self.filter_asset_arch = Some(value);
698 self
699 }
700 pub fn filter_asset_operating_system_name(mut self, value: String) -> Self {
702 self.filter_asset_operating_system_name = Some(value);
703 self
704 }
705 pub fn filter_asset_operating_system_version(mut self, value: String) -> Self {
707 self.filter_asset_operating_system_version = Some(value);
708 self
709 }
710}
711
712#[non_exhaustive]
714#[derive(Clone, Default, Debug)]
715pub struct ListVulnerableAssetsOptionalParams {
716 pub page_token: Option<String>,
718 pub page_number: Option<i64>,
720 pub filter_name: Option<String>,
722 pub filter_type: Option<crate::datadogV2::model::AssetType>,
724 pub filter_version_first: Option<String>,
726 pub filter_version_last: Option<String>,
728 pub filter_repository_url: Option<String>,
730 pub filter_risks_in_production: Option<bool>,
732 pub filter_risks_under_attack: Option<bool>,
734 pub filter_risks_is_publicly_accessible: Option<bool>,
736 pub filter_risks_has_privileged_access: Option<bool>,
738 pub filter_risks_has_access_to_sensitive_data: Option<bool>,
740 pub filter_environments: Option<String>,
742 pub filter_teams: Option<String>,
744 pub filter_arch: Option<String>,
746 pub filter_operating_system_name: Option<String>,
748 pub filter_operating_system_version: Option<String>,
750}
751
752impl ListVulnerableAssetsOptionalParams {
753 pub fn page_token(mut self, value: String) -> Self {
755 self.page_token = Some(value);
756 self
757 }
758 pub fn page_number(mut self, value: i64) -> Self {
760 self.page_number = Some(value);
761 self
762 }
763 pub fn filter_name(mut self, value: String) -> Self {
765 self.filter_name = Some(value);
766 self
767 }
768 pub fn filter_type(mut self, value: crate::datadogV2::model::AssetType) -> Self {
770 self.filter_type = Some(value);
771 self
772 }
773 pub fn filter_version_first(mut self, value: String) -> Self {
775 self.filter_version_first = Some(value);
776 self
777 }
778 pub fn filter_version_last(mut self, value: String) -> Self {
780 self.filter_version_last = Some(value);
781 self
782 }
783 pub fn filter_repository_url(mut self, value: String) -> Self {
785 self.filter_repository_url = Some(value);
786 self
787 }
788 pub fn filter_risks_in_production(mut self, value: bool) -> Self {
790 self.filter_risks_in_production = Some(value);
791 self
792 }
793 pub fn filter_risks_under_attack(mut self, value: bool) -> Self {
795 self.filter_risks_under_attack = Some(value);
796 self
797 }
798 pub fn filter_risks_is_publicly_accessible(mut self, value: bool) -> Self {
800 self.filter_risks_is_publicly_accessible = Some(value);
801 self
802 }
803 pub fn filter_risks_has_privileged_access(mut self, value: bool) -> Self {
805 self.filter_risks_has_privileged_access = Some(value);
806 self
807 }
808 pub fn filter_risks_has_access_to_sensitive_data(mut self, value: bool) -> Self {
810 self.filter_risks_has_access_to_sensitive_data = Some(value);
811 self
812 }
813 pub fn filter_environments(mut self, value: String) -> Self {
815 self.filter_environments = Some(value);
816 self
817 }
818 pub fn filter_teams(mut self, value: String) -> Self {
820 self.filter_teams = Some(value);
821 self
822 }
823 pub fn filter_arch(mut self, value: String) -> Self {
825 self.filter_arch = Some(value);
826 self
827 }
828 pub fn filter_operating_system_name(mut self, value: String) -> Self {
830 self.filter_operating_system_name = Some(value);
831 self
832 }
833 pub fn filter_operating_system_version(mut self, value: String) -> Self {
835 self.filter_operating_system_version = Some(value);
836 self
837 }
838}
839
840#[non_exhaustive]
842#[derive(Clone, Default, Debug)]
843pub struct SearchSecurityMonitoringSignalsOptionalParams {
844 pub body: Option<crate::datadogV2::model::SecurityMonitoringSignalListRequest>,
845}
846
847impl SearchSecurityMonitoringSignalsOptionalParams {
848 pub fn body(
849 mut self,
850 value: crate::datadogV2::model::SecurityMonitoringSignalListRequest,
851 ) -> Self {
852 self.body = Some(value);
853 self
854 }
855}
856
857#[derive(Debug, Clone, Serialize, Deserialize)]
859#[serde(untagged)]
860pub enum CancelHistoricalJobError {
861 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
862 UnknownValue(serde_json::Value),
863}
864
865#[derive(Debug, Clone, Serialize, Deserialize)]
867#[serde(untagged)]
868pub enum ConvertExistingSecurityMonitoringRuleError {
869 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
870 UnknownValue(serde_json::Value),
871}
872
873#[derive(Debug, Clone, Serialize, Deserialize)]
875#[serde(untagged)]
876pub enum ConvertJobResultToSignalError {
877 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
878 UnknownValue(serde_json::Value),
879}
880
881#[derive(Debug, Clone, Serialize, Deserialize)]
883#[serde(untagged)]
884pub enum ConvertSecurityMonitoringRuleFromJSONToTerraformError {
885 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
886 UnknownValue(serde_json::Value),
887}
888
889#[derive(Debug, Clone, Serialize, Deserialize)]
891#[serde(untagged)]
892pub enum CreateCustomFrameworkError {
893 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
894 UnknownValue(serde_json::Value),
895}
896
897#[derive(Debug, Clone, Serialize, Deserialize)]
899#[serde(untagged)]
900pub enum CreateSecurityFilterError {
901 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
902 UnknownValue(serde_json::Value),
903}
904
905#[derive(Debug, Clone, Serialize, Deserialize)]
907#[serde(untagged)]
908pub enum CreateSecurityMonitoringRuleError {
909 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
910 UnknownValue(serde_json::Value),
911}
912
913#[derive(Debug, Clone, Serialize, Deserialize)]
915#[serde(untagged)]
916pub enum CreateSecurityMonitoringSuppressionError {
917 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
918 UnknownValue(serde_json::Value),
919}
920
921#[derive(Debug, Clone, Serialize, Deserialize)]
923#[serde(untagged)]
924pub enum CreateSignalNotificationRuleError {
925 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
926 UnknownValue(serde_json::Value),
927}
928
929#[derive(Debug, Clone, Serialize, Deserialize)]
931#[serde(untagged)]
932pub enum CreateVulnerabilityNotificationRuleError {
933 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
934 UnknownValue(serde_json::Value),
935}
936
937#[derive(Debug, Clone, Serialize, Deserialize)]
939#[serde(untagged)]
940pub enum DeleteCustomFrameworkError {
941 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
942 UnknownValue(serde_json::Value),
943}
944
945#[derive(Debug, Clone, Serialize, Deserialize)]
947#[serde(untagged)]
948pub enum DeleteHistoricalJobError {
949 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
950 UnknownValue(serde_json::Value),
951}
952
953#[derive(Debug, Clone, Serialize, Deserialize)]
955#[serde(untagged)]
956pub enum DeleteSecurityFilterError {
957 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
958 UnknownValue(serde_json::Value),
959}
960
961#[derive(Debug, Clone, Serialize, Deserialize)]
963#[serde(untagged)]
964pub enum DeleteSecurityMonitoringRuleError {
965 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
966 UnknownValue(serde_json::Value),
967}
968
969#[derive(Debug, Clone, Serialize, Deserialize)]
971#[serde(untagged)]
972pub enum DeleteSecurityMonitoringSuppressionError {
973 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
974 UnknownValue(serde_json::Value),
975}
976
977#[derive(Debug, Clone, Serialize, Deserialize)]
979#[serde(untagged)]
980pub enum DeleteSignalNotificationRuleError {
981 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
982 UnknownValue(serde_json::Value),
983}
984
985#[derive(Debug, Clone, Serialize, Deserialize)]
987#[serde(untagged)]
988pub enum DeleteVulnerabilityNotificationRuleError {
989 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
990 UnknownValue(serde_json::Value),
991}
992
993#[derive(Debug, Clone, Serialize, Deserialize)]
995#[serde(untagged)]
996pub enum EditSecurityMonitoringSignalAssigneeError {
997 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
998 UnknownValue(serde_json::Value),
999}
1000
1001#[derive(Debug, Clone, Serialize, Deserialize)]
1003#[serde(untagged)]
1004pub enum EditSecurityMonitoringSignalIncidentsError {
1005 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1006 UnknownValue(serde_json::Value),
1007}
1008
1009#[derive(Debug, Clone, Serialize, Deserialize)]
1011#[serde(untagged)]
1012pub enum EditSecurityMonitoringSignalStateError {
1013 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1014 UnknownValue(serde_json::Value),
1015}
1016
1017#[derive(Debug, Clone, Serialize, Deserialize)]
1019#[serde(untagged)]
1020pub enum GetCustomFrameworkError {
1021 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1022 UnknownValue(serde_json::Value),
1023}
1024
1025#[derive(Debug, Clone, Serialize, Deserialize)]
1027#[serde(untagged)]
1028pub enum GetFindingError {
1029 JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
1030 UnknownValue(serde_json::Value),
1031}
1032
1033#[derive(Debug, Clone, Serialize, Deserialize)]
1035#[serde(untagged)]
1036pub enum GetHistoricalJobError {
1037 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1038 UnknownValue(serde_json::Value),
1039}
1040
1041#[derive(Debug, Clone, Serialize, Deserialize)]
1043#[serde(untagged)]
1044pub enum GetResourceEvaluationFiltersError {
1045 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1046 UnknownValue(serde_json::Value),
1047}
1048
1049#[derive(Debug, Clone, Serialize, Deserialize)]
1051#[serde(untagged)]
1052pub enum GetRuleVersionHistoryError {
1053 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1054 UnknownValue(serde_json::Value),
1055}
1056
1057#[derive(Debug, Clone, Serialize, Deserialize)]
1059#[serde(untagged)]
1060pub enum GetSBOMError {
1061 JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
1062 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1063 UnknownValue(serde_json::Value),
1064}
1065
1066#[derive(Debug, Clone, Serialize, Deserialize)]
1068#[serde(untagged)]
1069pub enum GetSecurityFilterError {
1070 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1071 UnknownValue(serde_json::Value),
1072}
1073
1074#[derive(Debug, Clone, Serialize, Deserialize)]
1076#[serde(untagged)]
1077pub enum GetSecurityMonitoringRuleError {
1078 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1079 UnknownValue(serde_json::Value),
1080}
1081
1082#[derive(Debug, Clone, Serialize, Deserialize)]
1084#[serde(untagged)]
1085pub enum GetSecurityMonitoringSignalError {
1086 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1087 UnknownValue(serde_json::Value),
1088}
1089
1090#[derive(Debug, Clone, Serialize, Deserialize)]
1092#[serde(untagged)]
1093pub enum GetSecurityMonitoringSuppressionError {
1094 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1095 UnknownValue(serde_json::Value),
1096}
1097
1098#[derive(Debug, Clone, Serialize, Deserialize)]
1100#[serde(untagged)]
1101pub enum GetSignalNotificationRuleError {
1102 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1103 UnknownValue(serde_json::Value),
1104}
1105
1106#[derive(Debug, Clone, Serialize, Deserialize)]
1108#[serde(untagged)]
1109pub enum GetSignalNotificationRulesError {
1110 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1111 UnknownValue(serde_json::Value),
1112}
1113
1114#[derive(Debug, Clone, Serialize, Deserialize)]
1116#[serde(untagged)]
1117pub enum GetVulnerabilityNotificationRuleError {
1118 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1119 UnknownValue(serde_json::Value),
1120}
1121
1122#[derive(Debug, Clone, Serialize, Deserialize)]
1124#[serde(untagged)]
1125pub enum GetVulnerabilityNotificationRulesError {
1126 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1127 UnknownValue(serde_json::Value),
1128}
1129
1130#[derive(Debug, Clone, Serialize, Deserialize)]
1132#[serde(untagged)]
1133pub enum ListAssetsSBOMsError {
1134 JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
1135 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1136 UnknownValue(serde_json::Value),
1137}
1138
1139#[derive(Debug, Clone, Serialize, Deserialize)]
1141#[serde(untagged)]
1142pub enum ListFindingsError {
1143 JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
1144 UnknownValue(serde_json::Value),
1145}
1146
1147#[derive(Debug, Clone, Serialize, Deserialize)]
1149#[serde(untagged)]
1150pub enum ListHistoricalJobsError {
1151 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1152 UnknownValue(serde_json::Value),
1153}
1154
1155#[derive(Debug, Clone, Serialize, Deserialize)]
1157#[serde(untagged)]
1158pub enum ListSecurityFiltersError {
1159 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1160 UnknownValue(serde_json::Value),
1161}
1162
1163#[derive(Debug, Clone, Serialize, Deserialize)]
1165#[serde(untagged)]
1166pub enum ListSecurityMonitoringRulesError {
1167 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1168 UnknownValue(serde_json::Value),
1169}
1170
1171#[derive(Debug, Clone, Serialize, Deserialize)]
1173#[serde(untagged)]
1174pub enum ListSecurityMonitoringSignalsError {
1175 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1176 UnknownValue(serde_json::Value),
1177}
1178
1179#[derive(Debug, Clone, Serialize, Deserialize)]
1181#[serde(untagged)]
1182pub enum ListSecurityMonitoringSuppressionsError {
1183 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1184 UnknownValue(serde_json::Value),
1185}
1186
1187#[derive(Debug, Clone, Serialize, Deserialize)]
1189#[serde(untagged)]
1190pub enum ListVulnerabilitiesError {
1191 JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
1192 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1193 UnknownValue(serde_json::Value),
1194}
1195
1196#[derive(Debug, Clone, Serialize, Deserialize)]
1198#[serde(untagged)]
1199pub enum ListVulnerableAssetsError {
1200 JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
1201 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1202 UnknownValue(serde_json::Value),
1203}
1204
1205#[derive(Debug, Clone, Serialize, Deserialize)]
1207#[serde(untagged)]
1208pub enum MuteFindingsError {
1209 JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
1210 UnknownValue(serde_json::Value),
1211}
1212
1213#[derive(Debug, Clone, Serialize, Deserialize)]
1215#[serde(untagged)]
1216pub enum PatchSignalNotificationRuleError {
1217 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1218 JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
1219 UnknownValue(serde_json::Value),
1220}
1221
1222#[derive(Debug, Clone, Serialize, Deserialize)]
1224#[serde(untagged)]
1225pub enum PatchVulnerabilityNotificationRuleError {
1226 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1227 JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
1228 UnknownValue(serde_json::Value),
1229}
1230
1231#[derive(Debug, Clone, Serialize, Deserialize)]
1233#[serde(untagged)]
1234pub enum RunHistoricalJobError {
1235 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1236 UnknownValue(serde_json::Value),
1237}
1238
1239#[derive(Debug, Clone, Serialize, Deserialize)]
1241#[serde(untagged)]
1242pub enum SearchSecurityMonitoringSignalsError {
1243 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1244 UnknownValue(serde_json::Value),
1245}
1246
1247#[derive(Debug, Clone, Serialize, Deserialize)]
1249#[serde(untagged)]
1250pub enum TestExistingSecurityMonitoringRuleError {
1251 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1252 UnknownValue(serde_json::Value),
1253}
1254
1255#[derive(Debug, Clone, Serialize, Deserialize)]
1257#[serde(untagged)]
1258pub enum TestSecurityMonitoringRuleError {
1259 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1260 UnknownValue(serde_json::Value),
1261}
1262
1263#[derive(Debug, Clone, Serialize, Deserialize)]
1265#[serde(untagged)]
1266pub enum UpdateCustomFrameworkError {
1267 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1268 UnknownValue(serde_json::Value),
1269}
1270
1271#[derive(Debug, Clone, Serialize, Deserialize)]
1273#[serde(untagged)]
1274pub enum UpdateResourceEvaluationFiltersError {
1275 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1276 UnknownValue(serde_json::Value),
1277}
1278
1279#[derive(Debug, Clone, Serialize, Deserialize)]
1281#[serde(untagged)]
1282pub enum UpdateSecurityFilterError {
1283 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1284 UnknownValue(serde_json::Value),
1285}
1286
1287#[derive(Debug, Clone, Serialize, Deserialize)]
1289#[serde(untagged)]
1290pub enum UpdateSecurityMonitoringRuleError {
1291 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1292 UnknownValue(serde_json::Value),
1293}
1294
1295#[derive(Debug, Clone, Serialize, Deserialize)]
1297#[serde(untagged)]
1298pub enum UpdateSecurityMonitoringSuppressionError {
1299 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1300 UnknownValue(serde_json::Value),
1301}
1302
1303#[derive(Debug, Clone, Serialize, Deserialize)]
1305#[serde(untagged)]
1306pub enum ValidateSecurityMonitoringRuleError {
1307 APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1308 UnknownValue(serde_json::Value),
1309}
1310
1311#[derive(Debug, Clone)]
1313pub struct SecurityMonitoringAPI {
1314 config: datadog::Configuration,
1315 client: reqwest_middleware::ClientWithMiddleware,
1316}
1317
1318impl Default for SecurityMonitoringAPI {
1319 fn default() -> Self {
1320 Self::with_config(datadog::Configuration::default())
1321 }
1322}
1323
1324impl SecurityMonitoringAPI {
1325 pub fn new() -> Self {
1326 Self::default()
1327 }
1328 pub fn with_config(config: datadog::Configuration) -> Self {
1329 let mut reqwest_client_builder = reqwest::Client::builder();
1330
1331 if let Some(proxy_url) = &config.proxy_url {
1332 let proxy = reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL");
1333 reqwest_client_builder = reqwest_client_builder.proxy(proxy);
1334 }
1335
1336 let mut middleware_client_builder =
1337 reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap());
1338
1339 if config.enable_retry {
1340 struct RetryableStatus;
1341 impl reqwest_retry::RetryableStrategy for RetryableStatus {
1342 fn handle(
1343 &self,
1344 res: &Result<reqwest::Response, reqwest_middleware::Error>,
1345 ) -> Option<reqwest_retry::Retryable> {
1346 match res {
1347 Ok(success) => reqwest_retry::default_on_request_success(success),
1348 Err(_) => None,
1349 }
1350 }
1351 }
1352 let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder()
1353 .build_with_max_retries(config.max_retries);
1354
1355 let retry_middleware =
1356 reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy(
1357 backoff_policy,
1358 RetryableStatus,
1359 );
1360
1361 middleware_client_builder = middleware_client_builder.with(retry_middleware);
1362 }
1363
1364 let client = middleware_client_builder.build();
1365
1366 Self { config, client }
1367 }
1368
1369 pub fn with_client_and_config(
1370 config: datadog::Configuration,
1371 client: reqwest_middleware::ClientWithMiddleware,
1372 ) -> Self {
1373 Self { config, client }
1374 }
1375
1376 pub async fn cancel_historical_job(
1378 &self,
1379 job_id: String,
1380 ) -> Result<(), datadog::Error<CancelHistoricalJobError>> {
1381 match self.cancel_historical_job_with_http_info(job_id).await {
1382 Ok(_) => Ok(()),
1383 Err(err) => Err(err),
1384 }
1385 }
1386
1387 pub async fn cancel_historical_job_with_http_info(
1389 &self,
1390 job_id: String,
1391 ) -> Result<datadog::ResponseContent<()>, datadog::Error<CancelHistoricalJobError>> {
1392 let local_configuration = &self.config;
1393 let operation_id = "v2.cancel_historical_job";
1394 if local_configuration.is_unstable_operation_enabled(operation_id) {
1395 warn!("Using unstable operation {operation_id}");
1396 } else {
1397 let local_error = datadog::UnstableOperationDisabledError {
1398 msg: "Operation 'v2.cancel_historical_job' is not enabled".to_string(),
1399 };
1400 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
1401 }
1402
1403 let local_client = &self.client;
1404
1405 let local_uri_str = format!(
1406 "{}/api/v2/siem-historical-detections/jobs/{job_id}/cancel",
1407 local_configuration.get_operation_host(operation_id),
1408 job_id = datadog::urlencode(job_id)
1409 );
1410 let mut local_req_builder =
1411 local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
1412
1413 let mut headers = HeaderMap::new();
1415 headers.insert("Accept", HeaderValue::from_static("*/*"));
1416
1417 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1419 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1420 Err(e) => {
1421 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1422 headers.insert(
1423 reqwest::header::USER_AGENT,
1424 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1425 )
1426 }
1427 };
1428
1429 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1431 headers.insert(
1432 "DD-API-KEY",
1433 HeaderValue::from_str(local_key.key.as_str())
1434 .expect("failed to parse DD-API-KEY header"),
1435 );
1436 };
1437 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1438 headers.insert(
1439 "DD-APPLICATION-KEY",
1440 HeaderValue::from_str(local_key.key.as_str())
1441 .expect("failed to parse DD-APPLICATION-KEY header"),
1442 );
1443 };
1444
1445 local_req_builder = local_req_builder.headers(headers);
1446 let local_req = local_req_builder.build()?;
1447 log::debug!("request content: {:?}", local_req.body());
1448 let local_resp = local_client.execute(local_req).await?;
1449
1450 let local_status = local_resp.status();
1451 let local_content = local_resp.text().await?;
1452 log::debug!("response content: {}", local_content);
1453
1454 if !local_status.is_client_error() && !local_status.is_server_error() {
1455 Ok(datadog::ResponseContent {
1456 status: local_status,
1457 content: local_content,
1458 entity: None,
1459 })
1460 } else {
1461 let local_entity: Option<CancelHistoricalJobError> =
1462 serde_json::from_str(&local_content).ok();
1463 let local_error = datadog::ResponseContent {
1464 status: local_status,
1465 content: local_content,
1466 entity: local_entity,
1467 };
1468 Err(datadog::Error::ResponseError(local_error))
1469 }
1470 }
1471
1472 pub async fn convert_existing_security_monitoring_rule(
1475 &self,
1476 rule_id: String,
1477 ) -> Result<
1478 crate::datadogV2::model::SecurityMonitoringRuleConvertResponse,
1479 datadog::Error<ConvertExistingSecurityMonitoringRuleError>,
1480 > {
1481 match self
1482 .convert_existing_security_monitoring_rule_with_http_info(rule_id)
1483 .await
1484 {
1485 Ok(response_content) => {
1486 if let Some(e) = response_content.entity {
1487 Ok(e)
1488 } else {
1489 Err(datadog::Error::Serde(serde::de::Error::custom(
1490 "response content was None",
1491 )))
1492 }
1493 }
1494 Err(err) => Err(err),
1495 }
1496 }
1497
1498 pub async fn convert_existing_security_monitoring_rule_with_http_info(
1501 &self,
1502 rule_id: String,
1503 ) -> Result<
1504 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleConvertResponse>,
1505 datadog::Error<ConvertExistingSecurityMonitoringRuleError>,
1506 > {
1507 let local_configuration = &self.config;
1508 let operation_id = "v2.convert_existing_security_monitoring_rule";
1509
1510 let local_client = &self.client;
1511
1512 let local_uri_str = format!(
1513 "{}/api/v2/security_monitoring/rules/{rule_id}/convert",
1514 local_configuration.get_operation_host(operation_id),
1515 rule_id = datadog::urlencode(rule_id)
1516 );
1517 let mut local_req_builder =
1518 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1519
1520 let mut headers = HeaderMap::new();
1522 headers.insert("Accept", HeaderValue::from_static("application/json"));
1523
1524 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1526 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1527 Err(e) => {
1528 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1529 headers.insert(
1530 reqwest::header::USER_AGENT,
1531 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1532 )
1533 }
1534 };
1535
1536 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1538 headers.insert(
1539 "DD-API-KEY",
1540 HeaderValue::from_str(local_key.key.as_str())
1541 .expect("failed to parse DD-API-KEY header"),
1542 );
1543 };
1544 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1545 headers.insert(
1546 "DD-APPLICATION-KEY",
1547 HeaderValue::from_str(local_key.key.as_str())
1548 .expect("failed to parse DD-APPLICATION-KEY header"),
1549 );
1550 };
1551
1552 local_req_builder = local_req_builder.headers(headers);
1553 let local_req = local_req_builder.build()?;
1554 log::debug!("request content: {:?}", local_req.body());
1555 let local_resp = local_client.execute(local_req).await?;
1556
1557 let local_status = local_resp.status();
1558 let local_content = local_resp.text().await?;
1559 log::debug!("response content: {}", local_content);
1560
1561 if !local_status.is_client_error() && !local_status.is_server_error() {
1562 match serde_json::from_str::<
1563 crate::datadogV2::model::SecurityMonitoringRuleConvertResponse,
1564 >(&local_content)
1565 {
1566 Ok(e) => {
1567 return Ok(datadog::ResponseContent {
1568 status: local_status,
1569 content: local_content,
1570 entity: Some(e),
1571 })
1572 }
1573 Err(e) => return Err(datadog::Error::Serde(e)),
1574 };
1575 } else {
1576 let local_entity: Option<ConvertExistingSecurityMonitoringRuleError> =
1577 serde_json::from_str(&local_content).ok();
1578 let local_error = datadog::ResponseContent {
1579 status: local_status,
1580 content: local_content,
1581 entity: local_entity,
1582 };
1583 Err(datadog::Error::ResponseError(local_error))
1584 }
1585 }
1586
1587 pub async fn convert_job_result_to_signal(
1589 &self,
1590 body: crate::datadogV2::model::ConvertJobResultsToSignalsRequest,
1591 ) -> Result<(), datadog::Error<ConvertJobResultToSignalError>> {
1592 match self.convert_job_result_to_signal_with_http_info(body).await {
1593 Ok(_) => Ok(()),
1594 Err(err) => Err(err),
1595 }
1596 }
1597
1598 pub async fn convert_job_result_to_signal_with_http_info(
1600 &self,
1601 body: crate::datadogV2::model::ConvertJobResultsToSignalsRequest,
1602 ) -> Result<datadog::ResponseContent<()>, datadog::Error<ConvertJobResultToSignalError>> {
1603 let local_configuration = &self.config;
1604 let operation_id = "v2.convert_job_result_to_signal";
1605 if local_configuration.is_unstable_operation_enabled(operation_id) {
1606 warn!("Using unstable operation {operation_id}");
1607 } else {
1608 let local_error = datadog::UnstableOperationDisabledError {
1609 msg: "Operation 'v2.convert_job_result_to_signal' is not enabled".to_string(),
1610 };
1611 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
1612 }
1613
1614 let local_client = &self.client;
1615
1616 let local_uri_str = format!(
1617 "{}/api/v2/siem-historical-detections/jobs/signal_convert",
1618 local_configuration.get_operation_host(operation_id)
1619 );
1620 let mut local_req_builder =
1621 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
1622
1623 let mut headers = HeaderMap::new();
1625 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1626 headers.insert("Accept", HeaderValue::from_static("*/*"));
1627
1628 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1630 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1631 Err(e) => {
1632 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1633 headers.insert(
1634 reqwest::header::USER_AGENT,
1635 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1636 )
1637 }
1638 };
1639
1640 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1642 headers.insert(
1643 "DD-API-KEY",
1644 HeaderValue::from_str(local_key.key.as_str())
1645 .expect("failed to parse DD-API-KEY header"),
1646 );
1647 };
1648 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1649 headers.insert(
1650 "DD-APPLICATION-KEY",
1651 HeaderValue::from_str(local_key.key.as_str())
1652 .expect("failed to parse DD-APPLICATION-KEY header"),
1653 );
1654 };
1655
1656 let output = Vec::new();
1658 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1659 if body.serialize(&mut ser).is_ok() {
1660 if let Some(content_encoding) = headers.get("Content-Encoding") {
1661 match content_encoding.to_str().unwrap_or_default() {
1662 "gzip" => {
1663 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1664 let _ = enc.write_all(ser.into_inner().as_slice());
1665 match enc.finish() {
1666 Ok(buf) => {
1667 local_req_builder = local_req_builder.body(buf);
1668 }
1669 Err(e) => return Err(datadog::Error::Io(e)),
1670 }
1671 }
1672 "deflate" => {
1673 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1674 let _ = enc.write_all(ser.into_inner().as_slice());
1675 match enc.finish() {
1676 Ok(buf) => {
1677 local_req_builder = local_req_builder.body(buf);
1678 }
1679 Err(e) => return Err(datadog::Error::Io(e)),
1680 }
1681 }
1682 "zstd1" => {
1683 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1684 let _ = enc.write_all(ser.into_inner().as_slice());
1685 match enc.finish() {
1686 Ok(buf) => {
1687 local_req_builder = local_req_builder.body(buf);
1688 }
1689 Err(e) => return Err(datadog::Error::Io(e)),
1690 }
1691 }
1692 _ => {
1693 local_req_builder = local_req_builder.body(ser.into_inner());
1694 }
1695 }
1696 } else {
1697 local_req_builder = local_req_builder.body(ser.into_inner());
1698 }
1699 }
1700
1701 local_req_builder = local_req_builder.headers(headers);
1702 let local_req = local_req_builder.build()?;
1703 log::debug!("request content: {:?}", local_req.body());
1704 let local_resp = local_client.execute(local_req).await?;
1705
1706 let local_status = local_resp.status();
1707 let local_content = local_resp.text().await?;
1708 log::debug!("response content: {}", local_content);
1709
1710 if !local_status.is_client_error() && !local_status.is_server_error() {
1711 Ok(datadog::ResponseContent {
1712 status: local_status,
1713 content: local_content,
1714 entity: None,
1715 })
1716 } else {
1717 let local_entity: Option<ConvertJobResultToSignalError> =
1718 serde_json::from_str(&local_content).ok();
1719 let local_error = datadog::ResponseContent {
1720 status: local_status,
1721 content: local_content,
1722 entity: local_entity,
1723 };
1724 Err(datadog::Error::ResponseError(local_error))
1725 }
1726 }
1727
1728 pub async fn convert_security_monitoring_rule_from_json_to_terraform(
1731 &self,
1732 body: crate::datadogV2::model::SecurityMonitoringRuleConvertPayload,
1733 ) -> Result<
1734 crate::datadogV2::model::SecurityMonitoringRuleConvertResponse,
1735 datadog::Error<ConvertSecurityMonitoringRuleFromJSONToTerraformError>,
1736 > {
1737 match self
1738 .convert_security_monitoring_rule_from_json_to_terraform_with_http_info(body)
1739 .await
1740 {
1741 Ok(response_content) => {
1742 if let Some(e) = response_content.entity {
1743 Ok(e)
1744 } else {
1745 Err(datadog::Error::Serde(serde::de::Error::custom(
1746 "response content was None",
1747 )))
1748 }
1749 }
1750 Err(err) => Err(err),
1751 }
1752 }
1753
1754 pub async fn convert_security_monitoring_rule_from_json_to_terraform_with_http_info(
1757 &self,
1758 body: crate::datadogV2::model::SecurityMonitoringRuleConvertPayload,
1759 ) -> Result<
1760 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleConvertResponse>,
1761 datadog::Error<ConvertSecurityMonitoringRuleFromJSONToTerraformError>,
1762 > {
1763 let local_configuration = &self.config;
1764 let operation_id = "v2.convert_security_monitoring_rule_from_json_to_terraform";
1765
1766 let local_client = &self.client;
1767
1768 let local_uri_str = format!(
1769 "{}/api/v2/security_monitoring/rules/convert",
1770 local_configuration.get_operation_host(operation_id)
1771 );
1772 let mut local_req_builder =
1773 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
1774
1775 let mut headers = HeaderMap::new();
1777 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1778 headers.insert("Accept", HeaderValue::from_static("application/json"));
1779
1780 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1782 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1783 Err(e) => {
1784 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1785 headers.insert(
1786 reqwest::header::USER_AGENT,
1787 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1788 )
1789 }
1790 };
1791
1792 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1794 headers.insert(
1795 "DD-API-KEY",
1796 HeaderValue::from_str(local_key.key.as_str())
1797 .expect("failed to parse DD-API-KEY header"),
1798 );
1799 };
1800 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1801 headers.insert(
1802 "DD-APPLICATION-KEY",
1803 HeaderValue::from_str(local_key.key.as_str())
1804 .expect("failed to parse DD-APPLICATION-KEY header"),
1805 );
1806 };
1807
1808 let output = Vec::new();
1810 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1811 if body.serialize(&mut ser).is_ok() {
1812 if let Some(content_encoding) = headers.get("Content-Encoding") {
1813 match content_encoding.to_str().unwrap_or_default() {
1814 "gzip" => {
1815 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1816 let _ = enc.write_all(ser.into_inner().as_slice());
1817 match enc.finish() {
1818 Ok(buf) => {
1819 local_req_builder = local_req_builder.body(buf);
1820 }
1821 Err(e) => return Err(datadog::Error::Io(e)),
1822 }
1823 }
1824 "deflate" => {
1825 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1826 let _ = enc.write_all(ser.into_inner().as_slice());
1827 match enc.finish() {
1828 Ok(buf) => {
1829 local_req_builder = local_req_builder.body(buf);
1830 }
1831 Err(e) => return Err(datadog::Error::Io(e)),
1832 }
1833 }
1834 "zstd1" => {
1835 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1836 let _ = enc.write_all(ser.into_inner().as_slice());
1837 match enc.finish() {
1838 Ok(buf) => {
1839 local_req_builder = local_req_builder.body(buf);
1840 }
1841 Err(e) => return Err(datadog::Error::Io(e)),
1842 }
1843 }
1844 _ => {
1845 local_req_builder = local_req_builder.body(ser.into_inner());
1846 }
1847 }
1848 } else {
1849 local_req_builder = local_req_builder.body(ser.into_inner());
1850 }
1851 }
1852
1853 local_req_builder = local_req_builder.headers(headers);
1854 let local_req = local_req_builder.build()?;
1855 log::debug!("request content: {:?}", local_req.body());
1856 let local_resp = local_client.execute(local_req).await?;
1857
1858 let local_status = local_resp.status();
1859 let local_content = local_resp.text().await?;
1860 log::debug!("response content: {}", local_content);
1861
1862 if !local_status.is_client_error() && !local_status.is_server_error() {
1863 match serde_json::from_str::<
1864 crate::datadogV2::model::SecurityMonitoringRuleConvertResponse,
1865 >(&local_content)
1866 {
1867 Ok(e) => {
1868 return Ok(datadog::ResponseContent {
1869 status: local_status,
1870 content: local_content,
1871 entity: Some(e),
1872 })
1873 }
1874 Err(e) => return Err(datadog::Error::Serde(e)),
1875 };
1876 } else {
1877 let local_entity: Option<ConvertSecurityMonitoringRuleFromJSONToTerraformError> =
1878 serde_json::from_str(&local_content).ok();
1879 let local_error = datadog::ResponseContent {
1880 status: local_status,
1881 content: local_content,
1882 entity: local_entity,
1883 };
1884 Err(datadog::Error::ResponseError(local_error))
1885 }
1886 }
1887
1888 pub async fn create_custom_framework(
1890 &self,
1891 body: crate::datadogV2::model::CreateCustomFrameworkRequest,
1892 ) -> Result<
1893 crate::datadogV2::model::CreateCustomFrameworkResponse,
1894 datadog::Error<CreateCustomFrameworkError>,
1895 > {
1896 match self.create_custom_framework_with_http_info(body).await {
1897 Ok(response_content) => {
1898 if let Some(e) = response_content.entity {
1899 Ok(e)
1900 } else {
1901 Err(datadog::Error::Serde(serde::de::Error::custom(
1902 "response content was None",
1903 )))
1904 }
1905 }
1906 Err(err) => Err(err),
1907 }
1908 }
1909
1910 pub async fn create_custom_framework_with_http_info(
1912 &self,
1913 body: crate::datadogV2::model::CreateCustomFrameworkRequest,
1914 ) -> Result<
1915 datadog::ResponseContent<crate::datadogV2::model::CreateCustomFrameworkResponse>,
1916 datadog::Error<CreateCustomFrameworkError>,
1917 > {
1918 let local_configuration = &self.config;
1919 let operation_id = "v2.create_custom_framework";
1920
1921 let local_client = &self.client;
1922
1923 let local_uri_str = format!(
1924 "{}/api/v2/cloud_security_management/custom_frameworks",
1925 local_configuration.get_operation_host(operation_id)
1926 );
1927 let mut local_req_builder =
1928 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
1929
1930 let mut headers = HeaderMap::new();
1932 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1933 headers.insert("Accept", HeaderValue::from_static("application/json"));
1934
1935 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1937 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1938 Err(e) => {
1939 log::warn!("Failed to parse user agent header: {e}, falling back to default");
1940 headers.insert(
1941 reqwest::header::USER_AGENT,
1942 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1943 )
1944 }
1945 };
1946
1947 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1949 headers.insert(
1950 "DD-API-KEY",
1951 HeaderValue::from_str(local_key.key.as_str())
1952 .expect("failed to parse DD-API-KEY header"),
1953 );
1954 };
1955 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1956 headers.insert(
1957 "DD-APPLICATION-KEY",
1958 HeaderValue::from_str(local_key.key.as_str())
1959 .expect("failed to parse DD-APPLICATION-KEY header"),
1960 );
1961 };
1962
1963 let output = Vec::new();
1965 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1966 if body.serialize(&mut ser).is_ok() {
1967 if let Some(content_encoding) = headers.get("Content-Encoding") {
1968 match content_encoding.to_str().unwrap_or_default() {
1969 "gzip" => {
1970 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1971 let _ = enc.write_all(ser.into_inner().as_slice());
1972 match enc.finish() {
1973 Ok(buf) => {
1974 local_req_builder = local_req_builder.body(buf);
1975 }
1976 Err(e) => return Err(datadog::Error::Io(e)),
1977 }
1978 }
1979 "deflate" => {
1980 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1981 let _ = enc.write_all(ser.into_inner().as_slice());
1982 match enc.finish() {
1983 Ok(buf) => {
1984 local_req_builder = local_req_builder.body(buf);
1985 }
1986 Err(e) => return Err(datadog::Error::Io(e)),
1987 }
1988 }
1989 "zstd1" => {
1990 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
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 _ => {
2000 local_req_builder = local_req_builder.body(ser.into_inner());
2001 }
2002 }
2003 } else {
2004 local_req_builder = local_req_builder.body(ser.into_inner());
2005 }
2006 }
2007
2008 local_req_builder = local_req_builder.headers(headers);
2009 let local_req = local_req_builder.build()?;
2010 log::debug!("request content: {:?}", local_req.body());
2011 let local_resp = local_client.execute(local_req).await?;
2012
2013 let local_status = local_resp.status();
2014 let local_content = local_resp.text().await?;
2015 log::debug!("response content: {}", local_content);
2016
2017 if !local_status.is_client_error() && !local_status.is_server_error() {
2018 match serde_json::from_str::<crate::datadogV2::model::CreateCustomFrameworkResponse>(
2019 &local_content,
2020 ) {
2021 Ok(e) => {
2022 return Ok(datadog::ResponseContent {
2023 status: local_status,
2024 content: local_content,
2025 entity: Some(e),
2026 })
2027 }
2028 Err(e) => return Err(datadog::Error::Serde(e)),
2029 };
2030 } else {
2031 let local_entity: Option<CreateCustomFrameworkError> =
2032 serde_json::from_str(&local_content).ok();
2033 let local_error = datadog::ResponseContent {
2034 status: local_status,
2035 content: local_content,
2036 entity: local_entity,
2037 };
2038 Err(datadog::Error::ResponseError(local_error))
2039 }
2040 }
2041
2042 pub async fn create_security_filter(
2047 &self,
2048 body: crate::datadogV2::model::SecurityFilterCreateRequest,
2049 ) -> Result<
2050 crate::datadogV2::model::SecurityFilterResponse,
2051 datadog::Error<CreateSecurityFilterError>,
2052 > {
2053 match self.create_security_filter_with_http_info(body).await {
2054 Ok(response_content) => {
2055 if let Some(e) = response_content.entity {
2056 Ok(e)
2057 } else {
2058 Err(datadog::Error::Serde(serde::de::Error::custom(
2059 "response content was None",
2060 )))
2061 }
2062 }
2063 Err(err) => Err(err),
2064 }
2065 }
2066
2067 pub async fn create_security_filter_with_http_info(
2072 &self,
2073 body: crate::datadogV2::model::SecurityFilterCreateRequest,
2074 ) -> Result<
2075 datadog::ResponseContent<crate::datadogV2::model::SecurityFilterResponse>,
2076 datadog::Error<CreateSecurityFilterError>,
2077 > {
2078 let local_configuration = &self.config;
2079 let operation_id = "v2.create_security_filter";
2080
2081 let local_client = &self.client;
2082
2083 let local_uri_str = format!(
2084 "{}/api/v2/security_monitoring/configuration/security_filters",
2085 local_configuration.get_operation_host(operation_id)
2086 );
2087 let mut local_req_builder =
2088 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
2089
2090 let mut headers = HeaderMap::new();
2092 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
2093 headers.insert("Accept", HeaderValue::from_static("application/json"));
2094
2095 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2097 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2098 Err(e) => {
2099 log::warn!("Failed to parse user agent header: {e}, falling back to default");
2100 headers.insert(
2101 reqwest::header::USER_AGENT,
2102 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2103 )
2104 }
2105 };
2106
2107 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2109 headers.insert(
2110 "DD-API-KEY",
2111 HeaderValue::from_str(local_key.key.as_str())
2112 .expect("failed to parse DD-API-KEY header"),
2113 );
2114 };
2115 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2116 headers.insert(
2117 "DD-APPLICATION-KEY",
2118 HeaderValue::from_str(local_key.key.as_str())
2119 .expect("failed to parse DD-APPLICATION-KEY header"),
2120 );
2121 };
2122
2123 let output = Vec::new();
2125 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
2126 if body.serialize(&mut ser).is_ok() {
2127 if let Some(content_encoding) = headers.get("Content-Encoding") {
2128 match content_encoding.to_str().unwrap_or_default() {
2129 "gzip" => {
2130 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
2131 let _ = enc.write_all(ser.into_inner().as_slice());
2132 match enc.finish() {
2133 Ok(buf) => {
2134 local_req_builder = local_req_builder.body(buf);
2135 }
2136 Err(e) => return Err(datadog::Error::Io(e)),
2137 }
2138 }
2139 "deflate" => {
2140 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
2141 let _ = enc.write_all(ser.into_inner().as_slice());
2142 match enc.finish() {
2143 Ok(buf) => {
2144 local_req_builder = local_req_builder.body(buf);
2145 }
2146 Err(e) => return Err(datadog::Error::Io(e)),
2147 }
2148 }
2149 "zstd1" => {
2150 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
2151 let _ = enc.write_all(ser.into_inner().as_slice());
2152 match enc.finish() {
2153 Ok(buf) => {
2154 local_req_builder = local_req_builder.body(buf);
2155 }
2156 Err(e) => return Err(datadog::Error::Io(e)),
2157 }
2158 }
2159 _ => {
2160 local_req_builder = local_req_builder.body(ser.into_inner());
2161 }
2162 }
2163 } else {
2164 local_req_builder = local_req_builder.body(ser.into_inner());
2165 }
2166 }
2167
2168 local_req_builder = local_req_builder.headers(headers);
2169 let local_req = local_req_builder.build()?;
2170 log::debug!("request content: {:?}", local_req.body());
2171 let local_resp = local_client.execute(local_req).await?;
2172
2173 let local_status = local_resp.status();
2174 let local_content = local_resp.text().await?;
2175 log::debug!("response content: {}", local_content);
2176
2177 if !local_status.is_client_error() && !local_status.is_server_error() {
2178 match serde_json::from_str::<crate::datadogV2::model::SecurityFilterResponse>(
2179 &local_content,
2180 ) {
2181 Ok(e) => {
2182 return Ok(datadog::ResponseContent {
2183 status: local_status,
2184 content: local_content,
2185 entity: Some(e),
2186 })
2187 }
2188 Err(e) => return Err(datadog::Error::Serde(e)),
2189 };
2190 } else {
2191 let local_entity: Option<CreateSecurityFilterError> =
2192 serde_json::from_str(&local_content).ok();
2193 let local_error = datadog::ResponseContent {
2194 status: local_status,
2195 content: local_content,
2196 entity: local_entity,
2197 };
2198 Err(datadog::Error::ResponseError(local_error))
2199 }
2200 }
2201
2202 pub async fn create_security_monitoring_rule(
2204 &self,
2205 body: crate::datadogV2::model::SecurityMonitoringRuleCreatePayload,
2206 ) -> Result<
2207 crate::datadogV2::model::SecurityMonitoringRuleResponse,
2208 datadog::Error<CreateSecurityMonitoringRuleError>,
2209 > {
2210 match self
2211 .create_security_monitoring_rule_with_http_info(body)
2212 .await
2213 {
2214 Ok(response_content) => {
2215 if let Some(e) = response_content.entity {
2216 Ok(e)
2217 } else {
2218 Err(datadog::Error::Serde(serde::de::Error::custom(
2219 "response content was None",
2220 )))
2221 }
2222 }
2223 Err(err) => Err(err),
2224 }
2225 }
2226
2227 pub async fn create_security_monitoring_rule_with_http_info(
2229 &self,
2230 body: crate::datadogV2::model::SecurityMonitoringRuleCreatePayload,
2231 ) -> Result<
2232 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleResponse>,
2233 datadog::Error<CreateSecurityMonitoringRuleError>,
2234 > {
2235 let local_configuration = &self.config;
2236 let operation_id = "v2.create_security_monitoring_rule";
2237
2238 let local_client = &self.client;
2239
2240 let local_uri_str = format!(
2241 "{}/api/v2/security_monitoring/rules",
2242 local_configuration.get_operation_host(operation_id)
2243 );
2244 let mut local_req_builder =
2245 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
2246
2247 let mut headers = HeaderMap::new();
2249 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
2250 headers.insert("Accept", HeaderValue::from_static("application/json"));
2251
2252 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2254 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2255 Err(e) => {
2256 log::warn!("Failed to parse user agent header: {e}, falling back to default");
2257 headers.insert(
2258 reqwest::header::USER_AGENT,
2259 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2260 )
2261 }
2262 };
2263
2264 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2266 headers.insert(
2267 "DD-API-KEY",
2268 HeaderValue::from_str(local_key.key.as_str())
2269 .expect("failed to parse DD-API-KEY header"),
2270 );
2271 };
2272 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2273 headers.insert(
2274 "DD-APPLICATION-KEY",
2275 HeaderValue::from_str(local_key.key.as_str())
2276 .expect("failed to parse DD-APPLICATION-KEY header"),
2277 );
2278 };
2279
2280 let output = Vec::new();
2282 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
2283 if body.serialize(&mut ser).is_ok() {
2284 if let Some(content_encoding) = headers.get("Content-Encoding") {
2285 match content_encoding.to_str().unwrap_or_default() {
2286 "gzip" => {
2287 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
2288 let _ = enc.write_all(ser.into_inner().as_slice());
2289 match enc.finish() {
2290 Ok(buf) => {
2291 local_req_builder = local_req_builder.body(buf);
2292 }
2293 Err(e) => return Err(datadog::Error::Io(e)),
2294 }
2295 }
2296 "deflate" => {
2297 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
2298 let _ = enc.write_all(ser.into_inner().as_slice());
2299 match enc.finish() {
2300 Ok(buf) => {
2301 local_req_builder = local_req_builder.body(buf);
2302 }
2303 Err(e) => return Err(datadog::Error::Io(e)),
2304 }
2305 }
2306 "zstd1" => {
2307 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
2308 let _ = enc.write_all(ser.into_inner().as_slice());
2309 match enc.finish() {
2310 Ok(buf) => {
2311 local_req_builder = local_req_builder.body(buf);
2312 }
2313 Err(e) => return Err(datadog::Error::Io(e)),
2314 }
2315 }
2316 _ => {
2317 local_req_builder = local_req_builder.body(ser.into_inner());
2318 }
2319 }
2320 } else {
2321 local_req_builder = local_req_builder.body(ser.into_inner());
2322 }
2323 }
2324
2325 local_req_builder = local_req_builder.headers(headers);
2326 let local_req = local_req_builder.build()?;
2327 log::debug!("request content: {:?}", local_req.body());
2328 let local_resp = local_client.execute(local_req).await?;
2329
2330 let local_status = local_resp.status();
2331 let local_content = local_resp.text().await?;
2332 log::debug!("response content: {}", local_content);
2333
2334 if !local_status.is_client_error() && !local_status.is_server_error() {
2335 match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringRuleResponse>(
2336 &local_content,
2337 ) {
2338 Ok(e) => {
2339 return Ok(datadog::ResponseContent {
2340 status: local_status,
2341 content: local_content,
2342 entity: Some(e),
2343 })
2344 }
2345 Err(e) => return Err(datadog::Error::Serde(e)),
2346 };
2347 } else {
2348 let local_entity: Option<CreateSecurityMonitoringRuleError> =
2349 serde_json::from_str(&local_content).ok();
2350 let local_error = datadog::ResponseContent {
2351 status: local_status,
2352 content: local_content,
2353 entity: local_entity,
2354 };
2355 Err(datadog::Error::ResponseError(local_error))
2356 }
2357 }
2358
2359 pub async fn create_security_monitoring_suppression(
2361 &self,
2362 body: crate::datadogV2::model::SecurityMonitoringSuppressionCreateRequest,
2363 ) -> Result<
2364 crate::datadogV2::model::SecurityMonitoringSuppressionResponse,
2365 datadog::Error<CreateSecurityMonitoringSuppressionError>,
2366 > {
2367 match self
2368 .create_security_monitoring_suppression_with_http_info(body)
2369 .await
2370 {
2371 Ok(response_content) => {
2372 if let Some(e) = response_content.entity {
2373 Ok(e)
2374 } else {
2375 Err(datadog::Error::Serde(serde::de::Error::custom(
2376 "response content was None",
2377 )))
2378 }
2379 }
2380 Err(err) => Err(err),
2381 }
2382 }
2383
2384 pub async fn create_security_monitoring_suppression_with_http_info(
2386 &self,
2387 body: crate::datadogV2::model::SecurityMonitoringSuppressionCreateRequest,
2388 ) -> Result<
2389 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSuppressionResponse>,
2390 datadog::Error<CreateSecurityMonitoringSuppressionError>,
2391 > {
2392 let local_configuration = &self.config;
2393 let operation_id = "v2.create_security_monitoring_suppression";
2394
2395 let local_client = &self.client;
2396
2397 let local_uri_str = format!(
2398 "{}/api/v2/security_monitoring/configuration/suppressions",
2399 local_configuration.get_operation_host(operation_id)
2400 );
2401 let mut local_req_builder =
2402 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
2403
2404 let mut headers = HeaderMap::new();
2406 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
2407 headers.insert("Accept", HeaderValue::from_static("application/json"));
2408
2409 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2411 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2412 Err(e) => {
2413 log::warn!("Failed to parse user agent header: {e}, falling back to default");
2414 headers.insert(
2415 reqwest::header::USER_AGENT,
2416 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2417 )
2418 }
2419 };
2420
2421 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2423 headers.insert(
2424 "DD-API-KEY",
2425 HeaderValue::from_str(local_key.key.as_str())
2426 .expect("failed to parse DD-API-KEY header"),
2427 );
2428 };
2429 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2430 headers.insert(
2431 "DD-APPLICATION-KEY",
2432 HeaderValue::from_str(local_key.key.as_str())
2433 .expect("failed to parse DD-APPLICATION-KEY header"),
2434 );
2435 };
2436
2437 let output = Vec::new();
2439 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
2440 if body.serialize(&mut ser).is_ok() {
2441 if let Some(content_encoding) = headers.get("Content-Encoding") {
2442 match content_encoding.to_str().unwrap_or_default() {
2443 "gzip" => {
2444 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
2445 let _ = enc.write_all(ser.into_inner().as_slice());
2446 match enc.finish() {
2447 Ok(buf) => {
2448 local_req_builder = local_req_builder.body(buf);
2449 }
2450 Err(e) => return Err(datadog::Error::Io(e)),
2451 }
2452 }
2453 "deflate" => {
2454 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
2455 let _ = enc.write_all(ser.into_inner().as_slice());
2456 match enc.finish() {
2457 Ok(buf) => {
2458 local_req_builder = local_req_builder.body(buf);
2459 }
2460 Err(e) => return Err(datadog::Error::Io(e)),
2461 }
2462 }
2463 "zstd1" => {
2464 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
2465 let _ = enc.write_all(ser.into_inner().as_slice());
2466 match enc.finish() {
2467 Ok(buf) => {
2468 local_req_builder = local_req_builder.body(buf);
2469 }
2470 Err(e) => return Err(datadog::Error::Io(e)),
2471 }
2472 }
2473 _ => {
2474 local_req_builder = local_req_builder.body(ser.into_inner());
2475 }
2476 }
2477 } else {
2478 local_req_builder = local_req_builder.body(ser.into_inner());
2479 }
2480 }
2481
2482 local_req_builder = local_req_builder.headers(headers);
2483 let local_req = local_req_builder.build()?;
2484 log::debug!("request content: {:?}", local_req.body());
2485 let local_resp = local_client.execute(local_req).await?;
2486
2487 let local_status = local_resp.status();
2488 let local_content = local_resp.text().await?;
2489 log::debug!("response content: {}", local_content);
2490
2491 if !local_status.is_client_error() && !local_status.is_server_error() {
2492 match serde_json::from_str::<
2493 crate::datadogV2::model::SecurityMonitoringSuppressionResponse,
2494 >(&local_content)
2495 {
2496 Ok(e) => {
2497 return Ok(datadog::ResponseContent {
2498 status: local_status,
2499 content: local_content,
2500 entity: Some(e),
2501 })
2502 }
2503 Err(e) => return Err(datadog::Error::Serde(e)),
2504 };
2505 } else {
2506 let local_entity: Option<CreateSecurityMonitoringSuppressionError> =
2507 serde_json::from_str(&local_content).ok();
2508 let local_error = datadog::ResponseContent {
2509 status: local_status,
2510 content: local_content,
2511 entity: local_entity,
2512 };
2513 Err(datadog::Error::ResponseError(local_error))
2514 }
2515 }
2516
2517 pub async fn create_signal_notification_rule(
2519 &self,
2520 body: crate::datadogV2::model::CreateNotificationRuleParameters,
2521 ) -> Result<
2522 crate::datadogV2::model::NotificationRuleResponse,
2523 datadog::Error<CreateSignalNotificationRuleError>,
2524 > {
2525 match self
2526 .create_signal_notification_rule_with_http_info(body)
2527 .await
2528 {
2529 Ok(response_content) => {
2530 if let Some(e) = response_content.entity {
2531 Ok(e)
2532 } else {
2533 Err(datadog::Error::Serde(serde::de::Error::custom(
2534 "response content was None",
2535 )))
2536 }
2537 }
2538 Err(err) => Err(err),
2539 }
2540 }
2541
2542 pub async fn create_signal_notification_rule_with_http_info(
2544 &self,
2545 body: crate::datadogV2::model::CreateNotificationRuleParameters,
2546 ) -> Result<
2547 datadog::ResponseContent<crate::datadogV2::model::NotificationRuleResponse>,
2548 datadog::Error<CreateSignalNotificationRuleError>,
2549 > {
2550 let local_configuration = &self.config;
2551 let operation_id = "v2.create_signal_notification_rule";
2552
2553 let local_client = &self.client;
2554
2555 let local_uri_str = format!(
2556 "{}/api/v2/security/signals/notification_rules",
2557 local_configuration.get_operation_host(operation_id)
2558 );
2559 let mut local_req_builder =
2560 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
2561
2562 let mut headers = HeaderMap::new();
2564 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
2565 headers.insert("Accept", HeaderValue::from_static("application/json"));
2566
2567 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2569 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2570 Err(e) => {
2571 log::warn!("Failed to parse user agent header: {e}, falling back to default");
2572 headers.insert(
2573 reqwest::header::USER_AGENT,
2574 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2575 )
2576 }
2577 };
2578
2579 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2581 headers.insert(
2582 "DD-API-KEY",
2583 HeaderValue::from_str(local_key.key.as_str())
2584 .expect("failed to parse DD-API-KEY header"),
2585 );
2586 };
2587 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2588 headers.insert(
2589 "DD-APPLICATION-KEY",
2590 HeaderValue::from_str(local_key.key.as_str())
2591 .expect("failed to parse DD-APPLICATION-KEY header"),
2592 );
2593 };
2594
2595 let output = Vec::new();
2597 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
2598 if body.serialize(&mut ser).is_ok() {
2599 if let Some(content_encoding) = headers.get("Content-Encoding") {
2600 match content_encoding.to_str().unwrap_or_default() {
2601 "gzip" => {
2602 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
2603 let _ = enc.write_all(ser.into_inner().as_slice());
2604 match enc.finish() {
2605 Ok(buf) => {
2606 local_req_builder = local_req_builder.body(buf);
2607 }
2608 Err(e) => return Err(datadog::Error::Io(e)),
2609 }
2610 }
2611 "deflate" => {
2612 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
2613 let _ = enc.write_all(ser.into_inner().as_slice());
2614 match enc.finish() {
2615 Ok(buf) => {
2616 local_req_builder = local_req_builder.body(buf);
2617 }
2618 Err(e) => return Err(datadog::Error::Io(e)),
2619 }
2620 }
2621 "zstd1" => {
2622 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
2623 let _ = enc.write_all(ser.into_inner().as_slice());
2624 match enc.finish() {
2625 Ok(buf) => {
2626 local_req_builder = local_req_builder.body(buf);
2627 }
2628 Err(e) => return Err(datadog::Error::Io(e)),
2629 }
2630 }
2631 _ => {
2632 local_req_builder = local_req_builder.body(ser.into_inner());
2633 }
2634 }
2635 } else {
2636 local_req_builder = local_req_builder.body(ser.into_inner());
2637 }
2638 }
2639
2640 local_req_builder = local_req_builder.headers(headers);
2641 let local_req = local_req_builder.build()?;
2642 log::debug!("request content: {:?}", local_req.body());
2643 let local_resp = local_client.execute(local_req).await?;
2644
2645 let local_status = local_resp.status();
2646 let local_content = local_resp.text().await?;
2647 log::debug!("response content: {}", local_content);
2648
2649 if !local_status.is_client_error() && !local_status.is_server_error() {
2650 match serde_json::from_str::<crate::datadogV2::model::NotificationRuleResponse>(
2651 &local_content,
2652 ) {
2653 Ok(e) => {
2654 return Ok(datadog::ResponseContent {
2655 status: local_status,
2656 content: local_content,
2657 entity: Some(e),
2658 })
2659 }
2660 Err(e) => return Err(datadog::Error::Serde(e)),
2661 };
2662 } else {
2663 let local_entity: Option<CreateSignalNotificationRuleError> =
2664 serde_json::from_str(&local_content).ok();
2665 let local_error = datadog::ResponseContent {
2666 status: local_status,
2667 content: local_content,
2668 entity: local_entity,
2669 };
2670 Err(datadog::Error::ResponseError(local_error))
2671 }
2672 }
2673
2674 pub async fn create_vulnerability_notification_rule(
2676 &self,
2677 body: crate::datadogV2::model::CreateNotificationRuleParameters,
2678 ) -> Result<
2679 crate::datadogV2::model::NotificationRuleResponse,
2680 datadog::Error<CreateVulnerabilityNotificationRuleError>,
2681 > {
2682 match self
2683 .create_vulnerability_notification_rule_with_http_info(body)
2684 .await
2685 {
2686 Ok(response_content) => {
2687 if let Some(e) = response_content.entity {
2688 Ok(e)
2689 } else {
2690 Err(datadog::Error::Serde(serde::de::Error::custom(
2691 "response content was None",
2692 )))
2693 }
2694 }
2695 Err(err) => Err(err),
2696 }
2697 }
2698
2699 pub async fn create_vulnerability_notification_rule_with_http_info(
2701 &self,
2702 body: crate::datadogV2::model::CreateNotificationRuleParameters,
2703 ) -> Result<
2704 datadog::ResponseContent<crate::datadogV2::model::NotificationRuleResponse>,
2705 datadog::Error<CreateVulnerabilityNotificationRuleError>,
2706 > {
2707 let local_configuration = &self.config;
2708 let operation_id = "v2.create_vulnerability_notification_rule";
2709
2710 let local_client = &self.client;
2711
2712 let local_uri_str = format!(
2713 "{}/api/v2/security/vulnerabilities/notification_rules",
2714 local_configuration.get_operation_host(operation_id)
2715 );
2716 let mut local_req_builder =
2717 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
2718
2719 let mut headers = HeaderMap::new();
2721 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
2722 headers.insert("Accept", HeaderValue::from_static("application/json"));
2723
2724 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2726 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2727 Err(e) => {
2728 log::warn!("Failed to parse user agent header: {e}, falling back to default");
2729 headers.insert(
2730 reqwest::header::USER_AGENT,
2731 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2732 )
2733 }
2734 };
2735
2736 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2738 headers.insert(
2739 "DD-API-KEY",
2740 HeaderValue::from_str(local_key.key.as_str())
2741 .expect("failed to parse DD-API-KEY header"),
2742 );
2743 };
2744 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2745 headers.insert(
2746 "DD-APPLICATION-KEY",
2747 HeaderValue::from_str(local_key.key.as_str())
2748 .expect("failed to parse DD-APPLICATION-KEY header"),
2749 );
2750 };
2751
2752 let output = Vec::new();
2754 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
2755 if body.serialize(&mut ser).is_ok() {
2756 if let Some(content_encoding) = headers.get("Content-Encoding") {
2757 match content_encoding.to_str().unwrap_or_default() {
2758 "gzip" => {
2759 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
2760 let _ = enc.write_all(ser.into_inner().as_slice());
2761 match enc.finish() {
2762 Ok(buf) => {
2763 local_req_builder = local_req_builder.body(buf);
2764 }
2765 Err(e) => return Err(datadog::Error::Io(e)),
2766 }
2767 }
2768 "deflate" => {
2769 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
2770 let _ = enc.write_all(ser.into_inner().as_slice());
2771 match enc.finish() {
2772 Ok(buf) => {
2773 local_req_builder = local_req_builder.body(buf);
2774 }
2775 Err(e) => return Err(datadog::Error::Io(e)),
2776 }
2777 }
2778 "zstd1" => {
2779 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
2780 let _ = enc.write_all(ser.into_inner().as_slice());
2781 match enc.finish() {
2782 Ok(buf) => {
2783 local_req_builder = local_req_builder.body(buf);
2784 }
2785 Err(e) => return Err(datadog::Error::Io(e)),
2786 }
2787 }
2788 _ => {
2789 local_req_builder = local_req_builder.body(ser.into_inner());
2790 }
2791 }
2792 } else {
2793 local_req_builder = local_req_builder.body(ser.into_inner());
2794 }
2795 }
2796
2797 local_req_builder = local_req_builder.headers(headers);
2798 let local_req = local_req_builder.build()?;
2799 log::debug!("request content: {:?}", local_req.body());
2800 let local_resp = local_client.execute(local_req).await?;
2801
2802 let local_status = local_resp.status();
2803 let local_content = local_resp.text().await?;
2804 log::debug!("response content: {}", local_content);
2805
2806 if !local_status.is_client_error() && !local_status.is_server_error() {
2807 match serde_json::from_str::<crate::datadogV2::model::NotificationRuleResponse>(
2808 &local_content,
2809 ) {
2810 Ok(e) => {
2811 return Ok(datadog::ResponseContent {
2812 status: local_status,
2813 content: local_content,
2814 entity: Some(e),
2815 })
2816 }
2817 Err(e) => return Err(datadog::Error::Serde(e)),
2818 };
2819 } else {
2820 let local_entity: Option<CreateVulnerabilityNotificationRuleError> =
2821 serde_json::from_str(&local_content).ok();
2822 let local_error = datadog::ResponseContent {
2823 status: local_status,
2824 content: local_content,
2825 entity: local_entity,
2826 };
2827 Err(datadog::Error::ResponseError(local_error))
2828 }
2829 }
2830
2831 pub async fn delete_custom_framework(
2833 &self,
2834 handle: String,
2835 version: String,
2836 ) -> Result<
2837 crate::datadogV2::model::DeleteCustomFrameworkResponse,
2838 datadog::Error<DeleteCustomFrameworkError>,
2839 > {
2840 match self
2841 .delete_custom_framework_with_http_info(handle, version)
2842 .await
2843 {
2844 Ok(response_content) => {
2845 if let Some(e) = response_content.entity {
2846 Ok(e)
2847 } else {
2848 Err(datadog::Error::Serde(serde::de::Error::custom(
2849 "response content was None",
2850 )))
2851 }
2852 }
2853 Err(err) => Err(err),
2854 }
2855 }
2856
2857 pub async fn delete_custom_framework_with_http_info(
2859 &self,
2860 handle: String,
2861 version: String,
2862 ) -> Result<
2863 datadog::ResponseContent<crate::datadogV2::model::DeleteCustomFrameworkResponse>,
2864 datadog::Error<DeleteCustomFrameworkError>,
2865 > {
2866 let local_configuration = &self.config;
2867 let operation_id = "v2.delete_custom_framework";
2868
2869 let local_client = &self.client;
2870
2871 let local_uri_str = format!(
2872 "{}/api/v2/cloud_security_management/custom_frameworks/{handle}/{version}",
2873 local_configuration.get_operation_host(operation_id),
2874 handle = datadog::urlencode(handle),
2875 version = datadog::urlencode(version)
2876 );
2877 let mut local_req_builder =
2878 local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
2879
2880 let mut headers = HeaderMap::new();
2882 headers.insert("Accept", HeaderValue::from_static("application/json"));
2883
2884 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2886 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2887 Err(e) => {
2888 log::warn!("Failed to parse user agent header: {e}, falling back to default");
2889 headers.insert(
2890 reqwest::header::USER_AGENT,
2891 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2892 )
2893 }
2894 };
2895
2896 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2898 headers.insert(
2899 "DD-API-KEY",
2900 HeaderValue::from_str(local_key.key.as_str())
2901 .expect("failed to parse DD-API-KEY header"),
2902 );
2903 };
2904 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2905 headers.insert(
2906 "DD-APPLICATION-KEY",
2907 HeaderValue::from_str(local_key.key.as_str())
2908 .expect("failed to parse DD-APPLICATION-KEY header"),
2909 );
2910 };
2911
2912 local_req_builder = local_req_builder.headers(headers);
2913 let local_req = local_req_builder.build()?;
2914 log::debug!("request content: {:?}", local_req.body());
2915 let local_resp = local_client.execute(local_req).await?;
2916
2917 let local_status = local_resp.status();
2918 let local_content = local_resp.text().await?;
2919 log::debug!("response content: {}", local_content);
2920
2921 if !local_status.is_client_error() && !local_status.is_server_error() {
2922 match serde_json::from_str::<crate::datadogV2::model::DeleteCustomFrameworkResponse>(
2923 &local_content,
2924 ) {
2925 Ok(e) => {
2926 return Ok(datadog::ResponseContent {
2927 status: local_status,
2928 content: local_content,
2929 entity: Some(e),
2930 })
2931 }
2932 Err(e) => return Err(datadog::Error::Serde(e)),
2933 };
2934 } else {
2935 let local_entity: Option<DeleteCustomFrameworkError> =
2936 serde_json::from_str(&local_content).ok();
2937 let local_error = datadog::ResponseContent {
2938 status: local_status,
2939 content: local_content,
2940 entity: local_entity,
2941 };
2942 Err(datadog::Error::ResponseError(local_error))
2943 }
2944 }
2945
2946 pub async fn delete_historical_job(
2948 &self,
2949 job_id: String,
2950 ) -> Result<(), datadog::Error<DeleteHistoricalJobError>> {
2951 match self.delete_historical_job_with_http_info(job_id).await {
2952 Ok(_) => Ok(()),
2953 Err(err) => Err(err),
2954 }
2955 }
2956
2957 pub async fn delete_historical_job_with_http_info(
2959 &self,
2960 job_id: String,
2961 ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteHistoricalJobError>> {
2962 let local_configuration = &self.config;
2963 let operation_id = "v2.delete_historical_job";
2964 if local_configuration.is_unstable_operation_enabled(operation_id) {
2965 warn!("Using unstable operation {operation_id}");
2966 } else {
2967 let local_error = datadog::UnstableOperationDisabledError {
2968 msg: "Operation 'v2.delete_historical_job' is not enabled".to_string(),
2969 };
2970 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
2971 }
2972
2973 let local_client = &self.client;
2974
2975 let local_uri_str = format!(
2976 "{}/api/v2/siem-historical-detections/jobs/{job_id}",
2977 local_configuration.get_operation_host(operation_id),
2978 job_id = datadog::urlencode(job_id)
2979 );
2980 let mut local_req_builder =
2981 local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
2982
2983 let mut headers = HeaderMap::new();
2985 headers.insert("Accept", HeaderValue::from_static("*/*"));
2986
2987 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2989 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2990 Err(e) => {
2991 log::warn!("Failed to parse user agent header: {e}, falling back to default");
2992 headers.insert(
2993 reqwest::header::USER_AGENT,
2994 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2995 )
2996 }
2997 };
2998
2999 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3001 headers.insert(
3002 "DD-API-KEY",
3003 HeaderValue::from_str(local_key.key.as_str())
3004 .expect("failed to parse DD-API-KEY header"),
3005 );
3006 };
3007 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3008 headers.insert(
3009 "DD-APPLICATION-KEY",
3010 HeaderValue::from_str(local_key.key.as_str())
3011 .expect("failed to parse DD-APPLICATION-KEY header"),
3012 );
3013 };
3014
3015 local_req_builder = local_req_builder.headers(headers);
3016 let local_req = local_req_builder.build()?;
3017 log::debug!("request content: {:?}", local_req.body());
3018 let local_resp = local_client.execute(local_req).await?;
3019
3020 let local_status = local_resp.status();
3021 let local_content = local_resp.text().await?;
3022 log::debug!("response content: {}", local_content);
3023
3024 if !local_status.is_client_error() && !local_status.is_server_error() {
3025 Ok(datadog::ResponseContent {
3026 status: local_status,
3027 content: local_content,
3028 entity: None,
3029 })
3030 } else {
3031 let local_entity: Option<DeleteHistoricalJobError> =
3032 serde_json::from_str(&local_content).ok();
3033 let local_error = datadog::ResponseContent {
3034 status: local_status,
3035 content: local_content,
3036 entity: local_entity,
3037 };
3038 Err(datadog::Error::ResponseError(local_error))
3039 }
3040 }
3041
3042 pub async fn delete_security_filter(
3044 &self,
3045 security_filter_id: String,
3046 ) -> Result<(), datadog::Error<DeleteSecurityFilterError>> {
3047 match self
3048 .delete_security_filter_with_http_info(security_filter_id)
3049 .await
3050 {
3051 Ok(_) => Ok(()),
3052 Err(err) => Err(err),
3053 }
3054 }
3055
3056 pub async fn delete_security_filter_with_http_info(
3058 &self,
3059 security_filter_id: String,
3060 ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteSecurityFilterError>> {
3061 let local_configuration = &self.config;
3062 let operation_id = "v2.delete_security_filter";
3063
3064 let local_client = &self.client;
3065
3066 let local_uri_str = format!(
3067 "{}/api/v2/security_monitoring/configuration/security_filters/{security_filter_id}",
3068 local_configuration.get_operation_host(operation_id),
3069 security_filter_id = datadog::urlencode(security_filter_id)
3070 );
3071 let mut local_req_builder =
3072 local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
3073
3074 let mut headers = HeaderMap::new();
3076 headers.insert("Accept", HeaderValue::from_static("*/*"));
3077
3078 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3080 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3081 Err(e) => {
3082 log::warn!("Failed to parse user agent header: {e}, falling back to default");
3083 headers.insert(
3084 reqwest::header::USER_AGENT,
3085 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3086 )
3087 }
3088 };
3089
3090 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3092 headers.insert(
3093 "DD-API-KEY",
3094 HeaderValue::from_str(local_key.key.as_str())
3095 .expect("failed to parse DD-API-KEY header"),
3096 );
3097 };
3098 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3099 headers.insert(
3100 "DD-APPLICATION-KEY",
3101 HeaderValue::from_str(local_key.key.as_str())
3102 .expect("failed to parse DD-APPLICATION-KEY header"),
3103 );
3104 };
3105
3106 local_req_builder = local_req_builder.headers(headers);
3107 let local_req = local_req_builder.build()?;
3108 log::debug!("request content: {:?}", local_req.body());
3109 let local_resp = local_client.execute(local_req).await?;
3110
3111 let local_status = local_resp.status();
3112 let local_content = local_resp.text().await?;
3113 log::debug!("response content: {}", local_content);
3114
3115 if !local_status.is_client_error() && !local_status.is_server_error() {
3116 Ok(datadog::ResponseContent {
3117 status: local_status,
3118 content: local_content,
3119 entity: None,
3120 })
3121 } else {
3122 let local_entity: Option<DeleteSecurityFilterError> =
3123 serde_json::from_str(&local_content).ok();
3124 let local_error = datadog::ResponseContent {
3125 status: local_status,
3126 content: local_content,
3127 entity: local_entity,
3128 };
3129 Err(datadog::Error::ResponseError(local_error))
3130 }
3131 }
3132
3133 pub async fn delete_security_monitoring_rule(
3135 &self,
3136 rule_id: String,
3137 ) -> Result<(), datadog::Error<DeleteSecurityMonitoringRuleError>> {
3138 match self
3139 .delete_security_monitoring_rule_with_http_info(rule_id)
3140 .await
3141 {
3142 Ok(_) => Ok(()),
3143 Err(err) => Err(err),
3144 }
3145 }
3146
3147 pub async fn delete_security_monitoring_rule_with_http_info(
3149 &self,
3150 rule_id: String,
3151 ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteSecurityMonitoringRuleError>>
3152 {
3153 let local_configuration = &self.config;
3154 let operation_id = "v2.delete_security_monitoring_rule";
3155
3156 let local_client = &self.client;
3157
3158 let local_uri_str = format!(
3159 "{}/api/v2/security_monitoring/rules/{rule_id}",
3160 local_configuration.get_operation_host(operation_id),
3161 rule_id = datadog::urlencode(rule_id)
3162 );
3163 let mut local_req_builder =
3164 local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
3165
3166 let mut headers = HeaderMap::new();
3168 headers.insert("Accept", HeaderValue::from_static("*/*"));
3169
3170 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3172 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3173 Err(e) => {
3174 log::warn!("Failed to parse user agent header: {e}, falling back to default");
3175 headers.insert(
3176 reqwest::header::USER_AGENT,
3177 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3178 )
3179 }
3180 };
3181
3182 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3184 headers.insert(
3185 "DD-API-KEY",
3186 HeaderValue::from_str(local_key.key.as_str())
3187 .expect("failed to parse DD-API-KEY header"),
3188 );
3189 };
3190 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3191 headers.insert(
3192 "DD-APPLICATION-KEY",
3193 HeaderValue::from_str(local_key.key.as_str())
3194 .expect("failed to parse DD-APPLICATION-KEY header"),
3195 );
3196 };
3197
3198 local_req_builder = local_req_builder.headers(headers);
3199 let local_req = local_req_builder.build()?;
3200 log::debug!("request content: {:?}", local_req.body());
3201 let local_resp = local_client.execute(local_req).await?;
3202
3203 let local_status = local_resp.status();
3204 let local_content = local_resp.text().await?;
3205 log::debug!("response content: {}", local_content);
3206
3207 if !local_status.is_client_error() && !local_status.is_server_error() {
3208 Ok(datadog::ResponseContent {
3209 status: local_status,
3210 content: local_content,
3211 entity: None,
3212 })
3213 } else {
3214 let local_entity: Option<DeleteSecurityMonitoringRuleError> =
3215 serde_json::from_str(&local_content).ok();
3216 let local_error = datadog::ResponseContent {
3217 status: local_status,
3218 content: local_content,
3219 entity: local_entity,
3220 };
3221 Err(datadog::Error::ResponseError(local_error))
3222 }
3223 }
3224
3225 pub async fn delete_security_monitoring_suppression(
3227 &self,
3228 suppression_id: String,
3229 ) -> Result<(), datadog::Error<DeleteSecurityMonitoringSuppressionError>> {
3230 match self
3231 .delete_security_monitoring_suppression_with_http_info(suppression_id)
3232 .await
3233 {
3234 Ok(_) => Ok(()),
3235 Err(err) => Err(err),
3236 }
3237 }
3238
3239 pub async fn delete_security_monitoring_suppression_with_http_info(
3241 &self,
3242 suppression_id: String,
3243 ) -> Result<
3244 datadog::ResponseContent<()>,
3245 datadog::Error<DeleteSecurityMonitoringSuppressionError>,
3246 > {
3247 let local_configuration = &self.config;
3248 let operation_id = "v2.delete_security_monitoring_suppression";
3249
3250 let local_client = &self.client;
3251
3252 let local_uri_str = format!(
3253 "{}/api/v2/security_monitoring/configuration/suppressions/{suppression_id}",
3254 local_configuration.get_operation_host(operation_id),
3255 suppression_id = datadog::urlencode(suppression_id)
3256 );
3257 let mut local_req_builder =
3258 local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
3259
3260 let mut headers = HeaderMap::new();
3262 headers.insert("Accept", HeaderValue::from_static("*/*"));
3263
3264 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3266 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3267 Err(e) => {
3268 log::warn!("Failed to parse user agent header: {e}, falling back to default");
3269 headers.insert(
3270 reqwest::header::USER_AGENT,
3271 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3272 )
3273 }
3274 };
3275
3276 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3278 headers.insert(
3279 "DD-API-KEY",
3280 HeaderValue::from_str(local_key.key.as_str())
3281 .expect("failed to parse DD-API-KEY header"),
3282 );
3283 };
3284 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3285 headers.insert(
3286 "DD-APPLICATION-KEY",
3287 HeaderValue::from_str(local_key.key.as_str())
3288 .expect("failed to parse DD-APPLICATION-KEY header"),
3289 );
3290 };
3291
3292 local_req_builder = local_req_builder.headers(headers);
3293 let local_req = local_req_builder.build()?;
3294 log::debug!("request content: {:?}", local_req.body());
3295 let local_resp = local_client.execute(local_req).await?;
3296
3297 let local_status = local_resp.status();
3298 let local_content = local_resp.text().await?;
3299 log::debug!("response content: {}", local_content);
3300
3301 if !local_status.is_client_error() && !local_status.is_server_error() {
3302 Ok(datadog::ResponseContent {
3303 status: local_status,
3304 content: local_content,
3305 entity: None,
3306 })
3307 } else {
3308 let local_entity: Option<DeleteSecurityMonitoringSuppressionError> =
3309 serde_json::from_str(&local_content).ok();
3310 let local_error = datadog::ResponseContent {
3311 status: local_status,
3312 content: local_content,
3313 entity: local_entity,
3314 };
3315 Err(datadog::Error::ResponseError(local_error))
3316 }
3317 }
3318
3319 pub async fn delete_signal_notification_rule(
3321 &self,
3322 id: String,
3323 ) -> Result<(), datadog::Error<DeleteSignalNotificationRuleError>> {
3324 match self
3325 .delete_signal_notification_rule_with_http_info(id)
3326 .await
3327 {
3328 Ok(_) => Ok(()),
3329 Err(err) => Err(err),
3330 }
3331 }
3332
3333 pub async fn delete_signal_notification_rule_with_http_info(
3335 &self,
3336 id: String,
3337 ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteSignalNotificationRuleError>>
3338 {
3339 let local_configuration = &self.config;
3340 let operation_id = "v2.delete_signal_notification_rule";
3341
3342 let local_client = &self.client;
3343
3344 let local_uri_str = format!(
3345 "{}/api/v2/security/signals/notification_rules/{id}",
3346 local_configuration.get_operation_host(operation_id),
3347 id = datadog::urlencode(id)
3348 );
3349 let mut local_req_builder =
3350 local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
3351
3352 let mut headers = HeaderMap::new();
3354 headers.insert("Accept", HeaderValue::from_static("*/*"));
3355
3356 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3358 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3359 Err(e) => {
3360 log::warn!("Failed to parse user agent header: {e}, falling back to default");
3361 headers.insert(
3362 reqwest::header::USER_AGENT,
3363 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3364 )
3365 }
3366 };
3367
3368 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3370 headers.insert(
3371 "DD-API-KEY",
3372 HeaderValue::from_str(local_key.key.as_str())
3373 .expect("failed to parse DD-API-KEY header"),
3374 );
3375 };
3376 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3377 headers.insert(
3378 "DD-APPLICATION-KEY",
3379 HeaderValue::from_str(local_key.key.as_str())
3380 .expect("failed to parse DD-APPLICATION-KEY header"),
3381 );
3382 };
3383
3384 local_req_builder = local_req_builder.headers(headers);
3385 let local_req = local_req_builder.build()?;
3386 log::debug!("request content: {:?}", local_req.body());
3387 let local_resp = local_client.execute(local_req).await?;
3388
3389 let local_status = local_resp.status();
3390 let local_content = local_resp.text().await?;
3391 log::debug!("response content: {}", local_content);
3392
3393 if !local_status.is_client_error() && !local_status.is_server_error() {
3394 Ok(datadog::ResponseContent {
3395 status: local_status,
3396 content: local_content,
3397 entity: None,
3398 })
3399 } else {
3400 let local_entity: Option<DeleteSignalNotificationRuleError> =
3401 serde_json::from_str(&local_content).ok();
3402 let local_error = datadog::ResponseContent {
3403 status: local_status,
3404 content: local_content,
3405 entity: local_entity,
3406 };
3407 Err(datadog::Error::ResponseError(local_error))
3408 }
3409 }
3410
3411 pub async fn delete_vulnerability_notification_rule(
3413 &self,
3414 id: String,
3415 ) -> Result<(), datadog::Error<DeleteVulnerabilityNotificationRuleError>> {
3416 match self
3417 .delete_vulnerability_notification_rule_with_http_info(id)
3418 .await
3419 {
3420 Ok(_) => Ok(()),
3421 Err(err) => Err(err),
3422 }
3423 }
3424
3425 pub async fn delete_vulnerability_notification_rule_with_http_info(
3427 &self,
3428 id: String,
3429 ) -> Result<
3430 datadog::ResponseContent<()>,
3431 datadog::Error<DeleteVulnerabilityNotificationRuleError>,
3432 > {
3433 let local_configuration = &self.config;
3434 let operation_id = "v2.delete_vulnerability_notification_rule";
3435
3436 let local_client = &self.client;
3437
3438 let local_uri_str = format!(
3439 "{}/api/v2/security/vulnerabilities/notification_rules/{id}",
3440 local_configuration.get_operation_host(operation_id),
3441 id = datadog::urlencode(id)
3442 );
3443 let mut local_req_builder =
3444 local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
3445
3446 let mut headers = HeaderMap::new();
3448 headers.insert("Accept", HeaderValue::from_static("*/*"));
3449
3450 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3452 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3453 Err(e) => {
3454 log::warn!("Failed to parse user agent header: {e}, falling back to default");
3455 headers.insert(
3456 reqwest::header::USER_AGENT,
3457 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3458 )
3459 }
3460 };
3461
3462 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3464 headers.insert(
3465 "DD-API-KEY",
3466 HeaderValue::from_str(local_key.key.as_str())
3467 .expect("failed to parse DD-API-KEY header"),
3468 );
3469 };
3470 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3471 headers.insert(
3472 "DD-APPLICATION-KEY",
3473 HeaderValue::from_str(local_key.key.as_str())
3474 .expect("failed to parse DD-APPLICATION-KEY header"),
3475 );
3476 };
3477
3478 local_req_builder = local_req_builder.headers(headers);
3479 let local_req = local_req_builder.build()?;
3480 log::debug!("request content: {:?}", local_req.body());
3481 let local_resp = local_client.execute(local_req).await?;
3482
3483 let local_status = local_resp.status();
3484 let local_content = local_resp.text().await?;
3485 log::debug!("response content: {}", local_content);
3486
3487 if !local_status.is_client_error() && !local_status.is_server_error() {
3488 Ok(datadog::ResponseContent {
3489 status: local_status,
3490 content: local_content,
3491 entity: None,
3492 })
3493 } else {
3494 let local_entity: Option<DeleteVulnerabilityNotificationRuleError> =
3495 serde_json::from_str(&local_content).ok();
3496 let local_error = datadog::ResponseContent {
3497 status: local_status,
3498 content: local_content,
3499 entity: local_entity,
3500 };
3501 Err(datadog::Error::ResponseError(local_error))
3502 }
3503 }
3504
3505 pub async fn edit_security_monitoring_signal_assignee(
3507 &self,
3508 signal_id: String,
3509 body: crate::datadogV2::model::SecurityMonitoringSignalAssigneeUpdateRequest,
3510 ) -> Result<
3511 crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
3512 datadog::Error<EditSecurityMonitoringSignalAssigneeError>,
3513 > {
3514 match self
3515 .edit_security_monitoring_signal_assignee_with_http_info(signal_id, body)
3516 .await
3517 {
3518 Ok(response_content) => {
3519 if let Some(e) = response_content.entity {
3520 Ok(e)
3521 } else {
3522 Err(datadog::Error::Serde(serde::de::Error::custom(
3523 "response content was None",
3524 )))
3525 }
3526 }
3527 Err(err) => Err(err),
3528 }
3529 }
3530
3531 pub async fn edit_security_monitoring_signal_assignee_with_http_info(
3533 &self,
3534 signal_id: String,
3535 body: crate::datadogV2::model::SecurityMonitoringSignalAssigneeUpdateRequest,
3536 ) -> Result<
3537 datadog::ResponseContent<
3538 crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
3539 >,
3540 datadog::Error<EditSecurityMonitoringSignalAssigneeError>,
3541 > {
3542 let local_configuration = &self.config;
3543 let operation_id = "v2.edit_security_monitoring_signal_assignee";
3544
3545 let local_client = &self.client;
3546
3547 let local_uri_str = format!(
3548 "{}/api/v2/security_monitoring/signals/{signal_id}/assignee",
3549 local_configuration.get_operation_host(operation_id),
3550 signal_id = datadog::urlencode(signal_id)
3551 );
3552 let mut local_req_builder =
3553 local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
3554
3555 let mut headers = HeaderMap::new();
3557 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
3558 headers.insert("Accept", HeaderValue::from_static("application/json"));
3559
3560 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3562 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3563 Err(e) => {
3564 log::warn!("Failed to parse user agent header: {e}, falling back to default");
3565 headers.insert(
3566 reqwest::header::USER_AGENT,
3567 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3568 )
3569 }
3570 };
3571
3572 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3574 headers.insert(
3575 "DD-API-KEY",
3576 HeaderValue::from_str(local_key.key.as_str())
3577 .expect("failed to parse DD-API-KEY header"),
3578 );
3579 };
3580 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3581 headers.insert(
3582 "DD-APPLICATION-KEY",
3583 HeaderValue::from_str(local_key.key.as_str())
3584 .expect("failed to parse DD-APPLICATION-KEY header"),
3585 );
3586 };
3587
3588 let output = Vec::new();
3590 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
3591 if body.serialize(&mut ser).is_ok() {
3592 if let Some(content_encoding) = headers.get("Content-Encoding") {
3593 match content_encoding.to_str().unwrap_or_default() {
3594 "gzip" => {
3595 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
3596 let _ = enc.write_all(ser.into_inner().as_slice());
3597 match enc.finish() {
3598 Ok(buf) => {
3599 local_req_builder = local_req_builder.body(buf);
3600 }
3601 Err(e) => return Err(datadog::Error::Io(e)),
3602 }
3603 }
3604 "deflate" => {
3605 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
3606 let _ = enc.write_all(ser.into_inner().as_slice());
3607 match enc.finish() {
3608 Ok(buf) => {
3609 local_req_builder = local_req_builder.body(buf);
3610 }
3611 Err(e) => return Err(datadog::Error::Io(e)),
3612 }
3613 }
3614 "zstd1" => {
3615 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
3616 let _ = enc.write_all(ser.into_inner().as_slice());
3617 match enc.finish() {
3618 Ok(buf) => {
3619 local_req_builder = local_req_builder.body(buf);
3620 }
3621 Err(e) => return Err(datadog::Error::Io(e)),
3622 }
3623 }
3624 _ => {
3625 local_req_builder = local_req_builder.body(ser.into_inner());
3626 }
3627 }
3628 } else {
3629 local_req_builder = local_req_builder.body(ser.into_inner());
3630 }
3631 }
3632
3633 local_req_builder = local_req_builder.headers(headers);
3634 let local_req = local_req_builder.build()?;
3635 log::debug!("request content: {:?}", local_req.body());
3636 let local_resp = local_client.execute(local_req).await?;
3637
3638 let local_status = local_resp.status();
3639 let local_content = local_resp.text().await?;
3640 log::debug!("response content: {}", local_content);
3641
3642 if !local_status.is_client_error() && !local_status.is_server_error() {
3643 match serde_json::from_str::<
3644 crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
3645 >(&local_content)
3646 {
3647 Ok(e) => {
3648 return Ok(datadog::ResponseContent {
3649 status: local_status,
3650 content: local_content,
3651 entity: Some(e),
3652 })
3653 }
3654 Err(e) => return Err(datadog::Error::Serde(e)),
3655 };
3656 } else {
3657 let local_entity: Option<EditSecurityMonitoringSignalAssigneeError> =
3658 serde_json::from_str(&local_content).ok();
3659 let local_error = datadog::ResponseContent {
3660 status: local_status,
3661 content: local_content,
3662 entity: local_entity,
3663 };
3664 Err(datadog::Error::ResponseError(local_error))
3665 }
3666 }
3667
3668 pub async fn edit_security_monitoring_signal_incidents(
3670 &self,
3671 signal_id: String,
3672 body: crate::datadogV2::model::SecurityMonitoringSignalIncidentsUpdateRequest,
3673 ) -> Result<
3674 crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
3675 datadog::Error<EditSecurityMonitoringSignalIncidentsError>,
3676 > {
3677 match self
3678 .edit_security_monitoring_signal_incidents_with_http_info(signal_id, body)
3679 .await
3680 {
3681 Ok(response_content) => {
3682 if let Some(e) = response_content.entity {
3683 Ok(e)
3684 } else {
3685 Err(datadog::Error::Serde(serde::de::Error::custom(
3686 "response content was None",
3687 )))
3688 }
3689 }
3690 Err(err) => Err(err),
3691 }
3692 }
3693
3694 pub async fn edit_security_monitoring_signal_incidents_with_http_info(
3696 &self,
3697 signal_id: String,
3698 body: crate::datadogV2::model::SecurityMonitoringSignalIncidentsUpdateRequest,
3699 ) -> Result<
3700 datadog::ResponseContent<
3701 crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
3702 >,
3703 datadog::Error<EditSecurityMonitoringSignalIncidentsError>,
3704 > {
3705 let local_configuration = &self.config;
3706 let operation_id = "v2.edit_security_monitoring_signal_incidents";
3707
3708 let local_client = &self.client;
3709
3710 let local_uri_str = format!(
3711 "{}/api/v2/security_monitoring/signals/{signal_id}/incidents",
3712 local_configuration.get_operation_host(operation_id),
3713 signal_id = datadog::urlencode(signal_id)
3714 );
3715 let mut local_req_builder =
3716 local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
3717
3718 let mut headers = HeaderMap::new();
3720 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
3721 headers.insert("Accept", HeaderValue::from_static("application/json"));
3722
3723 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3725 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3726 Err(e) => {
3727 log::warn!("Failed to parse user agent header: {e}, falling back to default");
3728 headers.insert(
3729 reqwest::header::USER_AGENT,
3730 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3731 )
3732 }
3733 };
3734
3735 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3737 headers.insert(
3738 "DD-API-KEY",
3739 HeaderValue::from_str(local_key.key.as_str())
3740 .expect("failed to parse DD-API-KEY header"),
3741 );
3742 };
3743 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3744 headers.insert(
3745 "DD-APPLICATION-KEY",
3746 HeaderValue::from_str(local_key.key.as_str())
3747 .expect("failed to parse DD-APPLICATION-KEY header"),
3748 );
3749 };
3750
3751 let output = Vec::new();
3753 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
3754 if body.serialize(&mut ser).is_ok() {
3755 if let Some(content_encoding) = headers.get("Content-Encoding") {
3756 match content_encoding.to_str().unwrap_or_default() {
3757 "gzip" => {
3758 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
3759 let _ = enc.write_all(ser.into_inner().as_slice());
3760 match enc.finish() {
3761 Ok(buf) => {
3762 local_req_builder = local_req_builder.body(buf);
3763 }
3764 Err(e) => return Err(datadog::Error::Io(e)),
3765 }
3766 }
3767 "deflate" => {
3768 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
3769 let _ = enc.write_all(ser.into_inner().as_slice());
3770 match enc.finish() {
3771 Ok(buf) => {
3772 local_req_builder = local_req_builder.body(buf);
3773 }
3774 Err(e) => return Err(datadog::Error::Io(e)),
3775 }
3776 }
3777 "zstd1" => {
3778 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
3779 let _ = enc.write_all(ser.into_inner().as_slice());
3780 match enc.finish() {
3781 Ok(buf) => {
3782 local_req_builder = local_req_builder.body(buf);
3783 }
3784 Err(e) => return Err(datadog::Error::Io(e)),
3785 }
3786 }
3787 _ => {
3788 local_req_builder = local_req_builder.body(ser.into_inner());
3789 }
3790 }
3791 } else {
3792 local_req_builder = local_req_builder.body(ser.into_inner());
3793 }
3794 }
3795
3796 local_req_builder = local_req_builder.headers(headers);
3797 let local_req = local_req_builder.build()?;
3798 log::debug!("request content: {:?}", local_req.body());
3799 let local_resp = local_client.execute(local_req).await?;
3800
3801 let local_status = local_resp.status();
3802 let local_content = local_resp.text().await?;
3803 log::debug!("response content: {}", local_content);
3804
3805 if !local_status.is_client_error() && !local_status.is_server_error() {
3806 match serde_json::from_str::<
3807 crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
3808 >(&local_content)
3809 {
3810 Ok(e) => {
3811 return Ok(datadog::ResponseContent {
3812 status: local_status,
3813 content: local_content,
3814 entity: Some(e),
3815 })
3816 }
3817 Err(e) => return Err(datadog::Error::Serde(e)),
3818 };
3819 } else {
3820 let local_entity: Option<EditSecurityMonitoringSignalIncidentsError> =
3821 serde_json::from_str(&local_content).ok();
3822 let local_error = datadog::ResponseContent {
3823 status: local_status,
3824 content: local_content,
3825 entity: local_entity,
3826 };
3827 Err(datadog::Error::ResponseError(local_error))
3828 }
3829 }
3830
3831 pub async fn edit_security_monitoring_signal_state(
3833 &self,
3834 signal_id: String,
3835 body: crate::datadogV2::model::SecurityMonitoringSignalStateUpdateRequest,
3836 ) -> Result<
3837 crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
3838 datadog::Error<EditSecurityMonitoringSignalStateError>,
3839 > {
3840 match self
3841 .edit_security_monitoring_signal_state_with_http_info(signal_id, body)
3842 .await
3843 {
3844 Ok(response_content) => {
3845 if let Some(e) = response_content.entity {
3846 Ok(e)
3847 } else {
3848 Err(datadog::Error::Serde(serde::de::Error::custom(
3849 "response content was None",
3850 )))
3851 }
3852 }
3853 Err(err) => Err(err),
3854 }
3855 }
3856
3857 pub async fn edit_security_monitoring_signal_state_with_http_info(
3859 &self,
3860 signal_id: String,
3861 body: crate::datadogV2::model::SecurityMonitoringSignalStateUpdateRequest,
3862 ) -> Result<
3863 datadog::ResponseContent<
3864 crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
3865 >,
3866 datadog::Error<EditSecurityMonitoringSignalStateError>,
3867 > {
3868 let local_configuration = &self.config;
3869 let operation_id = "v2.edit_security_monitoring_signal_state";
3870
3871 let local_client = &self.client;
3872
3873 let local_uri_str = format!(
3874 "{}/api/v2/security_monitoring/signals/{signal_id}/state",
3875 local_configuration.get_operation_host(operation_id),
3876 signal_id = datadog::urlencode(signal_id)
3877 );
3878 let mut local_req_builder =
3879 local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
3880
3881 let mut headers = HeaderMap::new();
3883 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
3884 headers.insert("Accept", HeaderValue::from_static("application/json"));
3885
3886 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3888 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3889 Err(e) => {
3890 log::warn!("Failed to parse user agent header: {e}, falling back to default");
3891 headers.insert(
3892 reqwest::header::USER_AGENT,
3893 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3894 )
3895 }
3896 };
3897
3898 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3900 headers.insert(
3901 "DD-API-KEY",
3902 HeaderValue::from_str(local_key.key.as_str())
3903 .expect("failed to parse DD-API-KEY header"),
3904 );
3905 };
3906 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3907 headers.insert(
3908 "DD-APPLICATION-KEY",
3909 HeaderValue::from_str(local_key.key.as_str())
3910 .expect("failed to parse DD-APPLICATION-KEY header"),
3911 );
3912 };
3913
3914 let output = Vec::new();
3916 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
3917 if body.serialize(&mut ser).is_ok() {
3918 if let Some(content_encoding) = headers.get("Content-Encoding") {
3919 match content_encoding.to_str().unwrap_or_default() {
3920 "gzip" => {
3921 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
3922 let _ = enc.write_all(ser.into_inner().as_slice());
3923 match enc.finish() {
3924 Ok(buf) => {
3925 local_req_builder = local_req_builder.body(buf);
3926 }
3927 Err(e) => return Err(datadog::Error::Io(e)),
3928 }
3929 }
3930 "deflate" => {
3931 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
3932 let _ = enc.write_all(ser.into_inner().as_slice());
3933 match enc.finish() {
3934 Ok(buf) => {
3935 local_req_builder = local_req_builder.body(buf);
3936 }
3937 Err(e) => return Err(datadog::Error::Io(e)),
3938 }
3939 }
3940 "zstd1" => {
3941 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
3942 let _ = enc.write_all(ser.into_inner().as_slice());
3943 match enc.finish() {
3944 Ok(buf) => {
3945 local_req_builder = local_req_builder.body(buf);
3946 }
3947 Err(e) => return Err(datadog::Error::Io(e)),
3948 }
3949 }
3950 _ => {
3951 local_req_builder = local_req_builder.body(ser.into_inner());
3952 }
3953 }
3954 } else {
3955 local_req_builder = local_req_builder.body(ser.into_inner());
3956 }
3957 }
3958
3959 local_req_builder = local_req_builder.headers(headers);
3960 let local_req = local_req_builder.build()?;
3961 log::debug!("request content: {:?}", local_req.body());
3962 let local_resp = local_client.execute(local_req).await?;
3963
3964 let local_status = local_resp.status();
3965 let local_content = local_resp.text().await?;
3966 log::debug!("response content: {}", local_content);
3967
3968 if !local_status.is_client_error() && !local_status.is_server_error() {
3969 match serde_json::from_str::<
3970 crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
3971 >(&local_content)
3972 {
3973 Ok(e) => {
3974 return Ok(datadog::ResponseContent {
3975 status: local_status,
3976 content: local_content,
3977 entity: Some(e),
3978 })
3979 }
3980 Err(e) => return Err(datadog::Error::Serde(e)),
3981 };
3982 } else {
3983 let local_entity: Option<EditSecurityMonitoringSignalStateError> =
3984 serde_json::from_str(&local_content).ok();
3985 let local_error = datadog::ResponseContent {
3986 status: local_status,
3987 content: local_content,
3988 entity: local_entity,
3989 };
3990 Err(datadog::Error::ResponseError(local_error))
3991 }
3992 }
3993
3994 pub async fn get_custom_framework(
3996 &self,
3997 handle: String,
3998 version: String,
3999 ) -> Result<
4000 crate::datadogV2::model::GetCustomFrameworkResponse,
4001 datadog::Error<GetCustomFrameworkError>,
4002 > {
4003 match self
4004 .get_custom_framework_with_http_info(handle, version)
4005 .await
4006 {
4007 Ok(response_content) => {
4008 if let Some(e) = response_content.entity {
4009 Ok(e)
4010 } else {
4011 Err(datadog::Error::Serde(serde::de::Error::custom(
4012 "response content was None",
4013 )))
4014 }
4015 }
4016 Err(err) => Err(err),
4017 }
4018 }
4019
4020 pub async fn get_custom_framework_with_http_info(
4022 &self,
4023 handle: String,
4024 version: String,
4025 ) -> Result<
4026 datadog::ResponseContent<crate::datadogV2::model::GetCustomFrameworkResponse>,
4027 datadog::Error<GetCustomFrameworkError>,
4028 > {
4029 let local_configuration = &self.config;
4030 let operation_id = "v2.get_custom_framework";
4031
4032 let local_client = &self.client;
4033
4034 let local_uri_str = format!(
4035 "{}/api/v2/cloud_security_management/custom_frameworks/{handle}/{version}",
4036 local_configuration.get_operation_host(operation_id),
4037 handle = datadog::urlencode(handle),
4038 version = datadog::urlencode(version)
4039 );
4040 let mut local_req_builder =
4041 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4042
4043 let mut headers = HeaderMap::new();
4045 headers.insert("Accept", HeaderValue::from_static("application/json"));
4046
4047 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4049 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4050 Err(e) => {
4051 log::warn!("Failed to parse user agent header: {e}, falling back to default");
4052 headers.insert(
4053 reqwest::header::USER_AGENT,
4054 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4055 )
4056 }
4057 };
4058
4059 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4061 headers.insert(
4062 "DD-API-KEY",
4063 HeaderValue::from_str(local_key.key.as_str())
4064 .expect("failed to parse DD-API-KEY header"),
4065 );
4066 };
4067 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4068 headers.insert(
4069 "DD-APPLICATION-KEY",
4070 HeaderValue::from_str(local_key.key.as_str())
4071 .expect("failed to parse DD-APPLICATION-KEY header"),
4072 );
4073 };
4074
4075 local_req_builder = local_req_builder.headers(headers);
4076 let local_req = local_req_builder.build()?;
4077 log::debug!("request content: {:?}", local_req.body());
4078 let local_resp = local_client.execute(local_req).await?;
4079
4080 let local_status = local_resp.status();
4081 let local_content = local_resp.text().await?;
4082 log::debug!("response content: {}", local_content);
4083
4084 if !local_status.is_client_error() && !local_status.is_server_error() {
4085 match serde_json::from_str::<crate::datadogV2::model::GetCustomFrameworkResponse>(
4086 &local_content,
4087 ) {
4088 Ok(e) => {
4089 return Ok(datadog::ResponseContent {
4090 status: local_status,
4091 content: local_content,
4092 entity: Some(e),
4093 })
4094 }
4095 Err(e) => return Err(datadog::Error::Serde(e)),
4096 };
4097 } else {
4098 let local_entity: Option<GetCustomFrameworkError> =
4099 serde_json::from_str(&local_content).ok();
4100 let local_error = datadog::ResponseContent {
4101 status: local_status,
4102 content: local_content,
4103 entity: local_entity,
4104 };
4105 Err(datadog::Error::ResponseError(local_error))
4106 }
4107 }
4108
4109 pub async fn get_finding(
4111 &self,
4112 finding_id: String,
4113 params: GetFindingOptionalParams,
4114 ) -> Result<crate::datadogV2::model::GetFindingResponse, datadog::Error<GetFindingError>> {
4115 match self.get_finding_with_http_info(finding_id, params).await {
4116 Ok(response_content) => {
4117 if let Some(e) = response_content.entity {
4118 Ok(e)
4119 } else {
4120 Err(datadog::Error::Serde(serde::de::Error::custom(
4121 "response content was None",
4122 )))
4123 }
4124 }
4125 Err(err) => Err(err),
4126 }
4127 }
4128
4129 pub async fn get_finding_with_http_info(
4131 &self,
4132 finding_id: String,
4133 params: GetFindingOptionalParams,
4134 ) -> Result<
4135 datadog::ResponseContent<crate::datadogV2::model::GetFindingResponse>,
4136 datadog::Error<GetFindingError>,
4137 > {
4138 let local_configuration = &self.config;
4139 let operation_id = "v2.get_finding";
4140 if local_configuration.is_unstable_operation_enabled(operation_id) {
4141 warn!("Using unstable operation {operation_id}");
4142 } else {
4143 let local_error = datadog::UnstableOperationDisabledError {
4144 msg: "Operation 'v2.get_finding' is not enabled".to_string(),
4145 };
4146 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
4147 }
4148
4149 let snapshot_timestamp = params.snapshot_timestamp;
4151
4152 let local_client = &self.client;
4153
4154 let local_uri_str = format!(
4155 "{}/api/v2/posture_management/findings/{finding_id}",
4156 local_configuration.get_operation_host(operation_id),
4157 finding_id = datadog::urlencode(finding_id)
4158 );
4159 let mut local_req_builder =
4160 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4161
4162 if let Some(ref local_query_param) = snapshot_timestamp {
4163 local_req_builder =
4164 local_req_builder.query(&[("snapshot_timestamp", &local_query_param.to_string())]);
4165 };
4166
4167 let mut headers = HeaderMap::new();
4169 headers.insert("Accept", HeaderValue::from_static("application/json"));
4170
4171 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4173 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4174 Err(e) => {
4175 log::warn!("Failed to parse user agent header: {e}, falling back to default");
4176 headers.insert(
4177 reqwest::header::USER_AGENT,
4178 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4179 )
4180 }
4181 };
4182
4183 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4185 headers.insert(
4186 "DD-API-KEY",
4187 HeaderValue::from_str(local_key.key.as_str())
4188 .expect("failed to parse DD-API-KEY header"),
4189 );
4190 };
4191 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4192 headers.insert(
4193 "DD-APPLICATION-KEY",
4194 HeaderValue::from_str(local_key.key.as_str())
4195 .expect("failed to parse DD-APPLICATION-KEY header"),
4196 );
4197 };
4198
4199 local_req_builder = local_req_builder.headers(headers);
4200 let local_req = local_req_builder.build()?;
4201 log::debug!("request content: {:?}", local_req.body());
4202 let local_resp = local_client.execute(local_req).await?;
4203
4204 let local_status = local_resp.status();
4205 let local_content = local_resp.text().await?;
4206 log::debug!("response content: {}", local_content);
4207
4208 if !local_status.is_client_error() && !local_status.is_server_error() {
4209 match serde_json::from_str::<crate::datadogV2::model::GetFindingResponse>(
4210 &local_content,
4211 ) {
4212 Ok(e) => {
4213 return Ok(datadog::ResponseContent {
4214 status: local_status,
4215 content: local_content,
4216 entity: Some(e),
4217 })
4218 }
4219 Err(e) => return Err(datadog::Error::Serde(e)),
4220 };
4221 } else {
4222 let local_entity: Option<GetFindingError> = serde_json::from_str(&local_content).ok();
4223 let local_error = datadog::ResponseContent {
4224 status: local_status,
4225 content: local_content,
4226 entity: local_entity,
4227 };
4228 Err(datadog::Error::ResponseError(local_error))
4229 }
4230 }
4231
4232 pub async fn get_historical_job(
4234 &self,
4235 job_id: String,
4236 ) -> Result<crate::datadogV2::model::HistoricalJobResponse, datadog::Error<GetHistoricalJobError>>
4237 {
4238 match self.get_historical_job_with_http_info(job_id).await {
4239 Ok(response_content) => {
4240 if let Some(e) = response_content.entity {
4241 Ok(e)
4242 } else {
4243 Err(datadog::Error::Serde(serde::de::Error::custom(
4244 "response content was None",
4245 )))
4246 }
4247 }
4248 Err(err) => Err(err),
4249 }
4250 }
4251
4252 pub async fn get_historical_job_with_http_info(
4254 &self,
4255 job_id: String,
4256 ) -> Result<
4257 datadog::ResponseContent<crate::datadogV2::model::HistoricalJobResponse>,
4258 datadog::Error<GetHistoricalJobError>,
4259 > {
4260 let local_configuration = &self.config;
4261 let operation_id = "v2.get_historical_job";
4262 if local_configuration.is_unstable_operation_enabled(operation_id) {
4263 warn!("Using unstable operation {operation_id}");
4264 } else {
4265 let local_error = datadog::UnstableOperationDisabledError {
4266 msg: "Operation 'v2.get_historical_job' is not enabled".to_string(),
4267 };
4268 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
4269 }
4270
4271 let local_client = &self.client;
4272
4273 let local_uri_str = format!(
4274 "{}/api/v2/siem-historical-detections/jobs/{job_id}",
4275 local_configuration.get_operation_host(operation_id),
4276 job_id = datadog::urlencode(job_id)
4277 );
4278 let mut local_req_builder =
4279 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4280
4281 let mut headers = HeaderMap::new();
4283 headers.insert("Accept", HeaderValue::from_static("application/json"));
4284
4285 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4287 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4288 Err(e) => {
4289 log::warn!("Failed to parse user agent header: {e}, falling back to default");
4290 headers.insert(
4291 reqwest::header::USER_AGENT,
4292 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4293 )
4294 }
4295 };
4296
4297 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4299 headers.insert(
4300 "DD-API-KEY",
4301 HeaderValue::from_str(local_key.key.as_str())
4302 .expect("failed to parse DD-API-KEY header"),
4303 );
4304 };
4305 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4306 headers.insert(
4307 "DD-APPLICATION-KEY",
4308 HeaderValue::from_str(local_key.key.as_str())
4309 .expect("failed to parse DD-APPLICATION-KEY header"),
4310 );
4311 };
4312
4313 local_req_builder = local_req_builder.headers(headers);
4314 let local_req = local_req_builder.build()?;
4315 log::debug!("request content: {:?}", local_req.body());
4316 let local_resp = local_client.execute(local_req).await?;
4317
4318 let local_status = local_resp.status();
4319 let local_content = local_resp.text().await?;
4320 log::debug!("response content: {}", local_content);
4321
4322 if !local_status.is_client_error() && !local_status.is_server_error() {
4323 match serde_json::from_str::<crate::datadogV2::model::HistoricalJobResponse>(
4324 &local_content,
4325 ) {
4326 Ok(e) => {
4327 return Ok(datadog::ResponseContent {
4328 status: local_status,
4329 content: local_content,
4330 entity: Some(e),
4331 })
4332 }
4333 Err(e) => return Err(datadog::Error::Serde(e)),
4334 };
4335 } else {
4336 let local_entity: Option<GetHistoricalJobError> =
4337 serde_json::from_str(&local_content).ok();
4338 let local_error = datadog::ResponseContent {
4339 status: local_status,
4340 content: local_content,
4341 entity: local_entity,
4342 };
4343 Err(datadog::Error::ResponseError(local_error))
4344 }
4345 }
4346
4347 pub async fn get_resource_evaluation_filters(
4349 &self,
4350 params: GetResourceEvaluationFiltersOptionalParams,
4351 ) -> Result<
4352 crate::datadogV2::model::GetResourceEvaluationFiltersResponse,
4353 datadog::Error<GetResourceEvaluationFiltersError>,
4354 > {
4355 match self
4356 .get_resource_evaluation_filters_with_http_info(params)
4357 .await
4358 {
4359 Ok(response_content) => {
4360 if let Some(e) = response_content.entity {
4361 Ok(e)
4362 } else {
4363 Err(datadog::Error::Serde(serde::de::Error::custom(
4364 "response content was None",
4365 )))
4366 }
4367 }
4368 Err(err) => Err(err),
4369 }
4370 }
4371
4372 pub async fn get_resource_evaluation_filters_with_http_info(
4374 &self,
4375 params: GetResourceEvaluationFiltersOptionalParams,
4376 ) -> Result<
4377 datadog::ResponseContent<crate::datadogV2::model::GetResourceEvaluationFiltersResponse>,
4378 datadog::Error<GetResourceEvaluationFiltersError>,
4379 > {
4380 let local_configuration = &self.config;
4381 let operation_id = "v2.get_resource_evaluation_filters";
4382
4383 let cloud_provider = params.cloud_provider;
4385 let account_id = params.account_id;
4386 let skip_cache = params.skip_cache;
4387
4388 let local_client = &self.client;
4389
4390 let local_uri_str = format!(
4391 "{}/api/v2/cloud_security_management/resource_filters",
4392 local_configuration.get_operation_host(operation_id)
4393 );
4394 let mut local_req_builder =
4395 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4396
4397 if let Some(ref local_query_param) = cloud_provider {
4398 local_req_builder =
4399 local_req_builder.query(&[("cloud_provider", &local_query_param.to_string())]);
4400 };
4401 if let Some(ref local_query_param) = account_id {
4402 local_req_builder =
4403 local_req_builder.query(&[("account_id", &local_query_param.to_string())]);
4404 };
4405 if let Some(ref local_query_param) = skip_cache {
4406 local_req_builder =
4407 local_req_builder.query(&[("skip_cache", &local_query_param.to_string())]);
4408 };
4409
4410 let mut headers = HeaderMap::new();
4412 headers.insert("Accept", HeaderValue::from_static("application/json"));
4413
4414 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4416 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4417 Err(e) => {
4418 log::warn!("Failed to parse user agent header: {e}, falling back to default");
4419 headers.insert(
4420 reqwest::header::USER_AGENT,
4421 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4422 )
4423 }
4424 };
4425
4426 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4428 headers.insert(
4429 "DD-API-KEY",
4430 HeaderValue::from_str(local_key.key.as_str())
4431 .expect("failed to parse DD-API-KEY header"),
4432 );
4433 };
4434 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4435 headers.insert(
4436 "DD-APPLICATION-KEY",
4437 HeaderValue::from_str(local_key.key.as_str())
4438 .expect("failed to parse DD-APPLICATION-KEY header"),
4439 );
4440 };
4441
4442 local_req_builder = local_req_builder.headers(headers);
4443 let local_req = local_req_builder.build()?;
4444 log::debug!("request content: {:?}", local_req.body());
4445 let local_resp = local_client.execute(local_req).await?;
4446
4447 let local_status = local_resp.status();
4448 let local_content = local_resp.text().await?;
4449 log::debug!("response content: {}", local_content);
4450
4451 if !local_status.is_client_error() && !local_status.is_server_error() {
4452 match serde_json::from_str::<
4453 crate::datadogV2::model::GetResourceEvaluationFiltersResponse,
4454 >(&local_content)
4455 {
4456 Ok(e) => {
4457 return Ok(datadog::ResponseContent {
4458 status: local_status,
4459 content: local_content,
4460 entity: Some(e),
4461 })
4462 }
4463 Err(e) => return Err(datadog::Error::Serde(e)),
4464 };
4465 } else {
4466 let local_entity: Option<GetResourceEvaluationFiltersError> =
4467 serde_json::from_str(&local_content).ok();
4468 let local_error = datadog::ResponseContent {
4469 status: local_status,
4470 content: local_content,
4471 entity: local_entity,
4472 };
4473 Err(datadog::Error::ResponseError(local_error))
4474 }
4475 }
4476
4477 pub async fn get_rule_version_history(
4479 &self,
4480 rule_id: String,
4481 params: GetRuleVersionHistoryOptionalParams,
4482 ) -> Result<
4483 crate::datadogV2::model::GetRuleVersionHistoryResponse,
4484 datadog::Error<GetRuleVersionHistoryError>,
4485 > {
4486 match self
4487 .get_rule_version_history_with_http_info(rule_id, params)
4488 .await
4489 {
4490 Ok(response_content) => {
4491 if let Some(e) = response_content.entity {
4492 Ok(e)
4493 } else {
4494 Err(datadog::Error::Serde(serde::de::Error::custom(
4495 "response content was None",
4496 )))
4497 }
4498 }
4499 Err(err) => Err(err),
4500 }
4501 }
4502
4503 pub async fn get_rule_version_history_with_http_info(
4505 &self,
4506 rule_id: String,
4507 params: GetRuleVersionHistoryOptionalParams,
4508 ) -> Result<
4509 datadog::ResponseContent<crate::datadogV2::model::GetRuleVersionHistoryResponse>,
4510 datadog::Error<GetRuleVersionHistoryError>,
4511 > {
4512 let local_configuration = &self.config;
4513 let operation_id = "v2.get_rule_version_history";
4514 if local_configuration.is_unstable_operation_enabled(operation_id) {
4515 warn!("Using unstable operation {operation_id}");
4516 } else {
4517 let local_error = datadog::UnstableOperationDisabledError {
4518 msg: "Operation 'v2.get_rule_version_history' is not enabled".to_string(),
4519 };
4520 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
4521 }
4522
4523 let page_size = params.page_size;
4525 let page_number = params.page_number;
4526
4527 let local_client = &self.client;
4528
4529 let local_uri_str = format!(
4530 "{}/api/v2/security_monitoring/rules/{rule_id}/version_history",
4531 local_configuration.get_operation_host(operation_id),
4532 rule_id = datadog::urlencode(rule_id)
4533 );
4534 let mut local_req_builder =
4535 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4536
4537 if let Some(ref local_query_param) = page_size {
4538 local_req_builder =
4539 local_req_builder.query(&[("page[size]", &local_query_param.to_string())]);
4540 };
4541 if let Some(ref local_query_param) = page_number {
4542 local_req_builder =
4543 local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
4544 };
4545
4546 let mut headers = HeaderMap::new();
4548 headers.insert("Accept", HeaderValue::from_static("application/json"));
4549
4550 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4552 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4553 Err(e) => {
4554 log::warn!("Failed to parse user agent header: {e}, falling back to default");
4555 headers.insert(
4556 reqwest::header::USER_AGENT,
4557 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4558 )
4559 }
4560 };
4561
4562 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4564 headers.insert(
4565 "DD-API-KEY",
4566 HeaderValue::from_str(local_key.key.as_str())
4567 .expect("failed to parse DD-API-KEY header"),
4568 );
4569 };
4570 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4571 headers.insert(
4572 "DD-APPLICATION-KEY",
4573 HeaderValue::from_str(local_key.key.as_str())
4574 .expect("failed to parse DD-APPLICATION-KEY header"),
4575 );
4576 };
4577
4578 local_req_builder = local_req_builder.headers(headers);
4579 let local_req = local_req_builder.build()?;
4580 log::debug!("request content: {:?}", local_req.body());
4581 let local_resp = local_client.execute(local_req).await?;
4582
4583 let local_status = local_resp.status();
4584 let local_content = local_resp.text().await?;
4585 log::debug!("response content: {}", local_content);
4586
4587 if !local_status.is_client_error() && !local_status.is_server_error() {
4588 match serde_json::from_str::<crate::datadogV2::model::GetRuleVersionHistoryResponse>(
4589 &local_content,
4590 ) {
4591 Ok(e) => {
4592 return Ok(datadog::ResponseContent {
4593 status: local_status,
4594 content: local_content,
4595 entity: Some(e),
4596 })
4597 }
4598 Err(e) => return Err(datadog::Error::Serde(e)),
4599 };
4600 } else {
4601 let local_entity: Option<GetRuleVersionHistoryError> =
4602 serde_json::from_str(&local_content).ok();
4603 let local_error = datadog::ResponseContent {
4604 status: local_status,
4605 content: local_content,
4606 entity: local_entity,
4607 };
4608 Err(datadog::Error::ResponseError(local_error))
4609 }
4610 }
4611
4612 pub async fn get_sbom(
4615 &self,
4616 asset_type: crate::datadogV2::model::AssetType,
4617 filter_asset_name: String,
4618 params: GetSBOMOptionalParams,
4619 ) -> Result<crate::datadogV2::model::GetSBOMResponse, datadog::Error<GetSBOMError>> {
4620 match self
4621 .get_sbom_with_http_info(asset_type, filter_asset_name, params)
4622 .await
4623 {
4624 Ok(response_content) => {
4625 if let Some(e) = response_content.entity {
4626 Ok(e)
4627 } else {
4628 Err(datadog::Error::Serde(serde::de::Error::custom(
4629 "response content was None",
4630 )))
4631 }
4632 }
4633 Err(err) => Err(err),
4634 }
4635 }
4636
4637 pub async fn get_sbom_with_http_info(
4640 &self,
4641 asset_type: crate::datadogV2::model::AssetType,
4642 filter_asset_name: String,
4643 params: GetSBOMOptionalParams,
4644 ) -> Result<
4645 datadog::ResponseContent<crate::datadogV2::model::GetSBOMResponse>,
4646 datadog::Error<GetSBOMError>,
4647 > {
4648 let local_configuration = &self.config;
4649 let operation_id = "v2.get_sbom";
4650 if local_configuration.is_unstable_operation_enabled(operation_id) {
4651 warn!("Using unstable operation {operation_id}");
4652 } else {
4653 let local_error = datadog::UnstableOperationDisabledError {
4654 msg: "Operation 'v2.get_sbom' is not enabled".to_string(),
4655 };
4656 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
4657 }
4658
4659 let filter_repo_digest = params.filter_repo_digest;
4661
4662 let local_client = &self.client;
4663
4664 let local_uri_str = format!(
4665 "{}/api/v2/security/sboms/{asset_type}",
4666 local_configuration.get_operation_host(operation_id),
4667 asset_type = datadog::urlencode(asset_type.to_string())
4668 );
4669 let mut local_req_builder =
4670 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4671
4672 local_req_builder =
4673 local_req_builder.query(&[("filter[asset_name]", &filter_asset_name.to_string())]);
4674 if let Some(ref local_query_param) = filter_repo_digest {
4675 local_req_builder =
4676 local_req_builder.query(&[("filter[repo_digest]", &local_query_param.to_string())]);
4677 };
4678
4679 let mut headers = HeaderMap::new();
4681 headers.insert("Accept", HeaderValue::from_static("application/json"));
4682
4683 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4685 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4686 Err(e) => {
4687 log::warn!("Failed to parse user agent header: {e}, falling back to default");
4688 headers.insert(
4689 reqwest::header::USER_AGENT,
4690 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4691 )
4692 }
4693 };
4694
4695 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4697 headers.insert(
4698 "DD-API-KEY",
4699 HeaderValue::from_str(local_key.key.as_str())
4700 .expect("failed to parse DD-API-KEY header"),
4701 );
4702 };
4703 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4704 headers.insert(
4705 "DD-APPLICATION-KEY",
4706 HeaderValue::from_str(local_key.key.as_str())
4707 .expect("failed to parse DD-APPLICATION-KEY header"),
4708 );
4709 };
4710
4711 local_req_builder = local_req_builder.headers(headers);
4712 let local_req = local_req_builder.build()?;
4713 log::debug!("request content: {:?}", local_req.body());
4714 let local_resp = local_client.execute(local_req).await?;
4715
4716 let local_status = local_resp.status();
4717 let local_content = local_resp.text().await?;
4718 log::debug!("response content: {}", local_content);
4719
4720 if !local_status.is_client_error() && !local_status.is_server_error() {
4721 match serde_json::from_str::<crate::datadogV2::model::GetSBOMResponse>(&local_content) {
4722 Ok(e) => {
4723 return Ok(datadog::ResponseContent {
4724 status: local_status,
4725 content: local_content,
4726 entity: Some(e),
4727 })
4728 }
4729 Err(e) => return Err(datadog::Error::Serde(e)),
4730 };
4731 } else {
4732 let local_entity: Option<GetSBOMError> = serde_json::from_str(&local_content).ok();
4733 let local_error = datadog::ResponseContent {
4734 status: local_status,
4735 content: local_content,
4736 entity: local_entity,
4737 };
4738 Err(datadog::Error::ResponseError(local_error))
4739 }
4740 }
4741
4742 pub async fn get_security_filter(
4747 &self,
4748 security_filter_id: String,
4749 ) -> Result<
4750 crate::datadogV2::model::SecurityFilterResponse,
4751 datadog::Error<GetSecurityFilterError>,
4752 > {
4753 match self
4754 .get_security_filter_with_http_info(security_filter_id)
4755 .await
4756 {
4757 Ok(response_content) => {
4758 if let Some(e) = response_content.entity {
4759 Ok(e)
4760 } else {
4761 Err(datadog::Error::Serde(serde::de::Error::custom(
4762 "response content was None",
4763 )))
4764 }
4765 }
4766 Err(err) => Err(err),
4767 }
4768 }
4769
4770 pub async fn get_security_filter_with_http_info(
4775 &self,
4776 security_filter_id: String,
4777 ) -> Result<
4778 datadog::ResponseContent<crate::datadogV2::model::SecurityFilterResponse>,
4779 datadog::Error<GetSecurityFilterError>,
4780 > {
4781 let local_configuration = &self.config;
4782 let operation_id = "v2.get_security_filter";
4783
4784 let local_client = &self.client;
4785
4786 let local_uri_str = format!(
4787 "{}/api/v2/security_monitoring/configuration/security_filters/{security_filter_id}",
4788 local_configuration.get_operation_host(operation_id),
4789 security_filter_id = datadog::urlencode(security_filter_id)
4790 );
4791 let mut local_req_builder =
4792 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4793
4794 let mut headers = HeaderMap::new();
4796 headers.insert("Accept", HeaderValue::from_static("application/json"));
4797
4798 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4800 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4801 Err(e) => {
4802 log::warn!("Failed to parse user agent header: {e}, falling back to default");
4803 headers.insert(
4804 reqwest::header::USER_AGENT,
4805 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4806 )
4807 }
4808 };
4809
4810 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4812 headers.insert(
4813 "DD-API-KEY",
4814 HeaderValue::from_str(local_key.key.as_str())
4815 .expect("failed to parse DD-API-KEY header"),
4816 );
4817 };
4818 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4819 headers.insert(
4820 "DD-APPLICATION-KEY",
4821 HeaderValue::from_str(local_key.key.as_str())
4822 .expect("failed to parse DD-APPLICATION-KEY header"),
4823 );
4824 };
4825
4826 local_req_builder = local_req_builder.headers(headers);
4827 let local_req = local_req_builder.build()?;
4828 log::debug!("request content: {:?}", local_req.body());
4829 let local_resp = local_client.execute(local_req).await?;
4830
4831 let local_status = local_resp.status();
4832 let local_content = local_resp.text().await?;
4833 log::debug!("response content: {}", local_content);
4834
4835 if !local_status.is_client_error() && !local_status.is_server_error() {
4836 match serde_json::from_str::<crate::datadogV2::model::SecurityFilterResponse>(
4837 &local_content,
4838 ) {
4839 Ok(e) => {
4840 return Ok(datadog::ResponseContent {
4841 status: local_status,
4842 content: local_content,
4843 entity: Some(e),
4844 })
4845 }
4846 Err(e) => return Err(datadog::Error::Serde(e)),
4847 };
4848 } else {
4849 let local_entity: Option<GetSecurityFilterError> =
4850 serde_json::from_str(&local_content).ok();
4851 let local_error = datadog::ResponseContent {
4852 status: local_status,
4853 content: local_content,
4854 entity: local_entity,
4855 };
4856 Err(datadog::Error::ResponseError(local_error))
4857 }
4858 }
4859
4860 pub async fn get_security_monitoring_rule(
4862 &self,
4863 rule_id: String,
4864 ) -> Result<
4865 crate::datadogV2::model::SecurityMonitoringRuleResponse,
4866 datadog::Error<GetSecurityMonitoringRuleError>,
4867 > {
4868 match self
4869 .get_security_monitoring_rule_with_http_info(rule_id)
4870 .await
4871 {
4872 Ok(response_content) => {
4873 if let Some(e) = response_content.entity {
4874 Ok(e)
4875 } else {
4876 Err(datadog::Error::Serde(serde::de::Error::custom(
4877 "response content was None",
4878 )))
4879 }
4880 }
4881 Err(err) => Err(err),
4882 }
4883 }
4884
4885 pub async fn get_security_monitoring_rule_with_http_info(
4887 &self,
4888 rule_id: String,
4889 ) -> Result<
4890 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleResponse>,
4891 datadog::Error<GetSecurityMonitoringRuleError>,
4892 > {
4893 let local_configuration = &self.config;
4894 let operation_id = "v2.get_security_monitoring_rule";
4895
4896 let local_client = &self.client;
4897
4898 let local_uri_str = format!(
4899 "{}/api/v2/security_monitoring/rules/{rule_id}",
4900 local_configuration.get_operation_host(operation_id),
4901 rule_id = datadog::urlencode(rule_id)
4902 );
4903 let mut local_req_builder =
4904 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4905
4906 let mut headers = HeaderMap::new();
4908 headers.insert("Accept", HeaderValue::from_static("application/json"));
4909
4910 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4912 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4913 Err(e) => {
4914 log::warn!("Failed to parse user agent header: {e}, falling back to default");
4915 headers.insert(
4916 reqwest::header::USER_AGENT,
4917 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4918 )
4919 }
4920 };
4921
4922 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4924 headers.insert(
4925 "DD-API-KEY",
4926 HeaderValue::from_str(local_key.key.as_str())
4927 .expect("failed to parse DD-API-KEY header"),
4928 );
4929 };
4930 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4931 headers.insert(
4932 "DD-APPLICATION-KEY",
4933 HeaderValue::from_str(local_key.key.as_str())
4934 .expect("failed to parse DD-APPLICATION-KEY header"),
4935 );
4936 };
4937
4938 local_req_builder = local_req_builder.headers(headers);
4939 let local_req = local_req_builder.build()?;
4940 log::debug!("request content: {:?}", local_req.body());
4941 let local_resp = local_client.execute(local_req).await?;
4942
4943 let local_status = local_resp.status();
4944 let local_content = local_resp.text().await?;
4945 log::debug!("response content: {}", local_content);
4946
4947 if !local_status.is_client_error() && !local_status.is_server_error() {
4948 match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringRuleResponse>(
4949 &local_content,
4950 ) {
4951 Ok(e) => {
4952 return Ok(datadog::ResponseContent {
4953 status: local_status,
4954 content: local_content,
4955 entity: Some(e),
4956 })
4957 }
4958 Err(e) => return Err(datadog::Error::Serde(e)),
4959 };
4960 } else {
4961 let local_entity: Option<GetSecurityMonitoringRuleError> =
4962 serde_json::from_str(&local_content).ok();
4963 let local_error = datadog::ResponseContent {
4964 status: local_status,
4965 content: local_content,
4966 entity: local_entity,
4967 };
4968 Err(datadog::Error::ResponseError(local_error))
4969 }
4970 }
4971
4972 pub async fn get_security_monitoring_signal(
4974 &self,
4975 signal_id: String,
4976 ) -> Result<
4977 crate::datadogV2::model::SecurityMonitoringSignalResponse,
4978 datadog::Error<GetSecurityMonitoringSignalError>,
4979 > {
4980 match self
4981 .get_security_monitoring_signal_with_http_info(signal_id)
4982 .await
4983 {
4984 Ok(response_content) => {
4985 if let Some(e) = response_content.entity {
4986 Ok(e)
4987 } else {
4988 Err(datadog::Error::Serde(serde::de::Error::custom(
4989 "response content was None",
4990 )))
4991 }
4992 }
4993 Err(err) => Err(err),
4994 }
4995 }
4996
4997 pub async fn get_security_monitoring_signal_with_http_info(
4999 &self,
5000 signal_id: String,
5001 ) -> Result<
5002 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSignalResponse>,
5003 datadog::Error<GetSecurityMonitoringSignalError>,
5004 > {
5005 let local_configuration = &self.config;
5006 let operation_id = "v2.get_security_monitoring_signal";
5007
5008 let local_client = &self.client;
5009
5010 let local_uri_str = format!(
5011 "{}/api/v2/security_monitoring/signals/{signal_id}",
5012 local_configuration.get_operation_host(operation_id),
5013 signal_id = datadog::urlencode(signal_id)
5014 );
5015 let mut local_req_builder =
5016 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5017
5018 let mut headers = HeaderMap::new();
5020 headers.insert("Accept", HeaderValue::from_static("application/json"));
5021
5022 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5024 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5025 Err(e) => {
5026 log::warn!("Failed to parse user agent header: {e}, falling back to default");
5027 headers.insert(
5028 reqwest::header::USER_AGENT,
5029 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5030 )
5031 }
5032 };
5033
5034 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5036 headers.insert(
5037 "DD-API-KEY",
5038 HeaderValue::from_str(local_key.key.as_str())
5039 .expect("failed to parse DD-API-KEY header"),
5040 );
5041 };
5042 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5043 headers.insert(
5044 "DD-APPLICATION-KEY",
5045 HeaderValue::from_str(local_key.key.as_str())
5046 .expect("failed to parse DD-APPLICATION-KEY header"),
5047 );
5048 };
5049
5050 local_req_builder = local_req_builder.headers(headers);
5051 let local_req = local_req_builder.build()?;
5052 log::debug!("request content: {:?}", local_req.body());
5053 let local_resp = local_client.execute(local_req).await?;
5054
5055 let local_status = local_resp.status();
5056 let local_content = local_resp.text().await?;
5057 log::debug!("response content: {}", local_content);
5058
5059 if !local_status.is_client_error() && !local_status.is_server_error() {
5060 match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringSignalResponse>(
5061 &local_content,
5062 ) {
5063 Ok(e) => {
5064 return Ok(datadog::ResponseContent {
5065 status: local_status,
5066 content: local_content,
5067 entity: Some(e),
5068 })
5069 }
5070 Err(e) => return Err(datadog::Error::Serde(e)),
5071 };
5072 } else {
5073 let local_entity: Option<GetSecurityMonitoringSignalError> =
5074 serde_json::from_str(&local_content).ok();
5075 let local_error = datadog::ResponseContent {
5076 status: local_status,
5077 content: local_content,
5078 entity: local_entity,
5079 };
5080 Err(datadog::Error::ResponseError(local_error))
5081 }
5082 }
5083
5084 pub async fn get_security_monitoring_suppression(
5086 &self,
5087 suppression_id: String,
5088 ) -> Result<
5089 crate::datadogV2::model::SecurityMonitoringSuppressionResponse,
5090 datadog::Error<GetSecurityMonitoringSuppressionError>,
5091 > {
5092 match self
5093 .get_security_monitoring_suppression_with_http_info(suppression_id)
5094 .await
5095 {
5096 Ok(response_content) => {
5097 if let Some(e) = response_content.entity {
5098 Ok(e)
5099 } else {
5100 Err(datadog::Error::Serde(serde::de::Error::custom(
5101 "response content was None",
5102 )))
5103 }
5104 }
5105 Err(err) => Err(err),
5106 }
5107 }
5108
5109 pub async fn get_security_monitoring_suppression_with_http_info(
5111 &self,
5112 suppression_id: String,
5113 ) -> Result<
5114 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSuppressionResponse>,
5115 datadog::Error<GetSecurityMonitoringSuppressionError>,
5116 > {
5117 let local_configuration = &self.config;
5118 let operation_id = "v2.get_security_monitoring_suppression";
5119
5120 let local_client = &self.client;
5121
5122 let local_uri_str = format!(
5123 "{}/api/v2/security_monitoring/configuration/suppressions/{suppression_id}",
5124 local_configuration.get_operation_host(operation_id),
5125 suppression_id = datadog::urlencode(suppression_id)
5126 );
5127 let mut local_req_builder =
5128 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5129
5130 let mut headers = HeaderMap::new();
5132 headers.insert("Accept", HeaderValue::from_static("application/json"));
5133
5134 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5136 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5137 Err(e) => {
5138 log::warn!("Failed to parse user agent header: {e}, falling back to default");
5139 headers.insert(
5140 reqwest::header::USER_AGENT,
5141 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5142 )
5143 }
5144 };
5145
5146 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5148 headers.insert(
5149 "DD-API-KEY",
5150 HeaderValue::from_str(local_key.key.as_str())
5151 .expect("failed to parse DD-API-KEY header"),
5152 );
5153 };
5154 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5155 headers.insert(
5156 "DD-APPLICATION-KEY",
5157 HeaderValue::from_str(local_key.key.as_str())
5158 .expect("failed to parse DD-APPLICATION-KEY header"),
5159 );
5160 };
5161
5162 local_req_builder = local_req_builder.headers(headers);
5163 let local_req = local_req_builder.build()?;
5164 log::debug!("request content: {:?}", local_req.body());
5165 let local_resp = local_client.execute(local_req).await?;
5166
5167 let local_status = local_resp.status();
5168 let local_content = local_resp.text().await?;
5169 log::debug!("response content: {}", local_content);
5170
5171 if !local_status.is_client_error() && !local_status.is_server_error() {
5172 match serde_json::from_str::<
5173 crate::datadogV2::model::SecurityMonitoringSuppressionResponse,
5174 >(&local_content)
5175 {
5176 Ok(e) => {
5177 return Ok(datadog::ResponseContent {
5178 status: local_status,
5179 content: local_content,
5180 entity: Some(e),
5181 })
5182 }
5183 Err(e) => return Err(datadog::Error::Serde(e)),
5184 };
5185 } else {
5186 let local_entity: Option<GetSecurityMonitoringSuppressionError> =
5187 serde_json::from_str(&local_content).ok();
5188 let local_error = datadog::ResponseContent {
5189 status: local_status,
5190 content: local_content,
5191 entity: local_entity,
5192 };
5193 Err(datadog::Error::ResponseError(local_error))
5194 }
5195 }
5196
5197 pub async fn get_signal_notification_rule(
5199 &self,
5200 id: String,
5201 ) -> Result<
5202 crate::datadogV2::model::NotificationRuleResponse,
5203 datadog::Error<GetSignalNotificationRuleError>,
5204 > {
5205 match self.get_signal_notification_rule_with_http_info(id).await {
5206 Ok(response_content) => {
5207 if let Some(e) = response_content.entity {
5208 Ok(e)
5209 } else {
5210 Err(datadog::Error::Serde(serde::de::Error::custom(
5211 "response content was None",
5212 )))
5213 }
5214 }
5215 Err(err) => Err(err),
5216 }
5217 }
5218
5219 pub async fn get_signal_notification_rule_with_http_info(
5221 &self,
5222 id: String,
5223 ) -> Result<
5224 datadog::ResponseContent<crate::datadogV2::model::NotificationRuleResponse>,
5225 datadog::Error<GetSignalNotificationRuleError>,
5226 > {
5227 let local_configuration = &self.config;
5228 let operation_id = "v2.get_signal_notification_rule";
5229
5230 let local_client = &self.client;
5231
5232 let local_uri_str = format!(
5233 "{}/api/v2/security/signals/notification_rules/{id}",
5234 local_configuration.get_operation_host(operation_id),
5235 id = datadog::urlencode(id)
5236 );
5237 let mut local_req_builder =
5238 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5239
5240 let mut headers = HeaderMap::new();
5242 headers.insert("Accept", HeaderValue::from_static("application/json"));
5243
5244 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5246 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5247 Err(e) => {
5248 log::warn!("Failed to parse user agent header: {e}, falling back to default");
5249 headers.insert(
5250 reqwest::header::USER_AGENT,
5251 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5252 )
5253 }
5254 };
5255
5256 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5258 headers.insert(
5259 "DD-API-KEY",
5260 HeaderValue::from_str(local_key.key.as_str())
5261 .expect("failed to parse DD-API-KEY header"),
5262 );
5263 };
5264 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5265 headers.insert(
5266 "DD-APPLICATION-KEY",
5267 HeaderValue::from_str(local_key.key.as_str())
5268 .expect("failed to parse DD-APPLICATION-KEY header"),
5269 );
5270 };
5271
5272 local_req_builder = local_req_builder.headers(headers);
5273 let local_req = local_req_builder.build()?;
5274 log::debug!("request content: {:?}", local_req.body());
5275 let local_resp = local_client.execute(local_req).await?;
5276
5277 let local_status = local_resp.status();
5278 let local_content = local_resp.text().await?;
5279 log::debug!("response content: {}", local_content);
5280
5281 if !local_status.is_client_error() && !local_status.is_server_error() {
5282 match serde_json::from_str::<crate::datadogV2::model::NotificationRuleResponse>(
5283 &local_content,
5284 ) {
5285 Ok(e) => {
5286 return Ok(datadog::ResponseContent {
5287 status: local_status,
5288 content: local_content,
5289 entity: Some(e),
5290 })
5291 }
5292 Err(e) => return Err(datadog::Error::Serde(e)),
5293 };
5294 } else {
5295 let local_entity: Option<GetSignalNotificationRuleError> =
5296 serde_json::from_str(&local_content).ok();
5297 let local_error = datadog::ResponseContent {
5298 status: local_status,
5299 content: local_content,
5300 entity: local_entity,
5301 };
5302 Err(datadog::Error::ResponseError(local_error))
5303 }
5304 }
5305
5306 pub async fn get_signal_notification_rules(
5308 &self,
5309 ) -> Result<
5310 std::collections::BTreeMap<String, serde_json::Value>,
5311 datadog::Error<GetSignalNotificationRulesError>,
5312 > {
5313 match self.get_signal_notification_rules_with_http_info().await {
5314 Ok(response_content) => {
5315 if let Some(e) = response_content.entity {
5316 Ok(e)
5317 } else {
5318 Err(datadog::Error::Serde(serde::de::Error::custom(
5319 "response content was None",
5320 )))
5321 }
5322 }
5323 Err(err) => Err(err),
5324 }
5325 }
5326
5327 pub async fn get_signal_notification_rules_with_http_info(
5329 &self,
5330 ) -> Result<
5331 datadog::ResponseContent<std::collections::BTreeMap<String, serde_json::Value>>,
5332 datadog::Error<GetSignalNotificationRulesError>,
5333 > {
5334 let local_configuration = &self.config;
5335 let operation_id = "v2.get_signal_notification_rules";
5336
5337 let local_client = &self.client;
5338
5339 let local_uri_str = format!(
5340 "{}/api/v2/security/signals/notification_rules",
5341 local_configuration.get_operation_host(operation_id)
5342 );
5343 let mut local_req_builder =
5344 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5345
5346 let mut headers = HeaderMap::new();
5348 headers.insert("Accept", HeaderValue::from_static("application/json"));
5349
5350 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5352 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5353 Err(e) => {
5354 log::warn!("Failed to parse user agent header: {e}, falling back to default");
5355 headers.insert(
5356 reqwest::header::USER_AGENT,
5357 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5358 )
5359 }
5360 };
5361
5362 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5364 headers.insert(
5365 "DD-API-KEY",
5366 HeaderValue::from_str(local_key.key.as_str())
5367 .expect("failed to parse DD-API-KEY header"),
5368 );
5369 };
5370 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5371 headers.insert(
5372 "DD-APPLICATION-KEY",
5373 HeaderValue::from_str(local_key.key.as_str())
5374 .expect("failed to parse DD-APPLICATION-KEY header"),
5375 );
5376 };
5377
5378 local_req_builder = local_req_builder.headers(headers);
5379 let local_req = local_req_builder.build()?;
5380 log::debug!("request content: {:?}", local_req.body());
5381 let local_resp = local_client.execute(local_req).await?;
5382
5383 let local_status = local_resp.status();
5384 let local_content = local_resp.text().await?;
5385 log::debug!("response content: {}", local_content);
5386
5387 if !local_status.is_client_error() && !local_status.is_server_error() {
5388 match serde_json::from_str::<std::collections::BTreeMap<String, serde_json::Value>>(
5389 &local_content,
5390 ) {
5391 Ok(e) => {
5392 return Ok(datadog::ResponseContent {
5393 status: local_status,
5394 content: local_content,
5395 entity: Some(e),
5396 })
5397 }
5398 Err(e) => return Err(datadog::Error::Serde(e)),
5399 };
5400 } else {
5401 let local_entity: Option<GetSignalNotificationRulesError> =
5402 serde_json::from_str(&local_content).ok();
5403 let local_error = datadog::ResponseContent {
5404 status: local_status,
5405 content: local_content,
5406 entity: local_entity,
5407 };
5408 Err(datadog::Error::ResponseError(local_error))
5409 }
5410 }
5411
5412 pub async fn get_vulnerability_notification_rule(
5414 &self,
5415 id: String,
5416 ) -> Result<
5417 crate::datadogV2::model::NotificationRuleResponse,
5418 datadog::Error<GetVulnerabilityNotificationRuleError>,
5419 > {
5420 match self
5421 .get_vulnerability_notification_rule_with_http_info(id)
5422 .await
5423 {
5424 Ok(response_content) => {
5425 if let Some(e) = response_content.entity {
5426 Ok(e)
5427 } else {
5428 Err(datadog::Error::Serde(serde::de::Error::custom(
5429 "response content was None",
5430 )))
5431 }
5432 }
5433 Err(err) => Err(err),
5434 }
5435 }
5436
5437 pub async fn get_vulnerability_notification_rule_with_http_info(
5439 &self,
5440 id: String,
5441 ) -> Result<
5442 datadog::ResponseContent<crate::datadogV2::model::NotificationRuleResponse>,
5443 datadog::Error<GetVulnerabilityNotificationRuleError>,
5444 > {
5445 let local_configuration = &self.config;
5446 let operation_id = "v2.get_vulnerability_notification_rule";
5447
5448 let local_client = &self.client;
5449
5450 let local_uri_str = format!(
5451 "{}/api/v2/security/vulnerabilities/notification_rules/{id}",
5452 local_configuration.get_operation_host(operation_id),
5453 id = datadog::urlencode(id)
5454 );
5455 let mut local_req_builder =
5456 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5457
5458 let mut headers = HeaderMap::new();
5460 headers.insert("Accept", HeaderValue::from_static("application/json"));
5461
5462 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5464 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5465 Err(e) => {
5466 log::warn!("Failed to parse user agent header: {e}, falling back to default");
5467 headers.insert(
5468 reqwest::header::USER_AGENT,
5469 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5470 )
5471 }
5472 };
5473
5474 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5476 headers.insert(
5477 "DD-API-KEY",
5478 HeaderValue::from_str(local_key.key.as_str())
5479 .expect("failed to parse DD-API-KEY header"),
5480 );
5481 };
5482 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5483 headers.insert(
5484 "DD-APPLICATION-KEY",
5485 HeaderValue::from_str(local_key.key.as_str())
5486 .expect("failed to parse DD-APPLICATION-KEY header"),
5487 );
5488 };
5489
5490 local_req_builder = local_req_builder.headers(headers);
5491 let local_req = local_req_builder.build()?;
5492 log::debug!("request content: {:?}", local_req.body());
5493 let local_resp = local_client.execute(local_req).await?;
5494
5495 let local_status = local_resp.status();
5496 let local_content = local_resp.text().await?;
5497 log::debug!("response content: {}", local_content);
5498
5499 if !local_status.is_client_error() && !local_status.is_server_error() {
5500 match serde_json::from_str::<crate::datadogV2::model::NotificationRuleResponse>(
5501 &local_content,
5502 ) {
5503 Ok(e) => {
5504 return Ok(datadog::ResponseContent {
5505 status: local_status,
5506 content: local_content,
5507 entity: Some(e),
5508 })
5509 }
5510 Err(e) => return Err(datadog::Error::Serde(e)),
5511 };
5512 } else {
5513 let local_entity: Option<GetVulnerabilityNotificationRuleError> =
5514 serde_json::from_str(&local_content).ok();
5515 let local_error = datadog::ResponseContent {
5516 status: local_status,
5517 content: local_content,
5518 entity: local_entity,
5519 };
5520 Err(datadog::Error::ResponseError(local_error))
5521 }
5522 }
5523
5524 pub async fn get_vulnerability_notification_rules(
5526 &self,
5527 ) -> Result<
5528 std::collections::BTreeMap<String, serde_json::Value>,
5529 datadog::Error<GetVulnerabilityNotificationRulesError>,
5530 > {
5531 match self
5532 .get_vulnerability_notification_rules_with_http_info()
5533 .await
5534 {
5535 Ok(response_content) => {
5536 if let Some(e) = response_content.entity {
5537 Ok(e)
5538 } else {
5539 Err(datadog::Error::Serde(serde::de::Error::custom(
5540 "response content was None",
5541 )))
5542 }
5543 }
5544 Err(err) => Err(err),
5545 }
5546 }
5547
5548 pub async fn get_vulnerability_notification_rules_with_http_info(
5550 &self,
5551 ) -> Result<
5552 datadog::ResponseContent<std::collections::BTreeMap<String, serde_json::Value>>,
5553 datadog::Error<GetVulnerabilityNotificationRulesError>,
5554 > {
5555 let local_configuration = &self.config;
5556 let operation_id = "v2.get_vulnerability_notification_rules";
5557
5558 let local_client = &self.client;
5559
5560 let local_uri_str = format!(
5561 "{}/api/v2/security/vulnerabilities/notification_rules",
5562 local_configuration.get_operation_host(operation_id)
5563 );
5564 let mut local_req_builder =
5565 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5566
5567 let mut headers = HeaderMap::new();
5569 headers.insert("Accept", HeaderValue::from_static("application/json"));
5570
5571 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5573 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5574 Err(e) => {
5575 log::warn!("Failed to parse user agent header: {e}, falling back to default");
5576 headers.insert(
5577 reqwest::header::USER_AGENT,
5578 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5579 )
5580 }
5581 };
5582
5583 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5585 headers.insert(
5586 "DD-API-KEY",
5587 HeaderValue::from_str(local_key.key.as_str())
5588 .expect("failed to parse DD-API-KEY header"),
5589 );
5590 };
5591 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5592 headers.insert(
5593 "DD-APPLICATION-KEY",
5594 HeaderValue::from_str(local_key.key.as_str())
5595 .expect("failed to parse DD-APPLICATION-KEY header"),
5596 );
5597 };
5598
5599 local_req_builder = local_req_builder.headers(headers);
5600 let local_req = local_req_builder.build()?;
5601 log::debug!("request content: {:?}", local_req.body());
5602 let local_resp = local_client.execute(local_req).await?;
5603
5604 let local_status = local_resp.status();
5605 let local_content = local_resp.text().await?;
5606 log::debug!("response content: {}", local_content);
5607
5608 if !local_status.is_client_error() && !local_status.is_server_error() {
5609 match serde_json::from_str::<std::collections::BTreeMap<String, serde_json::Value>>(
5610 &local_content,
5611 ) {
5612 Ok(e) => {
5613 return Ok(datadog::ResponseContent {
5614 status: local_status,
5615 content: local_content,
5616 entity: Some(e),
5617 })
5618 }
5619 Err(e) => return Err(datadog::Error::Serde(e)),
5620 };
5621 } else {
5622 let local_entity: Option<GetVulnerabilityNotificationRulesError> =
5623 serde_json::from_str(&local_content).ok();
5624 let local_error = datadog::ResponseContent {
5625 status: local_status,
5626 content: local_content,
5627 entity: local_entity,
5628 };
5629 Err(datadog::Error::ResponseError(local_error))
5630 }
5631 }
5632
5633 pub async fn list_assets_sbo_ms(
5647 &self,
5648 params: ListAssetsSBOMsOptionalParams,
5649 ) -> Result<
5650 crate::datadogV2::model::ListAssetsSBOMsResponse,
5651 datadog::Error<ListAssetsSBOMsError>,
5652 > {
5653 match self.list_assets_sbo_ms_with_http_info(params).await {
5654 Ok(response_content) => {
5655 if let Some(e) = response_content.entity {
5656 Ok(e)
5657 } else {
5658 Err(datadog::Error::Serde(serde::de::Error::custom(
5659 "response content was None",
5660 )))
5661 }
5662 }
5663 Err(err) => Err(err),
5664 }
5665 }
5666
5667 pub async fn list_assets_sbo_ms_with_http_info(
5681 &self,
5682 params: ListAssetsSBOMsOptionalParams,
5683 ) -> Result<
5684 datadog::ResponseContent<crate::datadogV2::model::ListAssetsSBOMsResponse>,
5685 datadog::Error<ListAssetsSBOMsError>,
5686 > {
5687 let local_configuration = &self.config;
5688 let operation_id = "v2.list_assets_sbo_ms";
5689 if local_configuration.is_unstable_operation_enabled(operation_id) {
5690 warn!("Using unstable operation {operation_id}");
5691 } else {
5692 let local_error = datadog::UnstableOperationDisabledError {
5693 msg: "Operation 'v2.list_assets_sbo_ms' is not enabled".to_string(),
5694 };
5695 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
5696 }
5697
5698 let page_token = params.page_token;
5700 let page_number = params.page_number;
5701 let filter_asset_type = params.filter_asset_type;
5702 let filter_asset_name = params.filter_asset_name;
5703 let filter_package_name = params.filter_package_name;
5704 let filter_package_version = params.filter_package_version;
5705 let filter_license_name = params.filter_license_name;
5706 let filter_license_type = params.filter_license_type;
5707
5708 let local_client = &self.client;
5709
5710 let local_uri_str = format!(
5711 "{}/api/v2/security/sboms",
5712 local_configuration.get_operation_host(operation_id)
5713 );
5714 let mut local_req_builder =
5715 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5716
5717 if let Some(ref local_query_param) = page_token {
5718 local_req_builder =
5719 local_req_builder.query(&[("page[token]", &local_query_param.to_string())]);
5720 };
5721 if let Some(ref local_query_param) = page_number {
5722 local_req_builder =
5723 local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
5724 };
5725 if let Some(ref local_query_param) = filter_asset_type {
5726 local_req_builder =
5727 local_req_builder.query(&[("filter[asset_type]", &local_query_param.to_string())]);
5728 };
5729 if let Some(ref local_query_param) = filter_asset_name {
5730 local_req_builder =
5731 local_req_builder.query(&[("filter[asset_name]", &local_query_param.to_string())]);
5732 };
5733 if let Some(ref local_query_param) = filter_package_name {
5734 local_req_builder = local_req_builder
5735 .query(&[("filter[package_name]", &local_query_param.to_string())]);
5736 };
5737 if let Some(ref local_query_param) = filter_package_version {
5738 local_req_builder = local_req_builder
5739 .query(&[("filter[package_version]", &local_query_param.to_string())]);
5740 };
5741 if let Some(ref local_query_param) = filter_license_name {
5742 local_req_builder = local_req_builder
5743 .query(&[("filter[license_name]", &local_query_param.to_string())]);
5744 };
5745 if let Some(ref local_query_param) = filter_license_type {
5746 local_req_builder = local_req_builder
5747 .query(&[("filter[license_type]", &local_query_param.to_string())]);
5748 };
5749
5750 let mut headers = HeaderMap::new();
5752 headers.insert("Accept", HeaderValue::from_static("application/json"));
5753
5754 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5756 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5757 Err(e) => {
5758 log::warn!("Failed to parse user agent header: {e}, falling back to default");
5759 headers.insert(
5760 reqwest::header::USER_AGENT,
5761 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5762 )
5763 }
5764 };
5765
5766 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5768 headers.insert(
5769 "DD-API-KEY",
5770 HeaderValue::from_str(local_key.key.as_str())
5771 .expect("failed to parse DD-API-KEY header"),
5772 );
5773 };
5774 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5775 headers.insert(
5776 "DD-APPLICATION-KEY",
5777 HeaderValue::from_str(local_key.key.as_str())
5778 .expect("failed to parse DD-APPLICATION-KEY header"),
5779 );
5780 };
5781
5782 local_req_builder = local_req_builder.headers(headers);
5783 let local_req = local_req_builder.build()?;
5784 log::debug!("request content: {:?}", local_req.body());
5785 let local_resp = local_client.execute(local_req).await?;
5786
5787 let local_status = local_resp.status();
5788 let local_content = local_resp.text().await?;
5789 log::debug!("response content: {}", local_content);
5790
5791 if !local_status.is_client_error() && !local_status.is_server_error() {
5792 match serde_json::from_str::<crate::datadogV2::model::ListAssetsSBOMsResponse>(
5793 &local_content,
5794 ) {
5795 Ok(e) => {
5796 return Ok(datadog::ResponseContent {
5797 status: local_status,
5798 content: local_content,
5799 entity: Some(e),
5800 })
5801 }
5802 Err(e) => return Err(datadog::Error::Serde(e)),
5803 };
5804 } else {
5805 let local_entity: Option<ListAssetsSBOMsError> =
5806 serde_json::from_str(&local_content).ok();
5807 let local_error = datadog::ResponseContent {
5808 status: local_status,
5809 content: local_content,
5810 entity: local_entity,
5811 };
5812 Err(datadog::Error::ResponseError(local_error))
5813 }
5814 }
5815
5816 pub async fn list_findings(
5862 &self,
5863 params: ListFindingsOptionalParams,
5864 ) -> Result<crate::datadogV2::model::ListFindingsResponse, datadog::Error<ListFindingsError>>
5865 {
5866 match self.list_findings_with_http_info(params).await {
5867 Ok(response_content) => {
5868 if let Some(e) = response_content.entity {
5869 Ok(e)
5870 } else {
5871 Err(datadog::Error::Serde(serde::de::Error::custom(
5872 "response content was None",
5873 )))
5874 }
5875 }
5876 Err(err) => Err(err),
5877 }
5878 }
5879
5880 pub fn list_findings_with_pagination(
5881 &self,
5882 mut params: ListFindingsOptionalParams,
5883 ) -> impl Stream<
5884 Item = Result<crate::datadogV2::model::Finding, datadog::Error<ListFindingsError>>,
5885 > + '_ {
5886 try_stream! {
5887 let mut page_size: i64 = 100;
5888 if params.page_limit.is_none() {
5889 params.page_limit = Some(page_size);
5890 } else {
5891 page_size = params.page_limit.unwrap().clone();
5892 }
5893 loop {
5894 let resp = self.list_findings(params.clone()).await?;
5895
5896 let r = resp.data;
5897 let count = r.len();
5898 for team in r {
5899 yield team;
5900 }
5901
5902 if count < page_size as usize {
5903 break;
5904 }
5905 let Some(page) = resp.meta.page else { break };
5906 let Some(cursor) = page.cursor else { break };
5907
5908 params.page_cursor = Some(cursor);
5909 }
5910 }
5911 }
5912
5913 pub async fn list_findings_with_http_info(
5959 &self,
5960 params: ListFindingsOptionalParams,
5961 ) -> Result<
5962 datadog::ResponseContent<crate::datadogV2::model::ListFindingsResponse>,
5963 datadog::Error<ListFindingsError>,
5964 > {
5965 let local_configuration = &self.config;
5966 let operation_id = "v2.list_findings";
5967 if local_configuration.is_unstable_operation_enabled(operation_id) {
5968 warn!("Using unstable operation {operation_id}");
5969 } else {
5970 let local_error = datadog::UnstableOperationDisabledError {
5971 msg: "Operation 'v2.list_findings' is not enabled".to_string(),
5972 };
5973 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
5974 }
5975
5976 let page_limit = params.page_limit;
5978 let snapshot_timestamp = params.snapshot_timestamp;
5979 let page_cursor = params.page_cursor;
5980 let filter_tags = params.filter_tags;
5981 let filter_evaluation_changed_at = params.filter_evaluation_changed_at;
5982 let filter_muted = params.filter_muted;
5983 let filter_rule_id = params.filter_rule_id;
5984 let filter_rule_name = params.filter_rule_name;
5985 let filter_resource_type = params.filter_resource_type;
5986 let filter_resource_id = params.filter_resource_id;
5987 let filter_discovery_timestamp = params.filter_discovery_timestamp;
5988 let filter_evaluation = params.filter_evaluation;
5989 let filter_status = params.filter_status;
5990 let filter_vulnerability_type = params.filter_vulnerability_type;
5991 let detailed_findings = params.detailed_findings;
5992
5993 let local_client = &self.client;
5994
5995 let local_uri_str = format!(
5996 "{}/api/v2/posture_management/findings",
5997 local_configuration.get_operation_host(operation_id)
5998 );
5999 let mut local_req_builder =
6000 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
6001
6002 if let Some(ref local_query_param) = page_limit {
6003 local_req_builder =
6004 local_req_builder.query(&[("page[limit]", &local_query_param.to_string())]);
6005 };
6006 if let Some(ref local_query_param) = snapshot_timestamp {
6007 local_req_builder =
6008 local_req_builder.query(&[("snapshot_timestamp", &local_query_param.to_string())]);
6009 };
6010 if let Some(ref local_query_param) = page_cursor {
6011 local_req_builder =
6012 local_req_builder.query(&[("page[cursor]", &local_query_param.to_string())]);
6013 };
6014 if let Some(ref local_query_param) = filter_tags {
6015 local_req_builder =
6016 local_req_builder.query(&[("filter[tags]", &local_query_param.to_string())]);
6017 };
6018 if let Some(ref local_query_param) = filter_evaluation_changed_at {
6019 local_req_builder = local_req_builder.query(&[(
6020 "filter[evaluation_changed_at]",
6021 &local_query_param.to_string(),
6022 )]);
6023 };
6024 if let Some(ref local_query_param) = filter_muted {
6025 local_req_builder =
6026 local_req_builder.query(&[("filter[muted]", &local_query_param.to_string())]);
6027 };
6028 if let Some(ref local_query_param) = filter_rule_id {
6029 local_req_builder =
6030 local_req_builder.query(&[("filter[rule_id]", &local_query_param.to_string())]);
6031 };
6032 if let Some(ref local_query_param) = filter_rule_name {
6033 local_req_builder =
6034 local_req_builder.query(&[("filter[rule_name]", &local_query_param.to_string())]);
6035 };
6036 if let Some(ref local_query_param) = filter_resource_type {
6037 local_req_builder = local_req_builder
6038 .query(&[("filter[resource_type]", &local_query_param.to_string())]);
6039 };
6040 if let Some(ref local_query_param) = filter_resource_id {
6041 local_req_builder = local_req_builder
6042 .query(&[("filter[@resource_id]", &local_query_param.to_string())]);
6043 };
6044 if let Some(ref local_query_param) = filter_discovery_timestamp {
6045 local_req_builder = local_req_builder.query(&[(
6046 "filter[discovery_timestamp]",
6047 &local_query_param.to_string(),
6048 )]);
6049 };
6050 if let Some(ref local_query_param) = filter_evaluation {
6051 local_req_builder =
6052 local_req_builder.query(&[("filter[evaluation]", &local_query_param.to_string())]);
6053 };
6054 if let Some(ref local_query_param) = filter_status {
6055 local_req_builder =
6056 local_req_builder.query(&[("filter[status]", &local_query_param.to_string())]);
6057 };
6058 if let Some(ref local) = filter_vulnerability_type {
6059 for param in local {
6060 local_req_builder =
6061 local_req_builder.query(&[("filter[vulnerability_type]", ¶m.to_string())]);
6062 }
6063 };
6064 if let Some(ref local_query_param) = detailed_findings {
6065 local_req_builder =
6066 local_req_builder.query(&[("detailed_findings", &local_query_param.to_string())]);
6067 };
6068
6069 let mut headers = HeaderMap::new();
6071 headers.insert("Accept", HeaderValue::from_static("application/json"));
6072
6073 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
6075 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
6076 Err(e) => {
6077 log::warn!("Failed to parse user agent header: {e}, falling back to default");
6078 headers.insert(
6079 reqwest::header::USER_AGENT,
6080 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
6081 )
6082 }
6083 };
6084
6085 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
6087 headers.insert(
6088 "DD-API-KEY",
6089 HeaderValue::from_str(local_key.key.as_str())
6090 .expect("failed to parse DD-API-KEY header"),
6091 );
6092 };
6093 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
6094 headers.insert(
6095 "DD-APPLICATION-KEY",
6096 HeaderValue::from_str(local_key.key.as_str())
6097 .expect("failed to parse DD-APPLICATION-KEY header"),
6098 );
6099 };
6100
6101 local_req_builder = local_req_builder.headers(headers);
6102 let local_req = local_req_builder.build()?;
6103 log::debug!("request content: {:?}", local_req.body());
6104 let local_resp = local_client.execute(local_req).await?;
6105
6106 let local_status = local_resp.status();
6107 let local_content = local_resp.text().await?;
6108 log::debug!("response content: {}", local_content);
6109
6110 if !local_status.is_client_error() && !local_status.is_server_error() {
6111 match serde_json::from_str::<crate::datadogV2::model::ListFindingsResponse>(
6112 &local_content,
6113 ) {
6114 Ok(e) => {
6115 return Ok(datadog::ResponseContent {
6116 status: local_status,
6117 content: local_content,
6118 entity: Some(e),
6119 })
6120 }
6121 Err(e) => return Err(datadog::Error::Serde(e)),
6122 };
6123 } else {
6124 let local_entity: Option<ListFindingsError> = serde_json::from_str(&local_content).ok();
6125 let local_error = datadog::ResponseContent {
6126 status: local_status,
6127 content: local_content,
6128 entity: local_entity,
6129 };
6130 Err(datadog::Error::ResponseError(local_error))
6131 }
6132 }
6133
6134 pub async fn list_historical_jobs(
6136 &self,
6137 params: ListHistoricalJobsOptionalParams,
6138 ) -> Result<
6139 crate::datadogV2::model::ListHistoricalJobsResponse,
6140 datadog::Error<ListHistoricalJobsError>,
6141 > {
6142 match self.list_historical_jobs_with_http_info(params).await {
6143 Ok(response_content) => {
6144 if let Some(e) = response_content.entity {
6145 Ok(e)
6146 } else {
6147 Err(datadog::Error::Serde(serde::de::Error::custom(
6148 "response content was None",
6149 )))
6150 }
6151 }
6152 Err(err) => Err(err),
6153 }
6154 }
6155
6156 pub async fn list_historical_jobs_with_http_info(
6158 &self,
6159 params: ListHistoricalJobsOptionalParams,
6160 ) -> Result<
6161 datadog::ResponseContent<crate::datadogV2::model::ListHistoricalJobsResponse>,
6162 datadog::Error<ListHistoricalJobsError>,
6163 > {
6164 let local_configuration = &self.config;
6165 let operation_id = "v2.list_historical_jobs";
6166 if local_configuration.is_unstable_operation_enabled(operation_id) {
6167 warn!("Using unstable operation {operation_id}");
6168 } else {
6169 let local_error = datadog::UnstableOperationDisabledError {
6170 msg: "Operation 'v2.list_historical_jobs' is not enabled".to_string(),
6171 };
6172 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
6173 }
6174
6175 let page_size = params.page_size;
6177 let page_number = params.page_number;
6178 let sort = params.sort;
6179 let filter_query = params.filter_query;
6180
6181 let local_client = &self.client;
6182
6183 let local_uri_str = format!(
6184 "{}/api/v2/siem-historical-detections/jobs",
6185 local_configuration.get_operation_host(operation_id)
6186 );
6187 let mut local_req_builder =
6188 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
6189
6190 if let Some(ref local_query_param) = page_size {
6191 local_req_builder =
6192 local_req_builder.query(&[("page[size]", &local_query_param.to_string())]);
6193 };
6194 if let Some(ref local_query_param) = page_number {
6195 local_req_builder =
6196 local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
6197 };
6198 if let Some(ref local_query_param) = sort {
6199 local_req_builder =
6200 local_req_builder.query(&[("sort", &local_query_param.to_string())]);
6201 };
6202 if let Some(ref local_query_param) = filter_query {
6203 local_req_builder =
6204 local_req_builder.query(&[("filter[query]", &local_query_param.to_string())]);
6205 };
6206
6207 let mut headers = HeaderMap::new();
6209 headers.insert("Accept", HeaderValue::from_static("application/json"));
6210
6211 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
6213 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
6214 Err(e) => {
6215 log::warn!("Failed to parse user agent header: {e}, falling back to default");
6216 headers.insert(
6217 reqwest::header::USER_AGENT,
6218 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
6219 )
6220 }
6221 };
6222
6223 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
6225 headers.insert(
6226 "DD-API-KEY",
6227 HeaderValue::from_str(local_key.key.as_str())
6228 .expect("failed to parse DD-API-KEY header"),
6229 );
6230 };
6231 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
6232 headers.insert(
6233 "DD-APPLICATION-KEY",
6234 HeaderValue::from_str(local_key.key.as_str())
6235 .expect("failed to parse DD-APPLICATION-KEY header"),
6236 );
6237 };
6238
6239 local_req_builder = local_req_builder.headers(headers);
6240 let local_req = local_req_builder.build()?;
6241 log::debug!("request content: {:?}", local_req.body());
6242 let local_resp = local_client.execute(local_req).await?;
6243
6244 let local_status = local_resp.status();
6245 let local_content = local_resp.text().await?;
6246 log::debug!("response content: {}", local_content);
6247
6248 if !local_status.is_client_error() && !local_status.is_server_error() {
6249 match serde_json::from_str::<crate::datadogV2::model::ListHistoricalJobsResponse>(
6250 &local_content,
6251 ) {
6252 Ok(e) => {
6253 return Ok(datadog::ResponseContent {
6254 status: local_status,
6255 content: local_content,
6256 entity: Some(e),
6257 })
6258 }
6259 Err(e) => return Err(datadog::Error::Serde(e)),
6260 };
6261 } else {
6262 let local_entity: Option<ListHistoricalJobsError> =
6263 serde_json::from_str(&local_content).ok();
6264 let local_error = datadog::ResponseContent {
6265 status: local_status,
6266 content: local_content,
6267 entity: local_entity,
6268 };
6269 Err(datadog::Error::ResponseError(local_error))
6270 }
6271 }
6272
6273 pub async fn list_security_filters(
6275 &self,
6276 ) -> Result<
6277 crate::datadogV2::model::SecurityFiltersResponse,
6278 datadog::Error<ListSecurityFiltersError>,
6279 > {
6280 match self.list_security_filters_with_http_info().await {
6281 Ok(response_content) => {
6282 if let Some(e) = response_content.entity {
6283 Ok(e)
6284 } else {
6285 Err(datadog::Error::Serde(serde::de::Error::custom(
6286 "response content was None",
6287 )))
6288 }
6289 }
6290 Err(err) => Err(err),
6291 }
6292 }
6293
6294 pub async fn list_security_filters_with_http_info(
6296 &self,
6297 ) -> Result<
6298 datadog::ResponseContent<crate::datadogV2::model::SecurityFiltersResponse>,
6299 datadog::Error<ListSecurityFiltersError>,
6300 > {
6301 let local_configuration = &self.config;
6302 let operation_id = "v2.list_security_filters";
6303
6304 let local_client = &self.client;
6305
6306 let local_uri_str = format!(
6307 "{}/api/v2/security_monitoring/configuration/security_filters",
6308 local_configuration.get_operation_host(operation_id)
6309 );
6310 let mut local_req_builder =
6311 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
6312
6313 let mut headers = HeaderMap::new();
6315 headers.insert("Accept", HeaderValue::from_static("application/json"));
6316
6317 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
6319 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
6320 Err(e) => {
6321 log::warn!("Failed to parse user agent header: {e}, falling back to default");
6322 headers.insert(
6323 reqwest::header::USER_AGENT,
6324 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
6325 )
6326 }
6327 };
6328
6329 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
6331 headers.insert(
6332 "DD-API-KEY",
6333 HeaderValue::from_str(local_key.key.as_str())
6334 .expect("failed to parse DD-API-KEY header"),
6335 );
6336 };
6337 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
6338 headers.insert(
6339 "DD-APPLICATION-KEY",
6340 HeaderValue::from_str(local_key.key.as_str())
6341 .expect("failed to parse DD-APPLICATION-KEY header"),
6342 );
6343 };
6344
6345 local_req_builder = local_req_builder.headers(headers);
6346 let local_req = local_req_builder.build()?;
6347 log::debug!("request content: {:?}", local_req.body());
6348 let local_resp = local_client.execute(local_req).await?;
6349
6350 let local_status = local_resp.status();
6351 let local_content = local_resp.text().await?;
6352 log::debug!("response content: {}", local_content);
6353
6354 if !local_status.is_client_error() && !local_status.is_server_error() {
6355 match serde_json::from_str::<crate::datadogV2::model::SecurityFiltersResponse>(
6356 &local_content,
6357 ) {
6358 Ok(e) => {
6359 return Ok(datadog::ResponseContent {
6360 status: local_status,
6361 content: local_content,
6362 entity: Some(e),
6363 })
6364 }
6365 Err(e) => return Err(datadog::Error::Serde(e)),
6366 };
6367 } else {
6368 let local_entity: Option<ListSecurityFiltersError> =
6369 serde_json::from_str(&local_content).ok();
6370 let local_error = datadog::ResponseContent {
6371 status: local_status,
6372 content: local_content,
6373 entity: local_entity,
6374 };
6375 Err(datadog::Error::ResponseError(local_error))
6376 }
6377 }
6378
6379 pub async fn list_security_monitoring_rules(
6381 &self,
6382 params: ListSecurityMonitoringRulesOptionalParams,
6383 ) -> Result<
6384 crate::datadogV2::model::SecurityMonitoringListRulesResponse,
6385 datadog::Error<ListSecurityMonitoringRulesError>,
6386 > {
6387 match self
6388 .list_security_monitoring_rules_with_http_info(params)
6389 .await
6390 {
6391 Ok(response_content) => {
6392 if let Some(e) = response_content.entity {
6393 Ok(e)
6394 } else {
6395 Err(datadog::Error::Serde(serde::de::Error::custom(
6396 "response content was None",
6397 )))
6398 }
6399 }
6400 Err(err) => Err(err),
6401 }
6402 }
6403
6404 pub async fn list_security_monitoring_rules_with_http_info(
6406 &self,
6407 params: ListSecurityMonitoringRulesOptionalParams,
6408 ) -> Result<
6409 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringListRulesResponse>,
6410 datadog::Error<ListSecurityMonitoringRulesError>,
6411 > {
6412 let local_configuration = &self.config;
6413 let operation_id = "v2.list_security_monitoring_rules";
6414
6415 let page_size = params.page_size;
6417 let page_number = params.page_number;
6418
6419 let local_client = &self.client;
6420
6421 let local_uri_str = format!(
6422 "{}/api/v2/security_monitoring/rules",
6423 local_configuration.get_operation_host(operation_id)
6424 );
6425 let mut local_req_builder =
6426 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
6427
6428 if let Some(ref local_query_param) = page_size {
6429 local_req_builder =
6430 local_req_builder.query(&[("page[size]", &local_query_param.to_string())]);
6431 };
6432 if let Some(ref local_query_param) = page_number {
6433 local_req_builder =
6434 local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
6435 };
6436
6437 let mut headers = HeaderMap::new();
6439 headers.insert("Accept", HeaderValue::from_static("application/json"));
6440
6441 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
6443 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
6444 Err(e) => {
6445 log::warn!("Failed to parse user agent header: {e}, falling back to default");
6446 headers.insert(
6447 reqwest::header::USER_AGENT,
6448 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
6449 )
6450 }
6451 };
6452
6453 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
6455 headers.insert(
6456 "DD-API-KEY",
6457 HeaderValue::from_str(local_key.key.as_str())
6458 .expect("failed to parse DD-API-KEY header"),
6459 );
6460 };
6461 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
6462 headers.insert(
6463 "DD-APPLICATION-KEY",
6464 HeaderValue::from_str(local_key.key.as_str())
6465 .expect("failed to parse DD-APPLICATION-KEY header"),
6466 );
6467 };
6468
6469 local_req_builder = local_req_builder.headers(headers);
6470 let local_req = local_req_builder.build()?;
6471 log::debug!("request content: {:?}", local_req.body());
6472 let local_resp = local_client.execute(local_req).await?;
6473
6474 let local_status = local_resp.status();
6475 let local_content = local_resp.text().await?;
6476 log::debug!("response content: {}", local_content);
6477
6478 if !local_status.is_client_error() && !local_status.is_server_error() {
6479 match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringListRulesResponse>(
6480 &local_content,
6481 ) {
6482 Ok(e) => {
6483 return Ok(datadog::ResponseContent {
6484 status: local_status,
6485 content: local_content,
6486 entity: Some(e),
6487 })
6488 }
6489 Err(e) => return Err(datadog::Error::Serde(e)),
6490 };
6491 } else {
6492 let local_entity: Option<ListSecurityMonitoringRulesError> =
6493 serde_json::from_str(&local_content).ok();
6494 let local_error = datadog::ResponseContent {
6495 status: local_status,
6496 content: local_content,
6497 entity: local_entity,
6498 };
6499 Err(datadog::Error::ResponseError(local_error))
6500 }
6501 }
6502
6503 pub async fn list_security_monitoring_signals(
6507 &self,
6508 params: ListSecurityMonitoringSignalsOptionalParams,
6509 ) -> Result<
6510 crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
6511 datadog::Error<ListSecurityMonitoringSignalsError>,
6512 > {
6513 match self
6514 .list_security_monitoring_signals_with_http_info(params)
6515 .await
6516 {
6517 Ok(response_content) => {
6518 if let Some(e) = response_content.entity {
6519 Ok(e)
6520 } else {
6521 Err(datadog::Error::Serde(serde::de::Error::custom(
6522 "response content was None",
6523 )))
6524 }
6525 }
6526 Err(err) => Err(err),
6527 }
6528 }
6529
6530 pub fn list_security_monitoring_signals_with_pagination(
6531 &self,
6532 mut params: ListSecurityMonitoringSignalsOptionalParams,
6533 ) -> impl Stream<
6534 Item = Result<
6535 crate::datadogV2::model::SecurityMonitoringSignal,
6536 datadog::Error<ListSecurityMonitoringSignalsError>,
6537 >,
6538 > + '_ {
6539 try_stream! {
6540 let mut page_size: i32 = 10;
6541 if params.page_limit.is_none() {
6542 params.page_limit = Some(page_size);
6543 } else {
6544 page_size = params.page_limit.unwrap().clone();
6545 }
6546 loop {
6547 let resp = self.list_security_monitoring_signals(params.clone()).await?;
6548 let Some(data) = resp.data else { break };
6549
6550 let r = data;
6551 let count = r.len();
6552 for team in r {
6553 yield team;
6554 }
6555
6556 if count < page_size as usize {
6557 break;
6558 }
6559 let Some(meta) = resp.meta else { break };
6560 let Some(page) = meta.page else { break };
6561 let Some(after) = page.after else { break };
6562
6563 params.page_cursor = Some(after);
6564 }
6565 }
6566 }
6567
6568 pub async fn list_security_monitoring_signals_with_http_info(
6572 &self,
6573 params: ListSecurityMonitoringSignalsOptionalParams,
6574 ) -> Result<
6575 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSignalsListResponse>,
6576 datadog::Error<ListSecurityMonitoringSignalsError>,
6577 > {
6578 let local_configuration = &self.config;
6579 let operation_id = "v2.list_security_monitoring_signals";
6580
6581 let filter_query = params.filter_query;
6583 let filter_from = params.filter_from;
6584 let filter_to = params.filter_to;
6585 let sort = params.sort;
6586 let page_cursor = params.page_cursor;
6587 let page_limit = params.page_limit;
6588
6589 let local_client = &self.client;
6590
6591 let local_uri_str = format!(
6592 "{}/api/v2/security_monitoring/signals",
6593 local_configuration.get_operation_host(operation_id)
6594 );
6595 let mut local_req_builder =
6596 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
6597
6598 if let Some(ref local_query_param) = filter_query {
6599 local_req_builder =
6600 local_req_builder.query(&[("filter[query]", &local_query_param.to_string())]);
6601 };
6602 if let Some(ref local_query_param) = filter_from {
6603 local_req_builder = local_req_builder.query(&[(
6604 "filter[from]",
6605 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
6606 )]);
6607 };
6608 if let Some(ref local_query_param) = filter_to {
6609 local_req_builder = local_req_builder.query(&[(
6610 "filter[to]",
6611 &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
6612 )]);
6613 };
6614 if let Some(ref local_query_param) = sort {
6615 local_req_builder =
6616 local_req_builder.query(&[("sort", &local_query_param.to_string())]);
6617 };
6618 if let Some(ref local_query_param) = page_cursor {
6619 local_req_builder =
6620 local_req_builder.query(&[("page[cursor]", &local_query_param.to_string())]);
6621 };
6622 if let Some(ref local_query_param) = page_limit {
6623 local_req_builder =
6624 local_req_builder.query(&[("page[limit]", &local_query_param.to_string())]);
6625 };
6626
6627 let mut headers = HeaderMap::new();
6629 headers.insert("Accept", HeaderValue::from_static("application/json"));
6630
6631 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
6633 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
6634 Err(e) => {
6635 log::warn!("Failed to parse user agent header: {e}, falling back to default");
6636 headers.insert(
6637 reqwest::header::USER_AGENT,
6638 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
6639 )
6640 }
6641 };
6642
6643 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
6645 headers.insert(
6646 "DD-API-KEY",
6647 HeaderValue::from_str(local_key.key.as_str())
6648 .expect("failed to parse DD-API-KEY header"),
6649 );
6650 };
6651 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
6652 headers.insert(
6653 "DD-APPLICATION-KEY",
6654 HeaderValue::from_str(local_key.key.as_str())
6655 .expect("failed to parse DD-APPLICATION-KEY header"),
6656 );
6657 };
6658
6659 local_req_builder = local_req_builder.headers(headers);
6660 let local_req = local_req_builder.build()?;
6661 log::debug!("request content: {:?}", local_req.body());
6662 let local_resp = local_client.execute(local_req).await?;
6663
6664 let local_status = local_resp.status();
6665 let local_content = local_resp.text().await?;
6666 log::debug!("response content: {}", local_content);
6667
6668 if !local_status.is_client_error() && !local_status.is_server_error() {
6669 match serde_json::from_str::<
6670 crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
6671 >(&local_content)
6672 {
6673 Ok(e) => {
6674 return Ok(datadog::ResponseContent {
6675 status: local_status,
6676 content: local_content,
6677 entity: Some(e),
6678 })
6679 }
6680 Err(e) => return Err(datadog::Error::Serde(e)),
6681 };
6682 } else {
6683 let local_entity: Option<ListSecurityMonitoringSignalsError> =
6684 serde_json::from_str(&local_content).ok();
6685 let local_error = datadog::ResponseContent {
6686 status: local_status,
6687 content: local_content,
6688 entity: local_entity,
6689 };
6690 Err(datadog::Error::ResponseError(local_error))
6691 }
6692 }
6693
6694 pub async fn list_security_monitoring_suppressions(
6696 &self,
6697 ) -> Result<
6698 crate::datadogV2::model::SecurityMonitoringSuppressionsResponse,
6699 datadog::Error<ListSecurityMonitoringSuppressionsError>,
6700 > {
6701 match self
6702 .list_security_monitoring_suppressions_with_http_info()
6703 .await
6704 {
6705 Ok(response_content) => {
6706 if let Some(e) = response_content.entity {
6707 Ok(e)
6708 } else {
6709 Err(datadog::Error::Serde(serde::de::Error::custom(
6710 "response content was None",
6711 )))
6712 }
6713 }
6714 Err(err) => Err(err),
6715 }
6716 }
6717
6718 pub async fn list_security_monitoring_suppressions_with_http_info(
6720 &self,
6721 ) -> Result<
6722 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSuppressionsResponse>,
6723 datadog::Error<ListSecurityMonitoringSuppressionsError>,
6724 > {
6725 let local_configuration = &self.config;
6726 let operation_id = "v2.list_security_monitoring_suppressions";
6727
6728 let local_client = &self.client;
6729
6730 let local_uri_str = format!(
6731 "{}/api/v2/security_monitoring/configuration/suppressions",
6732 local_configuration.get_operation_host(operation_id)
6733 );
6734 let mut local_req_builder =
6735 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
6736
6737 let mut headers = HeaderMap::new();
6739 headers.insert("Accept", HeaderValue::from_static("application/json"));
6740
6741 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
6743 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
6744 Err(e) => {
6745 log::warn!("Failed to parse user agent header: {e}, falling back to default");
6746 headers.insert(
6747 reqwest::header::USER_AGENT,
6748 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
6749 )
6750 }
6751 };
6752
6753 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
6755 headers.insert(
6756 "DD-API-KEY",
6757 HeaderValue::from_str(local_key.key.as_str())
6758 .expect("failed to parse DD-API-KEY header"),
6759 );
6760 };
6761 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
6762 headers.insert(
6763 "DD-APPLICATION-KEY",
6764 HeaderValue::from_str(local_key.key.as_str())
6765 .expect("failed to parse DD-APPLICATION-KEY header"),
6766 );
6767 };
6768
6769 local_req_builder = local_req_builder.headers(headers);
6770 let local_req = local_req_builder.build()?;
6771 log::debug!("request content: {:?}", local_req.body());
6772 let local_resp = local_client.execute(local_req).await?;
6773
6774 let local_status = local_resp.status();
6775 let local_content = local_resp.text().await?;
6776 log::debug!("response content: {}", local_content);
6777
6778 if !local_status.is_client_error() && !local_status.is_server_error() {
6779 match serde_json::from_str::<
6780 crate::datadogV2::model::SecurityMonitoringSuppressionsResponse,
6781 >(&local_content)
6782 {
6783 Ok(e) => {
6784 return Ok(datadog::ResponseContent {
6785 status: local_status,
6786 content: local_content,
6787 entity: Some(e),
6788 })
6789 }
6790 Err(e) => return Err(datadog::Error::Serde(e)),
6791 };
6792 } else {
6793 let local_entity: Option<ListSecurityMonitoringSuppressionsError> =
6794 serde_json::from_str(&local_content).ok();
6795 let local_error = datadog::ResponseContent {
6796 status: local_status,
6797 content: local_content,
6798 entity: local_entity,
6799 };
6800 Err(datadog::Error::ResponseError(local_error))
6801 }
6802 }
6803
6804 pub async fn list_vulnerabilities(
6886 &self,
6887 params: ListVulnerabilitiesOptionalParams,
6888 ) -> Result<
6889 crate::datadogV2::model::ListVulnerabilitiesResponse,
6890 datadog::Error<ListVulnerabilitiesError>,
6891 > {
6892 match self.list_vulnerabilities_with_http_info(params).await {
6893 Ok(response_content) => {
6894 if let Some(e) = response_content.entity {
6895 Ok(e)
6896 } else {
6897 Err(datadog::Error::Serde(serde::de::Error::custom(
6898 "response content was None",
6899 )))
6900 }
6901 }
6902 Err(err) => Err(err),
6903 }
6904 }
6905
6906 pub async fn list_vulnerabilities_with_http_info(
6988 &self,
6989 params: ListVulnerabilitiesOptionalParams,
6990 ) -> Result<
6991 datadog::ResponseContent<crate::datadogV2::model::ListVulnerabilitiesResponse>,
6992 datadog::Error<ListVulnerabilitiesError>,
6993 > {
6994 let local_configuration = &self.config;
6995 let operation_id = "v2.list_vulnerabilities";
6996 if local_configuration.is_unstable_operation_enabled(operation_id) {
6997 warn!("Using unstable operation {operation_id}");
6998 } else {
6999 let local_error = datadog::UnstableOperationDisabledError {
7000 msg: "Operation 'v2.list_vulnerabilities' is not enabled".to_string(),
7001 };
7002 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
7003 }
7004
7005 let page_token = params.page_token;
7007 let page_number = params.page_number;
7008 let filter_type = params.filter_type;
7009 let filter_cvss_base_score_op = params.filter_cvss_base_score_op;
7010 let filter_cvss_base_severity = params.filter_cvss_base_severity;
7011 let filter_cvss_base_vector = params.filter_cvss_base_vector;
7012 let filter_cvss_datadog_score_op = params.filter_cvss_datadog_score_op;
7013 let filter_cvss_datadog_severity = params.filter_cvss_datadog_severity;
7014 let filter_cvss_datadog_vector = params.filter_cvss_datadog_vector;
7015 let filter_status = params.filter_status;
7016 let filter_tool = params.filter_tool;
7017 let filter_library_name = params.filter_library_name;
7018 let filter_library_version = params.filter_library_version;
7019 let filter_advisory_id = params.filter_advisory_id;
7020 let filter_risks_exploitation_probability = params.filter_risks_exploitation_probability;
7021 let filter_risks_poc_exploit_available = params.filter_risks_poc_exploit_available;
7022 let filter_risks_exploit_available = params.filter_risks_exploit_available;
7023 let filter_risks_epss_score_op = params.filter_risks_epss_score_op;
7024 let filter_risks_epss_severity = params.filter_risks_epss_severity;
7025 let filter_language = params.filter_language;
7026 let filter_ecosystem = params.filter_ecosystem;
7027 let filter_code_location_location = params.filter_code_location_location;
7028 let filter_code_location_file_path = params.filter_code_location_file_path;
7029 let filter_code_location_method = params.filter_code_location_method;
7030 let filter_fix_available = params.filter_fix_available;
7031 let filter_repo_digests = params.filter_repo_digests;
7032 let filter_origin = params.filter_origin;
7033 let filter_asset_name = params.filter_asset_name;
7034 let filter_asset_type = params.filter_asset_type;
7035 let filter_asset_version_first = params.filter_asset_version_first;
7036 let filter_asset_version_last = params.filter_asset_version_last;
7037 let filter_asset_repository_url = params.filter_asset_repository_url;
7038 let filter_asset_risks_in_production = params.filter_asset_risks_in_production;
7039 let filter_asset_risks_under_attack = params.filter_asset_risks_under_attack;
7040 let filter_asset_risks_is_publicly_accessible =
7041 params.filter_asset_risks_is_publicly_accessible;
7042 let filter_asset_risks_has_privileged_access =
7043 params.filter_asset_risks_has_privileged_access;
7044 let filter_asset_risks_has_access_to_sensitive_data =
7045 params.filter_asset_risks_has_access_to_sensitive_data;
7046 let filter_asset_environments = params.filter_asset_environments;
7047 let filter_asset_teams = params.filter_asset_teams;
7048 let filter_asset_arch = params.filter_asset_arch;
7049 let filter_asset_operating_system_name = params.filter_asset_operating_system_name;
7050 let filter_asset_operating_system_version = params.filter_asset_operating_system_version;
7051
7052 let local_client = &self.client;
7053
7054 let local_uri_str = format!(
7055 "{}/api/v2/security/vulnerabilities",
7056 local_configuration.get_operation_host(operation_id)
7057 );
7058 let mut local_req_builder =
7059 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
7060
7061 if let Some(ref local_query_param) = page_token {
7062 local_req_builder =
7063 local_req_builder.query(&[("page[token]", &local_query_param.to_string())]);
7064 };
7065 if let Some(ref local_query_param) = page_number {
7066 local_req_builder =
7067 local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
7068 };
7069 if let Some(ref local_query_param) = filter_type {
7070 local_req_builder =
7071 local_req_builder.query(&[("filter[type]", &local_query_param.to_string())]);
7072 };
7073 if let Some(ref local_query_param) = filter_cvss_base_score_op {
7074 local_req_builder = local_req_builder.query(&[(
7075 "filter[cvss.base.score][`$op`]",
7076 &local_query_param.to_string(),
7077 )]);
7078 };
7079 if let Some(ref local_query_param) = filter_cvss_base_severity {
7080 local_req_builder = local_req_builder
7081 .query(&[("filter[cvss.base.severity]", &local_query_param.to_string())]);
7082 };
7083 if let Some(ref local_query_param) = filter_cvss_base_vector {
7084 local_req_builder = local_req_builder
7085 .query(&[("filter[cvss.base.vector]", &local_query_param.to_string())]);
7086 };
7087 if let Some(ref local_query_param) = filter_cvss_datadog_score_op {
7088 local_req_builder = local_req_builder.query(&[(
7089 "filter[cvss.datadog.score][`$op`]",
7090 &local_query_param.to_string(),
7091 )]);
7092 };
7093 if let Some(ref local_query_param) = filter_cvss_datadog_severity {
7094 local_req_builder = local_req_builder.query(&[(
7095 "filter[cvss.datadog.severity]",
7096 &local_query_param.to_string(),
7097 )]);
7098 };
7099 if let Some(ref local_query_param) = filter_cvss_datadog_vector {
7100 local_req_builder = local_req_builder.query(&[(
7101 "filter[cvss.datadog.vector]",
7102 &local_query_param.to_string(),
7103 )]);
7104 };
7105 if let Some(ref local_query_param) = filter_status {
7106 local_req_builder =
7107 local_req_builder.query(&[("filter[status]", &local_query_param.to_string())]);
7108 };
7109 if let Some(ref local_query_param) = filter_tool {
7110 local_req_builder =
7111 local_req_builder.query(&[("filter[tool]", &local_query_param.to_string())]);
7112 };
7113 if let Some(ref local_query_param) = filter_library_name {
7114 local_req_builder = local_req_builder
7115 .query(&[("filter[library.name]", &local_query_param.to_string())]);
7116 };
7117 if let Some(ref local_query_param) = filter_library_version {
7118 local_req_builder = local_req_builder
7119 .query(&[("filter[library.version]", &local_query_param.to_string())]);
7120 };
7121 if let Some(ref local_query_param) = filter_advisory_id {
7122 local_req_builder =
7123 local_req_builder.query(&[("filter[advisory_id]", &local_query_param.to_string())]);
7124 };
7125 if let Some(ref local_query_param) = filter_risks_exploitation_probability {
7126 local_req_builder = local_req_builder.query(&[(
7127 "filter[risks.exploitation_probability]",
7128 &local_query_param.to_string(),
7129 )]);
7130 };
7131 if let Some(ref local_query_param) = filter_risks_poc_exploit_available {
7132 local_req_builder = local_req_builder.query(&[(
7133 "filter[risks.poc_exploit_available]",
7134 &local_query_param.to_string(),
7135 )]);
7136 };
7137 if let Some(ref local_query_param) = filter_risks_exploit_available {
7138 local_req_builder = local_req_builder.query(&[(
7139 "filter[risks.exploit_available]",
7140 &local_query_param.to_string(),
7141 )]);
7142 };
7143 if let Some(ref local_query_param) = filter_risks_epss_score_op {
7144 local_req_builder = local_req_builder.query(&[(
7145 "filter[risks.epss.score][`$op`]",
7146 &local_query_param.to_string(),
7147 )]);
7148 };
7149 if let Some(ref local_query_param) = filter_risks_epss_severity {
7150 local_req_builder = local_req_builder.query(&[(
7151 "filter[risks.epss.severity]",
7152 &local_query_param.to_string(),
7153 )]);
7154 };
7155 if let Some(ref local_query_param) = filter_language {
7156 local_req_builder =
7157 local_req_builder.query(&[("filter[language]", &local_query_param.to_string())]);
7158 };
7159 if let Some(ref local_query_param) = filter_ecosystem {
7160 local_req_builder =
7161 local_req_builder.query(&[("filter[ecosystem]", &local_query_param.to_string())]);
7162 };
7163 if let Some(ref local_query_param) = filter_code_location_location {
7164 local_req_builder = local_req_builder.query(&[(
7165 "filter[code_location.location]",
7166 &local_query_param.to_string(),
7167 )]);
7168 };
7169 if let Some(ref local_query_param) = filter_code_location_file_path {
7170 local_req_builder = local_req_builder.query(&[(
7171 "filter[code_location.file_path]",
7172 &local_query_param.to_string(),
7173 )]);
7174 };
7175 if let Some(ref local_query_param) = filter_code_location_method {
7176 local_req_builder = local_req_builder.query(&[(
7177 "filter[code_location.method]",
7178 &local_query_param.to_string(),
7179 )]);
7180 };
7181 if let Some(ref local_query_param) = filter_fix_available {
7182 local_req_builder = local_req_builder
7183 .query(&[("filter[fix_available]", &local_query_param.to_string())]);
7184 };
7185 if let Some(ref local_query_param) = filter_repo_digests {
7186 local_req_builder = local_req_builder
7187 .query(&[("filter[repo_digests]", &local_query_param.to_string())]);
7188 };
7189 if let Some(ref local_query_param) = filter_origin {
7190 local_req_builder =
7191 local_req_builder.query(&[("filter[origin]", &local_query_param.to_string())]);
7192 };
7193 if let Some(ref local_query_param) = filter_asset_name {
7194 local_req_builder =
7195 local_req_builder.query(&[("filter[asset.name]", &local_query_param.to_string())]);
7196 };
7197 if let Some(ref local_query_param) = filter_asset_type {
7198 local_req_builder =
7199 local_req_builder.query(&[("filter[asset.type]", &local_query_param.to_string())]);
7200 };
7201 if let Some(ref local_query_param) = filter_asset_version_first {
7202 local_req_builder = local_req_builder.query(&[(
7203 "filter[asset.version.first]",
7204 &local_query_param.to_string(),
7205 )]);
7206 };
7207 if let Some(ref local_query_param) = filter_asset_version_last {
7208 local_req_builder = local_req_builder
7209 .query(&[("filter[asset.version.last]", &local_query_param.to_string())]);
7210 };
7211 if let Some(ref local_query_param) = filter_asset_repository_url {
7212 local_req_builder = local_req_builder.query(&[(
7213 "filter[asset.repository_url]",
7214 &local_query_param.to_string(),
7215 )]);
7216 };
7217 if let Some(ref local_query_param) = filter_asset_risks_in_production {
7218 local_req_builder = local_req_builder.query(&[(
7219 "filter[asset.risks.in_production]",
7220 &local_query_param.to_string(),
7221 )]);
7222 };
7223 if let Some(ref local_query_param) = filter_asset_risks_under_attack {
7224 local_req_builder = local_req_builder.query(&[(
7225 "filter[asset.risks.under_attack]",
7226 &local_query_param.to_string(),
7227 )]);
7228 };
7229 if let Some(ref local_query_param) = filter_asset_risks_is_publicly_accessible {
7230 local_req_builder = local_req_builder.query(&[(
7231 "filter[asset.risks.is_publicly_accessible]",
7232 &local_query_param.to_string(),
7233 )]);
7234 };
7235 if let Some(ref local_query_param) = filter_asset_risks_has_privileged_access {
7236 local_req_builder = local_req_builder.query(&[(
7237 "filter[asset.risks.has_privileged_access]",
7238 &local_query_param.to_string(),
7239 )]);
7240 };
7241 if let Some(ref local_query_param) = filter_asset_risks_has_access_to_sensitive_data {
7242 local_req_builder = local_req_builder.query(&[(
7243 "filter[asset.risks.has_access_to_sensitive_data]",
7244 &local_query_param.to_string(),
7245 )]);
7246 };
7247 if let Some(ref local_query_param) = filter_asset_environments {
7248 local_req_builder = local_req_builder
7249 .query(&[("filter[asset.environments]", &local_query_param.to_string())]);
7250 };
7251 if let Some(ref local_query_param) = filter_asset_teams {
7252 local_req_builder =
7253 local_req_builder.query(&[("filter[asset.teams]", &local_query_param.to_string())]);
7254 };
7255 if let Some(ref local_query_param) = filter_asset_arch {
7256 local_req_builder =
7257 local_req_builder.query(&[("filter[asset.arch]", &local_query_param.to_string())]);
7258 };
7259 if let Some(ref local_query_param) = filter_asset_operating_system_name {
7260 local_req_builder = local_req_builder.query(&[(
7261 "filter[asset.operating_system.name]",
7262 &local_query_param.to_string(),
7263 )]);
7264 };
7265 if let Some(ref local_query_param) = filter_asset_operating_system_version {
7266 local_req_builder = local_req_builder.query(&[(
7267 "filter[asset.operating_system.version]",
7268 &local_query_param.to_string(),
7269 )]);
7270 };
7271
7272 let mut headers = HeaderMap::new();
7274 headers.insert("Accept", HeaderValue::from_static("application/json"));
7275
7276 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
7278 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
7279 Err(e) => {
7280 log::warn!("Failed to parse user agent header: {e}, falling back to default");
7281 headers.insert(
7282 reqwest::header::USER_AGENT,
7283 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
7284 )
7285 }
7286 };
7287
7288 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
7290 headers.insert(
7291 "DD-API-KEY",
7292 HeaderValue::from_str(local_key.key.as_str())
7293 .expect("failed to parse DD-API-KEY header"),
7294 );
7295 };
7296 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
7297 headers.insert(
7298 "DD-APPLICATION-KEY",
7299 HeaderValue::from_str(local_key.key.as_str())
7300 .expect("failed to parse DD-APPLICATION-KEY header"),
7301 );
7302 };
7303
7304 local_req_builder = local_req_builder.headers(headers);
7305 let local_req = local_req_builder.build()?;
7306 log::debug!("request content: {:?}", local_req.body());
7307 let local_resp = local_client.execute(local_req).await?;
7308
7309 let local_status = local_resp.status();
7310 let local_content = local_resp.text().await?;
7311 log::debug!("response content: {}", local_content);
7312
7313 if !local_status.is_client_error() && !local_status.is_server_error() {
7314 match serde_json::from_str::<crate::datadogV2::model::ListVulnerabilitiesResponse>(
7315 &local_content,
7316 ) {
7317 Ok(e) => {
7318 return Ok(datadog::ResponseContent {
7319 status: local_status,
7320 content: local_content,
7321 entity: Some(e),
7322 })
7323 }
7324 Err(e) => return Err(datadog::Error::Serde(e)),
7325 };
7326 } else {
7327 let local_entity: Option<ListVulnerabilitiesError> =
7328 serde_json::from_str(&local_content).ok();
7329 let local_error = datadog::ResponseContent {
7330 status: local_status,
7331 content: local_content,
7332 entity: local_entity,
7333 };
7334 Err(datadog::Error::ResponseError(local_error))
7335 }
7336 }
7337
7338 pub async fn list_vulnerable_assets(
7353 &self,
7354 params: ListVulnerableAssetsOptionalParams,
7355 ) -> Result<
7356 crate::datadogV2::model::ListVulnerableAssetsResponse,
7357 datadog::Error<ListVulnerableAssetsError>,
7358 > {
7359 match self.list_vulnerable_assets_with_http_info(params).await {
7360 Ok(response_content) => {
7361 if let Some(e) = response_content.entity {
7362 Ok(e)
7363 } else {
7364 Err(datadog::Error::Serde(serde::de::Error::custom(
7365 "response content was None",
7366 )))
7367 }
7368 }
7369 Err(err) => Err(err),
7370 }
7371 }
7372
7373 pub async fn list_vulnerable_assets_with_http_info(
7388 &self,
7389 params: ListVulnerableAssetsOptionalParams,
7390 ) -> Result<
7391 datadog::ResponseContent<crate::datadogV2::model::ListVulnerableAssetsResponse>,
7392 datadog::Error<ListVulnerableAssetsError>,
7393 > {
7394 let local_configuration = &self.config;
7395 let operation_id = "v2.list_vulnerable_assets";
7396 if local_configuration.is_unstable_operation_enabled(operation_id) {
7397 warn!("Using unstable operation {operation_id}");
7398 } else {
7399 let local_error = datadog::UnstableOperationDisabledError {
7400 msg: "Operation 'v2.list_vulnerable_assets' is not enabled".to_string(),
7401 };
7402 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
7403 }
7404
7405 let page_token = params.page_token;
7407 let page_number = params.page_number;
7408 let filter_name = params.filter_name;
7409 let filter_type = params.filter_type;
7410 let filter_version_first = params.filter_version_first;
7411 let filter_version_last = params.filter_version_last;
7412 let filter_repository_url = params.filter_repository_url;
7413 let filter_risks_in_production = params.filter_risks_in_production;
7414 let filter_risks_under_attack = params.filter_risks_under_attack;
7415 let filter_risks_is_publicly_accessible = params.filter_risks_is_publicly_accessible;
7416 let filter_risks_has_privileged_access = params.filter_risks_has_privileged_access;
7417 let filter_risks_has_access_to_sensitive_data =
7418 params.filter_risks_has_access_to_sensitive_data;
7419 let filter_environments = params.filter_environments;
7420 let filter_teams = params.filter_teams;
7421 let filter_arch = params.filter_arch;
7422 let filter_operating_system_name = params.filter_operating_system_name;
7423 let filter_operating_system_version = params.filter_operating_system_version;
7424
7425 let local_client = &self.client;
7426
7427 let local_uri_str = format!(
7428 "{}/api/v2/security/assets",
7429 local_configuration.get_operation_host(operation_id)
7430 );
7431 let mut local_req_builder =
7432 local_client.request(reqwest::Method::GET, local_uri_str.as_str());
7433
7434 if let Some(ref local_query_param) = page_token {
7435 local_req_builder =
7436 local_req_builder.query(&[("page[token]", &local_query_param.to_string())]);
7437 };
7438 if let Some(ref local_query_param) = page_number {
7439 local_req_builder =
7440 local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
7441 };
7442 if let Some(ref local_query_param) = filter_name {
7443 local_req_builder =
7444 local_req_builder.query(&[("filter[name]", &local_query_param.to_string())]);
7445 };
7446 if let Some(ref local_query_param) = filter_type {
7447 local_req_builder =
7448 local_req_builder.query(&[("filter[type]", &local_query_param.to_string())]);
7449 };
7450 if let Some(ref local_query_param) = filter_version_first {
7451 local_req_builder = local_req_builder
7452 .query(&[("filter[version.first]", &local_query_param.to_string())]);
7453 };
7454 if let Some(ref local_query_param) = filter_version_last {
7455 local_req_builder = local_req_builder
7456 .query(&[("filter[version.last]", &local_query_param.to_string())]);
7457 };
7458 if let Some(ref local_query_param) = filter_repository_url {
7459 local_req_builder = local_req_builder
7460 .query(&[("filter[repository_url]", &local_query_param.to_string())]);
7461 };
7462 if let Some(ref local_query_param) = filter_risks_in_production {
7463 local_req_builder = local_req_builder.query(&[(
7464 "filter[risks.in_production]",
7465 &local_query_param.to_string(),
7466 )]);
7467 };
7468 if let Some(ref local_query_param) = filter_risks_under_attack {
7469 local_req_builder = local_req_builder
7470 .query(&[("filter[risks.under_attack]", &local_query_param.to_string())]);
7471 };
7472 if let Some(ref local_query_param) = filter_risks_is_publicly_accessible {
7473 local_req_builder = local_req_builder.query(&[(
7474 "filter[risks.is_publicly_accessible]",
7475 &local_query_param.to_string(),
7476 )]);
7477 };
7478 if let Some(ref local_query_param) = filter_risks_has_privileged_access {
7479 local_req_builder = local_req_builder.query(&[(
7480 "filter[risks.has_privileged_access]",
7481 &local_query_param.to_string(),
7482 )]);
7483 };
7484 if let Some(ref local_query_param) = filter_risks_has_access_to_sensitive_data {
7485 local_req_builder = local_req_builder.query(&[(
7486 "filter[risks.has_access_to_sensitive_data]",
7487 &local_query_param.to_string(),
7488 )]);
7489 };
7490 if let Some(ref local_query_param) = filter_environments {
7491 local_req_builder = local_req_builder
7492 .query(&[("filter[environments]", &local_query_param.to_string())]);
7493 };
7494 if let Some(ref local_query_param) = filter_teams {
7495 local_req_builder =
7496 local_req_builder.query(&[("filter[teams]", &local_query_param.to_string())]);
7497 };
7498 if let Some(ref local_query_param) = filter_arch {
7499 local_req_builder =
7500 local_req_builder.query(&[("filter[arch]", &local_query_param.to_string())]);
7501 };
7502 if let Some(ref local_query_param) = filter_operating_system_name {
7503 local_req_builder = local_req_builder.query(&[(
7504 "filter[operating_system.name]",
7505 &local_query_param.to_string(),
7506 )]);
7507 };
7508 if let Some(ref local_query_param) = filter_operating_system_version {
7509 local_req_builder = local_req_builder.query(&[(
7510 "filter[operating_system.version]",
7511 &local_query_param.to_string(),
7512 )]);
7513 };
7514
7515 let mut headers = HeaderMap::new();
7517 headers.insert("Accept", HeaderValue::from_static("application/json"));
7518
7519 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
7521 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
7522 Err(e) => {
7523 log::warn!("Failed to parse user agent header: {e}, falling back to default");
7524 headers.insert(
7525 reqwest::header::USER_AGENT,
7526 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
7527 )
7528 }
7529 };
7530
7531 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
7533 headers.insert(
7534 "DD-API-KEY",
7535 HeaderValue::from_str(local_key.key.as_str())
7536 .expect("failed to parse DD-API-KEY header"),
7537 );
7538 };
7539 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
7540 headers.insert(
7541 "DD-APPLICATION-KEY",
7542 HeaderValue::from_str(local_key.key.as_str())
7543 .expect("failed to parse DD-APPLICATION-KEY header"),
7544 );
7545 };
7546
7547 local_req_builder = local_req_builder.headers(headers);
7548 let local_req = local_req_builder.build()?;
7549 log::debug!("request content: {:?}", local_req.body());
7550 let local_resp = local_client.execute(local_req).await?;
7551
7552 let local_status = local_resp.status();
7553 let local_content = local_resp.text().await?;
7554 log::debug!("response content: {}", local_content);
7555
7556 if !local_status.is_client_error() && !local_status.is_server_error() {
7557 match serde_json::from_str::<crate::datadogV2::model::ListVulnerableAssetsResponse>(
7558 &local_content,
7559 ) {
7560 Ok(e) => {
7561 return Ok(datadog::ResponseContent {
7562 status: local_status,
7563 content: local_content,
7564 entity: Some(e),
7565 })
7566 }
7567 Err(e) => return Err(datadog::Error::Serde(e)),
7568 };
7569 } else {
7570 let local_entity: Option<ListVulnerableAssetsError> =
7571 serde_json::from_str(&local_content).ok();
7572 let local_error = datadog::ResponseContent {
7573 status: local_status,
7574 content: local_content,
7575 entity: local_entity,
7576 };
7577 Err(datadog::Error::ResponseError(local_error))
7578 }
7579 }
7580
7581 pub async fn mute_findings(
7583 &self,
7584 body: crate::datadogV2::model::BulkMuteFindingsRequest,
7585 ) -> Result<crate::datadogV2::model::BulkMuteFindingsResponse, datadog::Error<MuteFindingsError>>
7586 {
7587 match self.mute_findings_with_http_info(body).await {
7588 Ok(response_content) => {
7589 if let Some(e) = response_content.entity {
7590 Ok(e)
7591 } else {
7592 Err(datadog::Error::Serde(serde::de::Error::custom(
7593 "response content was None",
7594 )))
7595 }
7596 }
7597 Err(err) => Err(err),
7598 }
7599 }
7600
7601 pub async fn mute_findings_with_http_info(
7603 &self,
7604 body: crate::datadogV2::model::BulkMuteFindingsRequest,
7605 ) -> Result<
7606 datadog::ResponseContent<crate::datadogV2::model::BulkMuteFindingsResponse>,
7607 datadog::Error<MuteFindingsError>,
7608 > {
7609 let local_configuration = &self.config;
7610 let operation_id = "v2.mute_findings";
7611 if local_configuration.is_unstable_operation_enabled(operation_id) {
7612 warn!("Using unstable operation {operation_id}");
7613 } else {
7614 let local_error = datadog::UnstableOperationDisabledError {
7615 msg: "Operation 'v2.mute_findings' is not enabled".to_string(),
7616 };
7617 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
7618 }
7619
7620 let local_client = &self.client;
7621
7622 let local_uri_str = format!(
7623 "{}/api/v2/posture_management/findings",
7624 local_configuration.get_operation_host(operation_id)
7625 );
7626 let mut local_req_builder =
7627 local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
7628
7629 let mut headers = HeaderMap::new();
7631 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
7632 headers.insert("Accept", HeaderValue::from_static("application/json"));
7633
7634 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
7636 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
7637 Err(e) => {
7638 log::warn!("Failed to parse user agent header: {e}, falling back to default");
7639 headers.insert(
7640 reqwest::header::USER_AGENT,
7641 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
7642 )
7643 }
7644 };
7645
7646 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
7648 headers.insert(
7649 "DD-API-KEY",
7650 HeaderValue::from_str(local_key.key.as_str())
7651 .expect("failed to parse DD-API-KEY header"),
7652 );
7653 };
7654 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
7655 headers.insert(
7656 "DD-APPLICATION-KEY",
7657 HeaderValue::from_str(local_key.key.as_str())
7658 .expect("failed to parse DD-APPLICATION-KEY header"),
7659 );
7660 };
7661
7662 let output = Vec::new();
7664 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
7665 if body.serialize(&mut ser).is_ok() {
7666 if let Some(content_encoding) = headers.get("Content-Encoding") {
7667 match content_encoding.to_str().unwrap_or_default() {
7668 "gzip" => {
7669 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
7670 let _ = enc.write_all(ser.into_inner().as_slice());
7671 match enc.finish() {
7672 Ok(buf) => {
7673 local_req_builder = local_req_builder.body(buf);
7674 }
7675 Err(e) => return Err(datadog::Error::Io(e)),
7676 }
7677 }
7678 "deflate" => {
7679 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
7680 let _ = enc.write_all(ser.into_inner().as_slice());
7681 match enc.finish() {
7682 Ok(buf) => {
7683 local_req_builder = local_req_builder.body(buf);
7684 }
7685 Err(e) => return Err(datadog::Error::Io(e)),
7686 }
7687 }
7688 "zstd1" => {
7689 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
7690 let _ = enc.write_all(ser.into_inner().as_slice());
7691 match enc.finish() {
7692 Ok(buf) => {
7693 local_req_builder = local_req_builder.body(buf);
7694 }
7695 Err(e) => return Err(datadog::Error::Io(e)),
7696 }
7697 }
7698 _ => {
7699 local_req_builder = local_req_builder.body(ser.into_inner());
7700 }
7701 }
7702 } else {
7703 local_req_builder = local_req_builder.body(ser.into_inner());
7704 }
7705 }
7706
7707 local_req_builder = local_req_builder.headers(headers);
7708 let local_req = local_req_builder.build()?;
7709 log::debug!("request content: {:?}", local_req.body());
7710 let local_resp = local_client.execute(local_req).await?;
7711
7712 let local_status = local_resp.status();
7713 let local_content = local_resp.text().await?;
7714 log::debug!("response content: {}", local_content);
7715
7716 if !local_status.is_client_error() && !local_status.is_server_error() {
7717 match serde_json::from_str::<crate::datadogV2::model::BulkMuteFindingsResponse>(
7718 &local_content,
7719 ) {
7720 Ok(e) => {
7721 return Ok(datadog::ResponseContent {
7722 status: local_status,
7723 content: local_content,
7724 entity: Some(e),
7725 })
7726 }
7727 Err(e) => return Err(datadog::Error::Serde(e)),
7728 };
7729 } else {
7730 let local_entity: Option<MuteFindingsError> = serde_json::from_str(&local_content).ok();
7731 let local_error = datadog::ResponseContent {
7732 status: local_status,
7733 content: local_content,
7734 entity: local_entity,
7735 };
7736 Err(datadog::Error::ResponseError(local_error))
7737 }
7738 }
7739
7740 pub async fn patch_signal_notification_rule(
7742 &self,
7743 id: String,
7744 body: crate::datadogV2::model::PatchNotificationRuleParameters,
7745 ) -> Result<
7746 crate::datadogV2::model::NotificationRuleResponse,
7747 datadog::Error<PatchSignalNotificationRuleError>,
7748 > {
7749 match self
7750 .patch_signal_notification_rule_with_http_info(id, body)
7751 .await
7752 {
7753 Ok(response_content) => {
7754 if let Some(e) = response_content.entity {
7755 Ok(e)
7756 } else {
7757 Err(datadog::Error::Serde(serde::de::Error::custom(
7758 "response content was None",
7759 )))
7760 }
7761 }
7762 Err(err) => Err(err),
7763 }
7764 }
7765
7766 pub async fn patch_signal_notification_rule_with_http_info(
7768 &self,
7769 id: String,
7770 body: crate::datadogV2::model::PatchNotificationRuleParameters,
7771 ) -> Result<
7772 datadog::ResponseContent<crate::datadogV2::model::NotificationRuleResponse>,
7773 datadog::Error<PatchSignalNotificationRuleError>,
7774 > {
7775 let local_configuration = &self.config;
7776 let operation_id = "v2.patch_signal_notification_rule";
7777
7778 let local_client = &self.client;
7779
7780 let local_uri_str = format!(
7781 "{}/api/v2/security/signals/notification_rules/{id}",
7782 local_configuration.get_operation_host(operation_id),
7783 id = datadog::urlencode(id)
7784 );
7785 let mut local_req_builder =
7786 local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
7787
7788 let mut headers = HeaderMap::new();
7790 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
7791 headers.insert("Accept", HeaderValue::from_static("application/json"));
7792
7793 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
7795 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
7796 Err(e) => {
7797 log::warn!("Failed to parse user agent header: {e}, falling back to default");
7798 headers.insert(
7799 reqwest::header::USER_AGENT,
7800 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
7801 )
7802 }
7803 };
7804
7805 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
7807 headers.insert(
7808 "DD-API-KEY",
7809 HeaderValue::from_str(local_key.key.as_str())
7810 .expect("failed to parse DD-API-KEY header"),
7811 );
7812 };
7813 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
7814 headers.insert(
7815 "DD-APPLICATION-KEY",
7816 HeaderValue::from_str(local_key.key.as_str())
7817 .expect("failed to parse DD-APPLICATION-KEY header"),
7818 );
7819 };
7820
7821 let output = Vec::new();
7823 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
7824 if body.serialize(&mut ser).is_ok() {
7825 if let Some(content_encoding) = headers.get("Content-Encoding") {
7826 match content_encoding.to_str().unwrap_or_default() {
7827 "gzip" => {
7828 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
7829 let _ = enc.write_all(ser.into_inner().as_slice());
7830 match enc.finish() {
7831 Ok(buf) => {
7832 local_req_builder = local_req_builder.body(buf);
7833 }
7834 Err(e) => return Err(datadog::Error::Io(e)),
7835 }
7836 }
7837 "deflate" => {
7838 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
7839 let _ = enc.write_all(ser.into_inner().as_slice());
7840 match enc.finish() {
7841 Ok(buf) => {
7842 local_req_builder = local_req_builder.body(buf);
7843 }
7844 Err(e) => return Err(datadog::Error::Io(e)),
7845 }
7846 }
7847 "zstd1" => {
7848 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
7849 let _ = enc.write_all(ser.into_inner().as_slice());
7850 match enc.finish() {
7851 Ok(buf) => {
7852 local_req_builder = local_req_builder.body(buf);
7853 }
7854 Err(e) => return Err(datadog::Error::Io(e)),
7855 }
7856 }
7857 _ => {
7858 local_req_builder = local_req_builder.body(ser.into_inner());
7859 }
7860 }
7861 } else {
7862 local_req_builder = local_req_builder.body(ser.into_inner());
7863 }
7864 }
7865
7866 local_req_builder = local_req_builder.headers(headers);
7867 let local_req = local_req_builder.build()?;
7868 log::debug!("request content: {:?}", local_req.body());
7869 let local_resp = local_client.execute(local_req).await?;
7870
7871 let local_status = local_resp.status();
7872 let local_content = local_resp.text().await?;
7873 log::debug!("response content: {}", local_content);
7874
7875 if !local_status.is_client_error() && !local_status.is_server_error() {
7876 match serde_json::from_str::<crate::datadogV2::model::NotificationRuleResponse>(
7877 &local_content,
7878 ) {
7879 Ok(e) => {
7880 return Ok(datadog::ResponseContent {
7881 status: local_status,
7882 content: local_content,
7883 entity: Some(e),
7884 })
7885 }
7886 Err(e) => return Err(datadog::Error::Serde(e)),
7887 };
7888 } else {
7889 let local_entity: Option<PatchSignalNotificationRuleError> =
7890 serde_json::from_str(&local_content).ok();
7891 let local_error = datadog::ResponseContent {
7892 status: local_status,
7893 content: local_content,
7894 entity: local_entity,
7895 };
7896 Err(datadog::Error::ResponseError(local_error))
7897 }
7898 }
7899
7900 pub async fn patch_vulnerability_notification_rule(
7902 &self,
7903 id: String,
7904 body: crate::datadogV2::model::PatchNotificationRuleParameters,
7905 ) -> Result<
7906 crate::datadogV2::model::NotificationRuleResponse,
7907 datadog::Error<PatchVulnerabilityNotificationRuleError>,
7908 > {
7909 match self
7910 .patch_vulnerability_notification_rule_with_http_info(id, body)
7911 .await
7912 {
7913 Ok(response_content) => {
7914 if let Some(e) = response_content.entity {
7915 Ok(e)
7916 } else {
7917 Err(datadog::Error::Serde(serde::de::Error::custom(
7918 "response content was None",
7919 )))
7920 }
7921 }
7922 Err(err) => Err(err),
7923 }
7924 }
7925
7926 pub async fn patch_vulnerability_notification_rule_with_http_info(
7928 &self,
7929 id: String,
7930 body: crate::datadogV2::model::PatchNotificationRuleParameters,
7931 ) -> Result<
7932 datadog::ResponseContent<crate::datadogV2::model::NotificationRuleResponse>,
7933 datadog::Error<PatchVulnerabilityNotificationRuleError>,
7934 > {
7935 let local_configuration = &self.config;
7936 let operation_id = "v2.patch_vulnerability_notification_rule";
7937
7938 let local_client = &self.client;
7939
7940 let local_uri_str = format!(
7941 "{}/api/v2/security/vulnerabilities/notification_rules/{id}",
7942 local_configuration.get_operation_host(operation_id),
7943 id = datadog::urlencode(id)
7944 );
7945 let mut local_req_builder =
7946 local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
7947
7948 let mut headers = HeaderMap::new();
7950 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
7951 headers.insert("Accept", HeaderValue::from_static("application/json"));
7952
7953 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
7955 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
7956 Err(e) => {
7957 log::warn!("Failed to parse user agent header: {e}, falling back to default");
7958 headers.insert(
7959 reqwest::header::USER_AGENT,
7960 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
7961 )
7962 }
7963 };
7964
7965 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
7967 headers.insert(
7968 "DD-API-KEY",
7969 HeaderValue::from_str(local_key.key.as_str())
7970 .expect("failed to parse DD-API-KEY header"),
7971 );
7972 };
7973 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
7974 headers.insert(
7975 "DD-APPLICATION-KEY",
7976 HeaderValue::from_str(local_key.key.as_str())
7977 .expect("failed to parse DD-APPLICATION-KEY header"),
7978 );
7979 };
7980
7981 let output = Vec::new();
7983 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
7984 if body.serialize(&mut ser).is_ok() {
7985 if let Some(content_encoding) = headers.get("Content-Encoding") {
7986 match content_encoding.to_str().unwrap_or_default() {
7987 "gzip" => {
7988 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
7989 let _ = enc.write_all(ser.into_inner().as_slice());
7990 match enc.finish() {
7991 Ok(buf) => {
7992 local_req_builder = local_req_builder.body(buf);
7993 }
7994 Err(e) => return Err(datadog::Error::Io(e)),
7995 }
7996 }
7997 "deflate" => {
7998 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
7999 let _ = enc.write_all(ser.into_inner().as_slice());
8000 match enc.finish() {
8001 Ok(buf) => {
8002 local_req_builder = local_req_builder.body(buf);
8003 }
8004 Err(e) => return Err(datadog::Error::Io(e)),
8005 }
8006 }
8007 "zstd1" => {
8008 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
8009 let _ = enc.write_all(ser.into_inner().as_slice());
8010 match enc.finish() {
8011 Ok(buf) => {
8012 local_req_builder = local_req_builder.body(buf);
8013 }
8014 Err(e) => return Err(datadog::Error::Io(e)),
8015 }
8016 }
8017 _ => {
8018 local_req_builder = local_req_builder.body(ser.into_inner());
8019 }
8020 }
8021 } else {
8022 local_req_builder = local_req_builder.body(ser.into_inner());
8023 }
8024 }
8025
8026 local_req_builder = local_req_builder.headers(headers);
8027 let local_req = local_req_builder.build()?;
8028 log::debug!("request content: {:?}", local_req.body());
8029 let local_resp = local_client.execute(local_req).await?;
8030
8031 let local_status = local_resp.status();
8032 let local_content = local_resp.text().await?;
8033 log::debug!("response content: {}", local_content);
8034
8035 if !local_status.is_client_error() && !local_status.is_server_error() {
8036 match serde_json::from_str::<crate::datadogV2::model::NotificationRuleResponse>(
8037 &local_content,
8038 ) {
8039 Ok(e) => {
8040 return Ok(datadog::ResponseContent {
8041 status: local_status,
8042 content: local_content,
8043 entity: Some(e),
8044 })
8045 }
8046 Err(e) => return Err(datadog::Error::Serde(e)),
8047 };
8048 } else {
8049 let local_entity: Option<PatchVulnerabilityNotificationRuleError> =
8050 serde_json::from_str(&local_content).ok();
8051 let local_error = datadog::ResponseContent {
8052 status: local_status,
8053 content: local_content,
8054 entity: local_entity,
8055 };
8056 Err(datadog::Error::ResponseError(local_error))
8057 }
8058 }
8059
8060 pub async fn run_historical_job(
8062 &self,
8063 body: crate::datadogV2::model::RunHistoricalJobRequest,
8064 ) -> Result<crate::datadogV2::model::JobCreateResponse, datadog::Error<RunHistoricalJobError>>
8065 {
8066 match self.run_historical_job_with_http_info(body).await {
8067 Ok(response_content) => {
8068 if let Some(e) = response_content.entity {
8069 Ok(e)
8070 } else {
8071 Err(datadog::Error::Serde(serde::de::Error::custom(
8072 "response content was None",
8073 )))
8074 }
8075 }
8076 Err(err) => Err(err),
8077 }
8078 }
8079
8080 pub async fn run_historical_job_with_http_info(
8082 &self,
8083 body: crate::datadogV2::model::RunHistoricalJobRequest,
8084 ) -> Result<
8085 datadog::ResponseContent<crate::datadogV2::model::JobCreateResponse>,
8086 datadog::Error<RunHistoricalJobError>,
8087 > {
8088 let local_configuration = &self.config;
8089 let operation_id = "v2.run_historical_job";
8090 if local_configuration.is_unstable_operation_enabled(operation_id) {
8091 warn!("Using unstable operation {operation_id}");
8092 } else {
8093 let local_error = datadog::UnstableOperationDisabledError {
8094 msg: "Operation 'v2.run_historical_job' is not enabled".to_string(),
8095 };
8096 return Err(datadog::Error::UnstableOperationDisabledError(local_error));
8097 }
8098
8099 let local_client = &self.client;
8100
8101 let local_uri_str = format!(
8102 "{}/api/v2/siem-historical-detections/jobs",
8103 local_configuration.get_operation_host(operation_id)
8104 );
8105 let mut local_req_builder =
8106 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
8107
8108 let mut headers = HeaderMap::new();
8110 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
8111 headers.insert("Accept", HeaderValue::from_static("application/json"));
8112
8113 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
8115 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
8116 Err(e) => {
8117 log::warn!("Failed to parse user agent header: {e}, falling back to default");
8118 headers.insert(
8119 reqwest::header::USER_AGENT,
8120 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
8121 )
8122 }
8123 };
8124
8125 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
8127 headers.insert(
8128 "DD-API-KEY",
8129 HeaderValue::from_str(local_key.key.as_str())
8130 .expect("failed to parse DD-API-KEY header"),
8131 );
8132 };
8133 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
8134 headers.insert(
8135 "DD-APPLICATION-KEY",
8136 HeaderValue::from_str(local_key.key.as_str())
8137 .expect("failed to parse DD-APPLICATION-KEY header"),
8138 );
8139 };
8140
8141 let output = Vec::new();
8143 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
8144 if body.serialize(&mut ser).is_ok() {
8145 if let Some(content_encoding) = headers.get("Content-Encoding") {
8146 match content_encoding.to_str().unwrap_or_default() {
8147 "gzip" => {
8148 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
8149 let _ = enc.write_all(ser.into_inner().as_slice());
8150 match enc.finish() {
8151 Ok(buf) => {
8152 local_req_builder = local_req_builder.body(buf);
8153 }
8154 Err(e) => return Err(datadog::Error::Io(e)),
8155 }
8156 }
8157 "deflate" => {
8158 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
8159 let _ = enc.write_all(ser.into_inner().as_slice());
8160 match enc.finish() {
8161 Ok(buf) => {
8162 local_req_builder = local_req_builder.body(buf);
8163 }
8164 Err(e) => return Err(datadog::Error::Io(e)),
8165 }
8166 }
8167 "zstd1" => {
8168 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
8169 let _ = enc.write_all(ser.into_inner().as_slice());
8170 match enc.finish() {
8171 Ok(buf) => {
8172 local_req_builder = local_req_builder.body(buf);
8173 }
8174 Err(e) => return Err(datadog::Error::Io(e)),
8175 }
8176 }
8177 _ => {
8178 local_req_builder = local_req_builder.body(ser.into_inner());
8179 }
8180 }
8181 } else {
8182 local_req_builder = local_req_builder.body(ser.into_inner());
8183 }
8184 }
8185
8186 local_req_builder = local_req_builder.headers(headers);
8187 let local_req = local_req_builder.build()?;
8188 log::debug!("request content: {:?}", local_req.body());
8189 let local_resp = local_client.execute(local_req).await?;
8190
8191 let local_status = local_resp.status();
8192 let local_content = local_resp.text().await?;
8193 log::debug!("response content: {}", local_content);
8194
8195 if !local_status.is_client_error() && !local_status.is_server_error() {
8196 match serde_json::from_str::<crate::datadogV2::model::JobCreateResponse>(&local_content)
8197 {
8198 Ok(e) => {
8199 return Ok(datadog::ResponseContent {
8200 status: local_status,
8201 content: local_content,
8202 entity: Some(e),
8203 })
8204 }
8205 Err(e) => return Err(datadog::Error::Serde(e)),
8206 };
8207 } else {
8208 let local_entity: Option<RunHistoricalJobError> =
8209 serde_json::from_str(&local_content).ok();
8210 let local_error = datadog::ResponseContent {
8211 status: local_status,
8212 content: local_content,
8213 entity: local_entity,
8214 };
8215 Err(datadog::Error::ResponseError(local_error))
8216 }
8217 }
8218
8219 pub async fn search_security_monitoring_signals(
8223 &self,
8224 params: SearchSecurityMonitoringSignalsOptionalParams,
8225 ) -> Result<
8226 crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
8227 datadog::Error<SearchSecurityMonitoringSignalsError>,
8228 > {
8229 match self
8230 .search_security_monitoring_signals_with_http_info(params)
8231 .await
8232 {
8233 Ok(response_content) => {
8234 if let Some(e) = response_content.entity {
8235 Ok(e)
8236 } else {
8237 Err(datadog::Error::Serde(serde::de::Error::custom(
8238 "response content was None",
8239 )))
8240 }
8241 }
8242 Err(err) => Err(err),
8243 }
8244 }
8245
8246 pub fn search_security_monitoring_signals_with_pagination(
8247 &self,
8248 mut params: SearchSecurityMonitoringSignalsOptionalParams,
8249 ) -> impl Stream<
8250 Item = Result<
8251 crate::datadogV2::model::SecurityMonitoringSignal,
8252 datadog::Error<SearchSecurityMonitoringSignalsError>,
8253 >,
8254 > + '_ {
8255 try_stream! {
8256 let mut page_size: i32 = 10;
8257 if params.body.is_none() {
8258 params.body = Some(crate::datadogV2::model::SecurityMonitoringSignalListRequest::new());
8259 }
8260 if params.body.as_ref().unwrap().page.is_none() {
8261 params.body.as_mut().unwrap().page = Some(crate::datadogV2::model::SecurityMonitoringSignalListRequestPage::new());
8262 }
8263 if params.body.as_ref().unwrap().page.as_ref().unwrap().limit.is_none() {
8264 params.body.as_mut().unwrap().page.as_mut().unwrap().limit = Some(page_size);
8265 } else {
8266 page_size = params.body.as_ref().unwrap().page.as_ref().unwrap().limit.unwrap().clone();
8267 }
8268 loop {
8269 let resp = self.search_security_monitoring_signals(params.clone()).await?;
8270 let Some(data) = resp.data else { break };
8271
8272 let r = data;
8273 let count = r.len();
8274 for team in r {
8275 yield team;
8276 }
8277
8278 if count < page_size as usize {
8279 break;
8280 }
8281 let Some(meta) = resp.meta else { break };
8282 let Some(page) = meta.page else { break };
8283 let Some(after) = page.after else { break };
8284
8285 params.body.as_mut().unwrap().page.as_mut().unwrap().cursor = Some(after);
8286 }
8287 }
8288 }
8289
8290 pub async fn search_security_monitoring_signals_with_http_info(
8294 &self,
8295 params: SearchSecurityMonitoringSignalsOptionalParams,
8296 ) -> Result<
8297 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSignalsListResponse>,
8298 datadog::Error<SearchSecurityMonitoringSignalsError>,
8299 > {
8300 let local_configuration = &self.config;
8301 let operation_id = "v2.search_security_monitoring_signals";
8302
8303 let body = params.body;
8305
8306 let local_client = &self.client;
8307
8308 let local_uri_str = format!(
8309 "{}/api/v2/security_monitoring/signals/search",
8310 local_configuration.get_operation_host(operation_id)
8311 );
8312 let mut local_req_builder =
8313 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
8314
8315 let mut headers = HeaderMap::new();
8317 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
8318 headers.insert("Accept", HeaderValue::from_static("application/json"));
8319
8320 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
8322 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
8323 Err(e) => {
8324 log::warn!("Failed to parse user agent header: {e}, falling back to default");
8325 headers.insert(
8326 reqwest::header::USER_AGENT,
8327 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
8328 )
8329 }
8330 };
8331
8332 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
8334 headers.insert(
8335 "DD-API-KEY",
8336 HeaderValue::from_str(local_key.key.as_str())
8337 .expect("failed to parse DD-API-KEY header"),
8338 );
8339 };
8340 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
8341 headers.insert(
8342 "DD-APPLICATION-KEY",
8343 HeaderValue::from_str(local_key.key.as_str())
8344 .expect("failed to parse DD-APPLICATION-KEY header"),
8345 );
8346 };
8347
8348 let output = Vec::new();
8350 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
8351 if body.serialize(&mut ser).is_ok() {
8352 if let Some(content_encoding) = headers.get("Content-Encoding") {
8353 match content_encoding.to_str().unwrap_or_default() {
8354 "gzip" => {
8355 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
8356 let _ = enc.write_all(ser.into_inner().as_slice());
8357 match enc.finish() {
8358 Ok(buf) => {
8359 local_req_builder = local_req_builder.body(buf);
8360 }
8361 Err(e) => return Err(datadog::Error::Io(e)),
8362 }
8363 }
8364 "deflate" => {
8365 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
8366 let _ = enc.write_all(ser.into_inner().as_slice());
8367 match enc.finish() {
8368 Ok(buf) => {
8369 local_req_builder = local_req_builder.body(buf);
8370 }
8371 Err(e) => return Err(datadog::Error::Io(e)),
8372 }
8373 }
8374 "zstd1" => {
8375 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
8376 let _ = enc.write_all(ser.into_inner().as_slice());
8377 match enc.finish() {
8378 Ok(buf) => {
8379 local_req_builder = local_req_builder.body(buf);
8380 }
8381 Err(e) => return Err(datadog::Error::Io(e)),
8382 }
8383 }
8384 _ => {
8385 local_req_builder = local_req_builder.body(ser.into_inner());
8386 }
8387 }
8388 } else {
8389 local_req_builder = local_req_builder.body(ser.into_inner());
8390 }
8391 }
8392
8393 local_req_builder = local_req_builder.headers(headers);
8394 let local_req = local_req_builder.build()?;
8395 log::debug!("request content: {:?}", local_req.body());
8396 let local_resp = local_client.execute(local_req).await?;
8397
8398 let local_status = local_resp.status();
8399 let local_content = local_resp.text().await?;
8400 log::debug!("response content: {}", local_content);
8401
8402 if !local_status.is_client_error() && !local_status.is_server_error() {
8403 match serde_json::from_str::<
8404 crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
8405 >(&local_content)
8406 {
8407 Ok(e) => {
8408 return Ok(datadog::ResponseContent {
8409 status: local_status,
8410 content: local_content,
8411 entity: Some(e),
8412 })
8413 }
8414 Err(e) => return Err(datadog::Error::Serde(e)),
8415 };
8416 } else {
8417 let local_entity: Option<SearchSecurityMonitoringSignalsError> =
8418 serde_json::from_str(&local_content).ok();
8419 let local_error = datadog::ResponseContent {
8420 status: local_status,
8421 content: local_content,
8422 entity: local_entity,
8423 };
8424 Err(datadog::Error::ResponseError(local_error))
8425 }
8426 }
8427
8428 pub async fn test_existing_security_monitoring_rule(
8430 &self,
8431 rule_id: String,
8432 body: crate::datadogV2::model::SecurityMonitoringRuleTestRequest,
8433 ) -> Result<
8434 crate::datadogV2::model::SecurityMonitoringRuleTestResponse,
8435 datadog::Error<TestExistingSecurityMonitoringRuleError>,
8436 > {
8437 match self
8438 .test_existing_security_monitoring_rule_with_http_info(rule_id, body)
8439 .await
8440 {
8441 Ok(response_content) => {
8442 if let Some(e) = response_content.entity {
8443 Ok(e)
8444 } else {
8445 Err(datadog::Error::Serde(serde::de::Error::custom(
8446 "response content was None",
8447 )))
8448 }
8449 }
8450 Err(err) => Err(err),
8451 }
8452 }
8453
8454 pub async fn test_existing_security_monitoring_rule_with_http_info(
8456 &self,
8457 rule_id: String,
8458 body: crate::datadogV2::model::SecurityMonitoringRuleTestRequest,
8459 ) -> Result<
8460 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleTestResponse>,
8461 datadog::Error<TestExistingSecurityMonitoringRuleError>,
8462 > {
8463 let local_configuration = &self.config;
8464 let operation_id = "v2.test_existing_security_monitoring_rule";
8465
8466 let local_client = &self.client;
8467
8468 let local_uri_str = format!(
8469 "{}/api/v2/security_monitoring/rules/{rule_id}/test",
8470 local_configuration.get_operation_host(operation_id),
8471 rule_id = datadog::urlencode(rule_id)
8472 );
8473 let mut local_req_builder =
8474 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
8475
8476 let mut headers = HeaderMap::new();
8478 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
8479 headers.insert("Accept", HeaderValue::from_static("application/json"));
8480
8481 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
8483 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
8484 Err(e) => {
8485 log::warn!("Failed to parse user agent header: {e}, falling back to default");
8486 headers.insert(
8487 reqwest::header::USER_AGENT,
8488 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
8489 )
8490 }
8491 };
8492
8493 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
8495 headers.insert(
8496 "DD-API-KEY",
8497 HeaderValue::from_str(local_key.key.as_str())
8498 .expect("failed to parse DD-API-KEY header"),
8499 );
8500 };
8501 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
8502 headers.insert(
8503 "DD-APPLICATION-KEY",
8504 HeaderValue::from_str(local_key.key.as_str())
8505 .expect("failed to parse DD-APPLICATION-KEY header"),
8506 );
8507 };
8508
8509 let output = Vec::new();
8511 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
8512 if body.serialize(&mut ser).is_ok() {
8513 if let Some(content_encoding) = headers.get("Content-Encoding") {
8514 match content_encoding.to_str().unwrap_or_default() {
8515 "gzip" => {
8516 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
8517 let _ = enc.write_all(ser.into_inner().as_slice());
8518 match enc.finish() {
8519 Ok(buf) => {
8520 local_req_builder = local_req_builder.body(buf);
8521 }
8522 Err(e) => return Err(datadog::Error::Io(e)),
8523 }
8524 }
8525 "deflate" => {
8526 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
8527 let _ = enc.write_all(ser.into_inner().as_slice());
8528 match enc.finish() {
8529 Ok(buf) => {
8530 local_req_builder = local_req_builder.body(buf);
8531 }
8532 Err(e) => return Err(datadog::Error::Io(e)),
8533 }
8534 }
8535 "zstd1" => {
8536 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
8537 let _ = enc.write_all(ser.into_inner().as_slice());
8538 match enc.finish() {
8539 Ok(buf) => {
8540 local_req_builder = local_req_builder.body(buf);
8541 }
8542 Err(e) => return Err(datadog::Error::Io(e)),
8543 }
8544 }
8545 _ => {
8546 local_req_builder = local_req_builder.body(ser.into_inner());
8547 }
8548 }
8549 } else {
8550 local_req_builder = local_req_builder.body(ser.into_inner());
8551 }
8552 }
8553
8554 local_req_builder = local_req_builder.headers(headers);
8555 let local_req = local_req_builder.build()?;
8556 log::debug!("request content: {:?}", local_req.body());
8557 let local_resp = local_client.execute(local_req).await?;
8558
8559 let local_status = local_resp.status();
8560 let local_content = local_resp.text().await?;
8561 log::debug!("response content: {}", local_content);
8562
8563 if !local_status.is_client_error() && !local_status.is_server_error() {
8564 match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringRuleTestResponse>(
8565 &local_content,
8566 ) {
8567 Ok(e) => {
8568 return Ok(datadog::ResponseContent {
8569 status: local_status,
8570 content: local_content,
8571 entity: Some(e),
8572 })
8573 }
8574 Err(e) => return Err(datadog::Error::Serde(e)),
8575 };
8576 } else {
8577 let local_entity: Option<TestExistingSecurityMonitoringRuleError> =
8578 serde_json::from_str(&local_content).ok();
8579 let local_error = datadog::ResponseContent {
8580 status: local_status,
8581 content: local_content,
8582 entity: local_entity,
8583 };
8584 Err(datadog::Error::ResponseError(local_error))
8585 }
8586 }
8587
8588 pub async fn test_security_monitoring_rule(
8590 &self,
8591 body: crate::datadogV2::model::SecurityMonitoringRuleTestRequest,
8592 ) -> Result<
8593 crate::datadogV2::model::SecurityMonitoringRuleTestResponse,
8594 datadog::Error<TestSecurityMonitoringRuleError>,
8595 > {
8596 match self
8597 .test_security_monitoring_rule_with_http_info(body)
8598 .await
8599 {
8600 Ok(response_content) => {
8601 if let Some(e) = response_content.entity {
8602 Ok(e)
8603 } else {
8604 Err(datadog::Error::Serde(serde::de::Error::custom(
8605 "response content was None",
8606 )))
8607 }
8608 }
8609 Err(err) => Err(err),
8610 }
8611 }
8612
8613 pub async fn test_security_monitoring_rule_with_http_info(
8615 &self,
8616 body: crate::datadogV2::model::SecurityMonitoringRuleTestRequest,
8617 ) -> Result<
8618 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleTestResponse>,
8619 datadog::Error<TestSecurityMonitoringRuleError>,
8620 > {
8621 let local_configuration = &self.config;
8622 let operation_id = "v2.test_security_monitoring_rule";
8623
8624 let local_client = &self.client;
8625
8626 let local_uri_str = format!(
8627 "{}/api/v2/security_monitoring/rules/test",
8628 local_configuration.get_operation_host(operation_id)
8629 );
8630 let mut local_req_builder =
8631 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
8632
8633 let mut headers = HeaderMap::new();
8635 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
8636 headers.insert("Accept", HeaderValue::from_static("application/json"));
8637
8638 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
8640 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
8641 Err(e) => {
8642 log::warn!("Failed to parse user agent header: {e}, falling back to default");
8643 headers.insert(
8644 reqwest::header::USER_AGENT,
8645 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
8646 )
8647 }
8648 };
8649
8650 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
8652 headers.insert(
8653 "DD-API-KEY",
8654 HeaderValue::from_str(local_key.key.as_str())
8655 .expect("failed to parse DD-API-KEY header"),
8656 );
8657 };
8658 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
8659 headers.insert(
8660 "DD-APPLICATION-KEY",
8661 HeaderValue::from_str(local_key.key.as_str())
8662 .expect("failed to parse DD-APPLICATION-KEY header"),
8663 );
8664 };
8665
8666 let output = Vec::new();
8668 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
8669 if body.serialize(&mut ser).is_ok() {
8670 if let Some(content_encoding) = headers.get("Content-Encoding") {
8671 match content_encoding.to_str().unwrap_or_default() {
8672 "gzip" => {
8673 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
8674 let _ = enc.write_all(ser.into_inner().as_slice());
8675 match enc.finish() {
8676 Ok(buf) => {
8677 local_req_builder = local_req_builder.body(buf);
8678 }
8679 Err(e) => return Err(datadog::Error::Io(e)),
8680 }
8681 }
8682 "deflate" => {
8683 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
8684 let _ = enc.write_all(ser.into_inner().as_slice());
8685 match enc.finish() {
8686 Ok(buf) => {
8687 local_req_builder = local_req_builder.body(buf);
8688 }
8689 Err(e) => return Err(datadog::Error::Io(e)),
8690 }
8691 }
8692 "zstd1" => {
8693 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
8694 let _ = enc.write_all(ser.into_inner().as_slice());
8695 match enc.finish() {
8696 Ok(buf) => {
8697 local_req_builder = local_req_builder.body(buf);
8698 }
8699 Err(e) => return Err(datadog::Error::Io(e)),
8700 }
8701 }
8702 _ => {
8703 local_req_builder = local_req_builder.body(ser.into_inner());
8704 }
8705 }
8706 } else {
8707 local_req_builder = local_req_builder.body(ser.into_inner());
8708 }
8709 }
8710
8711 local_req_builder = local_req_builder.headers(headers);
8712 let local_req = local_req_builder.build()?;
8713 log::debug!("request content: {:?}", local_req.body());
8714 let local_resp = local_client.execute(local_req).await?;
8715
8716 let local_status = local_resp.status();
8717 let local_content = local_resp.text().await?;
8718 log::debug!("response content: {}", local_content);
8719
8720 if !local_status.is_client_error() && !local_status.is_server_error() {
8721 match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringRuleTestResponse>(
8722 &local_content,
8723 ) {
8724 Ok(e) => {
8725 return Ok(datadog::ResponseContent {
8726 status: local_status,
8727 content: local_content,
8728 entity: Some(e),
8729 })
8730 }
8731 Err(e) => return Err(datadog::Error::Serde(e)),
8732 };
8733 } else {
8734 let local_entity: Option<TestSecurityMonitoringRuleError> =
8735 serde_json::from_str(&local_content).ok();
8736 let local_error = datadog::ResponseContent {
8737 status: local_status,
8738 content: local_content,
8739 entity: local_entity,
8740 };
8741 Err(datadog::Error::ResponseError(local_error))
8742 }
8743 }
8744
8745 pub async fn update_custom_framework(
8747 &self,
8748 handle: String,
8749 version: String,
8750 body: crate::datadogV2::model::UpdateCustomFrameworkRequest,
8751 ) -> Result<
8752 crate::datadogV2::model::UpdateCustomFrameworkResponse,
8753 datadog::Error<UpdateCustomFrameworkError>,
8754 > {
8755 match self
8756 .update_custom_framework_with_http_info(handle, version, body)
8757 .await
8758 {
8759 Ok(response_content) => {
8760 if let Some(e) = response_content.entity {
8761 Ok(e)
8762 } else {
8763 Err(datadog::Error::Serde(serde::de::Error::custom(
8764 "response content was None",
8765 )))
8766 }
8767 }
8768 Err(err) => Err(err),
8769 }
8770 }
8771
8772 pub async fn update_custom_framework_with_http_info(
8774 &self,
8775 handle: String,
8776 version: String,
8777 body: crate::datadogV2::model::UpdateCustomFrameworkRequest,
8778 ) -> Result<
8779 datadog::ResponseContent<crate::datadogV2::model::UpdateCustomFrameworkResponse>,
8780 datadog::Error<UpdateCustomFrameworkError>,
8781 > {
8782 let local_configuration = &self.config;
8783 let operation_id = "v2.update_custom_framework";
8784
8785 let local_client = &self.client;
8786
8787 let local_uri_str = format!(
8788 "{}/api/v2/cloud_security_management/custom_frameworks/{handle}/{version}",
8789 local_configuration.get_operation_host(operation_id),
8790 handle = datadog::urlencode(handle),
8791 version = datadog::urlencode(version)
8792 );
8793 let mut local_req_builder =
8794 local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
8795
8796 let mut headers = HeaderMap::new();
8798 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
8799 headers.insert("Accept", HeaderValue::from_static("application/json"));
8800
8801 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
8803 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
8804 Err(e) => {
8805 log::warn!("Failed to parse user agent header: {e}, falling back to default");
8806 headers.insert(
8807 reqwest::header::USER_AGENT,
8808 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
8809 )
8810 }
8811 };
8812
8813 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
8815 headers.insert(
8816 "DD-API-KEY",
8817 HeaderValue::from_str(local_key.key.as_str())
8818 .expect("failed to parse DD-API-KEY header"),
8819 );
8820 };
8821 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
8822 headers.insert(
8823 "DD-APPLICATION-KEY",
8824 HeaderValue::from_str(local_key.key.as_str())
8825 .expect("failed to parse DD-APPLICATION-KEY header"),
8826 );
8827 };
8828
8829 let output = Vec::new();
8831 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
8832 if body.serialize(&mut ser).is_ok() {
8833 if let Some(content_encoding) = headers.get("Content-Encoding") {
8834 match content_encoding.to_str().unwrap_or_default() {
8835 "gzip" => {
8836 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
8837 let _ = enc.write_all(ser.into_inner().as_slice());
8838 match enc.finish() {
8839 Ok(buf) => {
8840 local_req_builder = local_req_builder.body(buf);
8841 }
8842 Err(e) => return Err(datadog::Error::Io(e)),
8843 }
8844 }
8845 "deflate" => {
8846 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
8847 let _ = enc.write_all(ser.into_inner().as_slice());
8848 match enc.finish() {
8849 Ok(buf) => {
8850 local_req_builder = local_req_builder.body(buf);
8851 }
8852 Err(e) => return Err(datadog::Error::Io(e)),
8853 }
8854 }
8855 "zstd1" => {
8856 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
8857 let _ = enc.write_all(ser.into_inner().as_slice());
8858 match enc.finish() {
8859 Ok(buf) => {
8860 local_req_builder = local_req_builder.body(buf);
8861 }
8862 Err(e) => return Err(datadog::Error::Io(e)),
8863 }
8864 }
8865 _ => {
8866 local_req_builder = local_req_builder.body(ser.into_inner());
8867 }
8868 }
8869 } else {
8870 local_req_builder = local_req_builder.body(ser.into_inner());
8871 }
8872 }
8873
8874 local_req_builder = local_req_builder.headers(headers);
8875 let local_req = local_req_builder.build()?;
8876 log::debug!("request content: {:?}", local_req.body());
8877 let local_resp = local_client.execute(local_req).await?;
8878
8879 let local_status = local_resp.status();
8880 let local_content = local_resp.text().await?;
8881 log::debug!("response content: {}", local_content);
8882
8883 if !local_status.is_client_error() && !local_status.is_server_error() {
8884 match serde_json::from_str::<crate::datadogV2::model::UpdateCustomFrameworkResponse>(
8885 &local_content,
8886 ) {
8887 Ok(e) => {
8888 return Ok(datadog::ResponseContent {
8889 status: local_status,
8890 content: local_content,
8891 entity: Some(e),
8892 })
8893 }
8894 Err(e) => return Err(datadog::Error::Serde(e)),
8895 };
8896 } else {
8897 let local_entity: Option<UpdateCustomFrameworkError> =
8898 serde_json::from_str(&local_content).ok();
8899 let local_error = datadog::ResponseContent {
8900 status: local_status,
8901 content: local_content,
8902 entity: local_entity,
8903 };
8904 Err(datadog::Error::ResponseError(local_error))
8905 }
8906 }
8907
8908 pub async fn update_resource_evaluation_filters(
8910 &self,
8911 body: crate::datadogV2::model::UpdateResourceEvaluationFiltersRequest,
8912 ) -> Result<
8913 crate::datadogV2::model::UpdateResourceEvaluationFiltersResponse,
8914 datadog::Error<UpdateResourceEvaluationFiltersError>,
8915 > {
8916 match self
8917 .update_resource_evaluation_filters_with_http_info(body)
8918 .await
8919 {
8920 Ok(response_content) => {
8921 if let Some(e) = response_content.entity {
8922 Ok(e)
8923 } else {
8924 Err(datadog::Error::Serde(serde::de::Error::custom(
8925 "response content was None",
8926 )))
8927 }
8928 }
8929 Err(err) => Err(err),
8930 }
8931 }
8932
8933 pub async fn update_resource_evaluation_filters_with_http_info(
8935 &self,
8936 body: crate::datadogV2::model::UpdateResourceEvaluationFiltersRequest,
8937 ) -> Result<
8938 datadog::ResponseContent<crate::datadogV2::model::UpdateResourceEvaluationFiltersResponse>,
8939 datadog::Error<UpdateResourceEvaluationFiltersError>,
8940 > {
8941 let local_configuration = &self.config;
8942 let operation_id = "v2.update_resource_evaluation_filters";
8943
8944 let local_client = &self.client;
8945
8946 let local_uri_str = format!(
8947 "{}/api/v2/cloud_security_management/resource_filters",
8948 local_configuration.get_operation_host(operation_id)
8949 );
8950 let mut local_req_builder =
8951 local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
8952
8953 let mut headers = HeaderMap::new();
8955 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
8956 headers.insert("Accept", HeaderValue::from_static("application/json"));
8957
8958 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
8960 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
8961 Err(e) => {
8962 log::warn!("Failed to parse user agent header: {e}, falling back to default");
8963 headers.insert(
8964 reqwest::header::USER_AGENT,
8965 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
8966 )
8967 }
8968 };
8969
8970 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
8972 headers.insert(
8973 "DD-API-KEY",
8974 HeaderValue::from_str(local_key.key.as_str())
8975 .expect("failed to parse DD-API-KEY header"),
8976 );
8977 };
8978 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
8979 headers.insert(
8980 "DD-APPLICATION-KEY",
8981 HeaderValue::from_str(local_key.key.as_str())
8982 .expect("failed to parse DD-APPLICATION-KEY header"),
8983 );
8984 };
8985
8986 let output = Vec::new();
8988 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
8989 if body.serialize(&mut ser).is_ok() {
8990 if let Some(content_encoding) = headers.get("Content-Encoding") {
8991 match content_encoding.to_str().unwrap_or_default() {
8992 "gzip" => {
8993 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
8994 let _ = enc.write_all(ser.into_inner().as_slice());
8995 match enc.finish() {
8996 Ok(buf) => {
8997 local_req_builder = local_req_builder.body(buf);
8998 }
8999 Err(e) => return Err(datadog::Error::Io(e)),
9000 }
9001 }
9002 "deflate" => {
9003 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
9004 let _ = enc.write_all(ser.into_inner().as_slice());
9005 match enc.finish() {
9006 Ok(buf) => {
9007 local_req_builder = local_req_builder.body(buf);
9008 }
9009 Err(e) => return Err(datadog::Error::Io(e)),
9010 }
9011 }
9012 "zstd1" => {
9013 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
9014 let _ = enc.write_all(ser.into_inner().as_slice());
9015 match enc.finish() {
9016 Ok(buf) => {
9017 local_req_builder = local_req_builder.body(buf);
9018 }
9019 Err(e) => return Err(datadog::Error::Io(e)),
9020 }
9021 }
9022 _ => {
9023 local_req_builder = local_req_builder.body(ser.into_inner());
9024 }
9025 }
9026 } else {
9027 local_req_builder = local_req_builder.body(ser.into_inner());
9028 }
9029 }
9030
9031 local_req_builder = local_req_builder.headers(headers);
9032 let local_req = local_req_builder.build()?;
9033 log::debug!("request content: {:?}", local_req.body());
9034 let local_resp = local_client.execute(local_req).await?;
9035
9036 let local_status = local_resp.status();
9037 let local_content = local_resp.text().await?;
9038 log::debug!("response content: {}", local_content);
9039
9040 if !local_status.is_client_error() && !local_status.is_server_error() {
9041 match serde_json::from_str::<
9042 crate::datadogV2::model::UpdateResourceEvaluationFiltersResponse,
9043 >(&local_content)
9044 {
9045 Ok(e) => {
9046 return Ok(datadog::ResponseContent {
9047 status: local_status,
9048 content: local_content,
9049 entity: Some(e),
9050 })
9051 }
9052 Err(e) => return Err(datadog::Error::Serde(e)),
9053 };
9054 } else {
9055 let local_entity: Option<UpdateResourceEvaluationFiltersError> =
9056 serde_json::from_str(&local_content).ok();
9057 let local_error = datadog::ResponseContent {
9058 status: local_status,
9059 content: local_content,
9060 entity: local_entity,
9061 };
9062 Err(datadog::Error::ResponseError(local_error))
9063 }
9064 }
9065
9066 pub async fn update_security_filter(
9069 &self,
9070 security_filter_id: String,
9071 body: crate::datadogV2::model::SecurityFilterUpdateRequest,
9072 ) -> Result<
9073 crate::datadogV2::model::SecurityFilterResponse,
9074 datadog::Error<UpdateSecurityFilterError>,
9075 > {
9076 match self
9077 .update_security_filter_with_http_info(security_filter_id, body)
9078 .await
9079 {
9080 Ok(response_content) => {
9081 if let Some(e) = response_content.entity {
9082 Ok(e)
9083 } else {
9084 Err(datadog::Error::Serde(serde::de::Error::custom(
9085 "response content was None",
9086 )))
9087 }
9088 }
9089 Err(err) => Err(err),
9090 }
9091 }
9092
9093 pub async fn update_security_filter_with_http_info(
9096 &self,
9097 security_filter_id: String,
9098 body: crate::datadogV2::model::SecurityFilterUpdateRequest,
9099 ) -> Result<
9100 datadog::ResponseContent<crate::datadogV2::model::SecurityFilterResponse>,
9101 datadog::Error<UpdateSecurityFilterError>,
9102 > {
9103 let local_configuration = &self.config;
9104 let operation_id = "v2.update_security_filter";
9105
9106 let local_client = &self.client;
9107
9108 let local_uri_str = format!(
9109 "{}/api/v2/security_monitoring/configuration/security_filters/{security_filter_id}",
9110 local_configuration.get_operation_host(operation_id),
9111 security_filter_id = datadog::urlencode(security_filter_id)
9112 );
9113 let mut local_req_builder =
9114 local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
9115
9116 let mut headers = HeaderMap::new();
9118 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
9119 headers.insert("Accept", HeaderValue::from_static("application/json"));
9120
9121 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
9123 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
9124 Err(e) => {
9125 log::warn!("Failed to parse user agent header: {e}, falling back to default");
9126 headers.insert(
9127 reqwest::header::USER_AGENT,
9128 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
9129 )
9130 }
9131 };
9132
9133 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
9135 headers.insert(
9136 "DD-API-KEY",
9137 HeaderValue::from_str(local_key.key.as_str())
9138 .expect("failed to parse DD-API-KEY header"),
9139 );
9140 };
9141 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
9142 headers.insert(
9143 "DD-APPLICATION-KEY",
9144 HeaderValue::from_str(local_key.key.as_str())
9145 .expect("failed to parse DD-APPLICATION-KEY header"),
9146 );
9147 };
9148
9149 let output = Vec::new();
9151 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
9152 if body.serialize(&mut ser).is_ok() {
9153 if let Some(content_encoding) = headers.get("Content-Encoding") {
9154 match content_encoding.to_str().unwrap_or_default() {
9155 "gzip" => {
9156 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
9157 let _ = enc.write_all(ser.into_inner().as_slice());
9158 match enc.finish() {
9159 Ok(buf) => {
9160 local_req_builder = local_req_builder.body(buf);
9161 }
9162 Err(e) => return Err(datadog::Error::Io(e)),
9163 }
9164 }
9165 "deflate" => {
9166 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
9167 let _ = enc.write_all(ser.into_inner().as_slice());
9168 match enc.finish() {
9169 Ok(buf) => {
9170 local_req_builder = local_req_builder.body(buf);
9171 }
9172 Err(e) => return Err(datadog::Error::Io(e)),
9173 }
9174 }
9175 "zstd1" => {
9176 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
9177 let _ = enc.write_all(ser.into_inner().as_slice());
9178 match enc.finish() {
9179 Ok(buf) => {
9180 local_req_builder = local_req_builder.body(buf);
9181 }
9182 Err(e) => return Err(datadog::Error::Io(e)),
9183 }
9184 }
9185 _ => {
9186 local_req_builder = local_req_builder.body(ser.into_inner());
9187 }
9188 }
9189 } else {
9190 local_req_builder = local_req_builder.body(ser.into_inner());
9191 }
9192 }
9193
9194 local_req_builder = local_req_builder.headers(headers);
9195 let local_req = local_req_builder.build()?;
9196 log::debug!("request content: {:?}", local_req.body());
9197 let local_resp = local_client.execute(local_req).await?;
9198
9199 let local_status = local_resp.status();
9200 let local_content = local_resp.text().await?;
9201 log::debug!("response content: {}", local_content);
9202
9203 if !local_status.is_client_error() && !local_status.is_server_error() {
9204 match serde_json::from_str::<crate::datadogV2::model::SecurityFilterResponse>(
9205 &local_content,
9206 ) {
9207 Ok(e) => {
9208 return Ok(datadog::ResponseContent {
9209 status: local_status,
9210 content: local_content,
9211 entity: Some(e),
9212 })
9213 }
9214 Err(e) => return Err(datadog::Error::Serde(e)),
9215 };
9216 } else {
9217 let local_entity: Option<UpdateSecurityFilterError> =
9218 serde_json::from_str(&local_content).ok();
9219 let local_error = datadog::ResponseContent {
9220 status: local_status,
9221 content: local_content,
9222 entity: local_entity,
9223 };
9224 Err(datadog::Error::ResponseError(local_error))
9225 }
9226 }
9227
9228 pub async fn update_security_monitoring_rule(
9233 &self,
9234 rule_id: String,
9235 body: crate::datadogV2::model::SecurityMonitoringRuleUpdatePayload,
9236 ) -> Result<
9237 crate::datadogV2::model::SecurityMonitoringRuleResponse,
9238 datadog::Error<UpdateSecurityMonitoringRuleError>,
9239 > {
9240 match self
9241 .update_security_monitoring_rule_with_http_info(rule_id, body)
9242 .await
9243 {
9244 Ok(response_content) => {
9245 if let Some(e) = response_content.entity {
9246 Ok(e)
9247 } else {
9248 Err(datadog::Error::Serde(serde::de::Error::custom(
9249 "response content was None",
9250 )))
9251 }
9252 }
9253 Err(err) => Err(err),
9254 }
9255 }
9256
9257 pub async fn update_security_monitoring_rule_with_http_info(
9262 &self,
9263 rule_id: String,
9264 body: crate::datadogV2::model::SecurityMonitoringRuleUpdatePayload,
9265 ) -> Result<
9266 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleResponse>,
9267 datadog::Error<UpdateSecurityMonitoringRuleError>,
9268 > {
9269 let local_configuration = &self.config;
9270 let operation_id = "v2.update_security_monitoring_rule";
9271
9272 let local_client = &self.client;
9273
9274 let local_uri_str = format!(
9275 "{}/api/v2/security_monitoring/rules/{rule_id}",
9276 local_configuration.get_operation_host(operation_id),
9277 rule_id = datadog::urlencode(rule_id)
9278 );
9279 let mut local_req_builder =
9280 local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
9281
9282 let mut headers = HeaderMap::new();
9284 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
9285 headers.insert("Accept", HeaderValue::from_static("application/json"));
9286
9287 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
9289 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
9290 Err(e) => {
9291 log::warn!("Failed to parse user agent header: {e}, falling back to default");
9292 headers.insert(
9293 reqwest::header::USER_AGENT,
9294 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
9295 )
9296 }
9297 };
9298
9299 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
9301 headers.insert(
9302 "DD-API-KEY",
9303 HeaderValue::from_str(local_key.key.as_str())
9304 .expect("failed to parse DD-API-KEY header"),
9305 );
9306 };
9307 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
9308 headers.insert(
9309 "DD-APPLICATION-KEY",
9310 HeaderValue::from_str(local_key.key.as_str())
9311 .expect("failed to parse DD-APPLICATION-KEY header"),
9312 );
9313 };
9314
9315 let output = Vec::new();
9317 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
9318 if body.serialize(&mut ser).is_ok() {
9319 if let Some(content_encoding) = headers.get("Content-Encoding") {
9320 match content_encoding.to_str().unwrap_or_default() {
9321 "gzip" => {
9322 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
9323 let _ = enc.write_all(ser.into_inner().as_slice());
9324 match enc.finish() {
9325 Ok(buf) => {
9326 local_req_builder = local_req_builder.body(buf);
9327 }
9328 Err(e) => return Err(datadog::Error::Io(e)),
9329 }
9330 }
9331 "deflate" => {
9332 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
9333 let _ = enc.write_all(ser.into_inner().as_slice());
9334 match enc.finish() {
9335 Ok(buf) => {
9336 local_req_builder = local_req_builder.body(buf);
9337 }
9338 Err(e) => return Err(datadog::Error::Io(e)),
9339 }
9340 }
9341 "zstd1" => {
9342 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
9343 let _ = enc.write_all(ser.into_inner().as_slice());
9344 match enc.finish() {
9345 Ok(buf) => {
9346 local_req_builder = local_req_builder.body(buf);
9347 }
9348 Err(e) => return Err(datadog::Error::Io(e)),
9349 }
9350 }
9351 _ => {
9352 local_req_builder = local_req_builder.body(ser.into_inner());
9353 }
9354 }
9355 } else {
9356 local_req_builder = local_req_builder.body(ser.into_inner());
9357 }
9358 }
9359
9360 local_req_builder = local_req_builder.headers(headers);
9361 let local_req = local_req_builder.build()?;
9362 log::debug!("request content: {:?}", local_req.body());
9363 let local_resp = local_client.execute(local_req).await?;
9364
9365 let local_status = local_resp.status();
9366 let local_content = local_resp.text().await?;
9367 log::debug!("response content: {}", local_content);
9368
9369 if !local_status.is_client_error() && !local_status.is_server_error() {
9370 match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringRuleResponse>(
9371 &local_content,
9372 ) {
9373 Ok(e) => {
9374 return Ok(datadog::ResponseContent {
9375 status: local_status,
9376 content: local_content,
9377 entity: Some(e),
9378 })
9379 }
9380 Err(e) => return Err(datadog::Error::Serde(e)),
9381 };
9382 } else {
9383 let local_entity: Option<UpdateSecurityMonitoringRuleError> =
9384 serde_json::from_str(&local_content).ok();
9385 let local_error = datadog::ResponseContent {
9386 status: local_status,
9387 content: local_content,
9388 entity: local_entity,
9389 };
9390 Err(datadog::Error::ResponseError(local_error))
9391 }
9392 }
9393
9394 pub async fn update_security_monitoring_suppression(
9396 &self,
9397 suppression_id: String,
9398 body: crate::datadogV2::model::SecurityMonitoringSuppressionUpdateRequest,
9399 ) -> Result<
9400 crate::datadogV2::model::SecurityMonitoringSuppressionResponse,
9401 datadog::Error<UpdateSecurityMonitoringSuppressionError>,
9402 > {
9403 match self
9404 .update_security_monitoring_suppression_with_http_info(suppression_id, body)
9405 .await
9406 {
9407 Ok(response_content) => {
9408 if let Some(e) = response_content.entity {
9409 Ok(e)
9410 } else {
9411 Err(datadog::Error::Serde(serde::de::Error::custom(
9412 "response content was None",
9413 )))
9414 }
9415 }
9416 Err(err) => Err(err),
9417 }
9418 }
9419
9420 pub async fn update_security_monitoring_suppression_with_http_info(
9422 &self,
9423 suppression_id: String,
9424 body: crate::datadogV2::model::SecurityMonitoringSuppressionUpdateRequest,
9425 ) -> Result<
9426 datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSuppressionResponse>,
9427 datadog::Error<UpdateSecurityMonitoringSuppressionError>,
9428 > {
9429 let local_configuration = &self.config;
9430 let operation_id = "v2.update_security_monitoring_suppression";
9431
9432 let local_client = &self.client;
9433
9434 let local_uri_str = format!(
9435 "{}/api/v2/security_monitoring/configuration/suppressions/{suppression_id}",
9436 local_configuration.get_operation_host(operation_id),
9437 suppression_id = datadog::urlencode(suppression_id)
9438 );
9439 let mut local_req_builder =
9440 local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
9441
9442 let mut headers = HeaderMap::new();
9444 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
9445 headers.insert("Accept", HeaderValue::from_static("application/json"));
9446
9447 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
9449 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
9450 Err(e) => {
9451 log::warn!("Failed to parse user agent header: {e}, falling back to default");
9452 headers.insert(
9453 reqwest::header::USER_AGENT,
9454 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
9455 )
9456 }
9457 };
9458
9459 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
9461 headers.insert(
9462 "DD-API-KEY",
9463 HeaderValue::from_str(local_key.key.as_str())
9464 .expect("failed to parse DD-API-KEY header"),
9465 );
9466 };
9467 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
9468 headers.insert(
9469 "DD-APPLICATION-KEY",
9470 HeaderValue::from_str(local_key.key.as_str())
9471 .expect("failed to parse DD-APPLICATION-KEY header"),
9472 );
9473 };
9474
9475 let output = Vec::new();
9477 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
9478 if body.serialize(&mut ser).is_ok() {
9479 if let Some(content_encoding) = headers.get("Content-Encoding") {
9480 match content_encoding.to_str().unwrap_or_default() {
9481 "gzip" => {
9482 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
9483 let _ = enc.write_all(ser.into_inner().as_slice());
9484 match enc.finish() {
9485 Ok(buf) => {
9486 local_req_builder = local_req_builder.body(buf);
9487 }
9488 Err(e) => return Err(datadog::Error::Io(e)),
9489 }
9490 }
9491 "deflate" => {
9492 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
9493 let _ = enc.write_all(ser.into_inner().as_slice());
9494 match enc.finish() {
9495 Ok(buf) => {
9496 local_req_builder = local_req_builder.body(buf);
9497 }
9498 Err(e) => return Err(datadog::Error::Io(e)),
9499 }
9500 }
9501 "zstd1" => {
9502 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
9503 let _ = enc.write_all(ser.into_inner().as_slice());
9504 match enc.finish() {
9505 Ok(buf) => {
9506 local_req_builder = local_req_builder.body(buf);
9507 }
9508 Err(e) => return Err(datadog::Error::Io(e)),
9509 }
9510 }
9511 _ => {
9512 local_req_builder = local_req_builder.body(ser.into_inner());
9513 }
9514 }
9515 } else {
9516 local_req_builder = local_req_builder.body(ser.into_inner());
9517 }
9518 }
9519
9520 local_req_builder = local_req_builder.headers(headers);
9521 let local_req = local_req_builder.build()?;
9522 log::debug!("request content: {:?}", local_req.body());
9523 let local_resp = local_client.execute(local_req).await?;
9524
9525 let local_status = local_resp.status();
9526 let local_content = local_resp.text().await?;
9527 log::debug!("response content: {}", local_content);
9528
9529 if !local_status.is_client_error() && !local_status.is_server_error() {
9530 match serde_json::from_str::<
9531 crate::datadogV2::model::SecurityMonitoringSuppressionResponse,
9532 >(&local_content)
9533 {
9534 Ok(e) => {
9535 return Ok(datadog::ResponseContent {
9536 status: local_status,
9537 content: local_content,
9538 entity: Some(e),
9539 })
9540 }
9541 Err(e) => return Err(datadog::Error::Serde(e)),
9542 };
9543 } else {
9544 let local_entity: Option<UpdateSecurityMonitoringSuppressionError> =
9545 serde_json::from_str(&local_content).ok();
9546 let local_error = datadog::ResponseContent {
9547 status: local_status,
9548 content: local_content,
9549 entity: local_entity,
9550 };
9551 Err(datadog::Error::ResponseError(local_error))
9552 }
9553 }
9554
9555 pub async fn validate_security_monitoring_rule(
9557 &self,
9558 body: crate::datadogV2::model::SecurityMonitoringRuleValidatePayload,
9559 ) -> Result<(), datadog::Error<ValidateSecurityMonitoringRuleError>> {
9560 match self
9561 .validate_security_monitoring_rule_with_http_info(body)
9562 .await
9563 {
9564 Ok(_) => Ok(()),
9565 Err(err) => Err(err),
9566 }
9567 }
9568
9569 pub async fn validate_security_monitoring_rule_with_http_info(
9571 &self,
9572 body: crate::datadogV2::model::SecurityMonitoringRuleValidatePayload,
9573 ) -> Result<datadog::ResponseContent<()>, datadog::Error<ValidateSecurityMonitoringRuleError>>
9574 {
9575 let local_configuration = &self.config;
9576 let operation_id = "v2.validate_security_monitoring_rule";
9577
9578 let local_client = &self.client;
9579
9580 let local_uri_str = format!(
9581 "{}/api/v2/security_monitoring/rules/validation",
9582 local_configuration.get_operation_host(operation_id)
9583 );
9584 let mut local_req_builder =
9585 local_client.request(reqwest::Method::POST, local_uri_str.as_str());
9586
9587 let mut headers = HeaderMap::new();
9589 headers.insert("Content-Type", HeaderValue::from_static("application/json"));
9590 headers.insert("Accept", HeaderValue::from_static("*/*"));
9591
9592 match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
9594 Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
9595 Err(e) => {
9596 log::warn!("Failed to parse user agent header: {e}, falling back to default");
9597 headers.insert(
9598 reqwest::header::USER_AGENT,
9599 HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
9600 )
9601 }
9602 };
9603
9604 if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
9606 headers.insert(
9607 "DD-API-KEY",
9608 HeaderValue::from_str(local_key.key.as_str())
9609 .expect("failed to parse DD-API-KEY header"),
9610 );
9611 };
9612 if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
9613 headers.insert(
9614 "DD-APPLICATION-KEY",
9615 HeaderValue::from_str(local_key.key.as_str())
9616 .expect("failed to parse DD-APPLICATION-KEY header"),
9617 );
9618 };
9619
9620 let output = Vec::new();
9622 let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
9623 if body.serialize(&mut ser).is_ok() {
9624 if let Some(content_encoding) = headers.get("Content-Encoding") {
9625 match content_encoding.to_str().unwrap_or_default() {
9626 "gzip" => {
9627 let mut enc = GzEncoder::new(Vec::new(), Compression::default());
9628 let _ = enc.write_all(ser.into_inner().as_slice());
9629 match enc.finish() {
9630 Ok(buf) => {
9631 local_req_builder = local_req_builder.body(buf);
9632 }
9633 Err(e) => return Err(datadog::Error::Io(e)),
9634 }
9635 }
9636 "deflate" => {
9637 let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
9638 let _ = enc.write_all(ser.into_inner().as_slice());
9639 match enc.finish() {
9640 Ok(buf) => {
9641 local_req_builder = local_req_builder.body(buf);
9642 }
9643 Err(e) => return Err(datadog::Error::Io(e)),
9644 }
9645 }
9646 "zstd1" => {
9647 let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
9648 let _ = enc.write_all(ser.into_inner().as_slice());
9649 match enc.finish() {
9650 Ok(buf) => {
9651 local_req_builder = local_req_builder.body(buf);
9652 }
9653 Err(e) => return Err(datadog::Error::Io(e)),
9654 }
9655 }
9656 _ => {
9657 local_req_builder = local_req_builder.body(ser.into_inner());
9658 }
9659 }
9660 } else {
9661 local_req_builder = local_req_builder.body(ser.into_inner());
9662 }
9663 }
9664
9665 local_req_builder = local_req_builder.headers(headers);
9666 let local_req = local_req_builder.build()?;
9667 log::debug!("request content: {:?}", local_req.body());
9668 let local_resp = local_client.execute(local_req).await?;
9669
9670 let local_status = local_resp.status();
9671 let local_content = local_resp.text().await?;
9672 log::debug!("response content: {}", local_content);
9673
9674 if !local_status.is_client_error() && !local_status.is_server_error() {
9675 Ok(datadog::ResponseContent {
9676 status: local_status,
9677 content: local_content,
9678 entity: None,
9679 })
9680 } else {
9681 let local_entity: Option<ValidateSecurityMonitoringRuleError> =
9682 serde_json::from_str(&local_content).ok();
9683 let local_error = datadog::ResponseContent {
9684 status: local_status,
9685 content: local_content,
9686 entity: local_entity,
9687 };
9688 Err(datadog::Error::ResponseError(local_error))
9689 }
9690 }
9691}