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