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