datadog_api_client/datadogV2/api/
api_security_monitoring.rs

1// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2// This product includes software developed at Datadog (https://www.datadoghq.com/).
3// Copyright 2019-Present Datadog, Inc.
4use crate::datadog;
5use 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/// GetFindingOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::get_finding`]
17#[non_exhaustive]
18#[derive(Clone, Default, Debug)]
19pub struct GetFindingOptionalParams {
20    /// Return the finding for a given snapshot of time (Unix ms).
21    pub snapshot_timestamp: Option<i64>,
22}
23
24impl GetFindingOptionalParams {
25    /// Return the finding for a given snapshot of time (Unix ms).
26    pub fn snapshot_timestamp(mut self, value: i64) -> Self {
27        self.snapshot_timestamp = Some(value);
28        self
29    }
30}
31
32/// GetRuleVersionHistoryOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::get_rule_version_history`]
33#[non_exhaustive]
34#[derive(Clone, Default, Debug)]
35pub struct GetRuleVersionHistoryOptionalParams {
36    /// Size for a given page. The maximum allowed value is 100.
37    pub page_size: Option<i64>,
38    /// Specific page number to return.
39    pub page_number: Option<i64>,
40}
41
42impl GetRuleVersionHistoryOptionalParams {
43    /// Size for a given page. The maximum allowed value is 100.
44    pub fn page_size(mut self, value: i64) -> Self {
45        self.page_size = Some(value);
46        self
47    }
48    /// Specific page number to return.
49    pub fn page_number(mut self, value: i64) -> Self {
50        self.page_number = Some(value);
51        self
52    }
53}
54
55/// GetSBOMOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::get_sbom`]
56#[non_exhaustive]
57#[derive(Clone, Default, Debug)]
58pub struct GetSBOMOptionalParams {
59    /// The container image `repo_digest` for the SBOM request. When the requested asset type is 'Image', this filter is mandatory.
60    pub filter_repo_digest: Option<String>,
61}
62
63impl GetSBOMOptionalParams {
64    /// The container image `repo_digest` for the SBOM request. When the requested asset type is 'Image', this filter is mandatory.
65    pub fn filter_repo_digest(mut self, value: String) -> Self {
66        self.filter_repo_digest = Some(value);
67        self
68    }
69}
70
71/// ListFindingsOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::list_findings`]
72#[non_exhaustive]
73#[derive(Clone, Default, Debug)]
74pub struct ListFindingsOptionalParams {
75    /// Limit the number of findings returned. Must be <= 1000.
76    pub page_limit: Option<i64>,
77    /// Return findings for a given snapshot of time (Unix ms).
78    pub snapshot_timestamp: Option<i64>,
79    /// Return the next page of findings pointed to by the cursor.
80    pub page_cursor: Option<String>,
81    /// Return findings that have these associated tags (repeatable).
82    pub filter_tags: Option<String>,
83    /// Return findings that have changed from pass to fail or vice versa on a specified date (Unix ms) or date range (using comparison operators).
84    pub filter_evaluation_changed_at: Option<String>,
85    /// Set to `true` to return findings that are muted. Set to `false` to return unmuted findings.
86    pub filter_muted: Option<bool>,
87    /// Return findings for the specified rule ID.
88    pub filter_rule_id: Option<String>,
89    /// Return findings for the specified rule.
90    pub filter_rule_name: Option<String>,
91    /// Return only findings for the specified resource type.
92    pub filter_resource_type: Option<String>,
93    /// Return findings that were found on a specified date (Unix ms) or date range (using comparison operators).
94    pub filter_discovery_timestamp: Option<String>,
95    /// Return only `pass` or `fail` findings.
96    pub filter_evaluation: Option<crate::datadogV2::model::FindingEvaluation>,
97    /// Return only findings with the specified status.
98    pub filter_status: Option<crate::datadogV2::model::FindingStatus>,
99    /// Return findings that match the selected vulnerability types (repeatable).
100    pub filter_vulnerability_type: Option<Vec<crate::datadogV2::model::FindingVulnerabilityType>>,
101}
102
103impl ListFindingsOptionalParams {
104    /// Limit the number of findings returned. Must be <= 1000.
105    pub fn page_limit(mut self, value: i64) -> Self {
106        self.page_limit = Some(value);
107        self
108    }
109    /// Return findings for a given snapshot of time (Unix ms).
110    pub fn snapshot_timestamp(mut self, value: i64) -> Self {
111        self.snapshot_timestamp = Some(value);
112        self
113    }
114    /// Return the next page of findings pointed to by the cursor.
115    pub fn page_cursor(mut self, value: String) -> Self {
116        self.page_cursor = Some(value);
117        self
118    }
119    /// Return findings that have these associated tags (repeatable).
120    pub fn filter_tags(mut self, value: String) -> Self {
121        self.filter_tags = Some(value);
122        self
123    }
124    /// Return findings that have changed from pass to fail or vice versa on a specified date (Unix ms) or date range (using comparison operators).
125    pub fn filter_evaluation_changed_at(mut self, value: String) -> Self {
126        self.filter_evaluation_changed_at = Some(value);
127        self
128    }
129    /// Set to `true` to return findings that are muted. Set to `false` to return unmuted findings.
130    pub fn filter_muted(mut self, value: bool) -> Self {
131        self.filter_muted = Some(value);
132        self
133    }
134    /// Return findings for the specified rule ID.
135    pub fn filter_rule_id(mut self, value: String) -> Self {
136        self.filter_rule_id = Some(value);
137        self
138    }
139    /// Return findings for the specified rule.
140    pub fn filter_rule_name(mut self, value: String) -> Self {
141        self.filter_rule_name = Some(value);
142        self
143    }
144    /// Return only findings for the specified resource type.
145    pub fn filter_resource_type(mut self, value: String) -> Self {
146        self.filter_resource_type = Some(value);
147        self
148    }
149    /// Return findings that were found on a specified date (Unix ms) or date range (using comparison operators).
150    pub fn filter_discovery_timestamp(mut self, value: String) -> Self {
151        self.filter_discovery_timestamp = Some(value);
152        self
153    }
154    /// Return only `pass` or `fail` findings.
155    pub fn filter_evaluation(mut self, value: crate::datadogV2::model::FindingEvaluation) -> Self {
156        self.filter_evaluation = Some(value);
157        self
158    }
159    /// Return only findings with the specified status.
160    pub fn filter_status(mut self, value: crate::datadogV2::model::FindingStatus) -> Self {
161        self.filter_status = Some(value);
162        self
163    }
164    /// Return findings that match the selected vulnerability types (repeatable).
165    pub fn filter_vulnerability_type(
166        mut self,
167        value: Vec<crate::datadogV2::model::FindingVulnerabilityType>,
168    ) -> Self {
169        self.filter_vulnerability_type = Some(value);
170        self
171    }
172}
173
174/// ListHistoricalJobsOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::list_historical_jobs`]
175#[non_exhaustive]
176#[derive(Clone, Default, Debug)]
177pub struct ListHistoricalJobsOptionalParams {
178    /// Size for a given page. The maximum allowed value is 100.
179    pub page_size: Option<i64>,
180    /// Specific page number to return.
181    pub page_number: Option<i64>,
182    /// The order of the jobs in results.
183    pub sort: Option<String>,
184    /// Query used to filter items from the fetched list.
185    pub filter_query: Option<String>,
186}
187
188impl ListHistoricalJobsOptionalParams {
189    /// Size for a given page. The maximum allowed value is 100.
190    pub fn page_size(mut self, value: i64) -> Self {
191        self.page_size = Some(value);
192        self
193    }
194    /// Specific page number to return.
195    pub fn page_number(mut self, value: i64) -> Self {
196        self.page_number = Some(value);
197        self
198    }
199    /// The order of the jobs in results.
200    pub fn sort(mut self, value: String) -> Self {
201        self.sort = Some(value);
202        self
203    }
204    /// Query used to filter items from the fetched list.
205    pub fn filter_query(mut self, value: String) -> Self {
206        self.filter_query = Some(value);
207        self
208    }
209}
210
211/// ListSecurityMonitoringRulesOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::list_security_monitoring_rules`]
212#[non_exhaustive]
213#[derive(Clone, Default, Debug)]
214pub struct ListSecurityMonitoringRulesOptionalParams {
215    /// Size for a given page. The maximum allowed value is 100.
216    pub page_size: Option<i64>,
217    /// Specific page number to return.
218    pub page_number: Option<i64>,
219}
220
221impl ListSecurityMonitoringRulesOptionalParams {
222    /// Size for a given page. The maximum allowed value is 100.
223    pub fn page_size(mut self, value: i64) -> Self {
224        self.page_size = Some(value);
225        self
226    }
227    /// Specific page number to return.
228    pub fn page_number(mut self, value: i64) -> Self {
229        self.page_number = Some(value);
230        self
231    }
232}
233
234/// ListSecurityMonitoringSignalsOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::list_security_monitoring_signals`]
235#[non_exhaustive]
236#[derive(Clone, Default, Debug)]
237pub struct ListSecurityMonitoringSignalsOptionalParams {
238    /// The search query for security signals.
239    pub filter_query: Option<String>,
240    /// The minimum timestamp for requested security signals.
241    pub filter_from: Option<chrono::DateTime<chrono::Utc>>,
242    /// The maximum timestamp for requested security signals.
243    pub filter_to: Option<chrono::DateTime<chrono::Utc>>,
244    /// The order of the security signals in results.
245    pub sort: Option<crate::datadogV2::model::SecurityMonitoringSignalsSort>,
246    /// A list of results using the cursor provided in the previous query.
247    pub page_cursor: Option<String>,
248    /// The maximum number of security signals in the response.
249    pub page_limit: Option<i32>,
250}
251
252impl ListSecurityMonitoringSignalsOptionalParams {
253    /// The search query for security signals.
254    pub fn filter_query(mut self, value: String) -> Self {
255        self.filter_query = Some(value);
256        self
257    }
258    /// The minimum timestamp for requested security signals.
259    pub fn filter_from(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
260        self.filter_from = Some(value);
261        self
262    }
263    /// The maximum timestamp for requested security signals.
264    pub fn filter_to(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
265        self.filter_to = Some(value);
266        self
267    }
268    /// The order of the security signals in results.
269    pub fn sort(mut self, value: crate::datadogV2::model::SecurityMonitoringSignalsSort) -> Self {
270        self.sort = Some(value);
271        self
272    }
273    /// A list of results using the cursor provided in the previous query.
274    pub fn page_cursor(mut self, value: String) -> Self {
275        self.page_cursor = Some(value);
276        self
277    }
278    /// The maximum number of security signals in the response.
279    pub fn page_limit(mut self, value: i32) -> Self {
280        self.page_limit = Some(value);
281        self
282    }
283}
284
285/// ListVulnerabilitiesOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::list_vulnerabilities`]
286#[non_exhaustive]
287#[derive(Clone, Default, Debug)]
288pub struct ListVulnerabilitiesOptionalParams {
289    /// Its value must come from the `links` section of the response of the first request. Do not manually edit it.
290    pub page_token: Option<String>,
291    /// The page number to be retrieved. It should be equal or greater than `1`
292    pub page_number: Option<i64>,
293    /// Filter by vulnerability type.
294    pub filter_type: Option<crate::datadogV2::model::VulnerabilityType>,
295    /// Filter by vulnerability base (i.e. from the original advisory) severity score.
296    pub filter_cvss_base_score_op: Option<f64>,
297    /// Filter by vulnerability base severity.
298    pub filter_cvss_base_severity: Option<crate::datadogV2::model::VulnerabilitySeverity>,
299    /// Filter by vulnerability base CVSS vector.
300    pub filter_cvss_base_vector: Option<String>,
301    /// Filter by vulnerability Datadog severity score.
302    pub filter_cvss_datadog_score_op: Option<f64>,
303    /// Filter by vulnerability Datadog severity.
304    pub filter_cvss_datadog_severity: Option<crate::datadogV2::model::VulnerabilitySeverity>,
305    /// Filter by vulnerability Datadog CVSS vector.
306    pub filter_cvss_datadog_vector: Option<String>,
307    /// Filter by the status of the vulnerability.
308    pub filter_status: Option<crate::datadogV2::model::VulnerabilityStatus>,
309    /// Filter by the tool of the vulnerability.
310    pub filter_tool: Option<crate::datadogV2::model::VulnerabilityTool>,
311    /// Filter by library name.
312    pub filter_library_name: Option<String>,
313    /// Filter by library version.
314    pub filter_library_version: Option<String>,
315    /// Filter by advisory ID.
316    pub filter_advisory_id: Option<String>,
317    /// Filter by exploitation probability.
318    pub filter_risks_exploitation_probability: Option<bool>,
319    /// Filter by POC exploit availability.
320    pub filter_risks_poc_exploit_available: Option<bool>,
321    /// Filter by public exploit availability.
322    pub filter_risks_exploit_available: Option<bool>,
323    /// Filter by vulnerability [EPSS](<https://www.first.org/epss/>) severity score.
324    pub filter_risks_epss_score_op: Option<f64>,
325    /// Filter by vulnerability [EPSS](<https://www.first.org/epss/>) severity.
326    pub filter_risks_epss_severity: Option<crate::datadogV2::model::VulnerabilitySeverity>,
327    /// Filter by language.
328    pub filter_language: Option<String>,
329    /// Filter by ecosystem.
330    pub filter_ecosystem: Option<crate::datadogV2::model::VulnerabilityEcosystem>,
331    /// Filter by vulnerability location.
332    pub filter_code_location_location: Option<String>,
333    /// Filter by vulnerability file path.
334    pub filter_code_location_file_path: Option<String>,
335    /// Filter by method.
336    pub filter_code_location_method: Option<String>,
337    /// Filter by fix availability.
338    pub filter_fix_available: Option<bool>,
339    /// Filter by vulnerability `repo_digest` (when the vulnerability is related to `Image` asset).
340    pub filter_repo_digests: Option<String>,
341    /// Filter by asset name.
342    pub filter_asset_name: Option<String>,
343    /// Filter by asset type.
344    pub filter_asset_type: Option<crate::datadogV2::model::AssetType>,
345    /// Filter by the first version of the asset this vulnerability has been detected on.
346    pub filter_asset_version_first: Option<String>,
347    /// Filter by the last version of the asset this vulnerability has been detected on.
348    pub filter_asset_version_last: Option<String>,
349    /// Filter by the repository url associated to the asset.
350    pub filter_asset_repository_url: Option<String>,
351    /// Filter whether the asset is in production or not.
352    pub filter_asset_risks_in_production: Option<bool>,
353    /// Filter whether the asset is under attack or not.
354    pub filter_asset_risks_under_attack: Option<bool>,
355    /// Filter whether the asset is publicly accessible or not.
356    pub filter_asset_risks_is_publicly_accessible: Option<bool>,
357    /// Filter whether the asset is publicly accessible or not.
358    pub filter_asset_risks_has_privileged_access: Option<bool>,
359    /// Filter whether the asset  has access to sensitive data or not.
360    pub filter_asset_risks_has_access_to_sensitive_data: Option<bool>,
361    /// Filter by asset environments.
362    pub filter_asset_environments: Option<String>,
363    /// Filter by asset architecture.
364    pub filter_asset_arch: Option<String>,
365    /// Filter by asset operating system name.
366    pub filter_asset_operating_system_name: Option<String>,
367    /// Filter by asset operating system version.
368    pub filter_asset_operating_system_version: Option<String>,
369}
370
371impl ListVulnerabilitiesOptionalParams {
372    /// Its value must come from the `links` section of the response of the first request. Do not manually edit it.
373    pub fn page_token(mut self, value: String) -> Self {
374        self.page_token = Some(value);
375        self
376    }
377    /// The page number to be retrieved. It should be equal or greater than `1`
378    pub fn page_number(mut self, value: i64) -> Self {
379        self.page_number = Some(value);
380        self
381    }
382    /// Filter by vulnerability type.
383    pub fn filter_type(mut self, value: crate::datadogV2::model::VulnerabilityType) -> Self {
384        self.filter_type = Some(value);
385        self
386    }
387    /// Filter by vulnerability base (i.e. from the original advisory) severity score.
388    pub fn filter_cvss_base_score_op(mut self, value: f64) -> Self {
389        self.filter_cvss_base_score_op = Some(value);
390        self
391    }
392    /// Filter by vulnerability base severity.
393    pub fn filter_cvss_base_severity(
394        mut self,
395        value: crate::datadogV2::model::VulnerabilitySeverity,
396    ) -> Self {
397        self.filter_cvss_base_severity = Some(value);
398        self
399    }
400    /// Filter by vulnerability base CVSS vector.
401    pub fn filter_cvss_base_vector(mut self, value: String) -> Self {
402        self.filter_cvss_base_vector = Some(value);
403        self
404    }
405    /// Filter by vulnerability Datadog severity score.
406    pub fn filter_cvss_datadog_score_op(mut self, value: f64) -> Self {
407        self.filter_cvss_datadog_score_op = Some(value);
408        self
409    }
410    /// Filter by vulnerability Datadog severity.
411    pub fn filter_cvss_datadog_severity(
412        mut self,
413        value: crate::datadogV2::model::VulnerabilitySeverity,
414    ) -> Self {
415        self.filter_cvss_datadog_severity = Some(value);
416        self
417    }
418    /// Filter by vulnerability Datadog CVSS vector.
419    pub fn filter_cvss_datadog_vector(mut self, value: String) -> Self {
420        self.filter_cvss_datadog_vector = Some(value);
421        self
422    }
423    /// Filter by the status of the vulnerability.
424    pub fn filter_status(mut self, value: crate::datadogV2::model::VulnerabilityStatus) -> Self {
425        self.filter_status = Some(value);
426        self
427    }
428    /// Filter by the tool of the vulnerability.
429    pub fn filter_tool(mut self, value: crate::datadogV2::model::VulnerabilityTool) -> Self {
430        self.filter_tool = Some(value);
431        self
432    }
433    /// Filter by library name.
434    pub fn filter_library_name(mut self, value: String) -> Self {
435        self.filter_library_name = Some(value);
436        self
437    }
438    /// Filter by library version.
439    pub fn filter_library_version(mut self, value: String) -> Self {
440        self.filter_library_version = Some(value);
441        self
442    }
443    /// Filter by advisory ID.
444    pub fn filter_advisory_id(mut self, value: String) -> Self {
445        self.filter_advisory_id = Some(value);
446        self
447    }
448    /// Filter by exploitation probability.
449    pub fn filter_risks_exploitation_probability(mut self, value: bool) -> Self {
450        self.filter_risks_exploitation_probability = Some(value);
451        self
452    }
453    /// Filter by POC exploit availability.
454    pub fn filter_risks_poc_exploit_available(mut self, value: bool) -> Self {
455        self.filter_risks_poc_exploit_available = Some(value);
456        self
457    }
458    /// Filter by public exploit availability.
459    pub fn filter_risks_exploit_available(mut self, value: bool) -> Self {
460        self.filter_risks_exploit_available = Some(value);
461        self
462    }
463    /// Filter by vulnerability [EPSS](<https://www.first.org/epss/>) severity score.
464    pub fn filter_risks_epss_score_op(mut self, value: f64) -> Self {
465        self.filter_risks_epss_score_op = Some(value);
466        self
467    }
468    /// Filter by vulnerability [EPSS](<https://www.first.org/epss/>) severity.
469    pub fn filter_risks_epss_severity(
470        mut self,
471        value: crate::datadogV2::model::VulnerabilitySeverity,
472    ) -> Self {
473        self.filter_risks_epss_severity = Some(value);
474        self
475    }
476    /// Filter by language.
477    pub fn filter_language(mut self, value: String) -> Self {
478        self.filter_language = Some(value);
479        self
480    }
481    /// Filter by ecosystem.
482    pub fn filter_ecosystem(
483        mut self,
484        value: crate::datadogV2::model::VulnerabilityEcosystem,
485    ) -> Self {
486        self.filter_ecosystem = Some(value);
487        self
488    }
489    /// Filter by vulnerability location.
490    pub fn filter_code_location_location(mut self, value: String) -> Self {
491        self.filter_code_location_location = Some(value);
492        self
493    }
494    /// Filter by vulnerability file path.
495    pub fn filter_code_location_file_path(mut self, value: String) -> Self {
496        self.filter_code_location_file_path = Some(value);
497        self
498    }
499    /// Filter by method.
500    pub fn filter_code_location_method(mut self, value: String) -> Self {
501        self.filter_code_location_method = Some(value);
502        self
503    }
504    /// Filter by fix availability.
505    pub fn filter_fix_available(mut self, value: bool) -> Self {
506        self.filter_fix_available = Some(value);
507        self
508    }
509    /// Filter by vulnerability `repo_digest` (when the vulnerability is related to `Image` asset).
510    pub fn filter_repo_digests(mut self, value: String) -> Self {
511        self.filter_repo_digests = Some(value);
512        self
513    }
514    /// Filter by asset name.
515    pub fn filter_asset_name(mut self, value: String) -> Self {
516        self.filter_asset_name = Some(value);
517        self
518    }
519    /// Filter by asset type.
520    pub fn filter_asset_type(mut self, value: crate::datadogV2::model::AssetType) -> Self {
521        self.filter_asset_type = Some(value);
522        self
523    }
524    /// Filter by the first version of the asset this vulnerability has been detected on.
525    pub fn filter_asset_version_first(mut self, value: String) -> Self {
526        self.filter_asset_version_first = Some(value);
527        self
528    }
529    /// Filter by the last version of the asset this vulnerability has been detected on.
530    pub fn filter_asset_version_last(mut self, value: String) -> Self {
531        self.filter_asset_version_last = Some(value);
532        self
533    }
534    /// Filter by the repository url associated to the asset.
535    pub fn filter_asset_repository_url(mut self, value: String) -> Self {
536        self.filter_asset_repository_url = Some(value);
537        self
538    }
539    /// Filter whether the asset is in production or not.
540    pub fn filter_asset_risks_in_production(mut self, value: bool) -> Self {
541        self.filter_asset_risks_in_production = Some(value);
542        self
543    }
544    /// Filter whether the asset is under attack or not.
545    pub fn filter_asset_risks_under_attack(mut self, value: bool) -> Self {
546        self.filter_asset_risks_under_attack = Some(value);
547        self
548    }
549    /// Filter whether the asset is publicly accessible or not.
550    pub fn filter_asset_risks_is_publicly_accessible(mut self, value: bool) -> Self {
551        self.filter_asset_risks_is_publicly_accessible = Some(value);
552        self
553    }
554    /// Filter whether the asset is publicly accessible or not.
555    pub fn filter_asset_risks_has_privileged_access(mut self, value: bool) -> Self {
556        self.filter_asset_risks_has_privileged_access = Some(value);
557        self
558    }
559    /// Filter whether the asset  has access to sensitive data or not.
560    pub fn filter_asset_risks_has_access_to_sensitive_data(mut self, value: bool) -> Self {
561        self.filter_asset_risks_has_access_to_sensitive_data = Some(value);
562        self
563    }
564    /// Filter by asset environments.
565    pub fn filter_asset_environments(mut self, value: String) -> Self {
566        self.filter_asset_environments = Some(value);
567        self
568    }
569    /// Filter by asset architecture.
570    pub fn filter_asset_arch(mut self, value: String) -> Self {
571        self.filter_asset_arch = Some(value);
572        self
573    }
574    /// Filter by asset operating system name.
575    pub fn filter_asset_operating_system_name(mut self, value: String) -> Self {
576        self.filter_asset_operating_system_name = Some(value);
577        self
578    }
579    /// Filter by asset operating system version.
580    pub fn filter_asset_operating_system_version(mut self, value: String) -> Self {
581        self.filter_asset_operating_system_version = Some(value);
582        self
583    }
584}
585
586/// ListVulnerableAssetsOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::list_vulnerable_assets`]
587#[non_exhaustive]
588#[derive(Clone, Default, Debug)]
589pub struct ListVulnerableAssetsOptionalParams {
590    /// Its value must come from the `links` section of the response of the first request. Do not manually edit it.
591    pub page_token: Option<String>,
592    /// The page number to be retrieved. It should be equal or greater than `1`
593    pub page_number: Option<i64>,
594    /// Filter by name.
595    pub filter_name: Option<String>,
596    /// Filter by type.
597    pub filter_type: Option<crate::datadogV2::model::AssetType>,
598    /// Filter by the first version of the asset since it has been vulnerable.
599    pub filter_version_first: Option<String>,
600    /// Filter by the last detected version of the asset.
601    pub filter_version_last: Option<String>,
602    /// Filter by the repository url associated to the asset.
603    pub filter_repository_url: Option<String>,
604    /// Filter whether the asset is in production or not.
605    pub filter_risks_in_production: Option<bool>,
606    /// Filter whether the asset (Service) is under attack or not.
607    pub filter_risks_under_attack: Option<bool>,
608    /// Filter whether the asset (Host) is publicly accessible or not.
609    pub filter_risks_is_publicly_accessible: Option<bool>,
610    /// Filter whether the asset (Host) has privileged access or not.
611    pub filter_risks_has_privileged_access: Option<bool>,
612    /// Filter whether the asset (Host)  has access to sensitive data or not.
613    pub filter_risks_has_access_to_sensitive_data: Option<bool>,
614    /// Filter by environment.
615    pub filter_environments: Option<String>,
616    /// Filter by architecture.
617    pub filter_arch: Option<String>,
618    /// Filter by operating system name.
619    pub filter_operating_system_name: Option<String>,
620    /// Filter by operating system version.
621    pub filter_operating_system_version: Option<String>,
622}
623
624impl ListVulnerableAssetsOptionalParams {
625    /// Its value must come from the `links` section of the response of the first request. Do not manually edit it.
626    pub fn page_token(mut self, value: String) -> Self {
627        self.page_token = Some(value);
628        self
629    }
630    /// The page number to be retrieved. It should be equal or greater than `1`
631    pub fn page_number(mut self, value: i64) -> Self {
632        self.page_number = Some(value);
633        self
634    }
635    /// Filter by name.
636    pub fn filter_name(mut self, value: String) -> Self {
637        self.filter_name = Some(value);
638        self
639    }
640    /// Filter by type.
641    pub fn filter_type(mut self, value: crate::datadogV2::model::AssetType) -> Self {
642        self.filter_type = Some(value);
643        self
644    }
645    /// Filter by the first version of the asset since it has been vulnerable.
646    pub fn filter_version_first(mut self, value: String) -> Self {
647        self.filter_version_first = Some(value);
648        self
649    }
650    /// Filter by the last detected version of the asset.
651    pub fn filter_version_last(mut self, value: String) -> Self {
652        self.filter_version_last = Some(value);
653        self
654    }
655    /// Filter by the repository url associated to the asset.
656    pub fn filter_repository_url(mut self, value: String) -> Self {
657        self.filter_repository_url = Some(value);
658        self
659    }
660    /// Filter whether the asset is in production or not.
661    pub fn filter_risks_in_production(mut self, value: bool) -> Self {
662        self.filter_risks_in_production = Some(value);
663        self
664    }
665    /// Filter whether the asset (Service) is under attack or not.
666    pub fn filter_risks_under_attack(mut self, value: bool) -> Self {
667        self.filter_risks_under_attack = Some(value);
668        self
669    }
670    /// Filter whether the asset (Host) is publicly accessible or not.
671    pub fn filter_risks_is_publicly_accessible(mut self, value: bool) -> Self {
672        self.filter_risks_is_publicly_accessible = Some(value);
673        self
674    }
675    /// Filter whether the asset (Host) has privileged access or not.
676    pub fn filter_risks_has_privileged_access(mut self, value: bool) -> Self {
677        self.filter_risks_has_privileged_access = Some(value);
678        self
679    }
680    /// Filter whether the asset (Host)  has access to sensitive data or not.
681    pub fn filter_risks_has_access_to_sensitive_data(mut self, value: bool) -> Self {
682        self.filter_risks_has_access_to_sensitive_data = Some(value);
683        self
684    }
685    /// Filter by environment.
686    pub fn filter_environments(mut self, value: String) -> Self {
687        self.filter_environments = Some(value);
688        self
689    }
690    /// Filter by architecture.
691    pub fn filter_arch(mut self, value: String) -> Self {
692        self.filter_arch = Some(value);
693        self
694    }
695    /// Filter by operating system name.
696    pub fn filter_operating_system_name(mut self, value: String) -> Self {
697        self.filter_operating_system_name = Some(value);
698        self
699    }
700    /// Filter by operating system version.
701    pub fn filter_operating_system_version(mut self, value: String) -> Self {
702        self.filter_operating_system_version = Some(value);
703        self
704    }
705}
706
707/// SearchSecurityMonitoringSignalsOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::search_security_monitoring_signals`]
708#[non_exhaustive]
709#[derive(Clone, Default, Debug)]
710pub struct SearchSecurityMonitoringSignalsOptionalParams {
711    pub body: Option<crate::datadogV2::model::SecurityMonitoringSignalListRequest>,
712}
713
714impl SearchSecurityMonitoringSignalsOptionalParams {
715    pub fn body(
716        mut self,
717        value: crate::datadogV2::model::SecurityMonitoringSignalListRequest,
718    ) -> Self {
719        self.body = Some(value);
720        self
721    }
722}
723
724/// CancelHistoricalJobError is a struct for typed errors of method [`SecurityMonitoringAPI::cancel_historical_job`]
725#[derive(Debug, Clone, Serialize, Deserialize)]
726#[serde(untagged)]
727pub enum CancelHistoricalJobError {
728    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
729    UnknownValue(serde_json::Value),
730}
731
732/// ConvertExistingSecurityMonitoringRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::convert_existing_security_monitoring_rule`]
733#[derive(Debug, Clone, Serialize, Deserialize)]
734#[serde(untagged)]
735pub enum ConvertExistingSecurityMonitoringRuleError {
736    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
737    UnknownValue(serde_json::Value),
738}
739
740/// ConvertJobResultToSignalError is a struct for typed errors of method [`SecurityMonitoringAPI::convert_job_result_to_signal`]
741#[derive(Debug, Clone, Serialize, Deserialize)]
742#[serde(untagged)]
743pub enum ConvertJobResultToSignalError {
744    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
745    UnknownValue(serde_json::Value),
746}
747
748/// ConvertSecurityMonitoringRuleFromJSONToTerraformError is a struct for typed errors of method [`SecurityMonitoringAPI::convert_security_monitoring_rule_from_json_to_terraform`]
749#[derive(Debug, Clone, Serialize, Deserialize)]
750#[serde(untagged)]
751pub enum ConvertSecurityMonitoringRuleFromJSONToTerraformError {
752    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
753    UnknownValue(serde_json::Value),
754}
755
756/// CreateSecurityFilterError is a struct for typed errors of method [`SecurityMonitoringAPI::create_security_filter`]
757#[derive(Debug, Clone, Serialize, Deserialize)]
758#[serde(untagged)]
759pub enum CreateSecurityFilterError {
760    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
761    UnknownValue(serde_json::Value),
762}
763
764/// CreateSecurityMonitoringRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::create_security_monitoring_rule`]
765#[derive(Debug, Clone, Serialize, Deserialize)]
766#[serde(untagged)]
767pub enum CreateSecurityMonitoringRuleError {
768    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
769    UnknownValue(serde_json::Value),
770}
771
772/// CreateSecurityMonitoringSuppressionError is a struct for typed errors of method [`SecurityMonitoringAPI::create_security_monitoring_suppression`]
773#[derive(Debug, Clone, Serialize, Deserialize)]
774#[serde(untagged)]
775pub enum CreateSecurityMonitoringSuppressionError {
776    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
777    UnknownValue(serde_json::Value),
778}
779
780/// CreateSignalNotificationRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::create_signal_notification_rule`]
781#[derive(Debug, Clone, Serialize, Deserialize)]
782#[serde(untagged)]
783pub enum CreateSignalNotificationRuleError {
784    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
785    UnknownValue(serde_json::Value),
786}
787
788/// CreateVulnerabilityNotificationRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::create_vulnerability_notification_rule`]
789#[derive(Debug, Clone, Serialize, Deserialize)]
790#[serde(untagged)]
791pub enum CreateVulnerabilityNotificationRuleError {
792    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
793    UnknownValue(serde_json::Value),
794}
795
796/// DeleteHistoricalJobError is a struct for typed errors of method [`SecurityMonitoringAPI::delete_historical_job`]
797#[derive(Debug, Clone, Serialize, Deserialize)]
798#[serde(untagged)]
799pub enum DeleteHistoricalJobError {
800    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
801    UnknownValue(serde_json::Value),
802}
803
804/// DeleteSecurityFilterError is a struct for typed errors of method [`SecurityMonitoringAPI::delete_security_filter`]
805#[derive(Debug, Clone, Serialize, Deserialize)]
806#[serde(untagged)]
807pub enum DeleteSecurityFilterError {
808    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
809    UnknownValue(serde_json::Value),
810}
811
812/// DeleteSecurityMonitoringRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::delete_security_monitoring_rule`]
813#[derive(Debug, Clone, Serialize, Deserialize)]
814#[serde(untagged)]
815pub enum DeleteSecurityMonitoringRuleError {
816    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
817    UnknownValue(serde_json::Value),
818}
819
820/// DeleteSecurityMonitoringSuppressionError is a struct for typed errors of method [`SecurityMonitoringAPI::delete_security_monitoring_suppression`]
821#[derive(Debug, Clone, Serialize, Deserialize)]
822#[serde(untagged)]
823pub enum DeleteSecurityMonitoringSuppressionError {
824    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
825    UnknownValue(serde_json::Value),
826}
827
828/// DeleteSignalNotificationRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::delete_signal_notification_rule`]
829#[derive(Debug, Clone, Serialize, Deserialize)]
830#[serde(untagged)]
831pub enum DeleteSignalNotificationRuleError {
832    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
833    UnknownValue(serde_json::Value),
834}
835
836/// DeleteVulnerabilityNotificationRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::delete_vulnerability_notification_rule`]
837#[derive(Debug, Clone, Serialize, Deserialize)]
838#[serde(untagged)]
839pub enum DeleteVulnerabilityNotificationRuleError {
840    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
841    UnknownValue(serde_json::Value),
842}
843
844/// EditSecurityMonitoringSignalAssigneeError is a struct for typed errors of method [`SecurityMonitoringAPI::edit_security_monitoring_signal_assignee`]
845#[derive(Debug, Clone, Serialize, Deserialize)]
846#[serde(untagged)]
847pub enum EditSecurityMonitoringSignalAssigneeError {
848    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
849    UnknownValue(serde_json::Value),
850}
851
852/// EditSecurityMonitoringSignalIncidentsError is a struct for typed errors of method [`SecurityMonitoringAPI::edit_security_monitoring_signal_incidents`]
853#[derive(Debug, Clone, Serialize, Deserialize)]
854#[serde(untagged)]
855pub enum EditSecurityMonitoringSignalIncidentsError {
856    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
857    UnknownValue(serde_json::Value),
858}
859
860/// EditSecurityMonitoringSignalStateError is a struct for typed errors of method [`SecurityMonitoringAPI::edit_security_monitoring_signal_state`]
861#[derive(Debug, Clone, Serialize, Deserialize)]
862#[serde(untagged)]
863pub enum EditSecurityMonitoringSignalStateError {
864    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
865    UnknownValue(serde_json::Value),
866}
867
868/// GetFindingError is a struct for typed errors of method [`SecurityMonitoringAPI::get_finding`]
869#[derive(Debug, Clone, Serialize, Deserialize)]
870#[serde(untagged)]
871pub enum GetFindingError {
872    JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
873    UnknownValue(serde_json::Value),
874}
875
876/// GetHistoricalJobError is a struct for typed errors of method [`SecurityMonitoringAPI::get_historical_job`]
877#[derive(Debug, Clone, Serialize, Deserialize)]
878#[serde(untagged)]
879pub enum GetHistoricalJobError {
880    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
881    UnknownValue(serde_json::Value),
882}
883
884/// GetRuleVersionHistoryError is a struct for typed errors of method [`SecurityMonitoringAPI::get_rule_version_history`]
885#[derive(Debug, Clone, Serialize, Deserialize)]
886#[serde(untagged)]
887pub enum GetRuleVersionHistoryError {
888    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
889    UnknownValue(serde_json::Value),
890}
891
892/// GetSBOMError is a struct for typed errors of method [`SecurityMonitoringAPI::get_sbom`]
893#[derive(Debug, Clone, Serialize, Deserialize)]
894#[serde(untagged)]
895pub enum GetSBOMError {
896    JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
897    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
898    UnknownValue(serde_json::Value),
899}
900
901/// GetSecurityFilterError is a struct for typed errors of method [`SecurityMonitoringAPI::get_security_filter`]
902#[derive(Debug, Clone, Serialize, Deserialize)]
903#[serde(untagged)]
904pub enum GetSecurityFilterError {
905    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
906    UnknownValue(serde_json::Value),
907}
908
909/// GetSecurityMonitoringRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::get_security_monitoring_rule`]
910#[derive(Debug, Clone, Serialize, Deserialize)]
911#[serde(untagged)]
912pub enum GetSecurityMonitoringRuleError {
913    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
914    UnknownValue(serde_json::Value),
915}
916
917/// GetSecurityMonitoringSignalError is a struct for typed errors of method [`SecurityMonitoringAPI::get_security_monitoring_signal`]
918#[derive(Debug, Clone, Serialize, Deserialize)]
919#[serde(untagged)]
920pub enum GetSecurityMonitoringSignalError {
921    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
922    UnknownValue(serde_json::Value),
923}
924
925/// GetSecurityMonitoringSuppressionError is a struct for typed errors of method [`SecurityMonitoringAPI::get_security_monitoring_suppression`]
926#[derive(Debug, Clone, Serialize, Deserialize)]
927#[serde(untagged)]
928pub enum GetSecurityMonitoringSuppressionError {
929    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
930    UnknownValue(serde_json::Value),
931}
932
933/// GetSignalNotificationRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::get_signal_notification_rule`]
934#[derive(Debug, Clone, Serialize, Deserialize)]
935#[serde(untagged)]
936pub enum GetSignalNotificationRuleError {
937    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
938    UnknownValue(serde_json::Value),
939}
940
941/// GetSignalNotificationRulesError is a struct for typed errors of method [`SecurityMonitoringAPI::get_signal_notification_rules`]
942#[derive(Debug, Clone, Serialize, Deserialize)]
943#[serde(untagged)]
944pub enum GetSignalNotificationRulesError {
945    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
946    UnknownValue(serde_json::Value),
947}
948
949/// GetVulnerabilityNotificationRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::get_vulnerability_notification_rule`]
950#[derive(Debug, Clone, Serialize, Deserialize)]
951#[serde(untagged)]
952pub enum GetVulnerabilityNotificationRuleError {
953    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
954    UnknownValue(serde_json::Value),
955}
956
957/// GetVulnerabilityNotificationRulesError is a struct for typed errors of method [`SecurityMonitoringAPI::get_vulnerability_notification_rules`]
958#[derive(Debug, Clone, Serialize, Deserialize)]
959#[serde(untagged)]
960pub enum GetVulnerabilityNotificationRulesError {
961    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
962    UnknownValue(serde_json::Value),
963}
964
965/// ListFindingsError is a struct for typed errors of method [`SecurityMonitoringAPI::list_findings`]
966#[derive(Debug, Clone, Serialize, Deserialize)]
967#[serde(untagged)]
968pub enum ListFindingsError {
969    JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
970    UnknownValue(serde_json::Value),
971}
972
973/// ListHistoricalJobsError is a struct for typed errors of method [`SecurityMonitoringAPI::list_historical_jobs`]
974#[derive(Debug, Clone, Serialize, Deserialize)]
975#[serde(untagged)]
976pub enum ListHistoricalJobsError {
977    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
978    UnknownValue(serde_json::Value),
979}
980
981/// ListSecurityFiltersError is a struct for typed errors of method [`SecurityMonitoringAPI::list_security_filters`]
982#[derive(Debug, Clone, Serialize, Deserialize)]
983#[serde(untagged)]
984pub enum ListSecurityFiltersError {
985    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
986    UnknownValue(serde_json::Value),
987}
988
989/// ListSecurityMonitoringRulesError is a struct for typed errors of method [`SecurityMonitoringAPI::list_security_monitoring_rules`]
990#[derive(Debug, Clone, Serialize, Deserialize)]
991#[serde(untagged)]
992pub enum ListSecurityMonitoringRulesError {
993    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
994    UnknownValue(serde_json::Value),
995}
996
997/// ListSecurityMonitoringSignalsError is a struct for typed errors of method [`SecurityMonitoringAPI::list_security_monitoring_signals`]
998#[derive(Debug, Clone, Serialize, Deserialize)]
999#[serde(untagged)]
1000pub enum ListSecurityMonitoringSignalsError {
1001    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1002    UnknownValue(serde_json::Value),
1003}
1004
1005/// ListSecurityMonitoringSuppressionsError is a struct for typed errors of method [`SecurityMonitoringAPI::list_security_monitoring_suppressions`]
1006#[derive(Debug, Clone, Serialize, Deserialize)]
1007#[serde(untagged)]
1008pub enum ListSecurityMonitoringSuppressionsError {
1009    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1010    UnknownValue(serde_json::Value),
1011}
1012
1013/// ListVulnerabilitiesError is a struct for typed errors of method [`SecurityMonitoringAPI::list_vulnerabilities`]
1014#[derive(Debug, Clone, Serialize, Deserialize)]
1015#[serde(untagged)]
1016pub enum ListVulnerabilitiesError {
1017    JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
1018    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1019    UnknownValue(serde_json::Value),
1020}
1021
1022/// ListVulnerableAssetsError is a struct for typed errors of method [`SecurityMonitoringAPI::list_vulnerable_assets`]
1023#[derive(Debug, Clone, Serialize, Deserialize)]
1024#[serde(untagged)]
1025pub enum ListVulnerableAssetsError {
1026    JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
1027    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1028    UnknownValue(serde_json::Value),
1029}
1030
1031/// MuteFindingsError is a struct for typed errors of method [`SecurityMonitoringAPI::mute_findings`]
1032#[derive(Debug, Clone, Serialize, Deserialize)]
1033#[serde(untagged)]
1034pub enum MuteFindingsError {
1035    JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
1036    UnknownValue(serde_json::Value),
1037}
1038
1039/// PatchSignalNotificationRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::patch_signal_notification_rule`]
1040#[derive(Debug, Clone, Serialize, Deserialize)]
1041#[serde(untagged)]
1042pub enum PatchSignalNotificationRuleError {
1043    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1044    JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
1045    UnknownValue(serde_json::Value),
1046}
1047
1048/// PatchVulnerabilityNotificationRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::patch_vulnerability_notification_rule`]
1049#[derive(Debug, Clone, Serialize, Deserialize)]
1050#[serde(untagged)]
1051pub enum PatchVulnerabilityNotificationRuleError {
1052    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1053    JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse),
1054    UnknownValue(serde_json::Value),
1055}
1056
1057/// RunHistoricalJobError is a struct for typed errors of method [`SecurityMonitoringAPI::run_historical_job`]
1058#[derive(Debug, Clone, Serialize, Deserialize)]
1059#[serde(untagged)]
1060pub enum RunHistoricalJobError {
1061    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1062    UnknownValue(serde_json::Value),
1063}
1064
1065/// SearchSecurityMonitoringSignalsError is a struct for typed errors of method [`SecurityMonitoringAPI::search_security_monitoring_signals`]
1066#[derive(Debug, Clone, Serialize, Deserialize)]
1067#[serde(untagged)]
1068pub enum SearchSecurityMonitoringSignalsError {
1069    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1070    UnknownValue(serde_json::Value),
1071}
1072
1073/// TestExistingSecurityMonitoringRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::test_existing_security_monitoring_rule`]
1074#[derive(Debug, Clone, Serialize, Deserialize)]
1075#[serde(untagged)]
1076pub enum TestExistingSecurityMonitoringRuleError {
1077    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1078    UnknownValue(serde_json::Value),
1079}
1080
1081/// TestSecurityMonitoringRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::test_security_monitoring_rule`]
1082#[derive(Debug, Clone, Serialize, Deserialize)]
1083#[serde(untagged)]
1084pub enum TestSecurityMonitoringRuleError {
1085    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1086    UnknownValue(serde_json::Value),
1087}
1088
1089/// UpdateSecurityFilterError is a struct for typed errors of method [`SecurityMonitoringAPI::update_security_filter`]
1090#[derive(Debug, Clone, Serialize, Deserialize)]
1091#[serde(untagged)]
1092pub enum UpdateSecurityFilterError {
1093    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1094    UnknownValue(serde_json::Value),
1095}
1096
1097/// UpdateSecurityMonitoringRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::update_security_monitoring_rule`]
1098#[derive(Debug, Clone, Serialize, Deserialize)]
1099#[serde(untagged)]
1100pub enum UpdateSecurityMonitoringRuleError {
1101    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1102    UnknownValue(serde_json::Value),
1103}
1104
1105/// UpdateSecurityMonitoringSuppressionError is a struct for typed errors of method [`SecurityMonitoringAPI::update_security_monitoring_suppression`]
1106#[derive(Debug, Clone, Serialize, Deserialize)]
1107#[serde(untagged)]
1108pub enum UpdateSecurityMonitoringSuppressionError {
1109    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1110    UnknownValue(serde_json::Value),
1111}
1112
1113/// ValidateSecurityMonitoringRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::validate_security_monitoring_rule`]
1114#[derive(Debug, Clone, Serialize, Deserialize)]
1115#[serde(untagged)]
1116pub enum ValidateSecurityMonitoringRuleError {
1117    APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
1118    UnknownValue(serde_json::Value),
1119}
1120
1121/// Create and manage your security rules, signals, filters, and more. See the [Datadog Security page](<https://docs.datadoghq.com/security/>) for more information.
1122#[derive(Debug, Clone)]
1123pub struct SecurityMonitoringAPI {
1124    config: datadog::Configuration,
1125    client: reqwest_middleware::ClientWithMiddleware,
1126}
1127
1128impl Default for SecurityMonitoringAPI {
1129    fn default() -> Self {
1130        Self::with_config(datadog::Configuration::default())
1131    }
1132}
1133
1134impl SecurityMonitoringAPI {
1135    pub fn new() -> Self {
1136        Self::default()
1137    }
1138    pub fn with_config(config: datadog::Configuration) -> Self {
1139        let mut reqwest_client_builder = reqwest::Client::builder();
1140
1141        if let Some(proxy_url) = &config.proxy_url {
1142            let proxy = reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL");
1143            reqwest_client_builder = reqwest_client_builder.proxy(proxy);
1144        }
1145
1146        let mut middleware_client_builder =
1147            reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap());
1148
1149        if config.enable_retry {
1150            struct RetryableStatus;
1151            impl reqwest_retry::RetryableStrategy for RetryableStatus {
1152                fn handle(
1153                    &self,
1154                    res: &Result<reqwest::Response, reqwest_middleware::Error>,
1155                ) -> Option<reqwest_retry::Retryable> {
1156                    match res {
1157                        Ok(success) => reqwest_retry::default_on_request_success(success),
1158                        Err(_) => None,
1159                    }
1160                }
1161            }
1162            let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder()
1163                .build_with_max_retries(config.max_retries);
1164
1165            let retry_middleware =
1166                reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy(
1167                    backoff_policy,
1168                    RetryableStatus,
1169                );
1170
1171            middleware_client_builder = middleware_client_builder.with(retry_middleware);
1172        }
1173
1174        let client = middleware_client_builder.build();
1175
1176        Self { config, client }
1177    }
1178
1179    pub fn with_client_and_config(
1180        config: datadog::Configuration,
1181        client: reqwest_middleware::ClientWithMiddleware,
1182    ) -> Self {
1183        Self { config, client }
1184    }
1185
1186    /// Cancel a historical job.
1187    pub async fn cancel_historical_job(
1188        &self,
1189        job_id: String,
1190    ) -> Result<(), datadog::Error<CancelHistoricalJobError>> {
1191        match self.cancel_historical_job_with_http_info(job_id).await {
1192            Ok(_) => Ok(()),
1193            Err(err) => Err(err),
1194        }
1195    }
1196
1197    /// Cancel a historical job.
1198    pub async fn cancel_historical_job_with_http_info(
1199        &self,
1200        job_id: String,
1201    ) -> Result<datadog::ResponseContent<()>, datadog::Error<CancelHistoricalJobError>> {
1202        let local_configuration = &self.config;
1203        let operation_id = "v2.cancel_historical_job";
1204        if local_configuration.is_unstable_operation_enabled(operation_id) {
1205            warn!("Using unstable operation {operation_id}");
1206        } else {
1207            let local_error = datadog::UnstableOperationDisabledError {
1208                msg: "Operation 'v2.cancel_historical_job' is not enabled".to_string(),
1209            };
1210            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
1211        }
1212
1213        let local_client = &self.client;
1214
1215        let local_uri_str = format!(
1216            "{}/api/v2/siem-historical-detections/jobs/{job_id}/cancel",
1217            local_configuration.get_operation_host(operation_id),
1218            job_id = datadog::urlencode(job_id)
1219        );
1220        let mut local_req_builder =
1221            local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
1222
1223        // build headers
1224        let mut headers = HeaderMap::new();
1225        headers.insert("Accept", HeaderValue::from_static("*/*"));
1226
1227        // build user agent
1228        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1229            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1230            Err(e) => {
1231                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1232                headers.insert(
1233                    reqwest::header::USER_AGENT,
1234                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1235                )
1236            }
1237        };
1238
1239        // build auth
1240        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1241            headers.insert(
1242                "DD-API-KEY",
1243                HeaderValue::from_str(local_key.key.as_str())
1244                    .expect("failed to parse DD-API-KEY header"),
1245            );
1246        };
1247        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1248            headers.insert(
1249                "DD-APPLICATION-KEY",
1250                HeaderValue::from_str(local_key.key.as_str())
1251                    .expect("failed to parse DD-APPLICATION-KEY header"),
1252            );
1253        };
1254
1255        local_req_builder = local_req_builder.headers(headers);
1256        let local_req = local_req_builder.build()?;
1257        log::debug!("request content: {:?}", local_req.body());
1258        let local_resp = local_client.execute(local_req).await?;
1259
1260        let local_status = local_resp.status();
1261        let local_content = local_resp.text().await?;
1262        log::debug!("response content: {}", local_content);
1263
1264        if !local_status.is_client_error() && !local_status.is_server_error() {
1265            Ok(datadog::ResponseContent {
1266                status: local_status,
1267                content: local_content,
1268                entity: None,
1269            })
1270        } else {
1271            let local_entity: Option<CancelHistoricalJobError> =
1272                serde_json::from_str(&local_content).ok();
1273            let local_error = datadog::ResponseContent {
1274                status: local_status,
1275                content: local_content,
1276                entity: local_entity,
1277            };
1278            Err(datadog::Error::ResponseError(local_error))
1279        }
1280    }
1281
1282    /// Convert an existing rule from JSON to Terraform for datadog provider
1283    /// resource datadog_security_monitoring_rule.
1284    pub async fn convert_existing_security_monitoring_rule(
1285        &self,
1286        rule_id: String,
1287    ) -> Result<
1288        crate::datadogV2::model::SecurityMonitoringRuleConvertResponse,
1289        datadog::Error<ConvertExistingSecurityMonitoringRuleError>,
1290    > {
1291        match self
1292            .convert_existing_security_monitoring_rule_with_http_info(rule_id)
1293            .await
1294        {
1295            Ok(response_content) => {
1296                if let Some(e) = response_content.entity {
1297                    Ok(e)
1298                } else {
1299                    Err(datadog::Error::Serde(serde::de::Error::custom(
1300                        "response content was None",
1301                    )))
1302                }
1303            }
1304            Err(err) => Err(err),
1305        }
1306    }
1307
1308    /// Convert an existing rule from JSON to Terraform for datadog provider
1309    /// resource datadog_security_monitoring_rule.
1310    pub async fn convert_existing_security_monitoring_rule_with_http_info(
1311        &self,
1312        rule_id: String,
1313    ) -> Result<
1314        datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleConvertResponse>,
1315        datadog::Error<ConvertExistingSecurityMonitoringRuleError>,
1316    > {
1317        let local_configuration = &self.config;
1318        let operation_id = "v2.convert_existing_security_monitoring_rule";
1319
1320        let local_client = &self.client;
1321
1322        let local_uri_str = format!(
1323            "{}/api/v2/security_monitoring/rules/{rule_id}/convert",
1324            local_configuration.get_operation_host(operation_id),
1325            rule_id = datadog::urlencode(rule_id)
1326        );
1327        let mut local_req_builder =
1328            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1329
1330        // build headers
1331        let mut headers = HeaderMap::new();
1332        headers.insert("Accept", HeaderValue::from_static("application/json"));
1333
1334        // build user agent
1335        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1336            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1337            Err(e) => {
1338                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1339                headers.insert(
1340                    reqwest::header::USER_AGENT,
1341                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1342                )
1343            }
1344        };
1345
1346        // build auth
1347        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1348            headers.insert(
1349                "DD-API-KEY",
1350                HeaderValue::from_str(local_key.key.as_str())
1351                    .expect("failed to parse DD-API-KEY header"),
1352            );
1353        };
1354        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1355            headers.insert(
1356                "DD-APPLICATION-KEY",
1357                HeaderValue::from_str(local_key.key.as_str())
1358                    .expect("failed to parse DD-APPLICATION-KEY header"),
1359            );
1360        };
1361
1362        local_req_builder = local_req_builder.headers(headers);
1363        let local_req = local_req_builder.build()?;
1364        log::debug!("request content: {:?}", local_req.body());
1365        let local_resp = local_client.execute(local_req).await?;
1366
1367        let local_status = local_resp.status();
1368        let local_content = local_resp.text().await?;
1369        log::debug!("response content: {}", local_content);
1370
1371        if !local_status.is_client_error() && !local_status.is_server_error() {
1372            match serde_json::from_str::<
1373                crate::datadogV2::model::SecurityMonitoringRuleConvertResponse,
1374            >(&local_content)
1375            {
1376                Ok(e) => {
1377                    return Ok(datadog::ResponseContent {
1378                        status: local_status,
1379                        content: local_content,
1380                        entity: Some(e),
1381                    })
1382                }
1383                Err(e) => return Err(datadog::Error::Serde(e)),
1384            };
1385        } else {
1386            let local_entity: Option<ConvertExistingSecurityMonitoringRuleError> =
1387                serde_json::from_str(&local_content).ok();
1388            let local_error = datadog::ResponseContent {
1389                status: local_status,
1390                content: local_content,
1391                entity: local_entity,
1392            };
1393            Err(datadog::Error::ResponseError(local_error))
1394        }
1395    }
1396
1397    /// Convert a job result to a signal.
1398    pub async fn convert_job_result_to_signal(
1399        &self,
1400        body: crate::datadogV2::model::ConvertJobResultsToSignalsRequest,
1401    ) -> Result<(), datadog::Error<ConvertJobResultToSignalError>> {
1402        match self.convert_job_result_to_signal_with_http_info(body).await {
1403            Ok(_) => Ok(()),
1404            Err(err) => Err(err),
1405        }
1406    }
1407
1408    /// Convert a job result to a signal.
1409    pub async fn convert_job_result_to_signal_with_http_info(
1410        &self,
1411        body: crate::datadogV2::model::ConvertJobResultsToSignalsRequest,
1412    ) -> Result<datadog::ResponseContent<()>, datadog::Error<ConvertJobResultToSignalError>> {
1413        let local_configuration = &self.config;
1414        let operation_id = "v2.convert_job_result_to_signal";
1415        if local_configuration.is_unstable_operation_enabled(operation_id) {
1416            warn!("Using unstable operation {operation_id}");
1417        } else {
1418            let local_error = datadog::UnstableOperationDisabledError {
1419                msg: "Operation 'v2.convert_job_result_to_signal' is not enabled".to_string(),
1420            };
1421            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
1422        }
1423
1424        let local_client = &self.client;
1425
1426        let local_uri_str = format!(
1427            "{}/api/v2/siem-historical-detections/jobs/signal_convert",
1428            local_configuration.get_operation_host(operation_id)
1429        );
1430        let mut local_req_builder =
1431            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
1432
1433        // build headers
1434        let mut headers = HeaderMap::new();
1435        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1436        headers.insert("Accept", HeaderValue::from_static("*/*"));
1437
1438        // build user agent
1439        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1440            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1441            Err(e) => {
1442                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1443                headers.insert(
1444                    reqwest::header::USER_AGENT,
1445                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1446                )
1447            }
1448        };
1449
1450        // build auth
1451        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1452            headers.insert(
1453                "DD-API-KEY",
1454                HeaderValue::from_str(local_key.key.as_str())
1455                    .expect("failed to parse DD-API-KEY header"),
1456            );
1457        };
1458        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1459            headers.insert(
1460                "DD-APPLICATION-KEY",
1461                HeaderValue::from_str(local_key.key.as_str())
1462                    .expect("failed to parse DD-APPLICATION-KEY header"),
1463            );
1464        };
1465
1466        // build body parameters
1467        let output = Vec::new();
1468        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1469        if body.serialize(&mut ser).is_ok() {
1470            if let Some(content_encoding) = headers.get("Content-Encoding") {
1471                match content_encoding.to_str().unwrap_or_default() {
1472                    "gzip" => {
1473                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1474                        let _ = enc.write_all(ser.into_inner().as_slice());
1475                        match enc.finish() {
1476                            Ok(buf) => {
1477                                local_req_builder = local_req_builder.body(buf);
1478                            }
1479                            Err(e) => return Err(datadog::Error::Io(e)),
1480                        }
1481                    }
1482                    "deflate" => {
1483                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1484                        let _ = enc.write_all(ser.into_inner().as_slice());
1485                        match enc.finish() {
1486                            Ok(buf) => {
1487                                local_req_builder = local_req_builder.body(buf);
1488                            }
1489                            Err(e) => return Err(datadog::Error::Io(e)),
1490                        }
1491                    }
1492                    "zstd1" => {
1493                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1494                        let _ = enc.write_all(ser.into_inner().as_slice());
1495                        match enc.finish() {
1496                            Ok(buf) => {
1497                                local_req_builder = local_req_builder.body(buf);
1498                            }
1499                            Err(e) => return Err(datadog::Error::Io(e)),
1500                        }
1501                    }
1502                    _ => {
1503                        local_req_builder = local_req_builder.body(ser.into_inner());
1504                    }
1505                }
1506            } else {
1507                local_req_builder = local_req_builder.body(ser.into_inner());
1508            }
1509        }
1510
1511        local_req_builder = local_req_builder.headers(headers);
1512        let local_req = local_req_builder.build()?;
1513        log::debug!("request content: {:?}", local_req.body());
1514        let local_resp = local_client.execute(local_req).await?;
1515
1516        let local_status = local_resp.status();
1517        let local_content = local_resp.text().await?;
1518        log::debug!("response content: {}", local_content);
1519
1520        if !local_status.is_client_error() && !local_status.is_server_error() {
1521            Ok(datadog::ResponseContent {
1522                status: local_status,
1523                content: local_content,
1524                entity: None,
1525            })
1526        } else {
1527            let local_entity: Option<ConvertJobResultToSignalError> =
1528                serde_json::from_str(&local_content).ok();
1529            let local_error = datadog::ResponseContent {
1530                status: local_status,
1531                content: local_content,
1532                entity: local_entity,
1533            };
1534            Err(datadog::Error::ResponseError(local_error))
1535        }
1536    }
1537
1538    /// Convert a rule that doesn't (yet) exist from JSON to Terraform for datadog provider
1539    /// resource datadog_security_monitoring_rule.
1540    pub async fn convert_security_monitoring_rule_from_json_to_terraform(
1541        &self,
1542        body: crate::datadogV2::model::SecurityMonitoringRuleConvertPayload,
1543    ) -> Result<
1544        crate::datadogV2::model::SecurityMonitoringRuleConvertResponse,
1545        datadog::Error<ConvertSecurityMonitoringRuleFromJSONToTerraformError>,
1546    > {
1547        match self
1548            .convert_security_monitoring_rule_from_json_to_terraform_with_http_info(body)
1549            .await
1550        {
1551            Ok(response_content) => {
1552                if let Some(e) = response_content.entity {
1553                    Ok(e)
1554                } else {
1555                    Err(datadog::Error::Serde(serde::de::Error::custom(
1556                        "response content was None",
1557                    )))
1558                }
1559            }
1560            Err(err) => Err(err),
1561        }
1562    }
1563
1564    /// Convert a rule that doesn't (yet) exist from JSON to Terraform for datadog provider
1565    /// resource datadog_security_monitoring_rule.
1566    pub async fn convert_security_monitoring_rule_from_json_to_terraform_with_http_info(
1567        &self,
1568        body: crate::datadogV2::model::SecurityMonitoringRuleConvertPayload,
1569    ) -> Result<
1570        datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleConvertResponse>,
1571        datadog::Error<ConvertSecurityMonitoringRuleFromJSONToTerraformError>,
1572    > {
1573        let local_configuration = &self.config;
1574        let operation_id = "v2.convert_security_monitoring_rule_from_json_to_terraform";
1575
1576        let local_client = &self.client;
1577
1578        let local_uri_str = format!(
1579            "{}/api/v2/security_monitoring/rules/convert",
1580            local_configuration.get_operation_host(operation_id)
1581        );
1582        let mut local_req_builder =
1583            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
1584
1585        // build headers
1586        let mut headers = HeaderMap::new();
1587        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1588        headers.insert("Accept", HeaderValue::from_static("application/json"));
1589
1590        // build user agent
1591        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1592            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1593            Err(e) => {
1594                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1595                headers.insert(
1596                    reqwest::header::USER_AGENT,
1597                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1598                )
1599            }
1600        };
1601
1602        // build auth
1603        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1604            headers.insert(
1605                "DD-API-KEY",
1606                HeaderValue::from_str(local_key.key.as_str())
1607                    .expect("failed to parse DD-API-KEY header"),
1608            );
1609        };
1610        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1611            headers.insert(
1612                "DD-APPLICATION-KEY",
1613                HeaderValue::from_str(local_key.key.as_str())
1614                    .expect("failed to parse DD-APPLICATION-KEY header"),
1615            );
1616        };
1617
1618        // build body parameters
1619        let output = Vec::new();
1620        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1621        if body.serialize(&mut ser).is_ok() {
1622            if let Some(content_encoding) = headers.get("Content-Encoding") {
1623                match content_encoding.to_str().unwrap_or_default() {
1624                    "gzip" => {
1625                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1626                        let _ = enc.write_all(ser.into_inner().as_slice());
1627                        match enc.finish() {
1628                            Ok(buf) => {
1629                                local_req_builder = local_req_builder.body(buf);
1630                            }
1631                            Err(e) => return Err(datadog::Error::Io(e)),
1632                        }
1633                    }
1634                    "deflate" => {
1635                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1636                        let _ = enc.write_all(ser.into_inner().as_slice());
1637                        match enc.finish() {
1638                            Ok(buf) => {
1639                                local_req_builder = local_req_builder.body(buf);
1640                            }
1641                            Err(e) => return Err(datadog::Error::Io(e)),
1642                        }
1643                    }
1644                    "zstd1" => {
1645                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1646                        let _ = enc.write_all(ser.into_inner().as_slice());
1647                        match enc.finish() {
1648                            Ok(buf) => {
1649                                local_req_builder = local_req_builder.body(buf);
1650                            }
1651                            Err(e) => return Err(datadog::Error::Io(e)),
1652                        }
1653                    }
1654                    _ => {
1655                        local_req_builder = local_req_builder.body(ser.into_inner());
1656                    }
1657                }
1658            } else {
1659                local_req_builder = local_req_builder.body(ser.into_inner());
1660            }
1661        }
1662
1663        local_req_builder = local_req_builder.headers(headers);
1664        let local_req = local_req_builder.build()?;
1665        log::debug!("request content: {:?}", local_req.body());
1666        let local_resp = local_client.execute(local_req).await?;
1667
1668        let local_status = local_resp.status();
1669        let local_content = local_resp.text().await?;
1670        log::debug!("response content: {}", local_content);
1671
1672        if !local_status.is_client_error() && !local_status.is_server_error() {
1673            match serde_json::from_str::<
1674                crate::datadogV2::model::SecurityMonitoringRuleConvertResponse,
1675            >(&local_content)
1676            {
1677                Ok(e) => {
1678                    return Ok(datadog::ResponseContent {
1679                        status: local_status,
1680                        content: local_content,
1681                        entity: Some(e),
1682                    })
1683                }
1684                Err(e) => return Err(datadog::Error::Serde(e)),
1685            };
1686        } else {
1687            let local_entity: Option<ConvertSecurityMonitoringRuleFromJSONToTerraformError> =
1688                serde_json::from_str(&local_content).ok();
1689            let local_error = datadog::ResponseContent {
1690                status: local_status,
1691                content: local_content,
1692                entity: local_entity,
1693            };
1694            Err(datadog::Error::ResponseError(local_error))
1695        }
1696    }
1697
1698    /// Create a security filter.
1699    ///
1700    /// See the [security filter guide](<https://docs.datadoghq.com/security_platform/guide/how-to-setup-security-filters-using-security-monitoring-api/>)
1701    /// for more examples.
1702    pub async fn create_security_filter(
1703        &self,
1704        body: crate::datadogV2::model::SecurityFilterCreateRequest,
1705    ) -> Result<
1706        crate::datadogV2::model::SecurityFilterResponse,
1707        datadog::Error<CreateSecurityFilterError>,
1708    > {
1709        match self.create_security_filter_with_http_info(body).await {
1710            Ok(response_content) => {
1711                if let Some(e) = response_content.entity {
1712                    Ok(e)
1713                } else {
1714                    Err(datadog::Error::Serde(serde::de::Error::custom(
1715                        "response content was None",
1716                    )))
1717                }
1718            }
1719            Err(err) => Err(err),
1720        }
1721    }
1722
1723    /// Create a security filter.
1724    ///
1725    /// See the [security filter guide](<https://docs.datadoghq.com/security_platform/guide/how-to-setup-security-filters-using-security-monitoring-api/>)
1726    /// for more examples.
1727    pub async fn create_security_filter_with_http_info(
1728        &self,
1729        body: crate::datadogV2::model::SecurityFilterCreateRequest,
1730    ) -> Result<
1731        datadog::ResponseContent<crate::datadogV2::model::SecurityFilterResponse>,
1732        datadog::Error<CreateSecurityFilterError>,
1733    > {
1734        let local_configuration = &self.config;
1735        let operation_id = "v2.create_security_filter";
1736
1737        let local_client = &self.client;
1738
1739        let local_uri_str = format!(
1740            "{}/api/v2/security_monitoring/configuration/security_filters",
1741            local_configuration.get_operation_host(operation_id)
1742        );
1743        let mut local_req_builder =
1744            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
1745
1746        // build headers
1747        let mut headers = HeaderMap::new();
1748        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1749        headers.insert("Accept", HeaderValue::from_static("application/json"));
1750
1751        // build user agent
1752        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1753            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1754            Err(e) => {
1755                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1756                headers.insert(
1757                    reqwest::header::USER_AGENT,
1758                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1759                )
1760            }
1761        };
1762
1763        // build auth
1764        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1765            headers.insert(
1766                "DD-API-KEY",
1767                HeaderValue::from_str(local_key.key.as_str())
1768                    .expect("failed to parse DD-API-KEY header"),
1769            );
1770        };
1771        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1772            headers.insert(
1773                "DD-APPLICATION-KEY",
1774                HeaderValue::from_str(local_key.key.as_str())
1775                    .expect("failed to parse DD-APPLICATION-KEY header"),
1776            );
1777        };
1778
1779        // build body parameters
1780        let output = Vec::new();
1781        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1782        if body.serialize(&mut ser).is_ok() {
1783            if let Some(content_encoding) = headers.get("Content-Encoding") {
1784                match content_encoding.to_str().unwrap_or_default() {
1785                    "gzip" => {
1786                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1787                        let _ = enc.write_all(ser.into_inner().as_slice());
1788                        match enc.finish() {
1789                            Ok(buf) => {
1790                                local_req_builder = local_req_builder.body(buf);
1791                            }
1792                            Err(e) => return Err(datadog::Error::Io(e)),
1793                        }
1794                    }
1795                    "deflate" => {
1796                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1797                        let _ = enc.write_all(ser.into_inner().as_slice());
1798                        match enc.finish() {
1799                            Ok(buf) => {
1800                                local_req_builder = local_req_builder.body(buf);
1801                            }
1802                            Err(e) => return Err(datadog::Error::Io(e)),
1803                        }
1804                    }
1805                    "zstd1" => {
1806                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1807                        let _ = enc.write_all(ser.into_inner().as_slice());
1808                        match enc.finish() {
1809                            Ok(buf) => {
1810                                local_req_builder = local_req_builder.body(buf);
1811                            }
1812                            Err(e) => return Err(datadog::Error::Io(e)),
1813                        }
1814                    }
1815                    _ => {
1816                        local_req_builder = local_req_builder.body(ser.into_inner());
1817                    }
1818                }
1819            } else {
1820                local_req_builder = local_req_builder.body(ser.into_inner());
1821            }
1822        }
1823
1824        local_req_builder = local_req_builder.headers(headers);
1825        let local_req = local_req_builder.build()?;
1826        log::debug!("request content: {:?}", local_req.body());
1827        let local_resp = local_client.execute(local_req).await?;
1828
1829        let local_status = local_resp.status();
1830        let local_content = local_resp.text().await?;
1831        log::debug!("response content: {}", local_content);
1832
1833        if !local_status.is_client_error() && !local_status.is_server_error() {
1834            match serde_json::from_str::<crate::datadogV2::model::SecurityFilterResponse>(
1835                &local_content,
1836            ) {
1837                Ok(e) => {
1838                    return Ok(datadog::ResponseContent {
1839                        status: local_status,
1840                        content: local_content,
1841                        entity: Some(e),
1842                    })
1843                }
1844                Err(e) => return Err(datadog::Error::Serde(e)),
1845            };
1846        } else {
1847            let local_entity: Option<CreateSecurityFilterError> =
1848                serde_json::from_str(&local_content).ok();
1849            let local_error = datadog::ResponseContent {
1850                status: local_status,
1851                content: local_content,
1852                entity: local_entity,
1853            };
1854            Err(datadog::Error::ResponseError(local_error))
1855        }
1856    }
1857
1858    /// Create a detection rule.
1859    pub async fn create_security_monitoring_rule(
1860        &self,
1861        body: crate::datadogV2::model::SecurityMonitoringRuleCreatePayload,
1862    ) -> Result<
1863        crate::datadogV2::model::SecurityMonitoringRuleResponse,
1864        datadog::Error<CreateSecurityMonitoringRuleError>,
1865    > {
1866        match self
1867            .create_security_monitoring_rule_with_http_info(body)
1868            .await
1869        {
1870            Ok(response_content) => {
1871                if let Some(e) = response_content.entity {
1872                    Ok(e)
1873                } else {
1874                    Err(datadog::Error::Serde(serde::de::Error::custom(
1875                        "response content was None",
1876                    )))
1877                }
1878            }
1879            Err(err) => Err(err),
1880        }
1881    }
1882
1883    /// Create a detection rule.
1884    pub async fn create_security_monitoring_rule_with_http_info(
1885        &self,
1886        body: crate::datadogV2::model::SecurityMonitoringRuleCreatePayload,
1887    ) -> Result<
1888        datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleResponse>,
1889        datadog::Error<CreateSecurityMonitoringRuleError>,
1890    > {
1891        let local_configuration = &self.config;
1892        let operation_id = "v2.create_security_monitoring_rule";
1893
1894        let local_client = &self.client;
1895
1896        let local_uri_str = format!(
1897            "{}/api/v2/security_monitoring/rules",
1898            local_configuration.get_operation_host(operation_id)
1899        );
1900        let mut local_req_builder =
1901            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
1902
1903        // build headers
1904        let mut headers = HeaderMap::new();
1905        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1906        headers.insert("Accept", HeaderValue::from_static("application/json"));
1907
1908        // build user agent
1909        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1910            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1911            Err(e) => {
1912                log::warn!("Failed to parse user agent header: {e}, falling back to default");
1913                headers.insert(
1914                    reqwest::header::USER_AGENT,
1915                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1916                )
1917            }
1918        };
1919
1920        // build auth
1921        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1922            headers.insert(
1923                "DD-API-KEY",
1924                HeaderValue::from_str(local_key.key.as_str())
1925                    .expect("failed to parse DD-API-KEY header"),
1926            );
1927        };
1928        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1929            headers.insert(
1930                "DD-APPLICATION-KEY",
1931                HeaderValue::from_str(local_key.key.as_str())
1932                    .expect("failed to parse DD-APPLICATION-KEY header"),
1933            );
1934        };
1935
1936        // build body parameters
1937        let output = Vec::new();
1938        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1939        if body.serialize(&mut ser).is_ok() {
1940            if let Some(content_encoding) = headers.get("Content-Encoding") {
1941                match content_encoding.to_str().unwrap_or_default() {
1942                    "gzip" => {
1943                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1944                        let _ = enc.write_all(ser.into_inner().as_slice());
1945                        match enc.finish() {
1946                            Ok(buf) => {
1947                                local_req_builder = local_req_builder.body(buf);
1948                            }
1949                            Err(e) => return Err(datadog::Error::Io(e)),
1950                        }
1951                    }
1952                    "deflate" => {
1953                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1954                        let _ = enc.write_all(ser.into_inner().as_slice());
1955                        match enc.finish() {
1956                            Ok(buf) => {
1957                                local_req_builder = local_req_builder.body(buf);
1958                            }
1959                            Err(e) => return Err(datadog::Error::Io(e)),
1960                        }
1961                    }
1962                    "zstd1" => {
1963                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1964                        let _ = enc.write_all(ser.into_inner().as_slice());
1965                        match enc.finish() {
1966                            Ok(buf) => {
1967                                local_req_builder = local_req_builder.body(buf);
1968                            }
1969                            Err(e) => return Err(datadog::Error::Io(e)),
1970                        }
1971                    }
1972                    _ => {
1973                        local_req_builder = local_req_builder.body(ser.into_inner());
1974                    }
1975                }
1976            } else {
1977                local_req_builder = local_req_builder.body(ser.into_inner());
1978            }
1979        }
1980
1981        local_req_builder = local_req_builder.headers(headers);
1982        let local_req = local_req_builder.build()?;
1983        log::debug!("request content: {:?}", local_req.body());
1984        let local_resp = local_client.execute(local_req).await?;
1985
1986        let local_status = local_resp.status();
1987        let local_content = local_resp.text().await?;
1988        log::debug!("response content: {}", local_content);
1989
1990        if !local_status.is_client_error() && !local_status.is_server_error() {
1991            match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringRuleResponse>(
1992                &local_content,
1993            ) {
1994                Ok(e) => {
1995                    return Ok(datadog::ResponseContent {
1996                        status: local_status,
1997                        content: local_content,
1998                        entity: Some(e),
1999                    })
2000                }
2001                Err(e) => return Err(datadog::Error::Serde(e)),
2002            };
2003        } else {
2004            let local_entity: Option<CreateSecurityMonitoringRuleError> =
2005                serde_json::from_str(&local_content).ok();
2006            let local_error = datadog::ResponseContent {
2007                status: local_status,
2008                content: local_content,
2009                entity: local_entity,
2010            };
2011            Err(datadog::Error::ResponseError(local_error))
2012        }
2013    }
2014
2015    /// Create a new suppression rule.
2016    pub async fn create_security_monitoring_suppression(
2017        &self,
2018        body: crate::datadogV2::model::SecurityMonitoringSuppressionCreateRequest,
2019    ) -> Result<
2020        crate::datadogV2::model::SecurityMonitoringSuppressionResponse,
2021        datadog::Error<CreateSecurityMonitoringSuppressionError>,
2022    > {
2023        match self
2024            .create_security_monitoring_suppression_with_http_info(body)
2025            .await
2026        {
2027            Ok(response_content) => {
2028                if let Some(e) = response_content.entity {
2029                    Ok(e)
2030                } else {
2031                    Err(datadog::Error::Serde(serde::de::Error::custom(
2032                        "response content was None",
2033                    )))
2034                }
2035            }
2036            Err(err) => Err(err),
2037        }
2038    }
2039
2040    /// Create a new suppression rule.
2041    pub async fn create_security_monitoring_suppression_with_http_info(
2042        &self,
2043        body: crate::datadogV2::model::SecurityMonitoringSuppressionCreateRequest,
2044    ) -> Result<
2045        datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSuppressionResponse>,
2046        datadog::Error<CreateSecurityMonitoringSuppressionError>,
2047    > {
2048        let local_configuration = &self.config;
2049        let operation_id = "v2.create_security_monitoring_suppression";
2050
2051        let local_client = &self.client;
2052
2053        let local_uri_str = format!(
2054            "{}/api/v2/security_monitoring/configuration/suppressions",
2055            local_configuration.get_operation_host(operation_id)
2056        );
2057        let mut local_req_builder =
2058            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
2059
2060        // build headers
2061        let mut headers = HeaderMap::new();
2062        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
2063        headers.insert("Accept", HeaderValue::from_static("application/json"));
2064
2065        // build user agent
2066        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2067            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2068            Err(e) => {
2069                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2070                headers.insert(
2071                    reqwest::header::USER_AGENT,
2072                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2073                )
2074            }
2075        };
2076
2077        // build auth
2078        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2079            headers.insert(
2080                "DD-API-KEY",
2081                HeaderValue::from_str(local_key.key.as_str())
2082                    .expect("failed to parse DD-API-KEY header"),
2083            );
2084        };
2085        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2086            headers.insert(
2087                "DD-APPLICATION-KEY",
2088                HeaderValue::from_str(local_key.key.as_str())
2089                    .expect("failed to parse DD-APPLICATION-KEY header"),
2090            );
2091        };
2092
2093        // build body parameters
2094        let output = Vec::new();
2095        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
2096        if body.serialize(&mut ser).is_ok() {
2097            if let Some(content_encoding) = headers.get("Content-Encoding") {
2098                match content_encoding.to_str().unwrap_or_default() {
2099                    "gzip" => {
2100                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
2101                        let _ = enc.write_all(ser.into_inner().as_slice());
2102                        match enc.finish() {
2103                            Ok(buf) => {
2104                                local_req_builder = local_req_builder.body(buf);
2105                            }
2106                            Err(e) => return Err(datadog::Error::Io(e)),
2107                        }
2108                    }
2109                    "deflate" => {
2110                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
2111                        let _ = enc.write_all(ser.into_inner().as_slice());
2112                        match enc.finish() {
2113                            Ok(buf) => {
2114                                local_req_builder = local_req_builder.body(buf);
2115                            }
2116                            Err(e) => return Err(datadog::Error::Io(e)),
2117                        }
2118                    }
2119                    "zstd1" => {
2120                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
2121                        let _ = enc.write_all(ser.into_inner().as_slice());
2122                        match enc.finish() {
2123                            Ok(buf) => {
2124                                local_req_builder = local_req_builder.body(buf);
2125                            }
2126                            Err(e) => return Err(datadog::Error::Io(e)),
2127                        }
2128                    }
2129                    _ => {
2130                        local_req_builder = local_req_builder.body(ser.into_inner());
2131                    }
2132                }
2133            } else {
2134                local_req_builder = local_req_builder.body(ser.into_inner());
2135            }
2136        }
2137
2138        local_req_builder = local_req_builder.headers(headers);
2139        let local_req = local_req_builder.build()?;
2140        log::debug!("request content: {:?}", local_req.body());
2141        let local_resp = local_client.execute(local_req).await?;
2142
2143        let local_status = local_resp.status();
2144        let local_content = local_resp.text().await?;
2145        log::debug!("response content: {}", local_content);
2146
2147        if !local_status.is_client_error() && !local_status.is_server_error() {
2148            match serde_json::from_str::<
2149                crate::datadogV2::model::SecurityMonitoringSuppressionResponse,
2150            >(&local_content)
2151            {
2152                Ok(e) => {
2153                    return Ok(datadog::ResponseContent {
2154                        status: local_status,
2155                        content: local_content,
2156                        entity: Some(e),
2157                    })
2158                }
2159                Err(e) => return Err(datadog::Error::Serde(e)),
2160            };
2161        } else {
2162            let local_entity: Option<CreateSecurityMonitoringSuppressionError> =
2163                serde_json::from_str(&local_content).ok();
2164            let local_error = datadog::ResponseContent {
2165                status: local_status,
2166                content: local_content,
2167                entity: local_entity,
2168            };
2169            Err(datadog::Error::ResponseError(local_error))
2170        }
2171    }
2172
2173    /// Create a new notification rule for security signals and return the created rule.
2174    pub async fn create_signal_notification_rule(
2175        &self,
2176        body: crate::datadogV2::model::CreateNotificationRuleParameters,
2177    ) -> Result<
2178        crate::datadogV2::model::NotificationRuleResponse,
2179        datadog::Error<CreateSignalNotificationRuleError>,
2180    > {
2181        match self
2182            .create_signal_notification_rule_with_http_info(body)
2183            .await
2184        {
2185            Ok(response_content) => {
2186                if let Some(e) = response_content.entity {
2187                    Ok(e)
2188                } else {
2189                    Err(datadog::Error::Serde(serde::de::Error::custom(
2190                        "response content was None",
2191                    )))
2192                }
2193            }
2194            Err(err) => Err(err),
2195        }
2196    }
2197
2198    /// Create a new notification rule for security signals and return the created rule.
2199    pub async fn create_signal_notification_rule_with_http_info(
2200        &self,
2201        body: crate::datadogV2::model::CreateNotificationRuleParameters,
2202    ) -> Result<
2203        datadog::ResponseContent<crate::datadogV2::model::NotificationRuleResponse>,
2204        datadog::Error<CreateSignalNotificationRuleError>,
2205    > {
2206        let local_configuration = &self.config;
2207        let operation_id = "v2.create_signal_notification_rule";
2208
2209        let local_client = &self.client;
2210
2211        let local_uri_str = format!(
2212            "{}/api/v2/security/signals/notification_rules",
2213            local_configuration.get_operation_host(operation_id)
2214        );
2215        let mut local_req_builder =
2216            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
2217
2218        // build headers
2219        let mut headers = HeaderMap::new();
2220        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
2221        headers.insert("Accept", HeaderValue::from_static("application/json"));
2222
2223        // build user agent
2224        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2225            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2226            Err(e) => {
2227                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2228                headers.insert(
2229                    reqwest::header::USER_AGENT,
2230                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2231                )
2232            }
2233        };
2234
2235        // build auth
2236        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2237            headers.insert(
2238                "DD-API-KEY",
2239                HeaderValue::from_str(local_key.key.as_str())
2240                    .expect("failed to parse DD-API-KEY header"),
2241            );
2242        };
2243        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2244            headers.insert(
2245                "DD-APPLICATION-KEY",
2246                HeaderValue::from_str(local_key.key.as_str())
2247                    .expect("failed to parse DD-APPLICATION-KEY header"),
2248            );
2249        };
2250
2251        // build body parameters
2252        let output = Vec::new();
2253        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
2254        if body.serialize(&mut ser).is_ok() {
2255            if let Some(content_encoding) = headers.get("Content-Encoding") {
2256                match content_encoding.to_str().unwrap_or_default() {
2257                    "gzip" => {
2258                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
2259                        let _ = enc.write_all(ser.into_inner().as_slice());
2260                        match enc.finish() {
2261                            Ok(buf) => {
2262                                local_req_builder = local_req_builder.body(buf);
2263                            }
2264                            Err(e) => return Err(datadog::Error::Io(e)),
2265                        }
2266                    }
2267                    "deflate" => {
2268                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
2269                        let _ = enc.write_all(ser.into_inner().as_slice());
2270                        match enc.finish() {
2271                            Ok(buf) => {
2272                                local_req_builder = local_req_builder.body(buf);
2273                            }
2274                            Err(e) => return Err(datadog::Error::Io(e)),
2275                        }
2276                    }
2277                    "zstd1" => {
2278                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
2279                        let _ = enc.write_all(ser.into_inner().as_slice());
2280                        match enc.finish() {
2281                            Ok(buf) => {
2282                                local_req_builder = local_req_builder.body(buf);
2283                            }
2284                            Err(e) => return Err(datadog::Error::Io(e)),
2285                        }
2286                    }
2287                    _ => {
2288                        local_req_builder = local_req_builder.body(ser.into_inner());
2289                    }
2290                }
2291            } else {
2292                local_req_builder = local_req_builder.body(ser.into_inner());
2293            }
2294        }
2295
2296        local_req_builder = local_req_builder.headers(headers);
2297        let local_req = local_req_builder.build()?;
2298        log::debug!("request content: {:?}", local_req.body());
2299        let local_resp = local_client.execute(local_req).await?;
2300
2301        let local_status = local_resp.status();
2302        let local_content = local_resp.text().await?;
2303        log::debug!("response content: {}", local_content);
2304
2305        if !local_status.is_client_error() && !local_status.is_server_error() {
2306            match serde_json::from_str::<crate::datadogV2::model::NotificationRuleResponse>(
2307                &local_content,
2308            ) {
2309                Ok(e) => {
2310                    return Ok(datadog::ResponseContent {
2311                        status: local_status,
2312                        content: local_content,
2313                        entity: Some(e),
2314                    })
2315                }
2316                Err(e) => return Err(datadog::Error::Serde(e)),
2317            };
2318        } else {
2319            let local_entity: Option<CreateSignalNotificationRuleError> =
2320                serde_json::from_str(&local_content).ok();
2321            let local_error = datadog::ResponseContent {
2322                status: local_status,
2323                content: local_content,
2324                entity: local_entity,
2325            };
2326            Err(datadog::Error::ResponseError(local_error))
2327        }
2328    }
2329
2330    /// Create a new notification rule for security vulnerabilities and return the created rule.
2331    pub async fn create_vulnerability_notification_rule(
2332        &self,
2333        body: crate::datadogV2::model::CreateNotificationRuleParameters,
2334    ) -> Result<
2335        crate::datadogV2::model::NotificationRuleResponse,
2336        datadog::Error<CreateVulnerabilityNotificationRuleError>,
2337    > {
2338        match self
2339            .create_vulnerability_notification_rule_with_http_info(body)
2340            .await
2341        {
2342            Ok(response_content) => {
2343                if let Some(e) = response_content.entity {
2344                    Ok(e)
2345                } else {
2346                    Err(datadog::Error::Serde(serde::de::Error::custom(
2347                        "response content was None",
2348                    )))
2349                }
2350            }
2351            Err(err) => Err(err),
2352        }
2353    }
2354
2355    /// Create a new notification rule for security vulnerabilities and return the created rule.
2356    pub async fn create_vulnerability_notification_rule_with_http_info(
2357        &self,
2358        body: crate::datadogV2::model::CreateNotificationRuleParameters,
2359    ) -> Result<
2360        datadog::ResponseContent<crate::datadogV2::model::NotificationRuleResponse>,
2361        datadog::Error<CreateVulnerabilityNotificationRuleError>,
2362    > {
2363        let local_configuration = &self.config;
2364        let operation_id = "v2.create_vulnerability_notification_rule";
2365
2366        let local_client = &self.client;
2367
2368        let local_uri_str = format!(
2369            "{}/api/v2/security/vulnerabilities/notification_rules",
2370            local_configuration.get_operation_host(operation_id)
2371        );
2372        let mut local_req_builder =
2373            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
2374
2375        // build headers
2376        let mut headers = HeaderMap::new();
2377        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
2378        headers.insert("Accept", HeaderValue::from_static("application/json"));
2379
2380        // build user agent
2381        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2382            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2383            Err(e) => {
2384                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2385                headers.insert(
2386                    reqwest::header::USER_AGENT,
2387                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2388                )
2389            }
2390        };
2391
2392        // build auth
2393        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2394            headers.insert(
2395                "DD-API-KEY",
2396                HeaderValue::from_str(local_key.key.as_str())
2397                    .expect("failed to parse DD-API-KEY header"),
2398            );
2399        };
2400        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2401            headers.insert(
2402                "DD-APPLICATION-KEY",
2403                HeaderValue::from_str(local_key.key.as_str())
2404                    .expect("failed to parse DD-APPLICATION-KEY header"),
2405            );
2406        };
2407
2408        // build body parameters
2409        let output = Vec::new();
2410        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
2411        if body.serialize(&mut ser).is_ok() {
2412            if let Some(content_encoding) = headers.get("Content-Encoding") {
2413                match content_encoding.to_str().unwrap_or_default() {
2414                    "gzip" => {
2415                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
2416                        let _ = enc.write_all(ser.into_inner().as_slice());
2417                        match enc.finish() {
2418                            Ok(buf) => {
2419                                local_req_builder = local_req_builder.body(buf);
2420                            }
2421                            Err(e) => return Err(datadog::Error::Io(e)),
2422                        }
2423                    }
2424                    "deflate" => {
2425                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
2426                        let _ = enc.write_all(ser.into_inner().as_slice());
2427                        match enc.finish() {
2428                            Ok(buf) => {
2429                                local_req_builder = local_req_builder.body(buf);
2430                            }
2431                            Err(e) => return Err(datadog::Error::Io(e)),
2432                        }
2433                    }
2434                    "zstd1" => {
2435                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
2436                        let _ = enc.write_all(ser.into_inner().as_slice());
2437                        match enc.finish() {
2438                            Ok(buf) => {
2439                                local_req_builder = local_req_builder.body(buf);
2440                            }
2441                            Err(e) => return Err(datadog::Error::Io(e)),
2442                        }
2443                    }
2444                    _ => {
2445                        local_req_builder = local_req_builder.body(ser.into_inner());
2446                    }
2447                }
2448            } else {
2449                local_req_builder = local_req_builder.body(ser.into_inner());
2450            }
2451        }
2452
2453        local_req_builder = local_req_builder.headers(headers);
2454        let local_req = local_req_builder.build()?;
2455        log::debug!("request content: {:?}", local_req.body());
2456        let local_resp = local_client.execute(local_req).await?;
2457
2458        let local_status = local_resp.status();
2459        let local_content = local_resp.text().await?;
2460        log::debug!("response content: {}", local_content);
2461
2462        if !local_status.is_client_error() && !local_status.is_server_error() {
2463            match serde_json::from_str::<crate::datadogV2::model::NotificationRuleResponse>(
2464                &local_content,
2465            ) {
2466                Ok(e) => {
2467                    return Ok(datadog::ResponseContent {
2468                        status: local_status,
2469                        content: local_content,
2470                        entity: Some(e),
2471                    })
2472                }
2473                Err(e) => return Err(datadog::Error::Serde(e)),
2474            };
2475        } else {
2476            let local_entity: Option<CreateVulnerabilityNotificationRuleError> =
2477                serde_json::from_str(&local_content).ok();
2478            let local_error = datadog::ResponseContent {
2479                status: local_status,
2480                content: local_content,
2481                entity: local_entity,
2482            };
2483            Err(datadog::Error::ResponseError(local_error))
2484        }
2485    }
2486
2487    /// Delete an existing job.
2488    pub async fn delete_historical_job(
2489        &self,
2490        job_id: String,
2491    ) -> Result<(), datadog::Error<DeleteHistoricalJobError>> {
2492        match self.delete_historical_job_with_http_info(job_id).await {
2493            Ok(_) => Ok(()),
2494            Err(err) => Err(err),
2495        }
2496    }
2497
2498    /// Delete an existing job.
2499    pub async fn delete_historical_job_with_http_info(
2500        &self,
2501        job_id: String,
2502    ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteHistoricalJobError>> {
2503        let local_configuration = &self.config;
2504        let operation_id = "v2.delete_historical_job";
2505        if local_configuration.is_unstable_operation_enabled(operation_id) {
2506            warn!("Using unstable operation {operation_id}");
2507        } else {
2508            let local_error = datadog::UnstableOperationDisabledError {
2509                msg: "Operation 'v2.delete_historical_job' is not enabled".to_string(),
2510            };
2511            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
2512        }
2513
2514        let local_client = &self.client;
2515
2516        let local_uri_str = format!(
2517            "{}/api/v2/siem-historical-detections/jobs/{job_id}",
2518            local_configuration.get_operation_host(operation_id),
2519            job_id = datadog::urlencode(job_id)
2520        );
2521        let mut local_req_builder =
2522            local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
2523
2524        // build headers
2525        let mut headers = HeaderMap::new();
2526        headers.insert("Accept", HeaderValue::from_static("*/*"));
2527
2528        // build user agent
2529        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2530            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2531            Err(e) => {
2532                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2533                headers.insert(
2534                    reqwest::header::USER_AGENT,
2535                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2536                )
2537            }
2538        };
2539
2540        // build auth
2541        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2542            headers.insert(
2543                "DD-API-KEY",
2544                HeaderValue::from_str(local_key.key.as_str())
2545                    .expect("failed to parse DD-API-KEY header"),
2546            );
2547        };
2548        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2549            headers.insert(
2550                "DD-APPLICATION-KEY",
2551                HeaderValue::from_str(local_key.key.as_str())
2552                    .expect("failed to parse DD-APPLICATION-KEY header"),
2553            );
2554        };
2555
2556        local_req_builder = local_req_builder.headers(headers);
2557        let local_req = local_req_builder.build()?;
2558        log::debug!("request content: {:?}", local_req.body());
2559        let local_resp = local_client.execute(local_req).await?;
2560
2561        let local_status = local_resp.status();
2562        let local_content = local_resp.text().await?;
2563        log::debug!("response content: {}", local_content);
2564
2565        if !local_status.is_client_error() && !local_status.is_server_error() {
2566            Ok(datadog::ResponseContent {
2567                status: local_status,
2568                content: local_content,
2569                entity: None,
2570            })
2571        } else {
2572            let local_entity: Option<DeleteHistoricalJobError> =
2573                serde_json::from_str(&local_content).ok();
2574            let local_error = datadog::ResponseContent {
2575                status: local_status,
2576                content: local_content,
2577                entity: local_entity,
2578            };
2579            Err(datadog::Error::ResponseError(local_error))
2580        }
2581    }
2582
2583    /// Delete a specific security filter.
2584    pub async fn delete_security_filter(
2585        &self,
2586        security_filter_id: String,
2587    ) -> Result<(), datadog::Error<DeleteSecurityFilterError>> {
2588        match self
2589            .delete_security_filter_with_http_info(security_filter_id)
2590            .await
2591        {
2592            Ok(_) => Ok(()),
2593            Err(err) => Err(err),
2594        }
2595    }
2596
2597    /// Delete a specific security filter.
2598    pub async fn delete_security_filter_with_http_info(
2599        &self,
2600        security_filter_id: String,
2601    ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteSecurityFilterError>> {
2602        let local_configuration = &self.config;
2603        let operation_id = "v2.delete_security_filter";
2604
2605        let local_client = &self.client;
2606
2607        let local_uri_str = format!(
2608            "{}/api/v2/security_monitoring/configuration/security_filters/{security_filter_id}",
2609            local_configuration.get_operation_host(operation_id),
2610            security_filter_id = datadog::urlencode(security_filter_id)
2611        );
2612        let mut local_req_builder =
2613            local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
2614
2615        // build headers
2616        let mut headers = HeaderMap::new();
2617        headers.insert("Accept", HeaderValue::from_static("*/*"));
2618
2619        // build user agent
2620        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2621            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2622            Err(e) => {
2623                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2624                headers.insert(
2625                    reqwest::header::USER_AGENT,
2626                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2627                )
2628            }
2629        };
2630
2631        // build auth
2632        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2633            headers.insert(
2634                "DD-API-KEY",
2635                HeaderValue::from_str(local_key.key.as_str())
2636                    .expect("failed to parse DD-API-KEY header"),
2637            );
2638        };
2639        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2640            headers.insert(
2641                "DD-APPLICATION-KEY",
2642                HeaderValue::from_str(local_key.key.as_str())
2643                    .expect("failed to parse DD-APPLICATION-KEY header"),
2644            );
2645        };
2646
2647        local_req_builder = local_req_builder.headers(headers);
2648        let local_req = local_req_builder.build()?;
2649        log::debug!("request content: {:?}", local_req.body());
2650        let local_resp = local_client.execute(local_req).await?;
2651
2652        let local_status = local_resp.status();
2653        let local_content = local_resp.text().await?;
2654        log::debug!("response content: {}", local_content);
2655
2656        if !local_status.is_client_error() && !local_status.is_server_error() {
2657            Ok(datadog::ResponseContent {
2658                status: local_status,
2659                content: local_content,
2660                entity: None,
2661            })
2662        } else {
2663            let local_entity: Option<DeleteSecurityFilterError> =
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    /// Delete an existing rule. Default rules cannot be deleted.
2675    pub async fn delete_security_monitoring_rule(
2676        &self,
2677        rule_id: String,
2678    ) -> Result<(), datadog::Error<DeleteSecurityMonitoringRuleError>> {
2679        match self
2680            .delete_security_monitoring_rule_with_http_info(rule_id)
2681            .await
2682        {
2683            Ok(_) => Ok(()),
2684            Err(err) => Err(err),
2685        }
2686    }
2687
2688    /// Delete an existing rule. Default rules cannot be deleted.
2689    pub async fn delete_security_monitoring_rule_with_http_info(
2690        &self,
2691        rule_id: String,
2692    ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteSecurityMonitoringRuleError>>
2693    {
2694        let local_configuration = &self.config;
2695        let operation_id = "v2.delete_security_monitoring_rule";
2696
2697        let local_client = &self.client;
2698
2699        let local_uri_str = format!(
2700            "{}/api/v2/security_monitoring/rules/{rule_id}",
2701            local_configuration.get_operation_host(operation_id),
2702            rule_id = datadog::urlencode(rule_id)
2703        );
2704        let mut local_req_builder =
2705            local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
2706
2707        // build headers
2708        let mut headers = HeaderMap::new();
2709        headers.insert("Accept", HeaderValue::from_static("*/*"));
2710
2711        // build user agent
2712        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2713            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2714            Err(e) => {
2715                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2716                headers.insert(
2717                    reqwest::header::USER_AGENT,
2718                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2719                )
2720            }
2721        };
2722
2723        // build auth
2724        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2725            headers.insert(
2726                "DD-API-KEY",
2727                HeaderValue::from_str(local_key.key.as_str())
2728                    .expect("failed to parse DD-API-KEY header"),
2729            );
2730        };
2731        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2732            headers.insert(
2733                "DD-APPLICATION-KEY",
2734                HeaderValue::from_str(local_key.key.as_str())
2735                    .expect("failed to parse DD-APPLICATION-KEY header"),
2736            );
2737        };
2738
2739        local_req_builder = local_req_builder.headers(headers);
2740        let local_req = local_req_builder.build()?;
2741        log::debug!("request content: {:?}", local_req.body());
2742        let local_resp = local_client.execute(local_req).await?;
2743
2744        let local_status = local_resp.status();
2745        let local_content = local_resp.text().await?;
2746        log::debug!("response content: {}", local_content);
2747
2748        if !local_status.is_client_error() && !local_status.is_server_error() {
2749            Ok(datadog::ResponseContent {
2750                status: local_status,
2751                content: local_content,
2752                entity: None,
2753            })
2754        } else {
2755            let local_entity: Option<DeleteSecurityMonitoringRuleError> =
2756                serde_json::from_str(&local_content).ok();
2757            let local_error = datadog::ResponseContent {
2758                status: local_status,
2759                content: local_content,
2760                entity: local_entity,
2761            };
2762            Err(datadog::Error::ResponseError(local_error))
2763        }
2764    }
2765
2766    /// Delete a specific suppression rule.
2767    pub async fn delete_security_monitoring_suppression(
2768        &self,
2769        suppression_id: String,
2770    ) -> Result<(), datadog::Error<DeleteSecurityMonitoringSuppressionError>> {
2771        match self
2772            .delete_security_monitoring_suppression_with_http_info(suppression_id)
2773            .await
2774        {
2775            Ok(_) => Ok(()),
2776            Err(err) => Err(err),
2777        }
2778    }
2779
2780    /// Delete a specific suppression rule.
2781    pub async fn delete_security_monitoring_suppression_with_http_info(
2782        &self,
2783        suppression_id: String,
2784    ) -> Result<
2785        datadog::ResponseContent<()>,
2786        datadog::Error<DeleteSecurityMonitoringSuppressionError>,
2787    > {
2788        let local_configuration = &self.config;
2789        let operation_id = "v2.delete_security_monitoring_suppression";
2790
2791        let local_client = &self.client;
2792
2793        let local_uri_str = format!(
2794            "{}/api/v2/security_monitoring/configuration/suppressions/{suppression_id}",
2795            local_configuration.get_operation_host(operation_id),
2796            suppression_id = datadog::urlencode(suppression_id)
2797        );
2798        let mut local_req_builder =
2799            local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
2800
2801        // build headers
2802        let mut headers = HeaderMap::new();
2803        headers.insert("Accept", HeaderValue::from_static("*/*"));
2804
2805        // build user agent
2806        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2807            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2808            Err(e) => {
2809                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2810                headers.insert(
2811                    reqwest::header::USER_AGENT,
2812                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2813                )
2814            }
2815        };
2816
2817        // build auth
2818        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2819            headers.insert(
2820                "DD-API-KEY",
2821                HeaderValue::from_str(local_key.key.as_str())
2822                    .expect("failed to parse DD-API-KEY header"),
2823            );
2824        };
2825        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2826            headers.insert(
2827                "DD-APPLICATION-KEY",
2828                HeaderValue::from_str(local_key.key.as_str())
2829                    .expect("failed to parse DD-APPLICATION-KEY header"),
2830            );
2831        };
2832
2833        local_req_builder = local_req_builder.headers(headers);
2834        let local_req = local_req_builder.build()?;
2835        log::debug!("request content: {:?}", local_req.body());
2836        let local_resp = local_client.execute(local_req).await?;
2837
2838        let local_status = local_resp.status();
2839        let local_content = local_resp.text().await?;
2840        log::debug!("response content: {}", local_content);
2841
2842        if !local_status.is_client_error() && !local_status.is_server_error() {
2843            Ok(datadog::ResponseContent {
2844                status: local_status,
2845                content: local_content,
2846                entity: None,
2847            })
2848        } else {
2849            let local_entity: Option<DeleteSecurityMonitoringSuppressionError> =
2850                serde_json::from_str(&local_content).ok();
2851            let local_error = datadog::ResponseContent {
2852                status: local_status,
2853                content: local_content,
2854                entity: local_entity,
2855            };
2856            Err(datadog::Error::ResponseError(local_error))
2857        }
2858    }
2859
2860    /// Delete a notification rule for security signals.
2861    pub async fn delete_signal_notification_rule(
2862        &self,
2863        id: String,
2864    ) -> Result<(), datadog::Error<DeleteSignalNotificationRuleError>> {
2865        match self
2866            .delete_signal_notification_rule_with_http_info(id)
2867            .await
2868        {
2869            Ok(_) => Ok(()),
2870            Err(err) => Err(err),
2871        }
2872    }
2873
2874    /// Delete a notification rule for security signals.
2875    pub async fn delete_signal_notification_rule_with_http_info(
2876        &self,
2877        id: String,
2878    ) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteSignalNotificationRuleError>>
2879    {
2880        let local_configuration = &self.config;
2881        let operation_id = "v2.delete_signal_notification_rule";
2882
2883        let local_client = &self.client;
2884
2885        let local_uri_str = format!(
2886            "{}/api/v2/security/signals/notification_rules/{id}",
2887            local_configuration.get_operation_host(operation_id),
2888            id = datadog::urlencode(id)
2889        );
2890        let mut local_req_builder =
2891            local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
2892
2893        // build headers
2894        let mut headers = HeaderMap::new();
2895        headers.insert("Accept", HeaderValue::from_static("*/*"));
2896
2897        // build user agent
2898        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2899            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2900            Err(e) => {
2901                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2902                headers.insert(
2903                    reqwest::header::USER_AGENT,
2904                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2905                )
2906            }
2907        };
2908
2909        // build auth
2910        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
2911            headers.insert(
2912                "DD-API-KEY",
2913                HeaderValue::from_str(local_key.key.as_str())
2914                    .expect("failed to parse DD-API-KEY header"),
2915            );
2916        };
2917        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
2918            headers.insert(
2919                "DD-APPLICATION-KEY",
2920                HeaderValue::from_str(local_key.key.as_str())
2921                    .expect("failed to parse DD-APPLICATION-KEY header"),
2922            );
2923        };
2924
2925        local_req_builder = local_req_builder.headers(headers);
2926        let local_req = local_req_builder.build()?;
2927        log::debug!("request content: {:?}", local_req.body());
2928        let local_resp = local_client.execute(local_req).await?;
2929
2930        let local_status = local_resp.status();
2931        let local_content = local_resp.text().await?;
2932        log::debug!("response content: {}", local_content);
2933
2934        if !local_status.is_client_error() && !local_status.is_server_error() {
2935            Ok(datadog::ResponseContent {
2936                status: local_status,
2937                content: local_content,
2938                entity: None,
2939            })
2940        } else {
2941            let local_entity: Option<DeleteSignalNotificationRuleError> =
2942                serde_json::from_str(&local_content).ok();
2943            let local_error = datadog::ResponseContent {
2944                status: local_status,
2945                content: local_content,
2946                entity: local_entity,
2947            };
2948            Err(datadog::Error::ResponseError(local_error))
2949        }
2950    }
2951
2952    /// Delete a notification rule for security vulnerabilities.
2953    pub async fn delete_vulnerability_notification_rule(
2954        &self,
2955        id: String,
2956    ) -> Result<(), datadog::Error<DeleteVulnerabilityNotificationRuleError>> {
2957        match self
2958            .delete_vulnerability_notification_rule_with_http_info(id)
2959            .await
2960        {
2961            Ok(_) => Ok(()),
2962            Err(err) => Err(err),
2963        }
2964    }
2965
2966    /// Delete a notification rule for security vulnerabilities.
2967    pub async fn delete_vulnerability_notification_rule_with_http_info(
2968        &self,
2969        id: String,
2970    ) -> Result<
2971        datadog::ResponseContent<()>,
2972        datadog::Error<DeleteVulnerabilityNotificationRuleError>,
2973    > {
2974        let local_configuration = &self.config;
2975        let operation_id = "v2.delete_vulnerability_notification_rule";
2976
2977        let local_client = &self.client;
2978
2979        let local_uri_str = format!(
2980            "{}/api/v2/security/vulnerabilities/notification_rules/{id}",
2981            local_configuration.get_operation_host(operation_id),
2982            id = datadog::urlencode(id)
2983        );
2984        let mut local_req_builder =
2985            local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
2986
2987        // build headers
2988        let mut headers = HeaderMap::new();
2989        headers.insert("Accept", HeaderValue::from_static("*/*"));
2990
2991        // build user agent
2992        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
2993            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
2994            Err(e) => {
2995                log::warn!("Failed to parse user agent header: {e}, falling back to default");
2996                headers.insert(
2997                    reqwest::header::USER_AGENT,
2998                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
2999                )
3000            }
3001        };
3002
3003        // build auth
3004        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3005            headers.insert(
3006                "DD-API-KEY",
3007                HeaderValue::from_str(local_key.key.as_str())
3008                    .expect("failed to parse DD-API-KEY header"),
3009            );
3010        };
3011        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3012            headers.insert(
3013                "DD-APPLICATION-KEY",
3014                HeaderValue::from_str(local_key.key.as_str())
3015                    .expect("failed to parse DD-APPLICATION-KEY header"),
3016            );
3017        };
3018
3019        local_req_builder = local_req_builder.headers(headers);
3020        let local_req = local_req_builder.build()?;
3021        log::debug!("request content: {:?}", local_req.body());
3022        let local_resp = local_client.execute(local_req).await?;
3023
3024        let local_status = local_resp.status();
3025        let local_content = local_resp.text().await?;
3026        log::debug!("response content: {}", local_content);
3027
3028        if !local_status.is_client_error() && !local_status.is_server_error() {
3029            Ok(datadog::ResponseContent {
3030                status: local_status,
3031                content: local_content,
3032                entity: None,
3033            })
3034        } else {
3035            let local_entity: Option<DeleteVulnerabilityNotificationRuleError> =
3036                serde_json::from_str(&local_content).ok();
3037            let local_error = datadog::ResponseContent {
3038                status: local_status,
3039                content: local_content,
3040                entity: local_entity,
3041            };
3042            Err(datadog::Error::ResponseError(local_error))
3043        }
3044    }
3045
3046    /// Modify the triage assignee of a security signal.
3047    pub async fn edit_security_monitoring_signal_assignee(
3048        &self,
3049        signal_id: String,
3050        body: crate::datadogV2::model::SecurityMonitoringSignalAssigneeUpdateRequest,
3051    ) -> Result<
3052        crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
3053        datadog::Error<EditSecurityMonitoringSignalAssigneeError>,
3054    > {
3055        match self
3056            .edit_security_monitoring_signal_assignee_with_http_info(signal_id, body)
3057            .await
3058        {
3059            Ok(response_content) => {
3060                if let Some(e) = response_content.entity {
3061                    Ok(e)
3062                } else {
3063                    Err(datadog::Error::Serde(serde::de::Error::custom(
3064                        "response content was None",
3065                    )))
3066                }
3067            }
3068            Err(err) => Err(err),
3069        }
3070    }
3071
3072    /// Modify the triage assignee of a security signal.
3073    pub async fn edit_security_monitoring_signal_assignee_with_http_info(
3074        &self,
3075        signal_id: String,
3076        body: crate::datadogV2::model::SecurityMonitoringSignalAssigneeUpdateRequest,
3077    ) -> Result<
3078        datadog::ResponseContent<
3079            crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
3080        >,
3081        datadog::Error<EditSecurityMonitoringSignalAssigneeError>,
3082    > {
3083        let local_configuration = &self.config;
3084        let operation_id = "v2.edit_security_monitoring_signal_assignee";
3085
3086        let local_client = &self.client;
3087
3088        let local_uri_str = format!(
3089            "{}/api/v2/security_monitoring/signals/{signal_id}/assignee",
3090            local_configuration.get_operation_host(operation_id),
3091            signal_id = datadog::urlencode(signal_id)
3092        );
3093        let mut local_req_builder =
3094            local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
3095
3096        // build headers
3097        let mut headers = HeaderMap::new();
3098        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
3099        headers.insert("Accept", HeaderValue::from_static("application/json"));
3100
3101        // build user agent
3102        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3103            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3104            Err(e) => {
3105                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3106                headers.insert(
3107                    reqwest::header::USER_AGENT,
3108                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3109                )
3110            }
3111        };
3112
3113        // build auth
3114        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3115            headers.insert(
3116                "DD-API-KEY",
3117                HeaderValue::from_str(local_key.key.as_str())
3118                    .expect("failed to parse DD-API-KEY header"),
3119            );
3120        };
3121        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3122            headers.insert(
3123                "DD-APPLICATION-KEY",
3124                HeaderValue::from_str(local_key.key.as_str())
3125                    .expect("failed to parse DD-APPLICATION-KEY header"),
3126            );
3127        };
3128
3129        // build body parameters
3130        let output = Vec::new();
3131        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
3132        if body.serialize(&mut ser).is_ok() {
3133            if let Some(content_encoding) = headers.get("Content-Encoding") {
3134                match content_encoding.to_str().unwrap_or_default() {
3135                    "gzip" => {
3136                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
3137                        let _ = enc.write_all(ser.into_inner().as_slice());
3138                        match enc.finish() {
3139                            Ok(buf) => {
3140                                local_req_builder = local_req_builder.body(buf);
3141                            }
3142                            Err(e) => return Err(datadog::Error::Io(e)),
3143                        }
3144                    }
3145                    "deflate" => {
3146                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
3147                        let _ = enc.write_all(ser.into_inner().as_slice());
3148                        match enc.finish() {
3149                            Ok(buf) => {
3150                                local_req_builder = local_req_builder.body(buf);
3151                            }
3152                            Err(e) => return Err(datadog::Error::Io(e)),
3153                        }
3154                    }
3155                    "zstd1" => {
3156                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
3157                        let _ = enc.write_all(ser.into_inner().as_slice());
3158                        match enc.finish() {
3159                            Ok(buf) => {
3160                                local_req_builder = local_req_builder.body(buf);
3161                            }
3162                            Err(e) => return Err(datadog::Error::Io(e)),
3163                        }
3164                    }
3165                    _ => {
3166                        local_req_builder = local_req_builder.body(ser.into_inner());
3167                    }
3168                }
3169            } else {
3170                local_req_builder = local_req_builder.body(ser.into_inner());
3171            }
3172        }
3173
3174        local_req_builder = local_req_builder.headers(headers);
3175        let local_req = local_req_builder.build()?;
3176        log::debug!("request content: {:?}", local_req.body());
3177        let local_resp = local_client.execute(local_req).await?;
3178
3179        let local_status = local_resp.status();
3180        let local_content = local_resp.text().await?;
3181        log::debug!("response content: {}", local_content);
3182
3183        if !local_status.is_client_error() && !local_status.is_server_error() {
3184            match serde_json::from_str::<
3185                crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
3186            >(&local_content)
3187            {
3188                Ok(e) => {
3189                    return Ok(datadog::ResponseContent {
3190                        status: local_status,
3191                        content: local_content,
3192                        entity: Some(e),
3193                    })
3194                }
3195                Err(e) => return Err(datadog::Error::Serde(e)),
3196            };
3197        } else {
3198            let local_entity: Option<EditSecurityMonitoringSignalAssigneeError> =
3199                serde_json::from_str(&local_content).ok();
3200            let local_error = datadog::ResponseContent {
3201                status: local_status,
3202                content: local_content,
3203                entity: local_entity,
3204            };
3205            Err(datadog::Error::ResponseError(local_error))
3206        }
3207    }
3208
3209    /// Change the related incidents for a security signal.
3210    pub async fn edit_security_monitoring_signal_incidents(
3211        &self,
3212        signal_id: String,
3213        body: crate::datadogV2::model::SecurityMonitoringSignalIncidentsUpdateRequest,
3214    ) -> Result<
3215        crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
3216        datadog::Error<EditSecurityMonitoringSignalIncidentsError>,
3217    > {
3218        match self
3219            .edit_security_monitoring_signal_incidents_with_http_info(signal_id, body)
3220            .await
3221        {
3222            Ok(response_content) => {
3223                if let Some(e) = response_content.entity {
3224                    Ok(e)
3225                } else {
3226                    Err(datadog::Error::Serde(serde::de::Error::custom(
3227                        "response content was None",
3228                    )))
3229                }
3230            }
3231            Err(err) => Err(err),
3232        }
3233    }
3234
3235    /// Change the related incidents for a security signal.
3236    pub async fn edit_security_monitoring_signal_incidents_with_http_info(
3237        &self,
3238        signal_id: String,
3239        body: crate::datadogV2::model::SecurityMonitoringSignalIncidentsUpdateRequest,
3240    ) -> Result<
3241        datadog::ResponseContent<
3242            crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
3243        >,
3244        datadog::Error<EditSecurityMonitoringSignalIncidentsError>,
3245    > {
3246        let local_configuration = &self.config;
3247        let operation_id = "v2.edit_security_monitoring_signal_incidents";
3248
3249        let local_client = &self.client;
3250
3251        let local_uri_str = format!(
3252            "{}/api/v2/security_monitoring/signals/{signal_id}/incidents",
3253            local_configuration.get_operation_host(operation_id),
3254            signal_id = datadog::urlencode(signal_id)
3255        );
3256        let mut local_req_builder =
3257            local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
3258
3259        // build headers
3260        let mut headers = HeaderMap::new();
3261        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
3262        headers.insert("Accept", HeaderValue::from_static("application/json"));
3263
3264        // build user agent
3265        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        // build auth
3277        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        // build body parameters
3293        let output = Vec::new();
3294        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
3295        if body.serialize(&mut ser).is_ok() {
3296            if let Some(content_encoding) = headers.get("Content-Encoding") {
3297                match content_encoding.to_str().unwrap_or_default() {
3298                    "gzip" => {
3299                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
3300                        let _ = enc.write_all(ser.into_inner().as_slice());
3301                        match enc.finish() {
3302                            Ok(buf) => {
3303                                local_req_builder = local_req_builder.body(buf);
3304                            }
3305                            Err(e) => return Err(datadog::Error::Io(e)),
3306                        }
3307                    }
3308                    "deflate" => {
3309                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
3310                        let _ = enc.write_all(ser.into_inner().as_slice());
3311                        match enc.finish() {
3312                            Ok(buf) => {
3313                                local_req_builder = local_req_builder.body(buf);
3314                            }
3315                            Err(e) => return Err(datadog::Error::Io(e)),
3316                        }
3317                    }
3318                    "zstd1" => {
3319                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
3320                        let _ = enc.write_all(ser.into_inner().as_slice());
3321                        match enc.finish() {
3322                            Ok(buf) => {
3323                                local_req_builder = local_req_builder.body(buf);
3324                            }
3325                            Err(e) => return Err(datadog::Error::Io(e)),
3326                        }
3327                    }
3328                    _ => {
3329                        local_req_builder = local_req_builder.body(ser.into_inner());
3330                    }
3331                }
3332            } else {
3333                local_req_builder = local_req_builder.body(ser.into_inner());
3334            }
3335        }
3336
3337        local_req_builder = local_req_builder.headers(headers);
3338        let local_req = local_req_builder.build()?;
3339        log::debug!("request content: {:?}", local_req.body());
3340        let local_resp = local_client.execute(local_req).await?;
3341
3342        let local_status = local_resp.status();
3343        let local_content = local_resp.text().await?;
3344        log::debug!("response content: {}", local_content);
3345
3346        if !local_status.is_client_error() && !local_status.is_server_error() {
3347            match serde_json::from_str::<
3348                crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
3349            >(&local_content)
3350            {
3351                Ok(e) => {
3352                    return Ok(datadog::ResponseContent {
3353                        status: local_status,
3354                        content: local_content,
3355                        entity: Some(e),
3356                    })
3357                }
3358                Err(e) => return Err(datadog::Error::Serde(e)),
3359            };
3360        } else {
3361            let local_entity: Option<EditSecurityMonitoringSignalIncidentsError> =
3362                serde_json::from_str(&local_content).ok();
3363            let local_error = datadog::ResponseContent {
3364                status: local_status,
3365                content: local_content,
3366                entity: local_entity,
3367            };
3368            Err(datadog::Error::ResponseError(local_error))
3369        }
3370    }
3371
3372    /// Change the triage state of a security signal.
3373    pub async fn edit_security_monitoring_signal_state(
3374        &self,
3375        signal_id: String,
3376        body: crate::datadogV2::model::SecurityMonitoringSignalStateUpdateRequest,
3377    ) -> Result<
3378        crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
3379        datadog::Error<EditSecurityMonitoringSignalStateError>,
3380    > {
3381        match self
3382            .edit_security_monitoring_signal_state_with_http_info(signal_id, body)
3383            .await
3384        {
3385            Ok(response_content) => {
3386                if let Some(e) = response_content.entity {
3387                    Ok(e)
3388                } else {
3389                    Err(datadog::Error::Serde(serde::de::Error::custom(
3390                        "response content was None",
3391                    )))
3392                }
3393            }
3394            Err(err) => Err(err),
3395        }
3396    }
3397
3398    /// Change the triage state of a security signal.
3399    pub async fn edit_security_monitoring_signal_state_with_http_info(
3400        &self,
3401        signal_id: String,
3402        body: crate::datadogV2::model::SecurityMonitoringSignalStateUpdateRequest,
3403    ) -> Result<
3404        datadog::ResponseContent<
3405            crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
3406        >,
3407        datadog::Error<EditSecurityMonitoringSignalStateError>,
3408    > {
3409        let local_configuration = &self.config;
3410        let operation_id = "v2.edit_security_monitoring_signal_state";
3411
3412        let local_client = &self.client;
3413
3414        let local_uri_str = format!(
3415            "{}/api/v2/security_monitoring/signals/{signal_id}/state",
3416            local_configuration.get_operation_host(operation_id),
3417            signal_id = datadog::urlencode(signal_id)
3418        );
3419        let mut local_req_builder =
3420            local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
3421
3422        // build headers
3423        let mut headers = HeaderMap::new();
3424        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
3425        headers.insert("Accept", HeaderValue::from_static("application/json"));
3426
3427        // build user agent
3428        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3429            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3430            Err(e) => {
3431                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3432                headers.insert(
3433                    reqwest::header::USER_AGENT,
3434                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3435                )
3436            }
3437        };
3438
3439        // build auth
3440        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3441            headers.insert(
3442                "DD-API-KEY",
3443                HeaderValue::from_str(local_key.key.as_str())
3444                    .expect("failed to parse DD-API-KEY header"),
3445            );
3446        };
3447        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3448            headers.insert(
3449                "DD-APPLICATION-KEY",
3450                HeaderValue::from_str(local_key.key.as_str())
3451                    .expect("failed to parse DD-APPLICATION-KEY header"),
3452            );
3453        };
3454
3455        // build body parameters
3456        let output = Vec::new();
3457        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
3458        if body.serialize(&mut ser).is_ok() {
3459            if let Some(content_encoding) = headers.get("Content-Encoding") {
3460                match content_encoding.to_str().unwrap_or_default() {
3461                    "gzip" => {
3462                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
3463                        let _ = enc.write_all(ser.into_inner().as_slice());
3464                        match enc.finish() {
3465                            Ok(buf) => {
3466                                local_req_builder = local_req_builder.body(buf);
3467                            }
3468                            Err(e) => return Err(datadog::Error::Io(e)),
3469                        }
3470                    }
3471                    "deflate" => {
3472                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
3473                        let _ = enc.write_all(ser.into_inner().as_slice());
3474                        match enc.finish() {
3475                            Ok(buf) => {
3476                                local_req_builder = local_req_builder.body(buf);
3477                            }
3478                            Err(e) => return Err(datadog::Error::Io(e)),
3479                        }
3480                    }
3481                    "zstd1" => {
3482                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
3483                        let _ = enc.write_all(ser.into_inner().as_slice());
3484                        match enc.finish() {
3485                            Ok(buf) => {
3486                                local_req_builder = local_req_builder.body(buf);
3487                            }
3488                            Err(e) => return Err(datadog::Error::Io(e)),
3489                        }
3490                    }
3491                    _ => {
3492                        local_req_builder = local_req_builder.body(ser.into_inner());
3493                    }
3494                }
3495            } else {
3496                local_req_builder = local_req_builder.body(ser.into_inner());
3497            }
3498        }
3499
3500        local_req_builder = local_req_builder.headers(headers);
3501        let local_req = local_req_builder.build()?;
3502        log::debug!("request content: {:?}", local_req.body());
3503        let local_resp = local_client.execute(local_req).await?;
3504
3505        let local_status = local_resp.status();
3506        let local_content = local_resp.text().await?;
3507        log::debug!("response content: {}", local_content);
3508
3509        if !local_status.is_client_error() && !local_status.is_server_error() {
3510            match serde_json::from_str::<
3511                crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse,
3512            >(&local_content)
3513            {
3514                Ok(e) => {
3515                    return Ok(datadog::ResponseContent {
3516                        status: local_status,
3517                        content: local_content,
3518                        entity: Some(e),
3519                    })
3520                }
3521                Err(e) => return Err(datadog::Error::Serde(e)),
3522            };
3523        } else {
3524            let local_entity: Option<EditSecurityMonitoringSignalStateError> =
3525                serde_json::from_str(&local_content).ok();
3526            let local_error = datadog::ResponseContent {
3527                status: local_status,
3528                content: local_content,
3529                entity: local_entity,
3530            };
3531            Err(datadog::Error::ResponseError(local_error))
3532        }
3533    }
3534
3535    /// Returns a single finding with message and resource configuration.
3536    pub async fn get_finding(
3537        &self,
3538        finding_id: String,
3539        params: GetFindingOptionalParams,
3540    ) -> Result<crate::datadogV2::model::GetFindingResponse, datadog::Error<GetFindingError>> {
3541        match self.get_finding_with_http_info(finding_id, params).await {
3542            Ok(response_content) => {
3543                if let Some(e) = response_content.entity {
3544                    Ok(e)
3545                } else {
3546                    Err(datadog::Error::Serde(serde::de::Error::custom(
3547                        "response content was None",
3548                    )))
3549                }
3550            }
3551            Err(err) => Err(err),
3552        }
3553    }
3554
3555    /// Returns a single finding with message and resource configuration.
3556    pub async fn get_finding_with_http_info(
3557        &self,
3558        finding_id: String,
3559        params: GetFindingOptionalParams,
3560    ) -> Result<
3561        datadog::ResponseContent<crate::datadogV2::model::GetFindingResponse>,
3562        datadog::Error<GetFindingError>,
3563    > {
3564        let local_configuration = &self.config;
3565        let operation_id = "v2.get_finding";
3566        if local_configuration.is_unstable_operation_enabled(operation_id) {
3567            warn!("Using unstable operation {operation_id}");
3568        } else {
3569            let local_error = datadog::UnstableOperationDisabledError {
3570                msg: "Operation 'v2.get_finding' is not enabled".to_string(),
3571            };
3572            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
3573        }
3574
3575        // unbox and build optional parameters
3576        let snapshot_timestamp = params.snapshot_timestamp;
3577
3578        let local_client = &self.client;
3579
3580        let local_uri_str = format!(
3581            "{}/api/v2/posture_management/findings/{finding_id}",
3582            local_configuration.get_operation_host(operation_id),
3583            finding_id = datadog::urlencode(finding_id)
3584        );
3585        let mut local_req_builder =
3586            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3587
3588        if let Some(ref local_query_param) = snapshot_timestamp {
3589            local_req_builder =
3590                local_req_builder.query(&[("snapshot_timestamp", &local_query_param.to_string())]);
3591        };
3592
3593        // build headers
3594        let mut headers = HeaderMap::new();
3595        headers.insert("Accept", HeaderValue::from_static("application/json"));
3596
3597        // build user agent
3598        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3599            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3600            Err(e) => {
3601                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3602                headers.insert(
3603                    reqwest::header::USER_AGENT,
3604                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3605                )
3606            }
3607        };
3608
3609        // build auth
3610        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3611            headers.insert(
3612                "DD-API-KEY",
3613                HeaderValue::from_str(local_key.key.as_str())
3614                    .expect("failed to parse DD-API-KEY header"),
3615            );
3616        };
3617        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3618            headers.insert(
3619                "DD-APPLICATION-KEY",
3620                HeaderValue::from_str(local_key.key.as_str())
3621                    .expect("failed to parse DD-APPLICATION-KEY header"),
3622            );
3623        };
3624
3625        local_req_builder = local_req_builder.headers(headers);
3626        let local_req = local_req_builder.build()?;
3627        log::debug!("request content: {:?}", local_req.body());
3628        let local_resp = local_client.execute(local_req).await?;
3629
3630        let local_status = local_resp.status();
3631        let local_content = local_resp.text().await?;
3632        log::debug!("response content: {}", local_content);
3633
3634        if !local_status.is_client_error() && !local_status.is_server_error() {
3635            match serde_json::from_str::<crate::datadogV2::model::GetFindingResponse>(
3636                &local_content,
3637            ) {
3638                Ok(e) => {
3639                    return Ok(datadog::ResponseContent {
3640                        status: local_status,
3641                        content: local_content,
3642                        entity: Some(e),
3643                    })
3644                }
3645                Err(e) => return Err(datadog::Error::Serde(e)),
3646            };
3647        } else {
3648            let local_entity: Option<GetFindingError> = serde_json::from_str(&local_content).ok();
3649            let local_error = datadog::ResponseContent {
3650                status: local_status,
3651                content: local_content,
3652                entity: local_entity,
3653            };
3654            Err(datadog::Error::ResponseError(local_error))
3655        }
3656    }
3657
3658    /// Get a job's details.
3659    pub async fn get_historical_job(
3660        &self,
3661        job_id: String,
3662    ) -> Result<crate::datadogV2::model::HistoricalJobResponse, datadog::Error<GetHistoricalJobError>>
3663    {
3664        match self.get_historical_job_with_http_info(job_id).await {
3665            Ok(response_content) => {
3666                if let Some(e) = response_content.entity {
3667                    Ok(e)
3668                } else {
3669                    Err(datadog::Error::Serde(serde::de::Error::custom(
3670                        "response content was None",
3671                    )))
3672                }
3673            }
3674            Err(err) => Err(err),
3675        }
3676    }
3677
3678    /// Get a job's details.
3679    pub async fn get_historical_job_with_http_info(
3680        &self,
3681        job_id: String,
3682    ) -> Result<
3683        datadog::ResponseContent<crate::datadogV2::model::HistoricalJobResponse>,
3684        datadog::Error<GetHistoricalJobError>,
3685    > {
3686        let local_configuration = &self.config;
3687        let operation_id = "v2.get_historical_job";
3688        if local_configuration.is_unstable_operation_enabled(operation_id) {
3689            warn!("Using unstable operation {operation_id}");
3690        } else {
3691            let local_error = datadog::UnstableOperationDisabledError {
3692                msg: "Operation 'v2.get_historical_job' is not enabled".to_string(),
3693            };
3694            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
3695        }
3696
3697        let local_client = &self.client;
3698
3699        let local_uri_str = format!(
3700            "{}/api/v2/siem-historical-detections/jobs/{job_id}",
3701            local_configuration.get_operation_host(operation_id),
3702            job_id = datadog::urlencode(job_id)
3703        );
3704        let mut local_req_builder =
3705            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3706
3707        // build headers
3708        let mut headers = HeaderMap::new();
3709        headers.insert("Accept", HeaderValue::from_static("application/json"));
3710
3711        // build user agent
3712        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3713            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3714            Err(e) => {
3715                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3716                headers.insert(
3717                    reqwest::header::USER_AGENT,
3718                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3719                )
3720            }
3721        };
3722
3723        // build auth
3724        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3725            headers.insert(
3726                "DD-API-KEY",
3727                HeaderValue::from_str(local_key.key.as_str())
3728                    .expect("failed to parse DD-API-KEY header"),
3729            );
3730        };
3731        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3732            headers.insert(
3733                "DD-APPLICATION-KEY",
3734                HeaderValue::from_str(local_key.key.as_str())
3735                    .expect("failed to parse DD-APPLICATION-KEY header"),
3736            );
3737        };
3738
3739        local_req_builder = local_req_builder.headers(headers);
3740        let local_req = local_req_builder.build()?;
3741        log::debug!("request content: {:?}", local_req.body());
3742        let local_resp = local_client.execute(local_req).await?;
3743
3744        let local_status = local_resp.status();
3745        let local_content = local_resp.text().await?;
3746        log::debug!("response content: {}", local_content);
3747
3748        if !local_status.is_client_error() && !local_status.is_server_error() {
3749            match serde_json::from_str::<crate::datadogV2::model::HistoricalJobResponse>(
3750                &local_content,
3751            ) {
3752                Ok(e) => {
3753                    return Ok(datadog::ResponseContent {
3754                        status: local_status,
3755                        content: local_content,
3756                        entity: Some(e),
3757                    })
3758                }
3759                Err(e) => return Err(datadog::Error::Serde(e)),
3760            };
3761        } else {
3762            let local_entity: Option<GetHistoricalJobError> =
3763                serde_json::from_str(&local_content).ok();
3764            let local_error = datadog::ResponseContent {
3765                status: local_status,
3766                content: local_content,
3767                entity: local_entity,
3768            };
3769            Err(datadog::Error::ResponseError(local_error))
3770        }
3771    }
3772
3773    /// Get a rule's version history.
3774    pub async fn get_rule_version_history(
3775        &self,
3776        rule_id: String,
3777        params: GetRuleVersionHistoryOptionalParams,
3778    ) -> Result<
3779        crate::datadogV2::model::GetRuleVersionHistoryResponse,
3780        datadog::Error<GetRuleVersionHistoryError>,
3781    > {
3782        match self
3783            .get_rule_version_history_with_http_info(rule_id, params)
3784            .await
3785        {
3786            Ok(response_content) => {
3787                if let Some(e) = response_content.entity {
3788                    Ok(e)
3789                } else {
3790                    Err(datadog::Error::Serde(serde::de::Error::custom(
3791                        "response content was None",
3792                    )))
3793                }
3794            }
3795            Err(err) => Err(err),
3796        }
3797    }
3798
3799    /// Get a rule's version history.
3800    pub async fn get_rule_version_history_with_http_info(
3801        &self,
3802        rule_id: String,
3803        params: GetRuleVersionHistoryOptionalParams,
3804    ) -> Result<
3805        datadog::ResponseContent<crate::datadogV2::model::GetRuleVersionHistoryResponse>,
3806        datadog::Error<GetRuleVersionHistoryError>,
3807    > {
3808        let local_configuration = &self.config;
3809        let operation_id = "v2.get_rule_version_history";
3810        if local_configuration.is_unstable_operation_enabled(operation_id) {
3811            warn!("Using unstable operation {operation_id}");
3812        } else {
3813            let local_error = datadog::UnstableOperationDisabledError {
3814                msg: "Operation 'v2.get_rule_version_history' is not enabled".to_string(),
3815            };
3816            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
3817        }
3818
3819        // unbox and build optional parameters
3820        let page_size = params.page_size;
3821        let page_number = params.page_number;
3822
3823        let local_client = &self.client;
3824
3825        let local_uri_str = format!(
3826            "{}/api/v2/security_monitoring/rules/{rule_id}/version_history",
3827            local_configuration.get_operation_host(operation_id),
3828            rule_id = datadog::urlencode(rule_id)
3829        );
3830        let mut local_req_builder =
3831            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3832
3833        if let Some(ref local_query_param) = page_size {
3834            local_req_builder =
3835                local_req_builder.query(&[("page[size]", &local_query_param.to_string())]);
3836        };
3837        if let Some(ref local_query_param) = page_number {
3838            local_req_builder =
3839                local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
3840        };
3841
3842        // build headers
3843        let mut headers = HeaderMap::new();
3844        headers.insert("Accept", HeaderValue::from_static("application/json"));
3845
3846        // build user agent
3847        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3848            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3849            Err(e) => {
3850                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3851                headers.insert(
3852                    reqwest::header::USER_AGENT,
3853                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3854                )
3855            }
3856        };
3857
3858        // build auth
3859        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3860            headers.insert(
3861                "DD-API-KEY",
3862                HeaderValue::from_str(local_key.key.as_str())
3863                    .expect("failed to parse DD-API-KEY header"),
3864            );
3865        };
3866        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
3867            headers.insert(
3868                "DD-APPLICATION-KEY",
3869                HeaderValue::from_str(local_key.key.as_str())
3870                    .expect("failed to parse DD-APPLICATION-KEY header"),
3871            );
3872        };
3873
3874        local_req_builder = local_req_builder.headers(headers);
3875        let local_req = local_req_builder.build()?;
3876        log::debug!("request content: {:?}", local_req.body());
3877        let local_resp = local_client.execute(local_req).await?;
3878
3879        let local_status = local_resp.status();
3880        let local_content = local_resp.text().await?;
3881        log::debug!("response content: {}", local_content);
3882
3883        if !local_status.is_client_error() && !local_status.is_server_error() {
3884            match serde_json::from_str::<crate::datadogV2::model::GetRuleVersionHistoryResponse>(
3885                &local_content,
3886            ) {
3887                Ok(e) => {
3888                    return Ok(datadog::ResponseContent {
3889                        status: local_status,
3890                        content: local_content,
3891                        entity: Some(e),
3892                    })
3893                }
3894                Err(e) => return Err(datadog::Error::Serde(e)),
3895            };
3896        } else {
3897            let local_entity: Option<GetRuleVersionHistoryError> =
3898                serde_json::from_str(&local_content).ok();
3899            let local_error = datadog::ResponseContent {
3900                status: local_status,
3901                content: local_content,
3902                entity: local_entity,
3903            };
3904            Err(datadog::Error::ResponseError(local_error))
3905        }
3906    }
3907
3908    /// Get a single SBOM related to an asset by its type and name.
3909    ///
3910    pub async fn get_sbom(
3911        &self,
3912        asset_type: crate::datadogV2::model::AssetType,
3913        filter_asset_name: String,
3914        params: GetSBOMOptionalParams,
3915    ) -> Result<crate::datadogV2::model::GetSBOMResponse, datadog::Error<GetSBOMError>> {
3916        match self
3917            .get_sbom_with_http_info(asset_type, filter_asset_name, params)
3918            .await
3919        {
3920            Ok(response_content) => {
3921                if let Some(e) = response_content.entity {
3922                    Ok(e)
3923                } else {
3924                    Err(datadog::Error::Serde(serde::de::Error::custom(
3925                        "response content was None",
3926                    )))
3927                }
3928            }
3929            Err(err) => Err(err),
3930        }
3931    }
3932
3933    /// Get a single SBOM related to an asset by its type and name.
3934    ///
3935    pub async fn get_sbom_with_http_info(
3936        &self,
3937        asset_type: crate::datadogV2::model::AssetType,
3938        filter_asset_name: String,
3939        params: GetSBOMOptionalParams,
3940    ) -> Result<
3941        datadog::ResponseContent<crate::datadogV2::model::GetSBOMResponse>,
3942        datadog::Error<GetSBOMError>,
3943    > {
3944        let local_configuration = &self.config;
3945        let operation_id = "v2.get_sbom";
3946        if local_configuration.is_unstable_operation_enabled(operation_id) {
3947            warn!("Using unstable operation {operation_id}");
3948        } else {
3949            let local_error = datadog::UnstableOperationDisabledError {
3950                msg: "Operation 'v2.get_sbom' is not enabled".to_string(),
3951            };
3952            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
3953        }
3954
3955        // unbox and build optional parameters
3956        let filter_repo_digest = params.filter_repo_digest;
3957
3958        let local_client = &self.client;
3959
3960        let local_uri_str = format!(
3961            "{}/api/v2/security/sboms/{asset_type}",
3962            local_configuration.get_operation_host(operation_id),
3963            asset_type = datadog::urlencode(asset_type.to_string())
3964        );
3965        let mut local_req_builder =
3966            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
3967
3968        local_req_builder =
3969            local_req_builder.query(&[("filter[asset_name]", &filter_asset_name.to_string())]);
3970        if let Some(ref local_query_param) = filter_repo_digest {
3971            local_req_builder =
3972                local_req_builder.query(&[("filter[repo_digest]", &local_query_param.to_string())]);
3973        };
3974
3975        // build headers
3976        let mut headers = HeaderMap::new();
3977        headers.insert("Accept", HeaderValue::from_static("application/json"));
3978
3979        // build user agent
3980        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
3981            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
3982            Err(e) => {
3983                log::warn!("Failed to parse user agent header: {e}, falling back to default");
3984                headers.insert(
3985                    reqwest::header::USER_AGENT,
3986                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
3987                )
3988            }
3989        };
3990
3991        // build auth
3992        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
3993            headers.insert(
3994                "DD-API-KEY",
3995                HeaderValue::from_str(local_key.key.as_str())
3996                    .expect("failed to parse DD-API-KEY header"),
3997            );
3998        };
3999        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4000            headers.insert(
4001                "DD-APPLICATION-KEY",
4002                HeaderValue::from_str(local_key.key.as_str())
4003                    .expect("failed to parse DD-APPLICATION-KEY header"),
4004            );
4005        };
4006
4007        local_req_builder = local_req_builder.headers(headers);
4008        let local_req = local_req_builder.build()?;
4009        log::debug!("request content: {:?}", local_req.body());
4010        let local_resp = local_client.execute(local_req).await?;
4011
4012        let local_status = local_resp.status();
4013        let local_content = local_resp.text().await?;
4014        log::debug!("response content: {}", local_content);
4015
4016        if !local_status.is_client_error() && !local_status.is_server_error() {
4017            match serde_json::from_str::<crate::datadogV2::model::GetSBOMResponse>(&local_content) {
4018                Ok(e) => {
4019                    return Ok(datadog::ResponseContent {
4020                        status: local_status,
4021                        content: local_content,
4022                        entity: Some(e),
4023                    })
4024                }
4025                Err(e) => return Err(datadog::Error::Serde(e)),
4026            };
4027        } else {
4028            let local_entity: Option<GetSBOMError> = serde_json::from_str(&local_content).ok();
4029            let local_error = datadog::ResponseContent {
4030                status: local_status,
4031                content: local_content,
4032                entity: local_entity,
4033            };
4034            Err(datadog::Error::ResponseError(local_error))
4035        }
4036    }
4037
4038    /// Get the details of a specific security filter.
4039    ///
4040    /// See the [security filter guide](<https://docs.datadoghq.com/security_platform/guide/how-to-setup-security-filters-using-security-monitoring-api/>)
4041    /// for more examples.
4042    pub async fn get_security_filter(
4043        &self,
4044        security_filter_id: String,
4045    ) -> Result<
4046        crate::datadogV2::model::SecurityFilterResponse,
4047        datadog::Error<GetSecurityFilterError>,
4048    > {
4049        match self
4050            .get_security_filter_with_http_info(security_filter_id)
4051            .await
4052        {
4053            Ok(response_content) => {
4054                if let Some(e) = response_content.entity {
4055                    Ok(e)
4056                } else {
4057                    Err(datadog::Error::Serde(serde::de::Error::custom(
4058                        "response content was None",
4059                    )))
4060                }
4061            }
4062            Err(err) => Err(err),
4063        }
4064    }
4065
4066    /// Get the details of a specific security filter.
4067    ///
4068    /// See the [security filter guide](<https://docs.datadoghq.com/security_platform/guide/how-to-setup-security-filters-using-security-monitoring-api/>)
4069    /// for more examples.
4070    pub async fn get_security_filter_with_http_info(
4071        &self,
4072        security_filter_id: String,
4073    ) -> Result<
4074        datadog::ResponseContent<crate::datadogV2::model::SecurityFilterResponse>,
4075        datadog::Error<GetSecurityFilterError>,
4076    > {
4077        let local_configuration = &self.config;
4078        let operation_id = "v2.get_security_filter";
4079
4080        let local_client = &self.client;
4081
4082        let local_uri_str = format!(
4083            "{}/api/v2/security_monitoring/configuration/security_filters/{security_filter_id}",
4084            local_configuration.get_operation_host(operation_id),
4085            security_filter_id = datadog::urlencode(security_filter_id)
4086        );
4087        let mut local_req_builder =
4088            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4089
4090        // build headers
4091        let mut headers = HeaderMap::new();
4092        headers.insert("Accept", HeaderValue::from_static("application/json"));
4093
4094        // build user agent
4095        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4096            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4097            Err(e) => {
4098                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4099                headers.insert(
4100                    reqwest::header::USER_AGENT,
4101                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4102                )
4103            }
4104        };
4105
4106        // build auth
4107        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4108            headers.insert(
4109                "DD-API-KEY",
4110                HeaderValue::from_str(local_key.key.as_str())
4111                    .expect("failed to parse DD-API-KEY header"),
4112            );
4113        };
4114        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4115            headers.insert(
4116                "DD-APPLICATION-KEY",
4117                HeaderValue::from_str(local_key.key.as_str())
4118                    .expect("failed to parse DD-APPLICATION-KEY header"),
4119            );
4120        };
4121
4122        local_req_builder = local_req_builder.headers(headers);
4123        let local_req = local_req_builder.build()?;
4124        log::debug!("request content: {:?}", local_req.body());
4125        let local_resp = local_client.execute(local_req).await?;
4126
4127        let local_status = local_resp.status();
4128        let local_content = local_resp.text().await?;
4129        log::debug!("response content: {}", local_content);
4130
4131        if !local_status.is_client_error() && !local_status.is_server_error() {
4132            match serde_json::from_str::<crate::datadogV2::model::SecurityFilterResponse>(
4133                &local_content,
4134            ) {
4135                Ok(e) => {
4136                    return Ok(datadog::ResponseContent {
4137                        status: local_status,
4138                        content: local_content,
4139                        entity: Some(e),
4140                    })
4141                }
4142                Err(e) => return Err(datadog::Error::Serde(e)),
4143            };
4144        } else {
4145            let local_entity: Option<GetSecurityFilterError> =
4146                serde_json::from_str(&local_content).ok();
4147            let local_error = datadog::ResponseContent {
4148                status: local_status,
4149                content: local_content,
4150                entity: local_entity,
4151            };
4152            Err(datadog::Error::ResponseError(local_error))
4153        }
4154    }
4155
4156    /// Get a rule's details.
4157    pub async fn get_security_monitoring_rule(
4158        &self,
4159        rule_id: String,
4160    ) -> Result<
4161        crate::datadogV2::model::SecurityMonitoringRuleResponse,
4162        datadog::Error<GetSecurityMonitoringRuleError>,
4163    > {
4164        match self
4165            .get_security_monitoring_rule_with_http_info(rule_id)
4166            .await
4167        {
4168            Ok(response_content) => {
4169                if let Some(e) = response_content.entity {
4170                    Ok(e)
4171                } else {
4172                    Err(datadog::Error::Serde(serde::de::Error::custom(
4173                        "response content was None",
4174                    )))
4175                }
4176            }
4177            Err(err) => Err(err),
4178        }
4179    }
4180
4181    /// Get a rule's details.
4182    pub async fn get_security_monitoring_rule_with_http_info(
4183        &self,
4184        rule_id: String,
4185    ) -> Result<
4186        datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleResponse>,
4187        datadog::Error<GetSecurityMonitoringRuleError>,
4188    > {
4189        let local_configuration = &self.config;
4190        let operation_id = "v2.get_security_monitoring_rule";
4191
4192        let local_client = &self.client;
4193
4194        let local_uri_str = format!(
4195            "{}/api/v2/security_monitoring/rules/{rule_id}",
4196            local_configuration.get_operation_host(operation_id),
4197            rule_id = datadog::urlencode(rule_id)
4198        );
4199        let mut local_req_builder =
4200            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4201
4202        // build headers
4203        let mut headers = HeaderMap::new();
4204        headers.insert("Accept", HeaderValue::from_static("application/json"));
4205
4206        // build user agent
4207        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4208            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4209            Err(e) => {
4210                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4211                headers.insert(
4212                    reqwest::header::USER_AGENT,
4213                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4214                )
4215            }
4216        };
4217
4218        // build auth
4219        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4220            headers.insert(
4221                "DD-API-KEY",
4222                HeaderValue::from_str(local_key.key.as_str())
4223                    .expect("failed to parse DD-API-KEY header"),
4224            );
4225        };
4226        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4227            headers.insert(
4228                "DD-APPLICATION-KEY",
4229                HeaderValue::from_str(local_key.key.as_str())
4230                    .expect("failed to parse DD-APPLICATION-KEY header"),
4231            );
4232        };
4233
4234        local_req_builder = local_req_builder.headers(headers);
4235        let local_req = local_req_builder.build()?;
4236        log::debug!("request content: {:?}", local_req.body());
4237        let local_resp = local_client.execute(local_req).await?;
4238
4239        let local_status = local_resp.status();
4240        let local_content = local_resp.text().await?;
4241        log::debug!("response content: {}", local_content);
4242
4243        if !local_status.is_client_error() && !local_status.is_server_error() {
4244            match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringRuleResponse>(
4245                &local_content,
4246            ) {
4247                Ok(e) => {
4248                    return Ok(datadog::ResponseContent {
4249                        status: local_status,
4250                        content: local_content,
4251                        entity: Some(e),
4252                    })
4253                }
4254                Err(e) => return Err(datadog::Error::Serde(e)),
4255            };
4256        } else {
4257            let local_entity: Option<GetSecurityMonitoringRuleError> =
4258                serde_json::from_str(&local_content).ok();
4259            let local_error = datadog::ResponseContent {
4260                status: local_status,
4261                content: local_content,
4262                entity: local_entity,
4263            };
4264            Err(datadog::Error::ResponseError(local_error))
4265        }
4266    }
4267
4268    /// Get a signal's details.
4269    pub async fn get_security_monitoring_signal(
4270        &self,
4271        signal_id: String,
4272    ) -> Result<
4273        crate::datadogV2::model::SecurityMonitoringSignalResponse,
4274        datadog::Error<GetSecurityMonitoringSignalError>,
4275    > {
4276        match self
4277            .get_security_monitoring_signal_with_http_info(signal_id)
4278            .await
4279        {
4280            Ok(response_content) => {
4281                if let Some(e) = response_content.entity {
4282                    Ok(e)
4283                } else {
4284                    Err(datadog::Error::Serde(serde::de::Error::custom(
4285                        "response content was None",
4286                    )))
4287                }
4288            }
4289            Err(err) => Err(err),
4290        }
4291    }
4292
4293    /// Get a signal's details.
4294    pub async fn get_security_monitoring_signal_with_http_info(
4295        &self,
4296        signal_id: String,
4297    ) -> Result<
4298        datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSignalResponse>,
4299        datadog::Error<GetSecurityMonitoringSignalError>,
4300    > {
4301        let local_configuration = &self.config;
4302        let operation_id = "v2.get_security_monitoring_signal";
4303
4304        let local_client = &self.client;
4305
4306        let local_uri_str = format!(
4307            "{}/api/v2/security_monitoring/signals/{signal_id}",
4308            local_configuration.get_operation_host(operation_id),
4309            signal_id = datadog::urlencode(signal_id)
4310        );
4311        let mut local_req_builder =
4312            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4313
4314        // build headers
4315        let mut headers = HeaderMap::new();
4316        headers.insert("Accept", HeaderValue::from_static("application/json"));
4317
4318        // build user agent
4319        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4320            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4321            Err(e) => {
4322                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4323                headers.insert(
4324                    reqwest::header::USER_AGENT,
4325                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4326                )
4327            }
4328        };
4329
4330        // build auth
4331        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4332            headers.insert(
4333                "DD-API-KEY",
4334                HeaderValue::from_str(local_key.key.as_str())
4335                    .expect("failed to parse DD-API-KEY header"),
4336            );
4337        };
4338        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4339            headers.insert(
4340                "DD-APPLICATION-KEY",
4341                HeaderValue::from_str(local_key.key.as_str())
4342                    .expect("failed to parse DD-APPLICATION-KEY header"),
4343            );
4344        };
4345
4346        local_req_builder = local_req_builder.headers(headers);
4347        let local_req = local_req_builder.build()?;
4348        log::debug!("request content: {:?}", local_req.body());
4349        let local_resp = local_client.execute(local_req).await?;
4350
4351        let local_status = local_resp.status();
4352        let local_content = local_resp.text().await?;
4353        log::debug!("response content: {}", local_content);
4354
4355        if !local_status.is_client_error() && !local_status.is_server_error() {
4356            match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringSignalResponse>(
4357                &local_content,
4358            ) {
4359                Ok(e) => {
4360                    return Ok(datadog::ResponseContent {
4361                        status: local_status,
4362                        content: local_content,
4363                        entity: Some(e),
4364                    })
4365                }
4366                Err(e) => return Err(datadog::Error::Serde(e)),
4367            };
4368        } else {
4369            let local_entity: Option<GetSecurityMonitoringSignalError> =
4370                serde_json::from_str(&local_content).ok();
4371            let local_error = datadog::ResponseContent {
4372                status: local_status,
4373                content: local_content,
4374                entity: local_entity,
4375            };
4376            Err(datadog::Error::ResponseError(local_error))
4377        }
4378    }
4379
4380    /// Get the details of a specific suppression rule.
4381    pub async fn get_security_monitoring_suppression(
4382        &self,
4383        suppression_id: String,
4384    ) -> Result<
4385        crate::datadogV2::model::SecurityMonitoringSuppressionResponse,
4386        datadog::Error<GetSecurityMonitoringSuppressionError>,
4387    > {
4388        match self
4389            .get_security_monitoring_suppression_with_http_info(suppression_id)
4390            .await
4391        {
4392            Ok(response_content) => {
4393                if let Some(e) = response_content.entity {
4394                    Ok(e)
4395                } else {
4396                    Err(datadog::Error::Serde(serde::de::Error::custom(
4397                        "response content was None",
4398                    )))
4399                }
4400            }
4401            Err(err) => Err(err),
4402        }
4403    }
4404
4405    /// Get the details of a specific suppression rule.
4406    pub async fn get_security_monitoring_suppression_with_http_info(
4407        &self,
4408        suppression_id: String,
4409    ) -> Result<
4410        datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSuppressionResponse>,
4411        datadog::Error<GetSecurityMonitoringSuppressionError>,
4412    > {
4413        let local_configuration = &self.config;
4414        let operation_id = "v2.get_security_monitoring_suppression";
4415
4416        let local_client = &self.client;
4417
4418        let local_uri_str = format!(
4419            "{}/api/v2/security_monitoring/configuration/suppressions/{suppression_id}",
4420            local_configuration.get_operation_host(operation_id),
4421            suppression_id = datadog::urlencode(suppression_id)
4422        );
4423        let mut local_req_builder =
4424            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4425
4426        // build headers
4427        let mut headers = HeaderMap::new();
4428        headers.insert("Accept", HeaderValue::from_static("application/json"));
4429
4430        // build user agent
4431        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4432            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4433            Err(e) => {
4434                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4435                headers.insert(
4436                    reqwest::header::USER_AGENT,
4437                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4438                )
4439            }
4440        };
4441
4442        // build auth
4443        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4444            headers.insert(
4445                "DD-API-KEY",
4446                HeaderValue::from_str(local_key.key.as_str())
4447                    .expect("failed to parse DD-API-KEY header"),
4448            );
4449        };
4450        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4451            headers.insert(
4452                "DD-APPLICATION-KEY",
4453                HeaderValue::from_str(local_key.key.as_str())
4454                    .expect("failed to parse DD-APPLICATION-KEY header"),
4455            );
4456        };
4457
4458        local_req_builder = local_req_builder.headers(headers);
4459        let local_req = local_req_builder.build()?;
4460        log::debug!("request content: {:?}", local_req.body());
4461        let local_resp = local_client.execute(local_req).await?;
4462
4463        let local_status = local_resp.status();
4464        let local_content = local_resp.text().await?;
4465        log::debug!("response content: {}", local_content);
4466
4467        if !local_status.is_client_error() && !local_status.is_server_error() {
4468            match serde_json::from_str::<
4469                crate::datadogV2::model::SecurityMonitoringSuppressionResponse,
4470            >(&local_content)
4471            {
4472                Ok(e) => {
4473                    return Ok(datadog::ResponseContent {
4474                        status: local_status,
4475                        content: local_content,
4476                        entity: Some(e),
4477                    })
4478                }
4479                Err(e) => return Err(datadog::Error::Serde(e)),
4480            };
4481        } else {
4482            let local_entity: Option<GetSecurityMonitoringSuppressionError> =
4483                serde_json::from_str(&local_content).ok();
4484            let local_error = datadog::ResponseContent {
4485                status: local_status,
4486                content: local_content,
4487                entity: local_entity,
4488            };
4489            Err(datadog::Error::ResponseError(local_error))
4490        }
4491    }
4492
4493    /// Get the details of a notification rule for security signals.
4494    pub async fn get_signal_notification_rule(
4495        &self,
4496        id: String,
4497    ) -> Result<
4498        crate::datadogV2::model::NotificationRuleResponse,
4499        datadog::Error<GetSignalNotificationRuleError>,
4500    > {
4501        match self.get_signal_notification_rule_with_http_info(id).await {
4502            Ok(response_content) => {
4503                if let Some(e) = response_content.entity {
4504                    Ok(e)
4505                } else {
4506                    Err(datadog::Error::Serde(serde::de::Error::custom(
4507                        "response content was None",
4508                    )))
4509                }
4510            }
4511            Err(err) => Err(err),
4512        }
4513    }
4514
4515    /// Get the details of a notification rule for security signals.
4516    pub async fn get_signal_notification_rule_with_http_info(
4517        &self,
4518        id: String,
4519    ) -> Result<
4520        datadog::ResponseContent<crate::datadogV2::model::NotificationRuleResponse>,
4521        datadog::Error<GetSignalNotificationRuleError>,
4522    > {
4523        let local_configuration = &self.config;
4524        let operation_id = "v2.get_signal_notification_rule";
4525
4526        let local_client = &self.client;
4527
4528        let local_uri_str = format!(
4529            "{}/api/v2/security/signals/notification_rules/{id}",
4530            local_configuration.get_operation_host(operation_id),
4531            id = datadog::urlencode(id)
4532        );
4533        let mut local_req_builder =
4534            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4535
4536        // build headers
4537        let mut headers = HeaderMap::new();
4538        headers.insert("Accept", HeaderValue::from_static("application/json"));
4539
4540        // build user agent
4541        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4542            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4543            Err(e) => {
4544                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4545                headers.insert(
4546                    reqwest::header::USER_AGENT,
4547                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4548                )
4549            }
4550        };
4551
4552        // build auth
4553        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4554            headers.insert(
4555                "DD-API-KEY",
4556                HeaderValue::from_str(local_key.key.as_str())
4557                    .expect("failed to parse DD-API-KEY header"),
4558            );
4559        };
4560        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4561            headers.insert(
4562                "DD-APPLICATION-KEY",
4563                HeaderValue::from_str(local_key.key.as_str())
4564                    .expect("failed to parse DD-APPLICATION-KEY header"),
4565            );
4566        };
4567
4568        local_req_builder = local_req_builder.headers(headers);
4569        let local_req = local_req_builder.build()?;
4570        log::debug!("request content: {:?}", local_req.body());
4571        let local_resp = local_client.execute(local_req).await?;
4572
4573        let local_status = local_resp.status();
4574        let local_content = local_resp.text().await?;
4575        log::debug!("response content: {}", local_content);
4576
4577        if !local_status.is_client_error() && !local_status.is_server_error() {
4578            match serde_json::from_str::<crate::datadogV2::model::NotificationRuleResponse>(
4579                &local_content,
4580            ) {
4581                Ok(e) => {
4582                    return Ok(datadog::ResponseContent {
4583                        status: local_status,
4584                        content: local_content,
4585                        entity: Some(e),
4586                    })
4587                }
4588                Err(e) => return Err(datadog::Error::Serde(e)),
4589            };
4590        } else {
4591            let local_entity: Option<GetSignalNotificationRuleError> =
4592                serde_json::from_str(&local_content).ok();
4593            let local_error = datadog::ResponseContent {
4594                status: local_status,
4595                content: local_content,
4596                entity: local_entity,
4597            };
4598            Err(datadog::Error::ResponseError(local_error))
4599        }
4600    }
4601
4602    /// Returns the list of notification rules for security signals.
4603    pub async fn get_signal_notification_rules(
4604        &self,
4605    ) -> Result<
4606        std::collections::BTreeMap<String, serde_json::Value>,
4607        datadog::Error<GetSignalNotificationRulesError>,
4608    > {
4609        match self.get_signal_notification_rules_with_http_info().await {
4610            Ok(response_content) => {
4611                if let Some(e) = response_content.entity {
4612                    Ok(e)
4613                } else {
4614                    Err(datadog::Error::Serde(serde::de::Error::custom(
4615                        "response content was None",
4616                    )))
4617                }
4618            }
4619            Err(err) => Err(err),
4620        }
4621    }
4622
4623    /// Returns the list of notification rules for security signals.
4624    pub async fn get_signal_notification_rules_with_http_info(
4625        &self,
4626    ) -> Result<
4627        datadog::ResponseContent<std::collections::BTreeMap<String, serde_json::Value>>,
4628        datadog::Error<GetSignalNotificationRulesError>,
4629    > {
4630        let local_configuration = &self.config;
4631        let operation_id = "v2.get_signal_notification_rules";
4632
4633        let local_client = &self.client;
4634
4635        let local_uri_str = format!(
4636            "{}/api/v2/security/signals/notification_rules",
4637            local_configuration.get_operation_host(operation_id)
4638        );
4639        let mut local_req_builder =
4640            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4641
4642        // build headers
4643        let mut headers = HeaderMap::new();
4644        headers.insert("Accept", HeaderValue::from_static("application/json"));
4645
4646        // build user agent
4647        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4648            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4649            Err(e) => {
4650                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4651                headers.insert(
4652                    reqwest::header::USER_AGENT,
4653                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4654                )
4655            }
4656        };
4657
4658        // build auth
4659        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4660            headers.insert(
4661                "DD-API-KEY",
4662                HeaderValue::from_str(local_key.key.as_str())
4663                    .expect("failed to parse DD-API-KEY header"),
4664            );
4665        };
4666        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4667            headers.insert(
4668                "DD-APPLICATION-KEY",
4669                HeaderValue::from_str(local_key.key.as_str())
4670                    .expect("failed to parse DD-APPLICATION-KEY header"),
4671            );
4672        };
4673
4674        local_req_builder = local_req_builder.headers(headers);
4675        let local_req = local_req_builder.build()?;
4676        log::debug!("request content: {:?}", local_req.body());
4677        let local_resp = local_client.execute(local_req).await?;
4678
4679        let local_status = local_resp.status();
4680        let local_content = local_resp.text().await?;
4681        log::debug!("response content: {}", local_content);
4682
4683        if !local_status.is_client_error() && !local_status.is_server_error() {
4684            match serde_json::from_str::<std::collections::BTreeMap<String, serde_json::Value>>(
4685                &local_content,
4686            ) {
4687                Ok(e) => {
4688                    return Ok(datadog::ResponseContent {
4689                        status: local_status,
4690                        content: local_content,
4691                        entity: Some(e),
4692                    })
4693                }
4694                Err(e) => return Err(datadog::Error::Serde(e)),
4695            };
4696        } else {
4697            let local_entity: Option<GetSignalNotificationRulesError> =
4698                serde_json::from_str(&local_content).ok();
4699            let local_error = datadog::ResponseContent {
4700                status: local_status,
4701                content: local_content,
4702                entity: local_entity,
4703            };
4704            Err(datadog::Error::ResponseError(local_error))
4705        }
4706    }
4707
4708    /// Get the details of a notification rule for security vulnerabilities.
4709    pub async fn get_vulnerability_notification_rule(
4710        &self,
4711        id: String,
4712    ) -> Result<
4713        crate::datadogV2::model::NotificationRuleResponse,
4714        datadog::Error<GetVulnerabilityNotificationRuleError>,
4715    > {
4716        match self
4717            .get_vulnerability_notification_rule_with_http_info(id)
4718            .await
4719        {
4720            Ok(response_content) => {
4721                if let Some(e) = response_content.entity {
4722                    Ok(e)
4723                } else {
4724                    Err(datadog::Error::Serde(serde::de::Error::custom(
4725                        "response content was None",
4726                    )))
4727                }
4728            }
4729            Err(err) => Err(err),
4730        }
4731    }
4732
4733    /// Get the details of a notification rule for security vulnerabilities.
4734    pub async fn get_vulnerability_notification_rule_with_http_info(
4735        &self,
4736        id: String,
4737    ) -> Result<
4738        datadog::ResponseContent<crate::datadogV2::model::NotificationRuleResponse>,
4739        datadog::Error<GetVulnerabilityNotificationRuleError>,
4740    > {
4741        let local_configuration = &self.config;
4742        let operation_id = "v2.get_vulnerability_notification_rule";
4743
4744        let local_client = &self.client;
4745
4746        let local_uri_str = format!(
4747            "{}/api/v2/security/vulnerabilities/notification_rules/{id}",
4748            local_configuration.get_operation_host(operation_id),
4749            id = datadog::urlencode(id)
4750        );
4751        let mut local_req_builder =
4752            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4753
4754        // build headers
4755        let mut headers = HeaderMap::new();
4756        headers.insert("Accept", HeaderValue::from_static("application/json"));
4757
4758        // build user agent
4759        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4760            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4761            Err(e) => {
4762                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4763                headers.insert(
4764                    reqwest::header::USER_AGENT,
4765                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4766                )
4767            }
4768        };
4769
4770        // build auth
4771        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4772            headers.insert(
4773                "DD-API-KEY",
4774                HeaderValue::from_str(local_key.key.as_str())
4775                    .expect("failed to parse DD-API-KEY header"),
4776            );
4777        };
4778        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4779            headers.insert(
4780                "DD-APPLICATION-KEY",
4781                HeaderValue::from_str(local_key.key.as_str())
4782                    .expect("failed to parse DD-APPLICATION-KEY header"),
4783            );
4784        };
4785
4786        local_req_builder = local_req_builder.headers(headers);
4787        let local_req = local_req_builder.build()?;
4788        log::debug!("request content: {:?}", local_req.body());
4789        let local_resp = local_client.execute(local_req).await?;
4790
4791        let local_status = local_resp.status();
4792        let local_content = local_resp.text().await?;
4793        log::debug!("response content: {}", local_content);
4794
4795        if !local_status.is_client_error() && !local_status.is_server_error() {
4796            match serde_json::from_str::<crate::datadogV2::model::NotificationRuleResponse>(
4797                &local_content,
4798            ) {
4799                Ok(e) => {
4800                    return Ok(datadog::ResponseContent {
4801                        status: local_status,
4802                        content: local_content,
4803                        entity: Some(e),
4804                    })
4805                }
4806                Err(e) => return Err(datadog::Error::Serde(e)),
4807            };
4808        } else {
4809            let local_entity: Option<GetVulnerabilityNotificationRuleError> =
4810                serde_json::from_str(&local_content).ok();
4811            let local_error = datadog::ResponseContent {
4812                status: local_status,
4813                content: local_content,
4814                entity: local_entity,
4815            };
4816            Err(datadog::Error::ResponseError(local_error))
4817        }
4818    }
4819
4820    /// Returns the list of notification rules for security vulnerabilities.
4821    pub async fn get_vulnerability_notification_rules(
4822        &self,
4823    ) -> Result<
4824        std::collections::BTreeMap<String, serde_json::Value>,
4825        datadog::Error<GetVulnerabilityNotificationRulesError>,
4826    > {
4827        match self
4828            .get_vulnerability_notification_rules_with_http_info()
4829            .await
4830        {
4831            Ok(response_content) => {
4832                if let Some(e) = response_content.entity {
4833                    Ok(e)
4834                } else {
4835                    Err(datadog::Error::Serde(serde::de::Error::custom(
4836                        "response content was None",
4837                    )))
4838                }
4839            }
4840            Err(err) => Err(err),
4841        }
4842    }
4843
4844    /// Returns the list of notification rules for security vulnerabilities.
4845    pub async fn get_vulnerability_notification_rules_with_http_info(
4846        &self,
4847    ) -> Result<
4848        datadog::ResponseContent<std::collections::BTreeMap<String, serde_json::Value>>,
4849        datadog::Error<GetVulnerabilityNotificationRulesError>,
4850    > {
4851        let local_configuration = &self.config;
4852        let operation_id = "v2.get_vulnerability_notification_rules";
4853
4854        let local_client = &self.client;
4855
4856        let local_uri_str = format!(
4857            "{}/api/v2/security/vulnerabilities/notification_rules",
4858            local_configuration.get_operation_host(operation_id)
4859        );
4860        let mut local_req_builder =
4861            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
4862
4863        // build headers
4864        let mut headers = HeaderMap::new();
4865        headers.insert("Accept", HeaderValue::from_static("application/json"));
4866
4867        // build user agent
4868        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
4869            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
4870            Err(e) => {
4871                log::warn!("Failed to parse user agent header: {e}, falling back to default");
4872                headers.insert(
4873                    reqwest::header::USER_AGENT,
4874                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
4875                )
4876            }
4877        };
4878
4879        // build auth
4880        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
4881            headers.insert(
4882                "DD-API-KEY",
4883                HeaderValue::from_str(local_key.key.as_str())
4884                    .expect("failed to parse DD-API-KEY header"),
4885            );
4886        };
4887        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
4888            headers.insert(
4889                "DD-APPLICATION-KEY",
4890                HeaderValue::from_str(local_key.key.as_str())
4891                    .expect("failed to parse DD-APPLICATION-KEY header"),
4892            );
4893        };
4894
4895        local_req_builder = local_req_builder.headers(headers);
4896        let local_req = local_req_builder.build()?;
4897        log::debug!("request content: {:?}", local_req.body());
4898        let local_resp = local_client.execute(local_req).await?;
4899
4900        let local_status = local_resp.status();
4901        let local_content = local_resp.text().await?;
4902        log::debug!("response content: {}", local_content);
4903
4904        if !local_status.is_client_error() && !local_status.is_server_error() {
4905            match serde_json::from_str::<std::collections::BTreeMap<String, serde_json::Value>>(
4906                &local_content,
4907            ) {
4908                Ok(e) => {
4909                    return Ok(datadog::ResponseContent {
4910                        status: local_status,
4911                        content: local_content,
4912                        entity: Some(e),
4913                    })
4914                }
4915                Err(e) => return Err(datadog::Error::Serde(e)),
4916            };
4917        } else {
4918            let local_entity: Option<GetVulnerabilityNotificationRulesError> =
4919                serde_json::from_str(&local_content).ok();
4920            let local_error = datadog::ResponseContent {
4921                status: local_status,
4922                content: local_content,
4923                entity: local_entity,
4924            };
4925            Err(datadog::Error::ResponseError(local_error))
4926        }
4927    }
4928
4929    /// Get a list of findings. These include both misconfigurations and identity risks.
4930    ///
4931    /// **Note**: To filter and return only identity risks, add the following query parameter: `?filter[tags]=dd_rule_type:ciem`
4932    ///
4933    /// ### Filtering
4934    ///
4935    /// Filters can be applied by appending query parameters to the URL.
4936    ///
4937    ///   - Using a single filter: `?filter[attribute_key]=attribute_value`
4938    ///   - Chaining filters: `?filter[attribute_key]=attribute_value&filter[attribute_key]=attribute_value...`
4939    ///   - Filtering on tags: `?filter[tags]=tag_key:tag_value&filter[tags]=tag_key_2:tag_value_2`
4940    ///
4941    /// Here, `attribute_key` can be any of the filter keys described further below.
4942    ///
4943    /// Query parameters of type `integer` support comparison operators (`>`, `>=`, `<`, `<=`). This is particularly useful when filtering by `evaluation_changed_at` or `resource_discovery_timestamp`. For example: `?filter[evaluation_changed_at]=>20123123121`.
4944    ///
4945    /// You can also use the negation operator on strings. For example, use `filter[resource_type]=-aws*` to filter for any non-AWS resources.
4946    ///
4947    /// The operator must come after the equal sign. For example, to filter with the `>=` operator, add the operator after the equal sign: `filter[evaluation_changed_at]=>=1678809373257`.
4948    ///
4949    /// Query parameters must be only among the documented ones and with values of correct types. Duplicated query parameters (e.g. `filter[status]=low&filter[status]=info`) are not allowed.
4950    ///
4951    /// ### Response
4952    ///
4953    /// The response includes an array of finding objects, pagination metadata, and a count of items that match the query.
4954    ///
4955    /// Each finding object contains the following:
4956    ///
4957    /// - The finding ID that can be used in a `GetFinding` request to retrieve the full finding details.
4958    /// - Core attributes, including status, evaluation, high-level resource details, muted state, and rule details.
4959    /// - `evaluation_changed_at` and `resource_discovery_date` time stamps.
4960    /// - An array of associated tags.
4961    ///
4962    pub async fn list_findings(
4963        &self,
4964        params: ListFindingsOptionalParams,
4965    ) -> Result<crate::datadogV2::model::ListFindingsResponse, datadog::Error<ListFindingsError>>
4966    {
4967        match self.list_findings_with_http_info(params).await {
4968            Ok(response_content) => {
4969                if let Some(e) = response_content.entity {
4970                    Ok(e)
4971                } else {
4972                    Err(datadog::Error::Serde(serde::de::Error::custom(
4973                        "response content was None",
4974                    )))
4975                }
4976            }
4977            Err(err) => Err(err),
4978        }
4979    }
4980
4981    pub fn list_findings_with_pagination(
4982        &self,
4983        mut params: ListFindingsOptionalParams,
4984    ) -> impl Stream<
4985        Item = Result<crate::datadogV2::model::Finding, datadog::Error<ListFindingsError>>,
4986    > + '_ {
4987        try_stream! {
4988            let mut page_size: i64 = 100;
4989            if params.page_limit.is_none() {
4990                params.page_limit = Some(page_size);
4991            } else {
4992                page_size = params.page_limit.unwrap().clone();
4993            }
4994            loop {
4995                let resp = self.list_findings(params.clone()).await?;
4996
4997                let r = resp.data;
4998                let count = r.len();
4999                for team in r {
5000                    yield team;
5001                }
5002
5003                if count < page_size as usize {
5004                    break;
5005                }
5006                let Some(page) = resp.meta.page else { break };
5007                let Some(cursor) = page.cursor else { break };
5008
5009                params.page_cursor = Some(cursor);
5010            }
5011        }
5012    }
5013
5014    /// Get a list of findings. These include both misconfigurations and identity risks.
5015    ///
5016    /// **Note**: To filter and return only identity risks, add the following query parameter: `?filter[tags]=dd_rule_type:ciem`
5017    ///
5018    /// ### Filtering
5019    ///
5020    /// Filters can be applied by appending query parameters to the URL.
5021    ///
5022    ///   - Using a single filter: `?filter[attribute_key]=attribute_value`
5023    ///   - Chaining filters: `?filter[attribute_key]=attribute_value&filter[attribute_key]=attribute_value...`
5024    ///   - Filtering on tags: `?filter[tags]=tag_key:tag_value&filter[tags]=tag_key_2:tag_value_2`
5025    ///
5026    /// Here, `attribute_key` can be any of the filter keys described further below.
5027    ///
5028    /// Query parameters of type `integer` support comparison operators (`>`, `>=`, `<`, `<=`). This is particularly useful when filtering by `evaluation_changed_at` or `resource_discovery_timestamp`. For example: `?filter[evaluation_changed_at]=>20123123121`.
5029    ///
5030    /// You can also use the negation operator on strings. For example, use `filter[resource_type]=-aws*` to filter for any non-AWS resources.
5031    ///
5032    /// The operator must come after the equal sign. For example, to filter with the `>=` operator, add the operator after the equal sign: `filter[evaluation_changed_at]=>=1678809373257`.
5033    ///
5034    /// Query parameters must be only among the documented ones and with values of correct types. Duplicated query parameters (e.g. `filter[status]=low&filter[status]=info`) are not allowed.
5035    ///
5036    /// ### Response
5037    ///
5038    /// The response includes an array of finding objects, pagination metadata, and a count of items that match the query.
5039    ///
5040    /// Each finding object contains the following:
5041    ///
5042    /// - The finding ID that can be used in a `GetFinding` request to retrieve the full finding details.
5043    /// - Core attributes, including status, evaluation, high-level resource details, muted state, and rule details.
5044    /// - `evaluation_changed_at` and `resource_discovery_date` time stamps.
5045    /// - An array of associated tags.
5046    ///
5047    pub async fn list_findings_with_http_info(
5048        &self,
5049        params: ListFindingsOptionalParams,
5050    ) -> Result<
5051        datadog::ResponseContent<crate::datadogV2::model::ListFindingsResponse>,
5052        datadog::Error<ListFindingsError>,
5053    > {
5054        let local_configuration = &self.config;
5055        let operation_id = "v2.list_findings";
5056        if local_configuration.is_unstable_operation_enabled(operation_id) {
5057            warn!("Using unstable operation {operation_id}");
5058        } else {
5059            let local_error = datadog::UnstableOperationDisabledError {
5060                msg: "Operation 'v2.list_findings' is not enabled".to_string(),
5061            };
5062            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
5063        }
5064
5065        // unbox and build optional parameters
5066        let page_limit = params.page_limit;
5067        let snapshot_timestamp = params.snapshot_timestamp;
5068        let page_cursor = params.page_cursor;
5069        let filter_tags = params.filter_tags;
5070        let filter_evaluation_changed_at = params.filter_evaluation_changed_at;
5071        let filter_muted = params.filter_muted;
5072        let filter_rule_id = params.filter_rule_id;
5073        let filter_rule_name = params.filter_rule_name;
5074        let filter_resource_type = params.filter_resource_type;
5075        let filter_discovery_timestamp = params.filter_discovery_timestamp;
5076        let filter_evaluation = params.filter_evaluation;
5077        let filter_status = params.filter_status;
5078        let filter_vulnerability_type = params.filter_vulnerability_type;
5079
5080        let local_client = &self.client;
5081
5082        let local_uri_str = format!(
5083            "{}/api/v2/posture_management/findings",
5084            local_configuration.get_operation_host(operation_id)
5085        );
5086        let mut local_req_builder =
5087            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5088
5089        if let Some(ref local_query_param) = page_limit {
5090            local_req_builder =
5091                local_req_builder.query(&[("page[limit]", &local_query_param.to_string())]);
5092        };
5093        if let Some(ref local_query_param) = snapshot_timestamp {
5094            local_req_builder =
5095                local_req_builder.query(&[("snapshot_timestamp", &local_query_param.to_string())]);
5096        };
5097        if let Some(ref local_query_param) = page_cursor {
5098            local_req_builder =
5099                local_req_builder.query(&[("page[cursor]", &local_query_param.to_string())]);
5100        };
5101        if let Some(ref local_query_param) = filter_tags {
5102            local_req_builder =
5103                local_req_builder.query(&[("filter[tags]", &local_query_param.to_string())]);
5104        };
5105        if let Some(ref local_query_param) = filter_evaluation_changed_at {
5106            local_req_builder = local_req_builder.query(&[(
5107                "filter[evaluation_changed_at]",
5108                &local_query_param.to_string(),
5109            )]);
5110        };
5111        if let Some(ref local_query_param) = filter_muted {
5112            local_req_builder =
5113                local_req_builder.query(&[("filter[muted]", &local_query_param.to_string())]);
5114        };
5115        if let Some(ref local_query_param) = filter_rule_id {
5116            local_req_builder =
5117                local_req_builder.query(&[("filter[rule_id]", &local_query_param.to_string())]);
5118        };
5119        if let Some(ref local_query_param) = filter_rule_name {
5120            local_req_builder =
5121                local_req_builder.query(&[("filter[rule_name]", &local_query_param.to_string())]);
5122        };
5123        if let Some(ref local_query_param) = filter_resource_type {
5124            local_req_builder = local_req_builder
5125                .query(&[("filter[resource_type]", &local_query_param.to_string())]);
5126        };
5127        if let Some(ref local_query_param) = filter_discovery_timestamp {
5128            local_req_builder = local_req_builder.query(&[(
5129                "filter[discovery_timestamp]",
5130                &local_query_param.to_string(),
5131            )]);
5132        };
5133        if let Some(ref local_query_param) = filter_evaluation {
5134            local_req_builder =
5135                local_req_builder.query(&[("filter[evaluation]", &local_query_param.to_string())]);
5136        };
5137        if let Some(ref local_query_param) = filter_status {
5138            local_req_builder =
5139                local_req_builder.query(&[("filter[status]", &local_query_param.to_string())]);
5140        };
5141        if let Some(ref local) = filter_vulnerability_type {
5142            for param in local {
5143                local_req_builder =
5144                    local_req_builder.query(&[("filter[vulnerability_type]", &param.to_string())]);
5145            }
5146        };
5147
5148        // build headers
5149        let mut headers = HeaderMap::new();
5150        headers.insert("Accept", HeaderValue::from_static("application/json"));
5151
5152        // build user agent
5153        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5154            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5155            Err(e) => {
5156                log::warn!("Failed to parse user agent header: {e}, falling back to default");
5157                headers.insert(
5158                    reqwest::header::USER_AGENT,
5159                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5160                )
5161            }
5162        };
5163
5164        // build auth
5165        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5166            headers.insert(
5167                "DD-API-KEY",
5168                HeaderValue::from_str(local_key.key.as_str())
5169                    .expect("failed to parse DD-API-KEY header"),
5170            );
5171        };
5172        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5173            headers.insert(
5174                "DD-APPLICATION-KEY",
5175                HeaderValue::from_str(local_key.key.as_str())
5176                    .expect("failed to parse DD-APPLICATION-KEY header"),
5177            );
5178        };
5179
5180        local_req_builder = local_req_builder.headers(headers);
5181        let local_req = local_req_builder.build()?;
5182        log::debug!("request content: {:?}", local_req.body());
5183        let local_resp = local_client.execute(local_req).await?;
5184
5185        let local_status = local_resp.status();
5186        let local_content = local_resp.text().await?;
5187        log::debug!("response content: {}", local_content);
5188
5189        if !local_status.is_client_error() && !local_status.is_server_error() {
5190            match serde_json::from_str::<crate::datadogV2::model::ListFindingsResponse>(
5191                &local_content,
5192            ) {
5193                Ok(e) => {
5194                    return Ok(datadog::ResponseContent {
5195                        status: local_status,
5196                        content: local_content,
5197                        entity: Some(e),
5198                    })
5199                }
5200                Err(e) => return Err(datadog::Error::Serde(e)),
5201            };
5202        } else {
5203            let local_entity: Option<ListFindingsError> = serde_json::from_str(&local_content).ok();
5204            let local_error = datadog::ResponseContent {
5205                status: local_status,
5206                content: local_content,
5207                entity: local_entity,
5208            };
5209            Err(datadog::Error::ResponseError(local_error))
5210        }
5211    }
5212
5213    /// List historical jobs.
5214    pub async fn list_historical_jobs(
5215        &self,
5216        params: ListHistoricalJobsOptionalParams,
5217    ) -> Result<
5218        crate::datadogV2::model::ListHistoricalJobsResponse,
5219        datadog::Error<ListHistoricalJobsError>,
5220    > {
5221        match self.list_historical_jobs_with_http_info(params).await {
5222            Ok(response_content) => {
5223                if let Some(e) = response_content.entity {
5224                    Ok(e)
5225                } else {
5226                    Err(datadog::Error::Serde(serde::de::Error::custom(
5227                        "response content was None",
5228                    )))
5229                }
5230            }
5231            Err(err) => Err(err),
5232        }
5233    }
5234
5235    /// List historical jobs.
5236    pub async fn list_historical_jobs_with_http_info(
5237        &self,
5238        params: ListHistoricalJobsOptionalParams,
5239    ) -> Result<
5240        datadog::ResponseContent<crate::datadogV2::model::ListHistoricalJobsResponse>,
5241        datadog::Error<ListHistoricalJobsError>,
5242    > {
5243        let local_configuration = &self.config;
5244        let operation_id = "v2.list_historical_jobs";
5245        if local_configuration.is_unstable_operation_enabled(operation_id) {
5246            warn!("Using unstable operation {operation_id}");
5247        } else {
5248            let local_error = datadog::UnstableOperationDisabledError {
5249                msg: "Operation 'v2.list_historical_jobs' is not enabled".to_string(),
5250            };
5251            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
5252        }
5253
5254        // unbox and build optional parameters
5255        let page_size = params.page_size;
5256        let page_number = params.page_number;
5257        let sort = params.sort;
5258        let filter_query = params.filter_query;
5259
5260        let local_client = &self.client;
5261
5262        let local_uri_str = format!(
5263            "{}/api/v2/siem-historical-detections/jobs",
5264            local_configuration.get_operation_host(operation_id)
5265        );
5266        let mut local_req_builder =
5267            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5268
5269        if let Some(ref local_query_param) = page_size {
5270            local_req_builder =
5271                local_req_builder.query(&[("page[size]", &local_query_param.to_string())]);
5272        };
5273        if let Some(ref local_query_param) = page_number {
5274            local_req_builder =
5275                local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
5276        };
5277        if let Some(ref local_query_param) = sort {
5278            local_req_builder =
5279                local_req_builder.query(&[("sort", &local_query_param.to_string())]);
5280        };
5281        if let Some(ref local_query_param) = filter_query {
5282            local_req_builder =
5283                local_req_builder.query(&[("filter[query]", &local_query_param.to_string())]);
5284        };
5285
5286        // build headers
5287        let mut headers = HeaderMap::new();
5288        headers.insert("Accept", HeaderValue::from_static("application/json"));
5289
5290        // build user agent
5291        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5292            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5293            Err(e) => {
5294                log::warn!("Failed to parse user agent header: {e}, falling back to default");
5295                headers.insert(
5296                    reqwest::header::USER_AGENT,
5297                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5298                )
5299            }
5300        };
5301
5302        // build auth
5303        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5304            headers.insert(
5305                "DD-API-KEY",
5306                HeaderValue::from_str(local_key.key.as_str())
5307                    .expect("failed to parse DD-API-KEY header"),
5308            );
5309        };
5310        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5311            headers.insert(
5312                "DD-APPLICATION-KEY",
5313                HeaderValue::from_str(local_key.key.as_str())
5314                    .expect("failed to parse DD-APPLICATION-KEY header"),
5315            );
5316        };
5317
5318        local_req_builder = local_req_builder.headers(headers);
5319        let local_req = local_req_builder.build()?;
5320        log::debug!("request content: {:?}", local_req.body());
5321        let local_resp = local_client.execute(local_req).await?;
5322
5323        let local_status = local_resp.status();
5324        let local_content = local_resp.text().await?;
5325        log::debug!("response content: {}", local_content);
5326
5327        if !local_status.is_client_error() && !local_status.is_server_error() {
5328            match serde_json::from_str::<crate::datadogV2::model::ListHistoricalJobsResponse>(
5329                &local_content,
5330            ) {
5331                Ok(e) => {
5332                    return Ok(datadog::ResponseContent {
5333                        status: local_status,
5334                        content: local_content,
5335                        entity: Some(e),
5336                    })
5337                }
5338                Err(e) => return Err(datadog::Error::Serde(e)),
5339            };
5340        } else {
5341            let local_entity: Option<ListHistoricalJobsError> =
5342                serde_json::from_str(&local_content).ok();
5343            let local_error = datadog::ResponseContent {
5344                status: local_status,
5345                content: local_content,
5346                entity: local_entity,
5347            };
5348            Err(datadog::Error::ResponseError(local_error))
5349        }
5350    }
5351
5352    /// Get the list of configured security filters with their definitions.
5353    pub async fn list_security_filters(
5354        &self,
5355    ) -> Result<
5356        crate::datadogV2::model::SecurityFiltersResponse,
5357        datadog::Error<ListSecurityFiltersError>,
5358    > {
5359        match self.list_security_filters_with_http_info().await {
5360            Ok(response_content) => {
5361                if let Some(e) = response_content.entity {
5362                    Ok(e)
5363                } else {
5364                    Err(datadog::Error::Serde(serde::de::Error::custom(
5365                        "response content was None",
5366                    )))
5367                }
5368            }
5369            Err(err) => Err(err),
5370        }
5371    }
5372
5373    /// Get the list of configured security filters with their definitions.
5374    pub async fn list_security_filters_with_http_info(
5375        &self,
5376    ) -> Result<
5377        datadog::ResponseContent<crate::datadogV2::model::SecurityFiltersResponse>,
5378        datadog::Error<ListSecurityFiltersError>,
5379    > {
5380        let local_configuration = &self.config;
5381        let operation_id = "v2.list_security_filters";
5382
5383        let local_client = &self.client;
5384
5385        let local_uri_str = format!(
5386            "{}/api/v2/security_monitoring/configuration/security_filters",
5387            local_configuration.get_operation_host(operation_id)
5388        );
5389        let mut local_req_builder =
5390            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5391
5392        // build headers
5393        let mut headers = HeaderMap::new();
5394        headers.insert("Accept", HeaderValue::from_static("application/json"));
5395
5396        // build user agent
5397        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5398            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5399            Err(e) => {
5400                log::warn!("Failed to parse user agent header: {e}, falling back to default");
5401                headers.insert(
5402                    reqwest::header::USER_AGENT,
5403                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5404                )
5405            }
5406        };
5407
5408        // build auth
5409        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5410            headers.insert(
5411                "DD-API-KEY",
5412                HeaderValue::from_str(local_key.key.as_str())
5413                    .expect("failed to parse DD-API-KEY header"),
5414            );
5415        };
5416        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5417            headers.insert(
5418                "DD-APPLICATION-KEY",
5419                HeaderValue::from_str(local_key.key.as_str())
5420                    .expect("failed to parse DD-APPLICATION-KEY header"),
5421            );
5422        };
5423
5424        local_req_builder = local_req_builder.headers(headers);
5425        let local_req = local_req_builder.build()?;
5426        log::debug!("request content: {:?}", local_req.body());
5427        let local_resp = local_client.execute(local_req).await?;
5428
5429        let local_status = local_resp.status();
5430        let local_content = local_resp.text().await?;
5431        log::debug!("response content: {}", local_content);
5432
5433        if !local_status.is_client_error() && !local_status.is_server_error() {
5434            match serde_json::from_str::<crate::datadogV2::model::SecurityFiltersResponse>(
5435                &local_content,
5436            ) {
5437                Ok(e) => {
5438                    return Ok(datadog::ResponseContent {
5439                        status: local_status,
5440                        content: local_content,
5441                        entity: Some(e),
5442                    })
5443                }
5444                Err(e) => return Err(datadog::Error::Serde(e)),
5445            };
5446        } else {
5447            let local_entity: Option<ListSecurityFiltersError> =
5448                serde_json::from_str(&local_content).ok();
5449            let local_error = datadog::ResponseContent {
5450                status: local_status,
5451                content: local_content,
5452                entity: local_entity,
5453            };
5454            Err(datadog::Error::ResponseError(local_error))
5455        }
5456    }
5457
5458    /// List rules.
5459    pub async fn list_security_monitoring_rules(
5460        &self,
5461        params: ListSecurityMonitoringRulesOptionalParams,
5462    ) -> Result<
5463        crate::datadogV2::model::SecurityMonitoringListRulesResponse,
5464        datadog::Error<ListSecurityMonitoringRulesError>,
5465    > {
5466        match self
5467            .list_security_monitoring_rules_with_http_info(params)
5468            .await
5469        {
5470            Ok(response_content) => {
5471                if let Some(e) = response_content.entity {
5472                    Ok(e)
5473                } else {
5474                    Err(datadog::Error::Serde(serde::de::Error::custom(
5475                        "response content was None",
5476                    )))
5477                }
5478            }
5479            Err(err) => Err(err),
5480        }
5481    }
5482
5483    /// List rules.
5484    pub async fn list_security_monitoring_rules_with_http_info(
5485        &self,
5486        params: ListSecurityMonitoringRulesOptionalParams,
5487    ) -> Result<
5488        datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringListRulesResponse>,
5489        datadog::Error<ListSecurityMonitoringRulesError>,
5490    > {
5491        let local_configuration = &self.config;
5492        let operation_id = "v2.list_security_monitoring_rules";
5493
5494        // unbox and build optional parameters
5495        let page_size = params.page_size;
5496        let page_number = params.page_number;
5497
5498        let local_client = &self.client;
5499
5500        let local_uri_str = format!(
5501            "{}/api/v2/security_monitoring/rules",
5502            local_configuration.get_operation_host(operation_id)
5503        );
5504        let mut local_req_builder =
5505            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5506
5507        if let Some(ref local_query_param) = page_size {
5508            local_req_builder =
5509                local_req_builder.query(&[("page[size]", &local_query_param.to_string())]);
5510        };
5511        if let Some(ref local_query_param) = page_number {
5512            local_req_builder =
5513                local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
5514        };
5515
5516        // build headers
5517        let mut headers = HeaderMap::new();
5518        headers.insert("Accept", HeaderValue::from_static("application/json"));
5519
5520        // build user agent
5521        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5522            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5523            Err(e) => {
5524                log::warn!("Failed to parse user agent header: {e}, falling back to default");
5525                headers.insert(
5526                    reqwest::header::USER_AGENT,
5527                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5528                )
5529            }
5530        };
5531
5532        // build auth
5533        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5534            headers.insert(
5535                "DD-API-KEY",
5536                HeaderValue::from_str(local_key.key.as_str())
5537                    .expect("failed to parse DD-API-KEY header"),
5538            );
5539        };
5540        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5541            headers.insert(
5542                "DD-APPLICATION-KEY",
5543                HeaderValue::from_str(local_key.key.as_str())
5544                    .expect("failed to parse DD-APPLICATION-KEY header"),
5545            );
5546        };
5547
5548        local_req_builder = local_req_builder.headers(headers);
5549        let local_req = local_req_builder.build()?;
5550        log::debug!("request content: {:?}", local_req.body());
5551        let local_resp = local_client.execute(local_req).await?;
5552
5553        let local_status = local_resp.status();
5554        let local_content = local_resp.text().await?;
5555        log::debug!("response content: {}", local_content);
5556
5557        if !local_status.is_client_error() && !local_status.is_server_error() {
5558            match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringListRulesResponse>(
5559                &local_content,
5560            ) {
5561                Ok(e) => {
5562                    return Ok(datadog::ResponseContent {
5563                        status: local_status,
5564                        content: local_content,
5565                        entity: Some(e),
5566                    })
5567                }
5568                Err(e) => return Err(datadog::Error::Serde(e)),
5569            };
5570        } else {
5571            let local_entity: Option<ListSecurityMonitoringRulesError> =
5572                serde_json::from_str(&local_content).ok();
5573            let local_error = datadog::ResponseContent {
5574                status: local_status,
5575                content: local_content,
5576                entity: local_entity,
5577            };
5578            Err(datadog::Error::ResponseError(local_error))
5579        }
5580    }
5581
5582    /// The list endpoint returns security signals that match a search query.
5583    /// Both this endpoint and the POST endpoint can be used interchangeably when listing
5584    /// security signals.
5585    pub async fn list_security_monitoring_signals(
5586        &self,
5587        params: ListSecurityMonitoringSignalsOptionalParams,
5588    ) -> Result<
5589        crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
5590        datadog::Error<ListSecurityMonitoringSignalsError>,
5591    > {
5592        match self
5593            .list_security_monitoring_signals_with_http_info(params)
5594            .await
5595        {
5596            Ok(response_content) => {
5597                if let Some(e) = response_content.entity {
5598                    Ok(e)
5599                } else {
5600                    Err(datadog::Error::Serde(serde::de::Error::custom(
5601                        "response content was None",
5602                    )))
5603                }
5604            }
5605            Err(err) => Err(err),
5606        }
5607    }
5608
5609    pub fn list_security_monitoring_signals_with_pagination(
5610        &self,
5611        mut params: ListSecurityMonitoringSignalsOptionalParams,
5612    ) -> impl Stream<
5613        Item = Result<
5614            crate::datadogV2::model::SecurityMonitoringSignal,
5615            datadog::Error<ListSecurityMonitoringSignalsError>,
5616        >,
5617    > + '_ {
5618        try_stream! {
5619            let mut page_size: i32 = 10;
5620            if params.page_limit.is_none() {
5621                params.page_limit = Some(page_size);
5622            } else {
5623                page_size = params.page_limit.unwrap().clone();
5624            }
5625            loop {
5626                let resp = self.list_security_monitoring_signals(params.clone()).await?;
5627                let Some(data) = resp.data else { break };
5628
5629                let r = data;
5630                let count = r.len();
5631                for team in r {
5632                    yield team;
5633                }
5634
5635                if count < page_size as usize {
5636                    break;
5637                }
5638                let Some(meta) = resp.meta else { break };
5639                let Some(page) = meta.page else { break };
5640                let Some(after) = page.after else { break };
5641
5642                params.page_cursor = Some(after);
5643            }
5644        }
5645    }
5646
5647    /// The list endpoint returns security signals that match a search query.
5648    /// Both this endpoint and the POST endpoint can be used interchangeably when listing
5649    /// security signals.
5650    pub async fn list_security_monitoring_signals_with_http_info(
5651        &self,
5652        params: ListSecurityMonitoringSignalsOptionalParams,
5653    ) -> Result<
5654        datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSignalsListResponse>,
5655        datadog::Error<ListSecurityMonitoringSignalsError>,
5656    > {
5657        let local_configuration = &self.config;
5658        let operation_id = "v2.list_security_monitoring_signals";
5659
5660        // unbox and build optional parameters
5661        let filter_query = params.filter_query;
5662        let filter_from = params.filter_from;
5663        let filter_to = params.filter_to;
5664        let sort = params.sort;
5665        let page_cursor = params.page_cursor;
5666        let page_limit = params.page_limit;
5667
5668        let local_client = &self.client;
5669
5670        let local_uri_str = format!(
5671            "{}/api/v2/security_monitoring/signals",
5672            local_configuration.get_operation_host(operation_id)
5673        );
5674        let mut local_req_builder =
5675            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5676
5677        if let Some(ref local_query_param) = filter_query {
5678            local_req_builder =
5679                local_req_builder.query(&[("filter[query]", &local_query_param.to_string())]);
5680        };
5681        if let Some(ref local_query_param) = filter_from {
5682            local_req_builder = local_req_builder.query(&[(
5683                "filter[from]",
5684                &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
5685            )]);
5686        };
5687        if let Some(ref local_query_param) = filter_to {
5688            local_req_builder = local_req_builder.query(&[(
5689                "filter[to]",
5690                &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
5691            )]);
5692        };
5693        if let Some(ref local_query_param) = sort {
5694            local_req_builder =
5695                local_req_builder.query(&[("sort", &local_query_param.to_string())]);
5696        };
5697        if let Some(ref local_query_param) = page_cursor {
5698            local_req_builder =
5699                local_req_builder.query(&[("page[cursor]", &local_query_param.to_string())]);
5700        };
5701        if let Some(ref local_query_param) = page_limit {
5702            local_req_builder =
5703                local_req_builder.query(&[("page[limit]", &local_query_param.to_string())]);
5704        };
5705
5706        // build headers
5707        let mut headers = HeaderMap::new();
5708        headers.insert("Accept", HeaderValue::from_static("application/json"));
5709
5710        // build user agent
5711        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5712            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5713            Err(e) => {
5714                log::warn!("Failed to parse user agent header: {e}, falling back to default");
5715                headers.insert(
5716                    reqwest::header::USER_AGENT,
5717                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5718                )
5719            }
5720        };
5721
5722        // build auth
5723        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5724            headers.insert(
5725                "DD-API-KEY",
5726                HeaderValue::from_str(local_key.key.as_str())
5727                    .expect("failed to parse DD-API-KEY header"),
5728            );
5729        };
5730        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5731            headers.insert(
5732                "DD-APPLICATION-KEY",
5733                HeaderValue::from_str(local_key.key.as_str())
5734                    .expect("failed to parse DD-APPLICATION-KEY header"),
5735            );
5736        };
5737
5738        local_req_builder = local_req_builder.headers(headers);
5739        let local_req = local_req_builder.build()?;
5740        log::debug!("request content: {:?}", local_req.body());
5741        let local_resp = local_client.execute(local_req).await?;
5742
5743        let local_status = local_resp.status();
5744        let local_content = local_resp.text().await?;
5745        log::debug!("response content: {}", local_content);
5746
5747        if !local_status.is_client_error() && !local_status.is_server_error() {
5748            match serde_json::from_str::<
5749                crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
5750            >(&local_content)
5751            {
5752                Ok(e) => {
5753                    return Ok(datadog::ResponseContent {
5754                        status: local_status,
5755                        content: local_content,
5756                        entity: Some(e),
5757                    })
5758                }
5759                Err(e) => return Err(datadog::Error::Serde(e)),
5760            };
5761        } else {
5762            let local_entity: Option<ListSecurityMonitoringSignalsError> =
5763                serde_json::from_str(&local_content).ok();
5764            let local_error = datadog::ResponseContent {
5765                status: local_status,
5766                content: local_content,
5767                entity: local_entity,
5768            };
5769            Err(datadog::Error::ResponseError(local_error))
5770        }
5771    }
5772
5773    /// Get the list of all suppression rules.
5774    pub async fn list_security_monitoring_suppressions(
5775        &self,
5776    ) -> Result<
5777        crate::datadogV2::model::SecurityMonitoringSuppressionsResponse,
5778        datadog::Error<ListSecurityMonitoringSuppressionsError>,
5779    > {
5780        match self
5781            .list_security_monitoring_suppressions_with_http_info()
5782            .await
5783        {
5784            Ok(response_content) => {
5785                if let Some(e) = response_content.entity {
5786                    Ok(e)
5787                } else {
5788                    Err(datadog::Error::Serde(serde::de::Error::custom(
5789                        "response content was None",
5790                    )))
5791                }
5792            }
5793            Err(err) => Err(err),
5794        }
5795    }
5796
5797    /// Get the list of all suppression rules.
5798    pub async fn list_security_monitoring_suppressions_with_http_info(
5799        &self,
5800    ) -> Result<
5801        datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSuppressionsResponse>,
5802        datadog::Error<ListSecurityMonitoringSuppressionsError>,
5803    > {
5804        let local_configuration = &self.config;
5805        let operation_id = "v2.list_security_monitoring_suppressions";
5806
5807        let local_client = &self.client;
5808
5809        let local_uri_str = format!(
5810            "{}/api/v2/security_monitoring/configuration/suppressions",
5811            local_configuration.get_operation_host(operation_id)
5812        );
5813        let mut local_req_builder =
5814            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
5815
5816        // build headers
5817        let mut headers = HeaderMap::new();
5818        headers.insert("Accept", HeaderValue::from_static("application/json"));
5819
5820        // build user agent
5821        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
5822            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
5823            Err(e) => {
5824                log::warn!("Failed to parse user agent header: {e}, falling back to default");
5825                headers.insert(
5826                    reqwest::header::USER_AGENT,
5827                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
5828                )
5829            }
5830        };
5831
5832        // build auth
5833        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
5834            headers.insert(
5835                "DD-API-KEY",
5836                HeaderValue::from_str(local_key.key.as_str())
5837                    .expect("failed to parse DD-API-KEY header"),
5838            );
5839        };
5840        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
5841            headers.insert(
5842                "DD-APPLICATION-KEY",
5843                HeaderValue::from_str(local_key.key.as_str())
5844                    .expect("failed to parse DD-APPLICATION-KEY header"),
5845            );
5846        };
5847
5848        local_req_builder = local_req_builder.headers(headers);
5849        let local_req = local_req_builder.build()?;
5850        log::debug!("request content: {:?}", local_req.body());
5851        let local_resp = local_client.execute(local_req).await?;
5852
5853        let local_status = local_resp.status();
5854        let local_content = local_resp.text().await?;
5855        log::debug!("response content: {}", local_content);
5856
5857        if !local_status.is_client_error() && !local_status.is_server_error() {
5858            match serde_json::from_str::<
5859                crate::datadogV2::model::SecurityMonitoringSuppressionsResponse,
5860            >(&local_content)
5861            {
5862                Ok(e) => {
5863                    return Ok(datadog::ResponseContent {
5864                        status: local_status,
5865                        content: local_content,
5866                        entity: Some(e),
5867                    })
5868                }
5869                Err(e) => return Err(datadog::Error::Serde(e)),
5870            };
5871        } else {
5872            let local_entity: Option<ListSecurityMonitoringSuppressionsError> =
5873                serde_json::from_str(&local_content).ok();
5874            let local_error = datadog::ResponseContent {
5875                status: local_status,
5876                content: local_content,
5877                entity: local_entity,
5878            };
5879            Err(datadog::Error::ResponseError(local_error))
5880        }
5881    }
5882
5883    /// Get a list of vulnerabilities.
5884    ///
5885    /// ### Pagination
5886    ///
5887    /// Pagination is enabled by default in both `vulnerabilities` and `assets`. The size of the page varies depending on the endpoint and cannot be modified. To automate the request of the next page, you can use the links section in the response.
5888    ///
5889    /// This endpoint will return paginated responses. The pages are stored in the links section of the response:
5890    ///
5891    /// ```JSON
5892    /// {
5893    ///   "data": [...],
5894    ///   "meta": {...},
5895    ///   "links": {
5896    ///     "self": "<https://.../api/v2/security/vulnerabilities",>
5897    ///     "first": "<https://.../api/v2/security/vulnerabilities?page[number]=1&page[token]=abc",>
5898    ///     "last": "<https://.../api/v2/security/vulnerabilities?page[number]=43&page[token]=abc",>
5899    ///     "next": "<https://.../api/v2/security/vulnerabilities?page[number]=2&page[token]=abc">
5900    ///   }
5901    /// }
5902    /// ```
5903    ///
5904    ///
5905    /// - `links.previous` is empty if the first page is requested.
5906    /// - `links.next` is empty if the last page is requested.
5907    ///
5908    /// #### Token
5909    ///
5910    /// Vulnerabilities can be created, updated or deleted at any point in time.
5911    ///
5912    /// Upon the first request, a token is created to ensure consistency across subsequent paginated requests.
5913    ///
5914    /// A token is valid only for 24 hours.
5915    ///
5916    /// #### First request
5917    ///
5918    /// We consider a request to be the first request when there is no `page[token]` parameter.
5919    ///
5920    /// The response of this first request contains the newly created token in the `links` section.
5921    ///
5922    /// This token can then be used in the subsequent paginated requests.
5923    ///
5924    /// #### Subsequent requests
5925    ///
5926    /// Any request containing valid `page[token]` and `page[number]` parameters will be considered a subsequent request.
5927    ///
5928    /// If the `token` is invalid, a `404` response will be returned.
5929    ///
5930    /// If the page `number` is invalid, a `400` response will be returned.
5931    ///
5932    /// ### Filtering
5933    ///
5934    /// The request can include some filter parameters to filter the data to be retrieved. The format of the filter parameters follows the [JSON:API format](<https://jsonapi.org/format/#fetching-filtering>): `filter[$prop_name]`, where `prop_name` is the property name in the entity being filtered by.
5935    ///
5936    /// All filters can include multiple values, where data will be filtered with an OR clause: `filter[title]=Title1,Title2` will filter all vulnerabilities where title is equal to `Title1` OR `Title2`.
5937    ///
5938    /// String filters are case sensitive.
5939    ///
5940    /// Boolean filters accept `true` or `false` as values.
5941    ///
5942    /// Number filters must include an operator as a second filter input: `filter[$prop_name][$operator]`. For example, for the vulnerabilities endpoint: `filter[cvss.base.score][lte]=8`.
5943    ///
5944    /// Available operators are: `eq` (==), `lt` (<), `lte` (<=), `gt` (>) and `gte` (>=).
5945    ///
5946    /// ### Metadata
5947    ///
5948    /// Following [JSON:API format](<https://jsonapi.org/format/#document-meta>), object including non-standard meta-information.
5949    ///
5950    /// This endpoint includes the meta member in the response. For more details on each of the properties included in this section, check the endpoints response tables.
5951    ///
5952    /// ```JSON
5953    /// {
5954    ///   "data": [...],
5955    ///   "meta": {
5956    ///     "total": 1500,
5957    ///     "count": 18732,
5958    ///     "token": "some_token"
5959    ///   },
5960    ///   "links": {...}
5961    /// }
5962    /// ```
5963    ///
5964    pub async fn list_vulnerabilities(
5965        &self,
5966        params: ListVulnerabilitiesOptionalParams,
5967    ) -> Result<
5968        crate::datadogV2::model::ListVulnerabilitiesResponse,
5969        datadog::Error<ListVulnerabilitiesError>,
5970    > {
5971        match self.list_vulnerabilities_with_http_info(params).await {
5972            Ok(response_content) => {
5973                if let Some(e) = response_content.entity {
5974                    Ok(e)
5975                } else {
5976                    Err(datadog::Error::Serde(serde::de::Error::custom(
5977                        "response content was None",
5978                    )))
5979                }
5980            }
5981            Err(err) => Err(err),
5982        }
5983    }
5984
5985    /// Get a list of vulnerabilities.
5986    ///
5987    /// ### Pagination
5988    ///
5989    /// Pagination is enabled by default in both `vulnerabilities` and `assets`. The size of the page varies depending on the endpoint and cannot be modified. To automate the request of the next page, you can use the links section in the response.
5990    ///
5991    /// This endpoint will return paginated responses. The pages are stored in the links section of the response:
5992    ///
5993    /// ```JSON
5994    /// {
5995    ///   "data": [...],
5996    ///   "meta": {...},
5997    ///   "links": {
5998    ///     "self": "<https://.../api/v2/security/vulnerabilities",>
5999    ///     "first": "<https://.../api/v2/security/vulnerabilities?page[number]=1&page[token]=abc",>
6000    ///     "last": "<https://.../api/v2/security/vulnerabilities?page[number]=43&page[token]=abc",>
6001    ///     "next": "<https://.../api/v2/security/vulnerabilities?page[number]=2&page[token]=abc">
6002    ///   }
6003    /// }
6004    /// ```
6005    ///
6006    ///
6007    /// - `links.previous` is empty if the first page is requested.
6008    /// - `links.next` is empty if the last page is requested.
6009    ///
6010    /// #### Token
6011    ///
6012    /// Vulnerabilities can be created, updated or deleted at any point in time.
6013    ///
6014    /// Upon the first request, a token is created to ensure consistency across subsequent paginated requests.
6015    ///
6016    /// A token is valid only for 24 hours.
6017    ///
6018    /// #### First request
6019    ///
6020    /// We consider a request to be the first request when there is no `page[token]` parameter.
6021    ///
6022    /// The response of this first request contains the newly created token in the `links` section.
6023    ///
6024    /// This token can then be used in the subsequent paginated requests.
6025    ///
6026    /// #### Subsequent requests
6027    ///
6028    /// Any request containing valid `page[token]` and `page[number]` parameters will be considered a subsequent request.
6029    ///
6030    /// If the `token` is invalid, a `404` response will be returned.
6031    ///
6032    /// If the page `number` is invalid, a `400` response will be returned.
6033    ///
6034    /// ### Filtering
6035    ///
6036    /// The request can include some filter parameters to filter the data to be retrieved. The format of the filter parameters follows the [JSON:API format](<https://jsonapi.org/format/#fetching-filtering>): `filter[$prop_name]`, where `prop_name` is the property name in the entity being filtered by.
6037    ///
6038    /// All filters can include multiple values, where data will be filtered with an OR clause: `filter[title]=Title1,Title2` will filter all vulnerabilities where title is equal to `Title1` OR `Title2`.
6039    ///
6040    /// String filters are case sensitive.
6041    ///
6042    /// Boolean filters accept `true` or `false` as values.
6043    ///
6044    /// Number filters must include an operator as a second filter input: `filter[$prop_name][$operator]`. For example, for the vulnerabilities endpoint: `filter[cvss.base.score][lte]=8`.
6045    ///
6046    /// Available operators are: `eq` (==), `lt` (<), `lte` (<=), `gt` (>) and `gte` (>=).
6047    ///
6048    /// ### Metadata
6049    ///
6050    /// Following [JSON:API format](<https://jsonapi.org/format/#document-meta>), object including non-standard meta-information.
6051    ///
6052    /// This endpoint includes the meta member in the response. For more details on each of the properties included in this section, check the endpoints response tables.
6053    ///
6054    /// ```JSON
6055    /// {
6056    ///   "data": [...],
6057    ///   "meta": {
6058    ///     "total": 1500,
6059    ///     "count": 18732,
6060    ///     "token": "some_token"
6061    ///   },
6062    ///   "links": {...}
6063    /// }
6064    /// ```
6065    ///
6066    pub async fn list_vulnerabilities_with_http_info(
6067        &self,
6068        params: ListVulnerabilitiesOptionalParams,
6069    ) -> Result<
6070        datadog::ResponseContent<crate::datadogV2::model::ListVulnerabilitiesResponse>,
6071        datadog::Error<ListVulnerabilitiesError>,
6072    > {
6073        let local_configuration = &self.config;
6074        let operation_id = "v2.list_vulnerabilities";
6075        if local_configuration.is_unstable_operation_enabled(operation_id) {
6076            warn!("Using unstable operation {operation_id}");
6077        } else {
6078            let local_error = datadog::UnstableOperationDisabledError {
6079                msg: "Operation 'v2.list_vulnerabilities' is not enabled".to_string(),
6080            };
6081            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
6082        }
6083
6084        // unbox and build optional parameters
6085        let page_token = params.page_token;
6086        let page_number = params.page_number;
6087        let filter_type = params.filter_type;
6088        let filter_cvss_base_score_op = params.filter_cvss_base_score_op;
6089        let filter_cvss_base_severity = params.filter_cvss_base_severity;
6090        let filter_cvss_base_vector = params.filter_cvss_base_vector;
6091        let filter_cvss_datadog_score_op = params.filter_cvss_datadog_score_op;
6092        let filter_cvss_datadog_severity = params.filter_cvss_datadog_severity;
6093        let filter_cvss_datadog_vector = params.filter_cvss_datadog_vector;
6094        let filter_status = params.filter_status;
6095        let filter_tool = params.filter_tool;
6096        let filter_library_name = params.filter_library_name;
6097        let filter_library_version = params.filter_library_version;
6098        let filter_advisory_id = params.filter_advisory_id;
6099        let filter_risks_exploitation_probability = params.filter_risks_exploitation_probability;
6100        let filter_risks_poc_exploit_available = params.filter_risks_poc_exploit_available;
6101        let filter_risks_exploit_available = params.filter_risks_exploit_available;
6102        let filter_risks_epss_score_op = params.filter_risks_epss_score_op;
6103        let filter_risks_epss_severity = params.filter_risks_epss_severity;
6104        let filter_language = params.filter_language;
6105        let filter_ecosystem = params.filter_ecosystem;
6106        let filter_code_location_location = params.filter_code_location_location;
6107        let filter_code_location_file_path = params.filter_code_location_file_path;
6108        let filter_code_location_method = params.filter_code_location_method;
6109        let filter_fix_available = params.filter_fix_available;
6110        let filter_repo_digests = params.filter_repo_digests;
6111        let filter_asset_name = params.filter_asset_name;
6112        let filter_asset_type = params.filter_asset_type;
6113        let filter_asset_version_first = params.filter_asset_version_first;
6114        let filter_asset_version_last = params.filter_asset_version_last;
6115        let filter_asset_repository_url = params.filter_asset_repository_url;
6116        let filter_asset_risks_in_production = params.filter_asset_risks_in_production;
6117        let filter_asset_risks_under_attack = params.filter_asset_risks_under_attack;
6118        let filter_asset_risks_is_publicly_accessible =
6119            params.filter_asset_risks_is_publicly_accessible;
6120        let filter_asset_risks_has_privileged_access =
6121            params.filter_asset_risks_has_privileged_access;
6122        let filter_asset_risks_has_access_to_sensitive_data =
6123            params.filter_asset_risks_has_access_to_sensitive_data;
6124        let filter_asset_environments = params.filter_asset_environments;
6125        let filter_asset_arch = params.filter_asset_arch;
6126        let filter_asset_operating_system_name = params.filter_asset_operating_system_name;
6127        let filter_asset_operating_system_version = params.filter_asset_operating_system_version;
6128
6129        let local_client = &self.client;
6130
6131        let local_uri_str = format!(
6132            "{}/api/v2/security/vulnerabilities",
6133            local_configuration.get_operation_host(operation_id)
6134        );
6135        let mut local_req_builder =
6136            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
6137
6138        if let Some(ref local_query_param) = page_token {
6139            local_req_builder =
6140                local_req_builder.query(&[("page[token]", &local_query_param.to_string())]);
6141        };
6142        if let Some(ref local_query_param) = page_number {
6143            local_req_builder =
6144                local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
6145        };
6146        if let Some(ref local_query_param) = filter_type {
6147            local_req_builder =
6148                local_req_builder.query(&[("filter[type]", &local_query_param.to_string())]);
6149        };
6150        if let Some(ref local_query_param) = filter_cvss_base_score_op {
6151            local_req_builder = local_req_builder.query(&[(
6152                "filter[cvss.base.score][`$op`]",
6153                &local_query_param.to_string(),
6154            )]);
6155        };
6156        if let Some(ref local_query_param) = filter_cvss_base_severity {
6157            local_req_builder = local_req_builder
6158                .query(&[("filter[cvss.base.severity]", &local_query_param.to_string())]);
6159        };
6160        if let Some(ref local_query_param) = filter_cvss_base_vector {
6161            local_req_builder = local_req_builder
6162                .query(&[("filter[cvss.base.vector]", &local_query_param.to_string())]);
6163        };
6164        if let Some(ref local_query_param) = filter_cvss_datadog_score_op {
6165            local_req_builder = local_req_builder.query(&[(
6166                "filter[cvss.datadog.score][`$op`]",
6167                &local_query_param.to_string(),
6168            )]);
6169        };
6170        if let Some(ref local_query_param) = filter_cvss_datadog_severity {
6171            local_req_builder = local_req_builder.query(&[(
6172                "filter[cvss.datadog.severity]",
6173                &local_query_param.to_string(),
6174            )]);
6175        };
6176        if let Some(ref local_query_param) = filter_cvss_datadog_vector {
6177            local_req_builder = local_req_builder.query(&[(
6178                "filter[cvss.datadog.vector]",
6179                &local_query_param.to_string(),
6180            )]);
6181        };
6182        if let Some(ref local_query_param) = filter_status {
6183            local_req_builder =
6184                local_req_builder.query(&[("filter[status]", &local_query_param.to_string())]);
6185        };
6186        if let Some(ref local_query_param) = filter_tool {
6187            local_req_builder =
6188                local_req_builder.query(&[("filter[tool]", &local_query_param.to_string())]);
6189        };
6190        if let Some(ref local_query_param) = filter_library_name {
6191            local_req_builder = local_req_builder
6192                .query(&[("filter[library.name]", &local_query_param.to_string())]);
6193        };
6194        if let Some(ref local_query_param) = filter_library_version {
6195            local_req_builder = local_req_builder
6196                .query(&[("filter[library.version]", &local_query_param.to_string())]);
6197        };
6198        if let Some(ref local_query_param) = filter_advisory_id {
6199            local_req_builder =
6200                local_req_builder.query(&[("filter[advisory_id]", &local_query_param.to_string())]);
6201        };
6202        if let Some(ref local_query_param) = filter_risks_exploitation_probability {
6203            local_req_builder = local_req_builder.query(&[(
6204                "filter[risks.exploitation_probability]",
6205                &local_query_param.to_string(),
6206            )]);
6207        };
6208        if let Some(ref local_query_param) = filter_risks_poc_exploit_available {
6209            local_req_builder = local_req_builder.query(&[(
6210                "filter[risks.poc_exploit_available]",
6211                &local_query_param.to_string(),
6212            )]);
6213        };
6214        if let Some(ref local_query_param) = filter_risks_exploit_available {
6215            local_req_builder = local_req_builder.query(&[(
6216                "filter[risks.exploit_available]",
6217                &local_query_param.to_string(),
6218            )]);
6219        };
6220        if let Some(ref local_query_param) = filter_risks_epss_score_op {
6221            local_req_builder = local_req_builder.query(&[(
6222                "filter[risks.epss.score][`$op`]",
6223                &local_query_param.to_string(),
6224            )]);
6225        };
6226        if let Some(ref local_query_param) = filter_risks_epss_severity {
6227            local_req_builder = local_req_builder.query(&[(
6228                "filter[risks.epss.severity]",
6229                &local_query_param.to_string(),
6230            )]);
6231        };
6232        if let Some(ref local_query_param) = filter_language {
6233            local_req_builder =
6234                local_req_builder.query(&[("filter[language]", &local_query_param.to_string())]);
6235        };
6236        if let Some(ref local_query_param) = filter_ecosystem {
6237            local_req_builder =
6238                local_req_builder.query(&[("filter[ecosystem]", &local_query_param.to_string())]);
6239        };
6240        if let Some(ref local_query_param) = filter_code_location_location {
6241            local_req_builder = local_req_builder.query(&[(
6242                "filter[code_location.location]",
6243                &local_query_param.to_string(),
6244            )]);
6245        };
6246        if let Some(ref local_query_param) = filter_code_location_file_path {
6247            local_req_builder = local_req_builder.query(&[(
6248                "filter[code_location.file_path]",
6249                &local_query_param.to_string(),
6250            )]);
6251        };
6252        if let Some(ref local_query_param) = filter_code_location_method {
6253            local_req_builder = local_req_builder.query(&[(
6254                "filter[code_location.method]",
6255                &local_query_param.to_string(),
6256            )]);
6257        };
6258        if let Some(ref local_query_param) = filter_fix_available {
6259            local_req_builder = local_req_builder
6260                .query(&[("filter[fix_available]", &local_query_param.to_string())]);
6261        };
6262        if let Some(ref local_query_param) = filter_repo_digests {
6263            local_req_builder = local_req_builder
6264                .query(&[("filter[repo_digests]", &local_query_param.to_string())]);
6265        };
6266        if let Some(ref local_query_param) = filter_asset_name {
6267            local_req_builder =
6268                local_req_builder.query(&[("filter[asset.name]", &local_query_param.to_string())]);
6269        };
6270        if let Some(ref local_query_param) = filter_asset_type {
6271            local_req_builder =
6272                local_req_builder.query(&[("filter[asset.type]", &local_query_param.to_string())]);
6273        };
6274        if let Some(ref local_query_param) = filter_asset_version_first {
6275            local_req_builder = local_req_builder.query(&[(
6276                "filter[asset.version.first]",
6277                &local_query_param.to_string(),
6278            )]);
6279        };
6280        if let Some(ref local_query_param) = filter_asset_version_last {
6281            local_req_builder = local_req_builder
6282                .query(&[("filter[asset.version.last]", &local_query_param.to_string())]);
6283        };
6284        if let Some(ref local_query_param) = filter_asset_repository_url {
6285            local_req_builder = local_req_builder.query(&[(
6286                "filter[asset.repository_url]",
6287                &local_query_param.to_string(),
6288            )]);
6289        };
6290        if let Some(ref local_query_param) = filter_asset_risks_in_production {
6291            local_req_builder = local_req_builder.query(&[(
6292                "filter[asset.risks.in_production]",
6293                &local_query_param.to_string(),
6294            )]);
6295        };
6296        if let Some(ref local_query_param) = filter_asset_risks_under_attack {
6297            local_req_builder = local_req_builder.query(&[(
6298                "filter[asset.risks.under_attack]",
6299                &local_query_param.to_string(),
6300            )]);
6301        };
6302        if let Some(ref local_query_param) = filter_asset_risks_is_publicly_accessible {
6303            local_req_builder = local_req_builder.query(&[(
6304                "filter[asset.risks.is_publicly_accessible]",
6305                &local_query_param.to_string(),
6306            )]);
6307        };
6308        if let Some(ref local_query_param) = filter_asset_risks_has_privileged_access {
6309            local_req_builder = local_req_builder.query(&[(
6310                "filter[asset.risks.has_privileged_access]",
6311                &local_query_param.to_string(),
6312            )]);
6313        };
6314        if let Some(ref local_query_param) = filter_asset_risks_has_access_to_sensitive_data {
6315            local_req_builder = local_req_builder.query(&[(
6316                "filter[asset.risks.has_access_to_sensitive_data]",
6317                &local_query_param.to_string(),
6318            )]);
6319        };
6320        if let Some(ref local_query_param) = filter_asset_environments {
6321            local_req_builder = local_req_builder
6322                .query(&[("filter[asset.environments]", &local_query_param.to_string())]);
6323        };
6324        if let Some(ref local_query_param) = filter_asset_arch {
6325            local_req_builder =
6326                local_req_builder.query(&[("filter[asset.arch]", &local_query_param.to_string())]);
6327        };
6328        if let Some(ref local_query_param) = filter_asset_operating_system_name {
6329            local_req_builder = local_req_builder.query(&[(
6330                "filter[asset.operating_system.name]",
6331                &local_query_param.to_string(),
6332            )]);
6333        };
6334        if let Some(ref local_query_param) = filter_asset_operating_system_version {
6335            local_req_builder = local_req_builder.query(&[(
6336                "filter[asset.operating_system.version]",
6337                &local_query_param.to_string(),
6338            )]);
6339        };
6340
6341        // build headers
6342        let mut headers = HeaderMap::new();
6343        headers.insert("Accept", HeaderValue::from_static("application/json"));
6344
6345        // build user agent
6346        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
6347            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
6348            Err(e) => {
6349                log::warn!("Failed to parse user agent header: {e}, falling back to default");
6350                headers.insert(
6351                    reqwest::header::USER_AGENT,
6352                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
6353                )
6354            }
6355        };
6356
6357        // build auth
6358        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
6359            headers.insert(
6360                "DD-API-KEY",
6361                HeaderValue::from_str(local_key.key.as_str())
6362                    .expect("failed to parse DD-API-KEY header"),
6363            );
6364        };
6365        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
6366            headers.insert(
6367                "DD-APPLICATION-KEY",
6368                HeaderValue::from_str(local_key.key.as_str())
6369                    .expect("failed to parse DD-APPLICATION-KEY header"),
6370            );
6371        };
6372
6373        local_req_builder = local_req_builder.headers(headers);
6374        let local_req = local_req_builder.build()?;
6375        log::debug!("request content: {:?}", local_req.body());
6376        let local_resp = local_client.execute(local_req).await?;
6377
6378        let local_status = local_resp.status();
6379        let local_content = local_resp.text().await?;
6380        log::debug!("response content: {}", local_content);
6381
6382        if !local_status.is_client_error() && !local_status.is_server_error() {
6383            match serde_json::from_str::<crate::datadogV2::model::ListVulnerabilitiesResponse>(
6384                &local_content,
6385            ) {
6386                Ok(e) => {
6387                    return Ok(datadog::ResponseContent {
6388                        status: local_status,
6389                        content: local_content,
6390                        entity: Some(e),
6391                    })
6392                }
6393                Err(e) => return Err(datadog::Error::Serde(e)),
6394            };
6395        } else {
6396            let local_entity: Option<ListVulnerabilitiesError> =
6397                serde_json::from_str(&local_content).ok();
6398            let local_error = datadog::ResponseContent {
6399                status: local_status,
6400                content: local_content,
6401                entity: local_entity,
6402            };
6403            Err(datadog::Error::ResponseError(local_error))
6404        }
6405    }
6406
6407    /// Get a list of vulnerable assets.
6408    ///
6409    /// ### Pagination
6410    ///
6411    /// Please review the [Pagination section for the "List Vulnerabilities"](#pagination) endpoint.
6412    ///
6413    /// ### Filtering
6414    ///
6415    /// Please review the [Filtering section for the "List Vulnerabilities"](#filtering) endpoint.
6416    ///
6417    /// ### Metadata
6418    ///
6419    /// Please review the [Metadata section for the "List Vulnerabilities"](#metadata) endpoint.
6420    ///
6421    pub async fn list_vulnerable_assets(
6422        &self,
6423        params: ListVulnerableAssetsOptionalParams,
6424    ) -> Result<
6425        crate::datadogV2::model::ListVulnerableAssetsResponse,
6426        datadog::Error<ListVulnerableAssetsError>,
6427    > {
6428        match self.list_vulnerable_assets_with_http_info(params).await {
6429            Ok(response_content) => {
6430                if let Some(e) = response_content.entity {
6431                    Ok(e)
6432                } else {
6433                    Err(datadog::Error::Serde(serde::de::Error::custom(
6434                        "response content was None",
6435                    )))
6436                }
6437            }
6438            Err(err) => Err(err),
6439        }
6440    }
6441
6442    /// Get a list of vulnerable assets.
6443    ///
6444    /// ### Pagination
6445    ///
6446    /// Please review the [Pagination section for the "List Vulnerabilities"](#pagination) endpoint.
6447    ///
6448    /// ### Filtering
6449    ///
6450    /// Please review the [Filtering section for the "List Vulnerabilities"](#filtering) endpoint.
6451    ///
6452    /// ### Metadata
6453    ///
6454    /// Please review the [Metadata section for the "List Vulnerabilities"](#metadata) endpoint.
6455    ///
6456    pub async fn list_vulnerable_assets_with_http_info(
6457        &self,
6458        params: ListVulnerableAssetsOptionalParams,
6459    ) -> Result<
6460        datadog::ResponseContent<crate::datadogV2::model::ListVulnerableAssetsResponse>,
6461        datadog::Error<ListVulnerableAssetsError>,
6462    > {
6463        let local_configuration = &self.config;
6464        let operation_id = "v2.list_vulnerable_assets";
6465        if local_configuration.is_unstable_operation_enabled(operation_id) {
6466            warn!("Using unstable operation {operation_id}");
6467        } else {
6468            let local_error = datadog::UnstableOperationDisabledError {
6469                msg: "Operation 'v2.list_vulnerable_assets' is not enabled".to_string(),
6470            };
6471            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
6472        }
6473
6474        // unbox and build optional parameters
6475        let page_token = params.page_token;
6476        let page_number = params.page_number;
6477        let filter_name = params.filter_name;
6478        let filter_type = params.filter_type;
6479        let filter_version_first = params.filter_version_first;
6480        let filter_version_last = params.filter_version_last;
6481        let filter_repository_url = params.filter_repository_url;
6482        let filter_risks_in_production = params.filter_risks_in_production;
6483        let filter_risks_under_attack = params.filter_risks_under_attack;
6484        let filter_risks_is_publicly_accessible = params.filter_risks_is_publicly_accessible;
6485        let filter_risks_has_privileged_access = params.filter_risks_has_privileged_access;
6486        let filter_risks_has_access_to_sensitive_data =
6487            params.filter_risks_has_access_to_sensitive_data;
6488        let filter_environments = params.filter_environments;
6489        let filter_arch = params.filter_arch;
6490        let filter_operating_system_name = params.filter_operating_system_name;
6491        let filter_operating_system_version = params.filter_operating_system_version;
6492
6493        let local_client = &self.client;
6494
6495        let local_uri_str = format!(
6496            "{}/api/v2/security/assets",
6497            local_configuration.get_operation_host(operation_id)
6498        );
6499        let mut local_req_builder =
6500            local_client.request(reqwest::Method::GET, local_uri_str.as_str());
6501
6502        if let Some(ref local_query_param) = page_token {
6503            local_req_builder =
6504                local_req_builder.query(&[("page[token]", &local_query_param.to_string())]);
6505        };
6506        if let Some(ref local_query_param) = page_number {
6507            local_req_builder =
6508                local_req_builder.query(&[("page[number]", &local_query_param.to_string())]);
6509        };
6510        if let Some(ref local_query_param) = filter_name {
6511            local_req_builder =
6512                local_req_builder.query(&[("filter[name]", &local_query_param.to_string())]);
6513        };
6514        if let Some(ref local_query_param) = filter_type {
6515            local_req_builder =
6516                local_req_builder.query(&[("filter[type]", &local_query_param.to_string())]);
6517        };
6518        if let Some(ref local_query_param) = filter_version_first {
6519            local_req_builder = local_req_builder
6520                .query(&[("filter[version.first]", &local_query_param.to_string())]);
6521        };
6522        if let Some(ref local_query_param) = filter_version_last {
6523            local_req_builder = local_req_builder
6524                .query(&[("filter[version.last]", &local_query_param.to_string())]);
6525        };
6526        if let Some(ref local_query_param) = filter_repository_url {
6527            local_req_builder = local_req_builder
6528                .query(&[("filter[repository_url]", &local_query_param.to_string())]);
6529        };
6530        if let Some(ref local_query_param) = filter_risks_in_production {
6531            local_req_builder = local_req_builder.query(&[(
6532                "filter[risks.in_production]",
6533                &local_query_param.to_string(),
6534            )]);
6535        };
6536        if let Some(ref local_query_param) = filter_risks_under_attack {
6537            local_req_builder = local_req_builder
6538                .query(&[("filter[risks.under_attack]", &local_query_param.to_string())]);
6539        };
6540        if let Some(ref local_query_param) = filter_risks_is_publicly_accessible {
6541            local_req_builder = local_req_builder.query(&[(
6542                "filter[risks.is_publicly_accessible]",
6543                &local_query_param.to_string(),
6544            )]);
6545        };
6546        if let Some(ref local_query_param) = filter_risks_has_privileged_access {
6547            local_req_builder = local_req_builder.query(&[(
6548                "filter[risks.has_privileged_access]",
6549                &local_query_param.to_string(),
6550            )]);
6551        };
6552        if let Some(ref local_query_param) = filter_risks_has_access_to_sensitive_data {
6553            local_req_builder = local_req_builder.query(&[(
6554                "filter[risks.has_access_to_sensitive_data]",
6555                &local_query_param.to_string(),
6556            )]);
6557        };
6558        if let Some(ref local_query_param) = filter_environments {
6559            local_req_builder = local_req_builder
6560                .query(&[("filter[environments]", &local_query_param.to_string())]);
6561        };
6562        if let Some(ref local_query_param) = filter_arch {
6563            local_req_builder =
6564                local_req_builder.query(&[("filter[arch]", &local_query_param.to_string())]);
6565        };
6566        if let Some(ref local_query_param) = filter_operating_system_name {
6567            local_req_builder = local_req_builder.query(&[(
6568                "filter[operating_system.name]",
6569                &local_query_param.to_string(),
6570            )]);
6571        };
6572        if let Some(ref local_query_param) = filter_operating_system_version {
6573            local_req_builder = local_req_builder.query(&[(
6574                "filter[operating_system.version]",
6575                &local_query_param.to_string(),
6576            )]);
6577        };
6578
6579        // build headers
6580        let mut headers = HeaderMap::new();
6581        headers.insert("Accept", HeaderValue::from_static("application/json"));
6582
6583        // build user agent
6584        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
6585            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
6586            Err(e) => {
6587                log::warn!("Failed to parse user agent header: {e}, falling back to default");
6588                headers.insert(
6589                    reqwest::header::USER_AGENT,
6590                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
6591                )
6592            }
6593        };
6594
6595        // build auth
6596        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
6597            headers.insert(
6598                "DD-API-KEY",
6599                HeaderValue::from_str(local_key.key.as_str())
6600                    .expect("failed to parse DD-API-KEY header"),
6601            );
6602        };
6603        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
6604            headers.insert(
6605                "DD-APPLICATION-KEY",
6606                HeaderValue::from_str(local_key.key.as_str())
6607                    .expect("failed to parse DD-APPLICATION-KEY header"),
6608            );
6609        };
6610
6611        local_req_builder = local_req_builder.headers(headers);
6612        let local_req = local_req_builder.build()?;
6613        log::debug!("request content: {:?}", local_req.body());
6614        let local_resp = local_client.execute(local_req).await?;
6615
6616        let local_status = local_resp.status();
6617        let local_content = local_resp.text().await?;
6618        log::debug!("response content: {}", local_content);
6619
6620        if !local_status.is_client_error() && !local_status.is_server_error() {
6621            match serde_json::from_str::<crate::datadogV2::model::ListVulnerableAssetsResponse>(
6622                &local_content,
6623            ) {
6624                Ok(e) => {
6625                    return Ok(datadog::ResponseContent {
6626                        status: local_status,
6627                        content: local_content,
6628                        entity: Some(e),
6629                    })
6630                }
6631                Err(e) => return Err(datadog::Error::Serde(e)),
6632            };
6633        } else {
6634            let local_entity: Option<ListVulnerableAssetsError> =
6635                serde_json::from_str(&local_content).ok();
6636            let local_error = datadog::ResponseContent {
6637                status: local_status,
6638                content: local_content,
6639                entity: local_entity,
6640            };
6641            Err(datadog::Error::ResponseError(local_error))
6642        }
6643    }
6644
6645    /// Mute or unmute findings.
6646    pub async fn mute_findings(
6647        &self,
6648        body: crate::datadogV2::model::BulkMuteFindingsRequest,
6649    ) -> Result<crate::datadogV2::model::BulkMuteFindingsResponse, datadog::Error<MuteFindingsError>>
6650    {
6651        match self.mute_findings_with_http_info(body).await {
6652            Ok(response_content) => {
6653                if let Some(e) = response_content.entity {
6654                    Ok(e)
6655                } else {
6656                    Err(datadog::Error::Serde(serde::de::Error::custom(
6657                        "response content was None",
6658                    )))
6659                }
6660            }
6661            Err(err) => Err(err),
6662        }
6663    }
6664
6665    /// Mute or unmute findings.
6666    pub async fn mute_findings_with_http_info(
6667        &self,
6668        body: crate::datadogV2::model::BulkMuteFindingsRequest,
6669    ) -> Result<
6670        datadog::ResponseContent<crate::datadogV2::model::BulkMuteFindingsResponse>,
6671        datadog::Error<MuteFindingsError>,
6672    > {
6673        let local_configuration = &self.config;
6674        let operation_id = "v2.mute_findings";
6675        if local_configuration.is_unstable_operation_enabled(operation_id) {
6676            warn!("Using unstable operation {operation_id}");
6677        } else {
6678            let local_error = datadog::UnstableOperationDisabledError {
6679                msg: "Operation 'v2.mute_findings' is not enabled".to_string(),
6680            };
6681            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
6682        }
6683
6684        let local_client = &self.client;
6685
6686        let local_uri_str = format!(
6687            "{}/api/v2/posture_management/findings",
6688            local_configuration.get_operation_host(operation_id)
6689        );
6690        let mut local_req_builder =
6691            local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
6692
6693        // build headers
6694        let mut headers = HeaderMap::new();
6695        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
6696        headers.insert("Accept", HeaderValue::from_static("application/json"));
6697
6698        // build user agent
6699        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
6700            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
6701            Err(e) => {
6702                log::warn!("Failed to parse user agent header: {e}, falling back to default");
6703                headers.insert(
6704                    reqwest::header::USER_AGENT,
6705                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
6706                )
6707            }
6708        };
6709
6710        // build auth
6711        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
6712            headers.insert(
6713                "DD-API-KEY",
6714                HeaderValue::from_str(local_key.key.as_str())
6715                    .expect("failed to parse DD-API-KEY header"),
6716            );
6717        };
6718        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
6719            headers.insert(
6720                "DD-APPLICATION-KEY",
6721                HeaderValue::from_str(local_key.key.as_str())
6722                    .expect("failed to parse DD-APPLICATION-KEY header"),
6723            );
6724        };
6725
6726        // build body parameters
6727        let output = Vec::new();
6728        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
6729        if body.serialize(&mut ser).is_ok() {
6730            if let Some(content_encoding) = headers.get("Content-Encoding") {
6731                match content_encoding.to_str().unwrap_or_default() {
6732                    "gzip" => {
6733                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
6734                        let _ = enc.write_all(ser.into_inner().as_slice());
6735                        match enc.finish() {
6736                            Ok(buf) => {
6737                                local_req_builder = local_req_builder.body(buf);
6738                            }
6739                            Err(e) => return Err(datadog::Error::Io(e)),
6740                        }
6741                    }
6742                    "deflate" => {
6743                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
6744                        let _ = enc.write_all(ser.into_inner().as_slice());
6745                        match enc.finish() {
6746                            Ok(buf) => {
6747                                local_req_builder = local_req_builder.body(buf);
6748                            }
6749                            Err(e) => return Err(datadog::Error::Io(e)),
6750                        }
6751                    }
6752                    "zstd1" => {
6753                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
6754                        let _ = enc.write_all(ser.into_inner().as_slice());
6755                        match enc.finish() {
6756                            Ok(buf) => {
6757                                local_req_builder = local_req_builder.body(buf);
6758                            }
6759                            Err(e) => return Err(datadog::Error::Io(e)),
6760                        }
6761                    }
6762                    _ => {
6763                        local_req_builder = local_req_builder.body(ser.into_inner());
6764                    }
6765                }
6766            } else {
6767                local_req_builder = local_req_builder.body(ser.into_inner());
6768            }
6769        }
6770
6771        local_req_builder = local_req_builder.headers(headers);
6772        let local_req = local_req_builder.build()?;
6773        log::debug!("request content: {:?}", local_req.body());
6774        let local_resp = local_client.execute(local_req).await?;
6775
6776        let local_status = local_resp.status();
6777        let local_content = local_resp.text().await?;
6778        log::debug!("response content: {}", local_content);
6779
6780        if !local_status.is_client_error() && !local_status.is_server_error() {
6781            match serde_json::from_str::<crate::datadogV2::model::BulkMuteFindingsResponse>(
6782                &local_content,
6783            ) {
6784                Ok(e) => {
6785                    return Ok(datadog::ResponseContent {
6786                        status: local_status,
6787                        content: local_content,
6788                        entity: Some(e),
6789                    })
6790                }
6791                Err(e) => return Err(datadog::Error::Serde(e)),
6792            };
6793        } else {
6794            let local_entity: Option<MuteFindingsError> = 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    /// Partially update the notification rule. All fields are optional; if a field is not provided, it is not updated.
6805    pub async fn patch_signal_notification_rule(
6806        &self,
6807        id: String,
6808        body: crate::datadogV2::model::PatchNotificationRuleParameters,
6809    ) -> Result<
6810        crate::datadogV2::model::NotificationRuleResponse,
6811        datadog::Error<PatchSignalNotificationRuleError>,
6812    > {
6813        match self
6814            .patch_signal_notification_rule_with_http_info(id, body)
6815            .await
6816        {
6817            Ok(response_content) => {
6818                if let Some(e) = response_content.entity {
6819                    Ok(e)
6820                } else {
6821                    Err(datadog::Error::Serde(serde::de::Error::custom(
6822                        "response content was None",
6823                    )))
6824                }
6825            }
6826            Err(err) => Err(err),
6827        }
6828    }
6829
6830    /// Partially update the notification rule. All fields are optional; if a field is not provided, it is not updated.
6831    pub async fn patch_signal_notification_rule_with_http_info(
6832        &self,
6833        id: String,
6834        body: crate::datadogV2::model::PatchNotificationRuleParameters,
6835    ) -> Result<
6836        datadog::ResponseContent<crate::datadogV2::model::NotificationRuleResponse>,
6837        datadog::Error<PatchSignalNotificationRuleError>,
6838    > {
6839        let local_configuration = &self.config;
6840        let operation_id = "v2.patch_signal_notification_rule";
6841
6842        let local_client = &self.client;
6843
6844        let local_uri_str = format!(
6845            "{}/api/v2/security/signals/notification_rules/{id}",
6846            local_configuration.get_operation_host(operation_id),
6847            id = datadog::urlencode(id)
6848        );
6849        let mut local_req_builder =
6850            local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
6851
6852        // build headers
6853        let mut headers = HeaderMap::new();
6854        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
6855        headers.insert("Accept", HeaderValue::from_static("application/json"));
6856
6857        // build user agent
6858        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
6859            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
6860            Err(e) => {
6861                log::warn!("Failed to parse user agent header: {e}, falling back to default");
6862                headers.insert(
6863                    reqwest::header::USER_AGENT,
6864                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
6865                )
6866            }
6867        };
6868
6869        // build auth
6870        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
6871            headers.insert(
6872                "DD-API-KEY",
6873                HeaderValue::from_str(local_key.key.as_str())
6874                    .expect("failed to parse DD-API-KEY header"),
6875            );
6876        };
6877        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
6878            headers.insert(
6879                "DD-APPLICATION-KEY",
6880                HeaderValue::from_str(local_key.key.as_str())
6881                    .expect("failed to parse DD-APPLICATION-KEY header"),
6882            );
6883        };
6884
6885        // build body parameters
6886        let output = Vec::new();
6887        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
6888        if body.serialize(&mut ser).is_ok() {
6889            if let Some(content_encoding) = headers.get("Content-Encoding") {
6890                match content_encoding.to_str().unwrap_or_default() {
6891                    "gzip" => {
6892                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
6893                        let _ = enc.write_all(ser.into_inner().as_slice());
6894                        match enc.finish() {
6895                            Ok(buf) => {
6896                                local_req_builder = local_req_builder.body(buf);
6897                            }
6898                            Err(e) => return Err(datadog::Error::Io(e)),
6899                        }
6900                    }
6901                    "deflate" => {
6902                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
6903                        let _ = enc.write_all(ser.into_inner().as_slice());
6904                        match enc.finish() {
6905                            Ok(buf) => {
6906                                local_req_builder = local_req_builder.body(buf);
6907                            }
6908                            Err(e) => return Err(datadog::Error::Io(e)),
6909                        }
6910                    }
6911                    "zstd1" => {
6912                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
6913                        let _ = enc.write_all(ser.into_inner().as_slice());
6914                        match enc.finish() {
6915                            Ok(buf) => {
6916                                local_req_builder = local_req_builder.body(buf);
6917                            }
6918                            Err(e) => return Err(datadog::Error::Io(e)),
6919                        }
6920                    }
6921                    _ => {
6922                        local_req_builder = local_req_builder.body(ser.into_inner());
6923                    }
6924                }
6925            } else {
6926                local_req_builder = local_req_builder.body(ser.into_inner());
6927            }
6928        }
6929
6930        local_req_builder = local_req_builder.headers(headers);
6931        let local_req = local_req_builder.build()?;
6932        log::debug!("request content: {:?}", local_req.body());
6933        let local_resp = local_client.execute(local_req).await?;
6934
6935        let local_status = local_resp.status();
6936        let local_content = local_resp.text().await?;
6937        log::debug!("response content: {}", local_content);
6938
6939        if !local_status.is_client_error() && !local_status.is_server_error() {
6940            match serde_json::from_str::<crate::datadogV2::model::NotificationRuleResponse>(
6941                &local_content,
6942            ) {
6943                Ok(e) => {
6944                    return Ok(datadog::ResponseContent {
6945                        status: local_status,
6946                        content: local_content,
6947                        entity: Some(e),
6948                    })
6949                }
6950                Err(e) => return Err(datadog::Error::Serde(e)),
6951            };
6952        } else {
6953            let local_entity: Option<PatchSignalNotificationRuleError> =
6954                serde_json::from_str(&local_content).ok();
6955            let local_error = datadog::ResponseContent {
6956                status: local_status,
6957                content: local_content,
6958                entity: local_entity,
6959            };
6960            Err(datadog::Error::ResponseError(local_error))
6961        }
6962    }
6963
6964    /// Partially update the notification rule. All fields are optional; if a field is not provided, it is not updated.
6965    pub async fn patch_vulnerability_notification_rule(
6966        &self,
6967        id: String,
6968        body: crate::datadogV2::model::PatchNotificationRuleParameters,
6969    ) -> Result<
6970        crate::datadogV2::model::NotificationRuleResponse,
6971        datadog::Error<PatchVulnerabilityNotificationRuleError>,
6972    > {
6973        match self
6974            .patch_vulnerability_notification_rule_with_http_info(id, body)
6975            .await
6976        {
6977            Ok(response_content) => {
6978                if let Some(e) = response_content.entity {
6979                    Ok(e)
6980                } else {
6981                    Err(datadog::Error::Serde(serde::de::Error::custom(
6982                        "response content was None",
6983                    )))
6984                }
6985            }
6986            Err(err) => Err(err),
6987        }
6988    }
6989
6990    /// Partially update the notification rule. All fields are optional; if a field is not provided, it is not updated.
6991    pub async fn patch_vulnerability_notification_rule_with_http_info(
6992        &self,
6993        id: String,
6994        body: crate::datadogV2::model::PatchNotificationRuleParameters,
6995    ) -> Result<
6996        datadog::ResponseContent<crate::datadogV2::model::NotificationRuleResponse>,
6997        datadog::Error<PatchVulnerabilityNotificationRuleError>,
6998    > {
6999        let local_configuration = &self.config;
7000        let operation_id = "v2.patch_vulnerability_notification_rule";
7001
7002        let local_client = &self.client;
7003
7004        let local_uri_str = format!(
7005            "{}/api/v2/security/vulnerabilities/notification_rules/{id}",
7006            local_configuration.get_operation_host(operation_id),
7007            id = datadog::urlencode(id)
7008        );
7009        let mut local_req_builder =
7010            local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
7011
7012        // build headers
7013        let mut headers = HeaderMap::new();
7014        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
7015        headers.insert("Accept", HeaderValue::from_static("application/json"));
7016
7017        // build user agent
7018        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
7019            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
7020            Err(e) => {
7021                log::warn!("Failed to parse user agent header: {e}, falling back to default");
7022                headers.insert(
7023                    reqwest::header::USER_AGENT,
7024                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
7025                )
7026            }
7027        };
7028
7029        // build auth
7030        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
7031            headers.insert(
7032                "DD-API-KEY",
7033                HeaderValue::from_str(local_key.key.as_str())
7034                    .expect("failed to parse DD-API-KEY header"),
7035            );
7036        };
7037        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
7038            headers.insert(
7039                "DD-APPLICATION-KEY",
7040                HeaderValue::from_str(local_key.key.as_str())
7041                    .expect("failed to parse DD-APPLICATION-KEY header"),
7042            );
7043        };
7044
7045        // build body parameters
7046        let output = Vec::new();
7047        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
7048        if body.serialize(&mut ser).is_ok() {
7049            if let Some(content_encoding) = headers.get("Content-Encoding") {
7050                match content_encoding.to_str().unwrap_or_default() {
7051                    "gzip" => {
7052                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
7053                        let _ = enc.write_all(ser.into_inner().as_slice());
7054                        match enc.finish() {
7055                            Ok(buf) => {
7056                                local_req_builder = local_req_builder.body(buf);
7057                            }
7058                            Err(e) => return Err(datadog::Error::Io(e)),
7059                        }
7060                    }
7061                    "deflate" => {
7062                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
7063                        let _ = enc.write_all(ser.into_inner().as_slice());
7064                        match enc.finish() {
7065                            Ok(buf) => {
7066                                local_req_builder = local_req_builder.body(buf);
7067                            }
7068                            Err(e) => return Err(datadog::Error::Io(e)),
7069                        }
7070                    }
7071                    "zstd1" => {
7072                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
7073                        let _ = enc.write_all(ser.into_inner().as_slice());
7074                        match enc.finish() {
7075                            Ok(buf) => {
7076                                local_req_builder = local_req_builder.body(buf);
7077                            }
7078                            Err(e) => return Err(datadog::Error::Io(e)),
7079                        }
7080                    }
7081                    _ => {
7082                        local_req_builder = local_req_builder.body(ser.into_inner());
7083                    }
7084                }
7085            } else {
7086                local_req_builder = local_req_builder.body(ser.into_inner());
7087            }
7088        }
7089
7090        local_req_builder = local_req_builder.headers(headers);
7091        let local_req = local_req_builder.build()?;
7092        log::debug!("request content: {:?}", local_req.body());
7093        let local_resp = local_client.execute(local_req).await?;
7094
7095        let local_status = local_resp.status();
7096        let local_content = local_resp.text().await?;
7097        log::debug!("response content: {}", local_content);
7098
7099        if !local_status.is_client_error() && !local_status.is_server_error() {
7100            match serde_json::from_str::<crate::datadogV2::model::NotificationRuleResponse>(
7101                &local_content,
7102            ) {
7103                Ok(e) => {
7104                    return Ok(datadog::ResponseContent {
7105                        status: local_status,
7106                        content: local_content,
7107                        entity: Some(e),
7108                    })
7109                }
7110                Err(e) => return Err(datadog::Error::Serde(e)),
7111            };
7112        } else {
7113            let local_entity: Option<PatchVulnerabilityNotificationRuleError> =
7114                serde_json::from_str(&local_content).ok();
7115            let local_error = datadog::ResponseContent {
7116                status: local_status,
7117                content: local_content,
7118                entity: local_entity,
7119            };
7120            Err(datadog::Error::ResponseError(local_error))
7121        }
7122    }
7123
7124    /// Run a historical job.
7125    pub async fn run_historical_job(
7126        &self,
7127        body: crate::datadogV2::model::RunHistoricalJobRequest,
7128    ) -> Result<crate::datadogV2::model::JobCreateResponse, datadog::Error<RunHistoricalJobError>>
7129    {
7130        match self.run_historical_job_with_http_info(body).await {
7131            Ok(response_content) => {
7132                if let Some(e) = response_content.entity {
7133                    Ok(e)
7134                } else {
7135                    Err(datadog::Error::Serde(serde::de::Error::custom(
7136                        "response content was None",
7137                    )))
7138                }
7139            }
7140            Err(err) => Err(err),
7141        }
7142    }
7143
7144    /// Run a historical job.
7145    pub async fn run_historical_job_with_http_info(
7146        &self,
7147        body: crate::datadogV2::model::RunHistoricalJobRequest,
7148    ) -> Result<
7149        datadog::ResponseContent<crate::datadogV2::model::JobCreateResponse>,
7150        datadog::Error<RunHistoricalJobError>,
7151    > {
7152        let local_configuration = &self.config;
7153        let operation_id = "v2.run_historical_job";
7154        if local_configuration.is_unstable_operation_enabled(operation_id) {
7155            warn!("Using unstable operation {operation_id}");
7156        } else {
7157            let local_error = datadog::UnstableOperationDisabledError {
7158                msg: "Operation 'v2.run_historical_job' is not enabled".to_string(),
7159            };
7160            return Err(datadog::Error::UnstableOperationDisabledError(local_error));
7161        }
7162
7163        let local_client = &self.client;
7164
7165        let local_uri_str = format!(
7166            "{}/api/v2/siem-historical-detections/jobs",
7167            local_configuration.get_operation_host(operation_id)
7168        );
7169        let mut local_req_builder =
7170            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
7171
7172        // build headers
7173        let mut headers = HeaderMap::new();
7174        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
7175        headers.insert("Accept", HeaderValue::from_static("application/json"));
7176
7177        // build user agent
7178        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
7179            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
7180            Err(e) => {
7181                log::warn!("Failed to parse user agent header: {e}, falling back to default");
7182                headers.insert(
7183                    reqwest::header::USER_AGENT,
7184                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
7185                )
7186            }
7187        };
7188
7189        // build auth
7190        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
7191            headers.insert(
7192                "DD-API-KEY",
7193                HeaderValue::from_str(local_key.key.as_str())
7194                    .expect("failed to parse DD-API-KEY header"),
7195            );
7196        };
7197        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
7198            headers.insert(
7199                "DD-APPLICATION-KEY",
7200                HeaderValue::from_str(local_key.key.as_str())
7201                    .expect("failed to parse DD-APPLICATION-KEY header"),
7202            );
7203        };
7204
7205        // build body parameters
7206        let output = Vec::new();
7207        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
7208        if body.serialize(&mut ser).is_ok() {
7209            if let Some(content_encoding) = headers.get("Content-Encoding") {
7210                match content_encoding.to_str().unwrap_or_default() {
7211                    "gzip" => {
7212                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
7213                        let _ = enc.write_all(ser.into_inner().as_slice());
7214                        match enc.finish() {
7215                            Ok(buf) => {
7216                                local_req_builder = local_req_builder.body(buf);
7217                            }
7218                            Err(e) => return Err(datadog::Error::Io(e)),
7219                        }
7220                    }
7221                    "deflate" => {
7222                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
7223                        let _ = enc.write_all(ser.into_inner().as_slice());
7224                        match enc.finish() {
7225                            Ok(buf) => {
7226                                local_req_builder = local_req_builder.body(buf);
7227                            }
7228                            Err(e) => return Err(datadog::Error::Io(e)),
7229                        }
7230                    }
7231                    "zstd1" => {
7232                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
7233                        let _ = enc.write_all(ser.into_inner().as_slice());
7234                        match enc.finish() {
7235                            Ok(buf) => {
7236                                local_req_builder = local_req_builder.body(buf);
7237                            }
7238                            Err(e) => return Err(datadog::Error::Io(e)),
7239                        }
7240                    }
7241                    _ => {
7242                        local_req_builder = local_req_builder.body(ser.into_inner());
7243                    }
7244                }
7245            } else {
7246                local_req_builder = local_req_builder.body(ser.into_inner());
7247            }
7248        }
7249
7250        local_req_builder = local_req_builder.headers(headers);
7251        let local_req = local_req_builder.build()?;
7252        log::debug!("request content: {:?}", local_req.body());
7253        let local_resp = local_client.execute(local_req).await?;
7254
7255        let local_status = local_resp.status();
7256        let local_content = local_resp.text().await?;
7257        log::debug!("response content: {}", local_content);
7258
7259        if !local_status.is_client_error() && !local_status.is_server_error() {
7260            match serde_json::from_str::<crate::datadogV2::model::JobCreateResponse>(&local_content)
7261            {
7262                Ok(e) => {
7263                    return Ok(datadog::ResponseContent {
7264                        status: local_status,
7265                        content: local_content,
7266                        entity: Some(e),
7267                    })
7268                }
7269                Err(e) => return Err(datadog::Error::Serde(e)),
7270            };
7271        } else {
7272            let local_entity: Option<RunHistoricalJobError> =
7273                serde_json::from_str(&local_content).ok();
7274            let local_error = datadog::ResponseContent {
7275                status: local_status,
7276                content: local_content,
7277                entity: local_entity,
7278            };
7279            Err(datadog::Error::ResponseError(local_error))
7280        }
7281    }
7282
7283    /// Returns security signals that match a search query.
7284    /// Both this endpoint and the GET endpoint can be used interchangeably for listing
7285    /// security signals.
7286    pub async fn search_security_monitoring_signals(
7287        &self,
7288        params: SearchSecurityMonitoringSignalsOptionalParams,
7289    ) -> Result<
7290        crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
7291        datadog::Error<SearchSecurityMonitoringSignalsError>,
7292    > {
7293        match self
7294            .search_security_monitoring_signals_with_http_info(params)
7295            .await
7296        {
7297            Ok(response_content) => {
7298                if let Some(e) = response_content.entity {
7299                    Ok(e)
7300                } else {
7301                    Err(datadog::Error::Serde(serde::de::Error::custom(
7302                        "response content was None",
7303                    )))
7304                }
7305            }
7306            Err(err) => Err(err),
7307        }
7308    }
7309
7310    pub fn search_security_monitoring_signals_with_pagination(
7311        &self,
7312        mut params: SearchSecurityMonitoringSignalsOptionalParams,
7313    ) -> impl Stream<
7314        Item = Result<
7315            crate::datadogV2::model::SecurityMonitoringSignal,
7316            datadog::Error<SearchSecurityMonitoringSignalsError>,
7317        >,
7318    > + '_ {
7319        try_stream! {
7320            let mut page_size: i32 = 10;
7321            if params.body.is_none() {
7322                params.body = Some(crate::datadogV2::model::SecurityMonitoringSignalListRequest::new());
7323            }
7324            if params.body.as_ref().unwrap().page.is_none() {
7325                params.body.as_mut().unwrap().page = Some(crate::datadogV2::model::SecurityMonitoringSignalListRequestPage::new());
7326            }
7327            if params.body.as_ref().unwrap().page.as_ref().unwrap().limit.is_none() {
7328                params.body.as_mut().unwrap().page.as_mut().unwrap().limit = Some(page_size);
7329            } else {
7330                page_size = params.body.as_ref().unwrap().page.as_ref().unwrap().limit.unwrap().clone();
7331            }
7332            loop {
7333                let resp = self.search_security_monitoring_signals(params.clone()).await?;
7334                let Some(data) = resp.data else { break };
7335
7336                let r = data;
7337                let count = r.len();
7338                for team in r {
7339                    yield team;
7340                }
7341
7342                if count < page_size as usize {
7343                    break;
7344                }
7345                let Some(meta) = resp.meta else { break };
7346                let Some(page) = meta.page else { break };
7347                let Some(after) = page.after else { break };
7348
7349                params.body.as_mut().unwrap().page.as_mut().unwrap().cursor = Some(after);
7350            }
7351        }
7352    }
7353
7354    /// Returns security signals that match a search query.
7355    /// Both this endpoint and the GET endpoint can be used interchangeably for listing
7356    /// security signals.
7357    pub async fn search_security_monitoring_signals_with_http_info(
7358        &self,
7359        params: SearchSecurityMonitoringSignalsOptionalParams,
7360    ) -> Result<
7361        datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSignalsListResponse>,
7362        datadog::Error<SearchSecurityMonitoringSignalsError>,
7363    > {
7364        let local_configuration = &self.config;
7365        let operation_id = "v2.search_security_monitoring_signals";
7366
7367        // unbox and build optional parameters
7368        let body = params.body;
7369
7370        let local_client = &self.client;
7371
7372        let local_uri_str = format!(
7373            "{}/api/v2/security_monitoring/signals/search",
7374            local_configuration.get_operation_host(operation_id)
7375        );
7376        let mut local_req_builder =
7377            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
7378
7379        // build headers
7380        let mut headers = HeaderMap::new();
7381        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
7382        headers.insert("Accept", HeaderValue::from_static("application/json"));
7383
7384        // build user agent
7385        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
7386            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
7387            Err(e) => {
7388                log::warn!("Failed to parse user agent header: {e}, falling back to default");
7389                headers.insert(
7390                    reqwest::header::USER_AGENT,
7391                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
7392                )
7393            }
7394        };
7395
7396        // build auth
7397        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
7398            headers.insert(
7399                "DD-API-KEY",
7400                HeaderValue::from_str(local_key.key.as_str())
7401                    .expect("failed to parse DD-API-KEY header"),
7402            );
7403        };
7404        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
7405            headers.insert(
7406                "DD-APPLICATION-KEY",
7407                HeaderValue::from_str(local_key.key.as_str())
7408                    .expect("failed to parse DD-APPLICATION-KEY header"),
7409            );
7410        };
7411
7412        // build body parameters
7413        let output = Vec::new();
7414        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
7415        if body.serialize(&mut ser).is_ok() {
7416            if let Some(content_encoding) = headers.get("Content-Encoding") {
7417                match content_encoding.to_str().unwrap_or_default() {
7418                    "gzip" => {
7419                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
7420                        let _ = enc.write_all(ser.into_inner().as_slice());
7421                        match enc.finish() {
7422                            Ok(buf) => {
7423                                local_req_builder = local_req_builder.body(buf);
7424                            }
7425                            Err(e) => return Err(datadog::Error::Io(e)),
7426                        }
7427                    }
7428                    "deflate" => {
7429                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
7430                        let _ = enc.write_all(ser.into_inner().as_slice());
7431                        match enc.finish() {
7432                            Ok(buf) => {
7433                                local_req_builder = local_req_builder.body(buf);
7434                            }
7435                            Err(e) => return Err(datadog::Error::Io(e)),
7436                        }
7437                    }
7438                    "zstd1" => {
7439                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
7440                        let _ = enc.write_all(ser.into_inner().as_slice());
7441                        match enc.finish() {
7442                            Ok(buf) => {
7443                                local_req_builder = local_req_builder.body(buf);
7444                            }
7445                            Err(e) => return Err(datadog::Error::Io(e)),
7446                        }
7447                    }
7448                    _ => {
7449                        local_req_builder = local_req_builder.body(ser.into_inner());
7450                    }
7451                }
7452            } else {
7453                local_req_builder = local_req_builder.body(ser.into_inner());
7454            }
7455        }
7456
7457        local_req_builder = local_req_builder.headers(headers);
7458        let local_req = local_req_builder.build()?;
7459        log::debug!("request content: {:?}", local_req.body());
7460        let local_resp = local_client.execute(local_req).await?;
7461
7462        let local_status = local_resp.status();
7463        let local_content = local_resp.text().await?;
7464        log::debug!("response content: {}", local_content);
7465
7466        if !local_status.is_client_error() && !local_status.is_server_error() {
7467            match serde_json::from_str::<
7468                crate::datadogV2::model::SecurityMonitoringSignalsListResponse,
7469            >(&local_content)
7470            {
7471                Ok(e) => {
7472                    return Ok(datadog::ResponseContent {
7473                        status: local_status,
7474                        content: local_content,
7475                        entity: Some(e),
7476                    })
7477                }
7478                Err(e) => return Err(datadog::Error::Serde(e)),
7479            };
7480        } else {
7481            let local_entity: Option<SearchSecurityMonitoringSignalsError> =
7482                serde_json::from_str(&local_content).ok();
7483            let local_error = datadog::ResponseContent {
7484                status: local_status,
7485                content: local_content,
7486                entity: local_entity,
7487            };
7488            Err(datadog::Error::ResponseError(local_error))
7489        }
7490    }
7491
7492    /// Test an existing rule.
7493    pub async fn test_existing_security_monitoring_rule(
7494        &self,
7495        rule_id: String,
7496        body: crate::datadogV2::model::SecurityMonitoringRuleTestRequest,
7497    ) -> Result<
7498        crate::datadogV2::model::SecurityMonitoringRuleTestResponse,
7499        datadog::Error<TestExistingSecurityMonitoringRuleError>,
7500    > {
7501        match self
7502            .test_existing_security_monitoring_rule_with_http_info(rule_id, body)
7503            .await
7504        {
7505            Ok(response_content) => {
7506                if let Some(e) = response_content.entity {
7507                    Ok(e)
7508                } else {
7509                    Err(datadog::Error::Serde(serde::de::Error::custom(
7510                        "response content was None",
7511                    )))
7512                }
7513            }
7514            Err(err) => Err(err),
7515        }
7516    }
7517
7518    /// Test an existing rule.
7519    pub async fn test_existing_security_monitoring_rule_with_http_info(
7520        &self,
7521        rule_id: String,
7522        body: crate::datadogV2::model::SecurityMonitoringRuleTestRequest,
7523    ) -> Result<
7524        datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleTestResponse>,
7525        datadog::Error<TestExistingSecurityMonitoringRuleError>,
7526    > {
7527        let local_configuration = &self.config;
7528        let operation_id = "v2.test_existing_security_monitoring_rule";
7529
7530        let local_client = &self.client;
7531
7532        let local_uri_str = format!(
7533            "{}/api/v2/security_monitoring/rules/{rule_id}/test",
7534            local_configuration.get_operation_host(operation_id),
7535            rule_id = datadog::urlencode(rule_id)
7536        );
7537        let mut local_req_builder =
7538            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
7539
7540        // build headers
7541        let mut headers = HeaderMap::new();
7542        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
7543        headers.insert("Accept", HeaderValue::from_static("application/json"));
7544
7545        // build user agent
7546        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
7547            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
7548            Err(e) => {
7549                log::warn!("Failed to parse user agent header: {e}, falling back to default");
7550                headers.insert(
7551                    reqwest::header::USER_AGENT,
7552                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
7553                )
7554            }
7555        };
7556
7557        // build auth
7558        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
7559            headers.insert(
7560                "DD-API-KEY",
7561                HeaderValue::from_str(local_key.key.as_str())
7562                    .expect("failed to parse DD-API-KEY header"),
7563            );
7564        };
7565        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
7566            headers.insert(
7567                "DD-APPLICATION-KEY",
7568                HeaderValue::from_str(local_key.key.as_str())
7569                    .expect("failed to parse DD-APPLICATION-KEY header"),
7570            );
7571        };
7572
7573        // build body parameters
7574        let output = Vec::new();
7575        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
7576        if body.serialize(&mut ser).is_ok() {
7577            if let Some(content_encoding) = headers.get("Content-Encoding") {
7578                match content_encoding.to_str().unwrap_or_default() {
7579                    "gzip" => {
7580                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
7581                        let _ = enc.write_all(ser.into_inner().as_slice());
7582                        match enc.finish() {
7583                            Ok(buf) => {
7584                                local_req_builder = local_req_builder.body(buf);
7585                            }
7586                            Err(e) => return Err(datadog::Error::Io(e)),
7587                        }
7588                    }
7589                    "deflate" => {
7590                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
7591                        let _ = enc.write_all(ser.into_inner().as_slice());
7592                        match enc.finish() {
7593                            Ok(buf) => {
7594                                local_req_builder = local_req_builder.body(buf);
7595                            }
7596                            Err(e) => return Err(datadog::Error::Io(e)),
7597                        }
7598                    }
7599                    "zstd1" => {
7600                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
7601                        let _ = enc.write_all(ser.into_inner().as_slice());
7602                        match enc.finish() {
7603                            Ok(buf) => {
7604                                local_req_builder = local_req_builder.body(buf);
7605                            }
7606                            Err(e) => return Err(datadog::Error::Io(e)),
7607                        }
7608                    }
7609                    _ => {
7610                        local_req_builder = local_req_builder.body(ser.into_inner());
7611                    }
7612                }
7613            } else {
7614                local_req_builder = local_req_builder.body(ser.into_inner());
7615            }
7616        }
7617
7618        local_req_builder = local_req_builder.headers(headers);
7619        let local_req = local_req_builder.build()?;
7620        log::debug!("request content: {:?}", local_req.body());
7621        let local_resp = local_client.execute(local_req).await?;
7622
7623        let local_status = local_resp.status();
7624        let local_content = local_resp.text().await?;
7625        log::debug!("response content: {}", local_content);
7626
7627        if !local_status.is_client_error() && !local_status.is_server_error() {
7628            match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringRuleTestResponse>(
7629                &local_content,
7630            ) {
7631                Ok(e) => {
7632                    return Ok(datadog::ResponseContent {
7633                        status: local_status,
7634                        content: local_content,
7635                        entity: Some(e),
7636                    })
7637                }
7638                Err(e) => return Err(datadog::Error::Serde(e)),
7639            };
7640        } else {
7641            let local_entity: Option<TestExistingSecurityMonitoringRuleError> =
7642                serde_json::from_str(&local_content).ok();
7643            let local_error = datadog::ResponseContent {
7644                status: local_status,
7645                content: local_content,
7646                entity: local_entity,
7647            };
7648            Err(datadog::Error::ResponseError(local_error))
7649        }
7650    }
7651
7652    /// Test a rule.
7653    pub async fn test_security_monitoring_rule(
7654        &self,
7655        body: crate::datadogV2::model::SecurityMonitoringRuleTestRequest,
7656    ) -> Result<
7657        crate::datadogV2::model::SecurityMonitoringRuleTestResponse,
7658        datadog::Error<TestSecurityMonitoringRuleError>,
7659    > {
7660        match self
7661            .test_security_monitoring_rule_with_http_info(body)
7662            .await
7663        {
7664            Ok(response_content) => {
7665                if let Some(e) = response_content.entity {
7666                    Ok(e)
7667                } else {
7668                    Err(datadog::Error::Serde(serde::de::Error::custom(
7669                        "response content was None",
7670                    )))
7671                }
7672            }
7673            Err(err) => Err(err),
7674        }
7675    }
7676
7677    /// Test a rule.
7678    pub async fn test_security_monitoring_rule_with_http_info(
7679        &self,
7680        body: crate::datadogV2::model::SecurityMonitoringRuleTestRequest,
7681    ) -> Result<
7682        datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleTestResponse>,
7683        datadog::Error<TestSecurityMonitoringRuleError>,
7684    > {
7685        let local_configuration = &self.config;
7686        let operation_id = "v2.test_security_monitoring_rule";
7687
7688        let local_client = &self.client;
7689
7690        let local_uri_str = format!(
7691            "{}/api/v2/security_monitoring/rules/test",
7692            local_configuration.get_operation_host(operation_id)
7693        );
7694        let mut local_req_builder =
7695            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
7696
7697        // build headers
7698        let mut headers = HeaderMap::new();
7699        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
7700        headers.insert("Accept", HeaderValue::from_static("application/json"));
7701
7702        // build user agent
7703        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
7704            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
7705            Err(e) => {
7706                log::warn!("Failed to parse user agent header: {e}, falling back to default");
7707                headers.insert(
7708                    reqwest::header::USER_AGENT,
7709                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
7710                )
7711            }
7712        };
7713
7714        // build auth
7715        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
7716            headers.insert(
7717                "DD-API-KEY",
7718                HeaderValue::from_str(local_key.key.as_str())
7719                    .expect("failed to parse DD-API-KEY header"),
7720            );
7721        };
7722        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
7723            headers.insert(
7724                "DD-APPLICATION-KEY",
7725                HeaderValue::from_str(local_key.key.as_str())
7726                    .expect("failed to parse DD-APPLICATION-KEY header"),
7727            );
7728        };
7729
7730        // build body parameters
7731        let output = Vec::new();
7732        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
7733        if body.serialize(&mut ser).is_ok() {
7734            if let Some(content_encoding) = headers.get("Content-Encoding") {
7735                match content_encoding.to_str().unwrap_or_default() {
7736                    "gzip" => {
7737                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
7738                        let _ = enc.write_all(ser.into_inner().as_slice());
7739                        match enc.finish() {
7740                            Ok(buf) => {
7741                                local_req_builder = local_req_builder.body(buf);
7742                            }
7743                            Err(e) => return Err(datadog::Error::Io(e)),
7744                        }
7745                    }
7746                    "deflate" => {
7747                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
7748                        let _ = enc.write_all(ser.into_inner().as_slice());
7749                        match enc.finish() {
7750                            Ok(buf) => {
7751                                local_req_builder = local_req_builder.body(buf);
7752                            }
7753                            Err(e) => return Err(datadog::Error::Io(e)),
7754                        }
7755                    }
7756                    "zstd1" => {
7757                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
7758                        let _ = enc.write_all(ser.into_inner().as_slice());
7759                        match enc.finish() {
7760                            Ok(buf) => {
7761                                local_req_builder = local_req_builder.body(buf);
7762                            }
7763                            Err(e) => return Err(datadog::Error::Io(e)),
7764                        }
7765                    }
7766                    _ => {
7767                        local_req_builder = local_req_builder.body(ser.into_inner());
7768                    }
7769                }
7770            } else {
7771                local_req_builder = local_req_builder.body(ser.into_inner());
7772            }
7773        }
7774
7775        local_req_builder = local_req_builder.headers(headers);
7776        let local_req = local_req_builder.build()?;
7777        log::debug!("request content: {:?}", local_req.body());
7778        let local_resp = local_client.execute(local_req).await?;
7779
7780        let local_status = local_resp.status();
7781        let local_content = local_resp.text().await?;
7782        log::debug!("response content: {}", local_content);
7783
7784        if !local_status.is_client_error() && !local_status.is_server_error() {
7785            match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringRuleTestResponse>(
7786                &local_content,
7787            ) {
7788                Ok(e) => {
7789                    return Ok(datadog::ResponseContent {
7790                        status: local_status,
7791                        content: local_content,
7792                        entity: Some(e),
7793                    })
7794                }
7795                Err(e) => return Err(datadog::Error::Serde(e)),
7796            };
7797        } else {
7798            let local_entity: Option<TestSecurityMonitoringRuleError> =
7799                serde_json::from_str(&local_content).ok();
7800            let local_error = datadog::ResponseContent {
7801                status: local_status,
7802                content: local_content,
7803                entity: local_entity,
7804            };
7805            Err(datadog::Error::ResponseError(local_error))
7806        }
7807    }
7808
7809    /// Update a specific security filter.
7810    /// Returns the security filter object when the request is successful.
7811    pub async fn update_security_filter(
7812        &self,
7813        security_filter_id: String,
7814        body: crate::datadogV2::model::SecurityFilterUpdateRequest,
7815    ) -> Result<
7816        crate::datadogV2::model::SecurityFilterResponse,
7817        datadog::Error<UpdateSecurityFilterError>,
7818    > {
7819        match self
7820            .update_security_filter_with_http_info(security_filter_id, body)
7821            .await
7822        {
7823            Ok(response_content) => {
7824                if let Some(e) = response_content.entity {
7825                    Ok(e)
7826                } else {
7827                    Err(datadog::Error::Serde(serde::de::Error::custom(
7828                        "response content was None",
7829                    )))
7830                }
7831            }
7832            Err(err) => Err(err),
7833        }
7834    }
7835
7836    /// Update a specific security filter.
7837    /// Returns the security filter object when the request is successful.
7838    pub async fn update_security_filter_with_http_info(
7839        &self,
7840        security_filter_id: String,
7841        body: crate::datadogV2::model::SecurityFilterUpdateRequest,
7842    ) -> Result<
7843        datadog::ResponseContent<crate::datadogV2::model::SecurityFilterResponse>,
7844        datadog::Error<UpdateSecurityFilterError>,
7845    > {
7846        let local_configuration = &self.config;
7847        let operation_id = "v2.update_security_filter";
7848
7849        let local_client = &self.client;
7850
7851        let local_uri_str = format!(
7852            "{}/api/v2/security_monitoring/configuration/security_filters/{security_filter_id}",
7853            local_configuration.get_operation_host(operation_id),
7854            security_filter_id = datadog::urlencode(security_filter_id)
7855        );
7856        let mut local_req_builder =
7857            local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
7858
7859        // build headers
7860        let mut headers = HeaderMap::new();
7861        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
7862        headers.insert("Accept", HeaderValue::from_static("application/json"));
7863
7864        // build user agent
7865        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
7866            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
7867            Err(e) => {
7868                log::warn!("Failed to parse user agent header: {e}, falling back to default");
7869                headers.insert(
7870                    reqwest::header::USER_AGENT,
7871                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
7872                )
7873            }
7874        };
7875
7876        // build auth
7877        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
7878            headers.insert(
7879                "DD-API-KEY",
7880                HeaderValue::from_str(local_key.key.as_str())
7881                    .expect("failed to parse DD-API-KEY header"),
7882            );
7883        };
7884        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
7885            headers.insert(
7886                "DD-APPLICATION-KEY",
7887                HeaderValue::from_str(local_key.key.as_str())
7888                    .expect("failed to parse DD-APPLICATION-KEY header"),
7889            );
7890        };
7891
7892        // build body parameters
7893        let output = Vec::new();
7894        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
7895        if body.serialize(&mut ser).is_ok() {
7896            if let Some(content_encoding) = headers.get("Content-Encoding") {
7897                match content_encoding.to_str().unwrap_or_default() {
7898                    "gzip" => {
7899                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
7900                        let _ = enc.write_all(ser.into_inner().as_slice());
7901                        match enc.finish() {
7902                            Ok(buf) => {
7903                                local_req_builder = local_req_builder.body(buf);
7904                            }
7905                            Err(e) => return Err(datadog::Error::Io(e)),
7906                        }
7907                    }
7908                    "deflate" => {
7909                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
7910                        let _ = enc.write_all(ser.into_inner().as_slice());
7911                        match enc.finish() {
7912                            Ok(buf) => {
7913                                local_req_builder = local_req_builder.body(buf);
7914                            }
7915                            Err(e) => return Err(datadog::Error::Io(e)),
7916                        }
7917                    }
7918                    "zstd1" => {
7919                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
7920                        let _ = enc.write_all(ser.into_inner().as_slice());
7921                        match enc.finish() {
7922                            Ok(buf) => {
7923                                local_req_builder = local_req_builder.body(buf);
7924                            }
7925                            Err(e) => return Err(datadog::Error::Io(e)),
7926                        }
7927                    }
7928                    _ => {
7929                        local_req_builder = local_req_builder.body(ser.into_inner());
7930                    }
7931                }
7932            } else {
7933                local_req_builder = local_req_builder.body(ser.into_inner());
7934            }
7935        }
7936
7937        local_req_builder = local_req_builder.headers(headers);
7938        let local_req = local_req_builder.build()?;
7939        log::debug!("request content: {:?}", local_req.body());
7940        let local_resp = local_client.execute(local_req).await?;
7941
7942        let local_status = local_resp.status();
7943        let local_content = local_resp.text().await?;
7944        log::debug!("response content: {}", local_content);
7945
7946        if !local_status.is_client_error() && !local_status.is_server_error() {
7947            match serde_json::from_str::<crate::datadogV2::model::SecurityFilterResponse>(
7948                &local_content,
7949            ) {
7950                Ok(e) => {
7951                    return Ok(datadog::ResponseContent {
7952                        status: local_status,
7953                        content: local_content,
7954                        entity: Some(e),
7955                    })
7956                }
7957                Err(e) => return Err(datadog::Error::Serde(e)),
7958            };
7959        } else {
7960            let local_entity: Option<UpdateSecurityFilterError> =
7961                serde_json::from_str(&local_content).ok();
7962            let local_error = datadog::ResponseContent {
7963                status: local_status,
7964                content: local_content,
7965                entity: local_entity,
7966            };
7967            Err(datadog::Error::ResponseError(local_error))
7968        }
7969    }
7970
7971    /// Update an existing rule. When updating `cases`, `queries` or `options`, the whole field
7972    /// must be included. For example, when modifying a query all queries must be included.
7973    /// Default rules can only be updated to be enabled, to change notifications, or to update
7974    /// the tags (default tags cannot be removed).
7975    pub async fn update_security_monitoring_rule(
7976        &self,
7977        rule_id: String,
7978        body: crate::datadogV2::model::SecurityMonitoringRuleUpdatePayload,
7979    ) -> Result<
7980        crate::datadogV2::model::SecurityMonitoringRuleResponse,
7981        datadog::Error<UpdateSecurityMonitoringRuleError>,
7982    > {
7983        match self
7984            .update_security_monitoring_rule_with_http_info(rule_id, body)
7985            .await
7986        {
7987            Ok(response_content) => {
7988                if let Some(e) = response_content.entity {
7989                    Ok(e)
7990                } else {
7991                    Err(datadog::Error::Serde(serde::de::Error::custom(
7992                        "response content was None",
7993                    )))
7994                }
7995            }
7996            Err(err) => Err(err),
7997        }
7998    }
7999
8000    /// Update an existing rule. When updating `cases`, `queries` or `options`, the whole field
8001    /// must be included. For example, when modifying a query all queries must be included.
8002    /// Default rules can only be updated to be enabled, to change notifications, or to update
8003    /// the tags (default tags cannot be removed).
8004    pub async fn update_security_monitoring_rule_with_http_info(
8005        &self,
8006        rule_id: String,
8007        body: crate::datadogV2::model::SecurityMonitoringRuleUpdatePayload,
8008    ) -> Result<
8009        datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringRuleResponse>,
8010        datadog::Error<UpdateSecurityMonitoringRuleError>,
8011    > {
8012        let local_configuration = &self.config;
8013        let operation_id = "v2.update_security_monitoring_rule";
8014
8015        let local_client = &self.client;
8016
8017        let local_uri_str = format!(
8018            "{}/api/v2/security_monitoring/rules/{rule_id}",
8019            local_configuration.get_operation_host(operation_id),
8020            rule_id = datadog::urlencode(rule_id)
8021        );
8022        let mut local_req_builder =
8023            local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
8024
8025        // build headers
8026        let mut headers = HeaderMap::new();
8027        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
8028        headers.insert("Accept", HeaderValue::from_static("application/json"));
8029
8030        // build user agent
8031        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
8032            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
8033            Err(e) => {
8034                log::warn!("Failed to parse user agent header: {e}, falling back to default");
8035                headers.insert(
8036                    reqwest::header::USER_AGENT,
8037                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
8038                )
8039            }
8040        };
8041
8042        // build auth
8043        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
8044            headers.insert(
8045                "DD-API-KEY",
8046                HeaderValue::from_str(local_key.key.as_str())
8047                    .expect("failed to parse DD-API-KEY header"),
8048            );
8049        };
8050        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
8051            headers.insert(
8052                "DD-APPLICATION-KEY",
8053                HeaderValue::from_str(local_key.key.as_str())
8054                    .expect("failed to parse DD-APPLICATION-KEY header"),
8055            );
8056        };
8057
8058        // build body parameters
8059        let output = Vec::new();
8060        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
8061        if body.serialize(&mut ser).is_ok() {
8062            if let Some(content_encoding) = headers.get("Content-Encoding") {
8063                match content_encoding.to_str().unwrap_or_default() {
8064                    "gzip" => {
8065                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
8066                        let _ = enc.write_all(ser.into_inner().as_slice());
8067                        match enc.finish() {
8068                            Ok(buf) => {
8069                                local_req_builder = local_req_builder.body(buf);
8070                            }
8071                            Err(e) => return Err(datadog::Error::Io(e)),
8072                        }
8073                    }
8074                    "deflate" => {
8075                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
8076                        let _ = enc.write_all(ser.into_inner().as_slice());
8077                        match enc.finish() {
8078                            Ok(buf) => {
8079                                local_req_builder = local_req_builder.body(buf);
8080                            }
8081                            Err(e) => return Err(datadog::Error::Io(e)),
8082                        }
8083                    }
8084                    "zstd1" => {
8085                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
8086                        let _ = enc.write_all(ser.into_inner().as_slice());
8087                        match enc.finish() {
8088                            Ok(buf) => {
8089                                local_req_builder = local_req_builder.body(buf);
8090                            }
8091                            Err(e) => return Err(datadog::Error::Io(e)),
8092                        }
8093                    }
8094                    _ => {
8095                        local_req_builder = local_req_builder.body(ser.into_inner());
8096                    }
8097                }
8098            } else {
8099                local_req_builder = local_req_builder.body(ser.into_inner());
8100            }
8101        }
8102
8103        local_req_builder = local_req_builder.headers(headers);
8104        let local_req = local_req_builder.build()?;
8105        log::debug!("request content: {:?}", local_req.body());
8106        let local_resp = local_client.execute(local_req).await?;
8107
8108        let local_status = local_resp.status();
8109        let local_content = local_resp.text().await?;
8110        log::debug!("response content: {}", local_content);
8111
8112        if !local_status.is_client_error() && !local_status.is_server_error() {
8113            match serde_json::from_str::<crate::datadogV2::model::SecurityMonitoringRuleResponse>(
8114                &local_content,
8115            ) {
8116                Ok(e) => {
8117                    return Ok(datadog::ResponseContent {
8118                        status: local_status,
8119                        content: local_content,
8120                        entity: Some(e),
8121                    })
8122                }
8123                Err(e) => return Err(datadog::Error::Serde(e)),
8124            };
8125        } else {
8126            let local_entity: Option<UpdateSecurityMonitoringRuleError> =
8127                serde_json::from_str(&local_content).ok();
8128            let local_error = datadog::ResponseContent {
8129                status: local_status,
8130                content: local_content,
8131                entity: local_entity,
8132            };
8133            Err(datadog::Error::ResponseError(local_error))
8134        }
8135    }
8136
8137    /// Update a specific suppression rule.
8138    pub async fn update_security_monitoring_suppression(
8139        &self,
8140        suppression_id: String,
8141        body: crate::datadogV2::model::SecurityMonitoringSuppressionUpdateRequest,
8142    ) -> Result<
8143        crate::datadogV2::model::SecurityMonitoringSuppressionResponse,
8144        datadog::Error<UpdateSecurityMonitoringSuppressionError>,
8145    > {
8146        match self
8147            .update_security_monitoring_suppression_with_http_info(suppression_id, body)
8148            .await
8149        {
8150            Ok(response_content) => {
8151                if let Some(e) = response_content.entity {
8152                    Ok(e)
8153                } else {
8154                    Err(datadog::Error::Serde(serde::de::Error::custom(
8155                        "response content was None",
8156                    )))
8157                }
8158            }
8159            Err(err) => Err(err),
8160        }
8161    }
8162
8163    /// Update a specific suppression rule.
8164    pub async fn update_security_monitoring_suppression_with_http_info(
8165        &self,
8166        suppression_id: String,
8167        body: crate::datadogV2::model::SecurityMonitoringSuppressionUpdateRequest,
8168    ) -> Result<
8169        datadog::ResponseContent<crate::datadogV2::model::SecurityMonitoringSuppressionResponse>,
8170        datadog::Error<UpdateSecurityMonitoringSuppressionError>,
8171    > {
8172        let local_configuration = &self.config;
8173        let operation_id = "v2.update_security_monitoring_suppression";
8174
8175        let local_client = &self.client;
8176
8177        let local_uri_str = format!(
8178            "{}/api/v2/security_monitoring/configuration/suppressions/{suppression_id}",
8179            local_configuration.get_operation_host(operation_id),
8180            suppression_id = datadog::urlencode(suppression_id)
8181        );
8182        let mut local_req_builder =
8183            local_client.request(reqwest::Method::PATCH, local_uri_str.as_str());
8184
8185        // build headers
8186        let mut headers = HeaderMap::new();
8187        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
8188        headers.insert("Accept", HeaderValue::from_static("application/json"));
8189
8190        // build user agent
8191        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
8192            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
8193            Err(e) => {
8194                log::warn!("Failed to parse user agent header: {e}, falling back to default");
8195                headers.insert(
8196                    reqwest::header::USER_AGENT,
8197                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
8198                )
8199            }
8200        };
8201
8202        // build auth
8203        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
8204            headers.insert(
8205                "DD-API-KEY",
8206                HeaderValue::from_str(local_key.key.as_str())
8207                    .expect("failed to parse DD-API-KEY header"),
8208            );
8209        };
8210        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
8211            headers.insert(
8212                "DD-APPLICATION-KEY",
8213                HeaderValue::from_str(local_key.key.as_str())
8214                    .expect("failed to parse DD-APPLICATION-KEY header"),
8215            );
8216        };
8217
8218        // build body parameters
8219        let output = Vec::new();
8220        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
8221        if body.serialize(&mut ser).is_ok() {
8222            if let Some(content_encoding) = headers.get("Content-Encoding") {
8223                match content_encoding.to_str().unwrap_or_default() {
8224                    "gzip" => {
8225                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
8226                        let _ = enc.write_all(ser.into_inner().as_slice());
8227                        match enc.finish() {
8228                            Ok(buf) => {
8229                                local_req_builder = local_req_builder.body(buf);
8230                            }
8231                            Err(e) => return Err(datadog::Error::Io(e)),
8232                        }
8233                    }
8234                    "deflate" => {
8235                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
8236                        let _ = enc.write_all(ser.into_inner().as_slice());
8237                        match enc.finish() {
8238                            Ok(buf) => {
8239                                local_req_builder = local_req_builder.body(buf);
8240                            }
8241                            Err(e) => return Err(datadog::Error::Io(e)),
8242                        }
8243                    }
8244                    "zstd1" => {
8245                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
8246                        let _ = enc.write_all(ser.into_inner().as_slice());
8247                        match enc.finish() {
8248                            Ok(buf) => {
8249                                local_req_builder = local_req_builder.body(buf);
8250                            }
8251                            Err(e) => return Err(datadog::Error::Io(e)),
8252                        }
8253                    }
8254                    _ => {
8255                        local_req_builder = local_req_builder.body(ser.into_inner());
8256                    }
8257                }
8258            } else {
8259                local_req_builder = local_req_builder.body(ser.into_inner());
8260            }
8261        }
8262
8263        local_req_builder = local_req_builder.headers(headers);
8264        let local_req = local_req_builder.build()?;
8265        log::debug!("request content: {:?}", local_req.body());
8266        let local_resp = local_client.execute(local_req).await?;
8267
8268        let local_status = local_resp.status();
8269        let local_content = local_resp.text().await?;
8270        log::debug!("response content: {}", local_content);
8271
8272        if !local_status.is_client_error() && !local_status.is_server_error() {
8273            match serde_json::from_str::<
8274                crate::datadogV2::model::SecurityMonitoringSuppressionResponse,
8275            >(&local_content)
8276            {
8277                Ok(e) => {
8278                    return Ok(datadog::ResponseContent {
8279                        status: local_status,
8280                        content: local_content,
8281                        entity: Some(e),
8282                    })
8283                }
8284                Err(e) => return Err(datadog::Error::Serde(e)),
8285            };
8286        } else {
8287            let local_entity: Option<UpdateSecurityMonitoringSuppressionError> =
8288                serde_json::from_str(&local_content).ok();
8289            let local_error = datadog::ResponseContent {
8290                status: local_status,
8291                content: local_content,
8292                entity: local_entity,
8293            };
8294            Err(datadog::Error::ResponseError(local_error))
8295        }
8296    }
8297
8298    /// Validate a detection rule.
8299    pub async fn validate_security_monitoring_rule(
8300        &self,
8301        body: crate::datadogV2::model::SecurityMonitoringRuleValidatePayload,
8302    ) -> Result<(), datadog::Error<ValidateSecurityMonitoringRuleError>> {
8303        match self
8304            .validate_security_monitoring_rule_with_http_info(body)
8305            .await
8306        {
8307            Ok(_) => Ok(()),
8308            Err(err) => Err(err),
8309        }
8310    }
8311
8312    /// Validate a detection rule.
8313    pub async fn validate_security_monitoring_rule_with_http_info(
8314        &self,
8315        body: crate::datadogV2::model::SecurityMonitoringRuleValidatePayload,
8316    ) -> Result<datadog::ResponseContent<()>, datadog::Error<ValidateSecurityMonitoringRuleError>>
8317    {
8318        let local_configuration = &self.config;
8319        let operation_id = "v2.validate_security_monitoring_rule";
8320
8321        let local_client = &self.client;
8322
8323        let local_uri_str = format!(
8324            "{}/api/v2/security_monitoring/rules/validation",
8325            local_configuration.get_operation_host(operation_id)
8326        );
8327        let mut local_req_builder =
8328            local_client.request(reqwest::Method::POST, local_uri_str.as_str());
8329
8330        // build headers
8331        let mut headers = HeaderMap::new();
8332        headers.insert("Content-Type", HeaderValue::from_static("application/json"));
8333        headers.insert("Accept", HeaderValue::from_static("*/*"));
8334
8335        // build user agent
8336        match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
8337            Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
8338            Err(e) => {
8339                log::warn!("Failed to parse user agent header: {e}, falling back to default");
8340                headers.insert(
8341                    reqwest::header::USER_AGENT,
8342                    HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
8343                )
8344            }
8345        };
8346
8347        // build auth
8348        if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
8349            headers.insert(
8350                "DD-API-KEY",
8351                HeaderValue::from_str(local_key.key.as_str())
8352                    .expect("failed to parse DD-API-KEY header"),
8353            );
8354        };
8355        if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
8356            headers.insert(
8357                "DD-APPLICATION-KEY",
8358                HeaderValue::from_str(local_key.key.as_str())
8359                    .expect("failed to parse DD-APPLICATION-KEY header"),
8360            );
8361        };
8362
8363        // build body parameters
8364        let output = Vec::new();
8365        let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
8366        if body.serialize(&mut ser).is_ok() {
8367            if let Some(content_encoding) = headers.get("Content-Encoding") {
8368                match content_encoding.to_str().unwrap_or_default() {
8369                    "gzip" => {
8370                        let mut enc = GzEncoder::new(Vec::new(), Compression::default());
8371                        let _ = enc.write_all(ser.into_inner().as_slice());
8372                        match enc.finish() {
8373                            Ok(buf) => {
8374                                local_req_builder = local_req_builder.body(buf);
8375                            }
8376                            Err(e) => return Err(datadog::Error::Io(e)),
8377                        }
8378                    }
8379                    "deflate" => {
8380                        let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
8381                        let _ = enc.write_all(ser.into_inner().as_slice());
8382                        match enc.finish() {
8383                            Ok(buf) => {
8384                                local_req_builder = local_req_builder.body(buf);
8385                            }
8386                            Err(e) => return Err(datadog::Error::Io(e)),
8387                        }
8388                    }
8389                    "zstd1" => {
8390                        let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
8391                        let _ = enc.write_all(ser.into_inner().as_slice());
8392                        match enc.finish() {
8393                            Ok(buf) => {
8394                                local_req_builder = local_req_builder.body(buf);
8395                            }
8396                            Err(e) => return Err(datadog::Error::Io(e)),
8397                        }
8398                    }
8399                    _ => {
8400                        local_req_builder = local_req_builder.body(ser.into_inner());
8401                    }
8402                }
8403            } else {
8404                local_req_builder = local_req_builder.body(ser.into_inner());
8405            }
8406        }
8407
8408        local_req_builder = local_req_builder.headers(headers);
8409        let local_req = local_req_builder.build()?;
8410        log::debug!("request content: {:?}", local_req.body());
8411        let local_resp = local_client.execute(local_req).await?;
8412
8413        let local_status = local_resp.status();
8414        let local_content = local_resp.text().await?;
8415        log::debug!("response content: {}", local_content);
8416
8417        if !local_status.is_client_error() && !local_status.is_server_error() {
8418            Ok(datadog::ResponseContent {
8419                status: local_status,
8420                content: local_content,
8421                entity: None,
8422            })
8423        } else {
8424            let local_entity: Option<ValidateSecurityMonitoringRuleError> =
8425                serde_json::from_str(&local_content).ok();
8426            let local_error = datadog::ResponseContent {
8427                status: local_status,
8428                content: local_content,
8429                entity: local_entity,
8430            };
8431            Err(datadog::Error::ResponseError(local_error))
8432        }
8433    }
8434}